diff options
author | yexo <yexo@openttd.org> | 2010-08-05 11:59:07 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2010-08-05 11:59:07 +0000 |
commit | 330c2f979e794f751ccd0ee05256f7b788f13091 (patch) | |
tree | 549c1ac6c659b2e71e8d1da0ac8d389a599979cb | |
parent | 6321eb5a00be509ce0415411677b34d63d995a33 (diff) | |
download | openttd-330c2f979e794f751ccd0ee05256f7b788f13091.tar.xz |
(svn r20365) -Codechange: allow multiple layouts for one airport statemachine, store the layout number
-rw-r--r-- | src/airport_gui.cpp | 41 | ||||
-rw-r--r-- | src/lang/english.txt | 1 | ||||
-rw-r--r-- | src/newgrf_airport.cpp | 2 | ||||
-rw-r--r-- | src/saveload/station_sl.cpp | 1 | ||||
-rw-r--r-- | src/station_base.h | 1 | ||||
-rw-r--r-- | src/station_cmd.cpp | 1 |
6 files changed, 44 insertions, 3 deletions
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 2952cab9d..a5fda1567 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -33,6 +33,7 @@ static AirportClassID _selected_airport_class; ///< the currently visible airport class static int _selected_airport_index; ///< the index of the selected airport in the current class or -1 +static byte _selected_airport_layout; ///< selected airport layout number. static void ShowBuildAirportPicker(Window *parent); @@ -52,6 +53,7 @@ static void PlaceAirport(TileIndex tile) SB(p2, 16, 16, INVALID_STATION); // no station to join uint32 p1 = GetAirportSpecFromClass(_selected_airport_class, _selected_airport_index)->GetIndex(); + p1 |= _selected_airport_layout << 8; CommandContainer cmdcont = { tile, p1, p2, CMD_BUILD_AIRPORT | CMD_MSG(STR_ERROR_CAN_T_BUILD_AIRPORT_HERE), CcBuildAirport, "" }; ShowSelectStationIfNeeded(cmdcont, TileArea(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE)); } @@ -197,6 +199,9 @@ enum AirportPickerWidgets { BAIRW_CLASS_DROPDOWN, BAIRW_AIRPORT_LIST, BAIRW_SCROLLBAR, + BAIRW_LAYOUT_NUM, + BAIRW_LAYOUT_DECREASE, + BAIRW_LAYOUT_INCREASE, BAIRW_BOTTOMPANEL, BAIRW_COVERAGE_LABEL, BAIRW_BTN_DONTHILIGHT, @@ -240,9 +245,18 @@ public: virtual void SetStringParameters(int widget) const { - if (widget != BAIRW_CLASS_DROPDOWN) return; + switch (widget) { + case BAIRW_CLASS_DROPDOWN: + SetDParam(0, GetAirportClassName(_selected_airport_class)); + break; + + case BAIRW_LAYOUT_NUM: + SetDParam(0, STR_STATION_BUILD_AIRPORT_LAYOUT_NAME); + SetDParam(1, _selected_airport_layout + 1); + break; - SetDParam(0, GetAirportClassName(_selected_airport_class)); + default: break; + } } virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) @@ -328,6 +342,7 @@ public: void SelectOtherAirport(int airport_index) { _selected_airport_index = airport_index; + _selected_airport_layout = 0; this->UpdateSelectSize(); this->SetDirty(); @@ -337,10 +352,15 @@ public: { if (_selected_airport_index == -1) { SetTileSelectSize(1, 1); + this->DisableWidget(BAIRW_LAYOUT_DECREASE); + this->DisableWidget(BAIRW_LAYOUT_INCREASE); } else { const AirportSpec *as = GetAirportSpecFromClass(_selected_airport_class, _selected_airport_index); SetTileSelectSize(as->size_x, as->size_y); + this->SetWidgetDisabledState(BAIRW_LAYOUT_DECREASE, _selected_airport_layout == 0); + this->SetWidgetDisabledState(BAIRW_LAYOUT_INCREASE, _selected_airport_layout + 1 >= as->num_table); + int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED; if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); } @@ -369,6 +389,18 @@ public: SndPlayFx(SND_15_BEEP); this->UpdateSelectSize(); break; + + case BAIRW_LAYOUT_DECREASE: + _selected_airport_layout--; + this->UpdateSelectSize(); + this->SetDirty(); + break; + + case BAIRW_LAYOUT_INCREASE: + _selected_airport_layout++; + this->UpdateSelectSize(); + this->SetDirty(); + break; } } @@ -431,6 +463,11 @@ static const NWidgetPart _nested_build_airport_widgets[] = { NWidget(WWT_MATRIX, COLOUR_GREY, BAIRW_AIRPORT_LIST), SetFill(1, 0), SetDataTip(0x501, STR_NULL), NWidget(WWT_SCROLLBAR, COLOUR_GREY, BAIRW_SCROLLBAR), EndContainer(), + NWidget(NWID_HORIZONTAL), + NWidget(NWID_BUTTON_ARROW, COLOUR_GREY, BAIRW_LAYOUT_DECREASE), SetMinimalSize(12, 0),SetDataTip(AWV_DECREASE, STR_NULL), + NWidget(WWT_LABEL, COLOUR_GREY, BAIRW_LAYOUT_NUM), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BLACK_STRING, STR_NULL), + NWidget(NWID_BUTTON_ARROW, COLOUR_GREY, BAIRW_LAYOUT_INCREASE), SetMinimalSize(12, 0), SetDataTip(AWV_INCREASE, STR_NULL), + EndContainer(), EndContainer(), /* Bottom panel. */ NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BAIRW_BOTTOMPANEL), SetPIP(2, 2, 2), diff --git a/src/lang/english.txt b/src/lang/english.txt index 4722365c7..ef6aed235 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -2025,6 +2025,7 @@ STR_TOOLBAR_AIRCRAFT_BUILD_AIRPORT_TOOLTIP :{BLACK}Build ai STR_STATION_BUILD_AIRPORT_CAPTION :{WHITE}Airport Selection STR_STATION_BUILD_AIRPORT_TOOLTIP :{BLACK}Select size/type of airport STR_STATION_BUILD_AIRPORT_CLASS_LABEL :{BLACK}Airport class +STR_STATION_BUILD_AIRPORT_LAYOUT_NAME :{BLACK}Layout {NUM} STR_AIRPORT_SMALL :Small STR_AIRPORT_CITY :City diff --git a/src/newgrf_airport.cpp b/src/newgrf_airport.cpp index 30b3d616a..3355603a4 100644 --- a/src/newgrf_airport.cpp +++ b/src/newgrf_airport.cpp @@ -326,7 +326,7 @@ uint16 GetAirportCallback(CallbackID callback, uint32 param1, uint32 param2, Sta { ResolverObject object; - NewAirportResolver(&object, tile, st, st->airport.type, 0); + NewAirportResolver(&object, tile, st, st->airport.type, st->airport.layout); object.callback = callback; object.callback_param1 = param1; object.callback_param2 = param2; diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp index 26c77f073..a57c71c55 100644 --- a/src/saveload/station_sl.cpp +++ b/src/saveload/station_sl.cpp @@ -335,6 +335,7 @@ static const SaveLoad _station_desc[] = { SLE_CONDVAR(Station, airport.w, SLE_FILE_U8 | SLE_VAR_U16, 140, SL_MAX_VERSION), SLE_CONDVAR(Station, airport.h, SLE_FILE_U8 | SLE_VAR_U16, 140, SL_MAX_VERSION), SLE_VAR(Station, airport.type, SLE_UINT8), + SLE_CONDVAR(Station, airport.layout, SLE_UINT8, 145, SL_MAX_VERSION), SLE_VAR(Station, airport.flags, SLE_UINT64), SLE_VAR(Station, indtype, SLE_UINT8), diff --git a/src/station_base.h b/src/station_base.h index 36bafcfa9..5329a2642 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -51,6 +51,7 @@ struct Airport : public TileArea { uint64 flags; ///< stores which blocks on the airport are taken. was 16 bit earlier on, then 32 byte type; ///< Type of this airport, @see AirportTypes. + byte layout; ///< Airport layout number. /** * Get the AirportSpec that from the airport type of this airport. If there diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index d99f77119..67000272b 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2214,6 +2214,7 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint st->AddFacility(FACIL_AIRPORT, tile); st->airport.type = airport_type; + st->airport.layout = layout; st->airport.flags = 0; st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY); |