diff options
author | smatz <smatz@openttd.org> | 2009-02-05 16:51:23 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2009-02-05 16:51:23 +0000 |
commit | 6dff31d34b2df4c1fb1332d33380bb99a2b40924 (patch) | |
tree | 490ad101e79e82d8edf8c90107fa2385aa3fb8bc /src | |
parent | ef4282f8de836cd547de32b6e1d21fb2cb44d917 (diff) | |
download | openttd-6dff31d34b2df4c1fb1332d33380bb99a2b40924.tar.xz |
(svn r15357) -Codechange: unify the way buttons are updated in the 'found town' window
Diffstat (limited to 'src')
-rw-r--r-- | src/lang/english.txt | 2 | ||||
-rw-r--r-- | src/town_gui.cpp | 31 |
2 files changed, 20 insertions, 13 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt index 677a6311a..ddba759dc 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -762,7 +762,7 @@ STR_02A2_MEDIUM :{BLACK}Medium STR_02A3_LARGE :{BLACK}Large STR_SELECT_TOWN_SIZE_RANDOM :{BLACK}Random STR_SCENARIO_EDITOR_CITY :{BLACK}City -STR_SCENARIO_EDITOR_CITY_TOOLTIP :{BLACK}Cities grow faster than regular towns{}Depending on settings, they are bigger when found +STR_SCENARIO_EDITOR_CITY_TOOLTIP :{BLACK}Cities grow faster than regular towns{}Depending on settings, they are bigger when founded STR_02A4_SELECT_TOWN_SIZE :{BLACK}Select town size STR_02A5_TOWN_SIZE :{YELLOW}Town size: diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 03175fc81..b4833ab3b 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -653,11 +653,25 @@ private: public: ScenarioEditorTownGenerationWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) { - this->LowerWidget(town_size + TSEW_SIZE_SMALL); this->FindWindowPlacementAndResize(desc); town_layout = _settings_game.economy.town_layout; - this->LowerWidget(town_layout + TSEW_LAYOUT_ORIGINAL); city = false; + this->UpdateButtons(); + } + + void UpdateButtons() + { + for (int i = TSEW_SIZE_SMALL; i <= TSEW_SIZE_RANDOM; i++) { + this->SetWidgetLoweredState(i, i == TSEW_SIZE_SMALL + town_size); + } + + this->SetWidgetLoweredState(TSEW_CITY, city); + + for (int i = TSEW_LAYOUT_ORIGINAL; i <= TSEW_LAYOUT_RANDOM; i++) { + this->SetWidgetLoweredState(i, i == TSEW_LAYOUT_ORIGINAL + town_layout); + } + + this->SetDirty(); } virtual void OnPaint() @@ -700,10 +714,8 @@ public: break; case TSEW_SIZE_SMALL: case TSEW_SIZE_MEDIUM: case TSEW_SIZE_LARGE: case TSEW_SIZE_RANDOM: - this->RaiseWidget(town_size + TSEW_SIZE_SMALL); town_size = (TownSize)(widget - TSEW_SIZE_SMALL); - this->LowerWidget(town_size + TSEW_SIZE_SMALL); - this->SetDirty(); + this->UpdateButtons(); break; case TSEW_CITY: @@ -714,10 +726,8 @@ public: case TSEW_LAYOUT_ORIGINAL: case TSEW_LAYOUT_BETTER: case TSEW_LAYOUT_GRID2: case TSEW_LAYOUT_GRID3: case TSEW_LAYOUT_RANDOM: - this->RaiseWidget(town_layout + TSEW_LAYOUT_ORIGINAL); town_layout = (TownLayout)(widget - TSEW_LAYOUT_ORIGINAL); - this->LowerWidget(town_layout + TSEW_LAYOUT_ORIGINAL); - this->SetDirty(); + this->UpdateButtons(); break; } } @@ -737,10 +747,7 @@ public: virtual void OnPlaceObjectAbort() { this->RaiseButtons(); - this->LowerWidget(town_size + TSEW_SIZE_SMALL); - this->SetWidgetLoweredState(TSEW_CITY, city); - this->LowerWidget(town_layout + TSEW_LAYOUT_ORIGINAL); - this->SetDirty(); + this->UpdateButtons(); } static void PlaceProc_Town(TileIndex tile) |