diff options
author | smatz <smatz@openttd.org> | 2009-11-24 21:18:11 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2009-11-24 21:18:11 +0000 |
commit | f0c64208cf917ff2a1f59c7640eac7e9fb80d605 (patch) | |
tree | 46ff00e56156495fa95821a99cf4f3d00a0acb49 /src/town_gui.cpp | |
parent | 8d6e323ef80fcb49c4fc8417564d1e2ef7797a73 (diff) | |
download | openttd-f0c64208cf917ff2a1f59c7640eac7e9fb80d605.tar.xz |
(svn r18281) -Feature: founding towns in-game (based on work by Belugas, TheJosh, GeekToo, Terkhen and others)
Diffstat (limited to 'src/town_gui.cpp')
-rw-r--r-- | src/town_gui.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/town_gui.cpp b/src/town_gui.cpp index cbf033115..b1fea3616 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -991,7 +991,7 @@ public: this->InitNested(desc, window_number); InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, MAX_LENGTH_TOWN_NAME_PIXELS); this->RandomTownName(); - this->UpdateButtons(); + this->UpdateButtons(true); } void RandomTownName() @@ -1010,8 +1010,15 @@ public: this->SetWidgetDirty(TSEW_TOWNNAME_EDITBOX); } - void UpdateButtons() + void UpdateButtons(bool check_availability) { + if (check_availability && _game_mode != GM_EDITOR) { + this->SetWidgetsDisabledState(true, TSEW_RANDOMTOWN, TSEW_MANYRANDOMTOWNS, TSEW_SIZE_LARGE, WIDGET_LIST_END); + this->SetWidgetsDisabledState(_settings_game.economy.found_town != TF_CUSTOM_LAYOUT, + TSEW_LAYOUT_ORIGINAL, TSEW_LAYOUT_BETTER, TSEW_LAYOUT_GRID2, TSEW_LAYOUT_GRID3, TSEW_LAYOUT_RANDOM, WIDGET_LIST_END); + if (_settings_game.economy.found_town != TF_CUSTOM_LAYOUT) town_layout = _settings_game.economy.town_layout; + } + for (int i = TSEW_SIZE_SMALL; i <= TSEW_SIZE_RANDOM; i++) { this->SetWidgetLoweredState(i, i == TSEW_SIZE_SMALL + this->town_size); } @@ -1080,7 +1087,7 @@ public: case TSEW_SIZE_SMALL: case TSEW_SIZE_MEDIUM: case TSEW_SIZE_LARGE: case TSEW_SIZE_RANDOM: this->town_size = (TownSize)(widget - TSEW_SIZE_SMALL); - this->UpdateButtons(); + this->UpdateButtons(false); break; case TSEW_CITY: @@ -1092,7 +1099,7 @@ public: case TSEW_LAYOUT_ORIGINAL: case TSEW_LAYOUT_BETTER: case TSEW_LAYOUT_GRID2: case TSEW_LAYOUT_GRID3: case TSEW_LAYOUT_RANDOM: this->town_layout = (TownLayout)(widget - TSEW_LAYOUT_ORIGINAL); - this->UpdateButtons(); + this->UpdateButtons(false); break; } } @@ -1124,7 +1131,12 @@ public: virtual void OnPlaceObjectAbort() { this->RaiseButtons(); - this->UpdateButtons(); + this->UpdateButtons(false); + } + + virtual void OnInvalidateData(int) + { + this->UpdateButtons(true); } }; |