From 9ed9aa9012fff20c9d73c5fa80e65e64c0925937 Mon Sep 17 00:00:00 2001 From: yexo Date: Fri, 21 May 2010 06:59:45 +0000 Subject: [PATCH] (svn r19871) -Fix [FS#3826]: update the landscape buttons in the main menu / newgame window correctly (planetmaker) --- src/genworld.h | 1 + src/genworld_gui.cpp | 22 ++++++++++++++-------- src/intro_gui.cpp | 13 ++----------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/genworld.h b/src/genworld.h index a32cf21159..6dd89e06ea 100644 --- a/src/genworld.h +++ b/src/genworld.h @@ -87,6 +87,7 @@ bool IsGeneratingWorldAborted(); void HandleGeneratingWorldAbortion(); /* genworld_gui.cpp */ +void SetNewLandscapeType(byte landscape); void SetGeneratingWorldProgress(GenWorldProgress cls, uint total); void IncreaseGeneratingWorldProgress(GenWorldProgress cls); void PrepareGenerateWorldProgress(); diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index 5efbe7271f..ab3fa10c89 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -52,11 +52,11 @@ extern void MakeNewgameSettingsLive(); * Changes landscape type and sets genworld window dirty * @param landscape new landscape type */ -static inline void SetNewLandscapeType(byte landscape) +void SetNewLandscapeType(byte landscape) { _settings_newgame.game_creation.landscape = landscape; - SetWindowClassesDirty(WC_SELECT_GAME); - SetWindowClassesDirty(WC_GENERATE_LANDSCAPE); + InvalidateWindowClassesData(WC_SELECT_GAME); + InvalidateWindowClassesData(WC_GENERATE_LANDSCAPE); } /** Widgets of GenerateLandscapeWindow */ @@ -363,6 +363,8 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow { this->afilter = CS_NUMERAL; this->mode = (GenenerateLandscapeWindowMode)this->window_number; + + this->OnInvalidateData(); } @@ -400,6 +402,15 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow { } } + virtual void OnInvalidateData(int data = 0) + { + /* Update the climate buttons */ + this->SetWidgetLoweredState(GLAND_TEMPERATE, _settings_newgame.game_creation.landscape == LT_TEMPERATE); + this->SetWidgetLoweredState(GLAND_ARCTIC, _settings_newgame.game_creation.landscape == LT_ARCTIC); + this->SetWidgetLoweredState(GLAND_TROPICAL, _settings_newgame.game_creation.landscape == LT_TROPIC); + this->SetWidgetLoweredState(GLAND_TOYLAND, _settings_newgame.game_creation.landscape == LT_TOYLAND); + } + virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) { const StringID *strs = NULL; @@ -509,11 +520,6 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow { this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_DOWN, _settings_newgame.game_creation.snow_line_height <= MIN_SNOWLINE_HEIGHT || _settings_newgame.game_creation.landscape != LT_ARCTIC); this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_UP, _settings_newgame.game_creation.snow_line_height >= MAX_SNOWLINE_HEIGHT || _settings_newgame.game_creation.landscape != LT_ARCTIC); - this->SetWidgetLoweredState(GLAND_TEMPERATE, _settings_newgame.game_creation.landscape == LT_TEMPERATE); - this->SetWidgetLoweredState(GLAND_ARCTIC, _settings_newgame.game_creation.landscape == LT_ARCTIC); - this->SetWidgetLoweredState(GLAND_TROPICAL, _settings_newgame.game_creation.landscape == LT_TROPIC); - this->SetWidgetLoweredState(GLAND_TOYLAND, _settings_newgame.game_creation.landscape == LT_TOYLAND); - this->DrawWidgets(); this->DrawEditBox(GLAND_RANDOM_EDITBOX); diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index 5cb4a38907..dc8befb75e 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -30,12 +30,6 @@ #include "table/strings.h" #include "table/sprites.h" -static inline void SetNewLandscapeType(byte landscape) -{ - _settings_newgame.game_creation.landscape = landscape; - SetWindowClassesDirty(WC_SELECT_GAME); -} - enum SelectGameIntroWidgets { SGI_GENERATE_GAME, SGI_LOAD_GAME, @@ -61,11 +55,10 @@ struct SelectGameWindow : public Window { SelectGameWindow(const WindowDesc *desc) : Window() { this->InitNested(desc); - this->LowerWidget(_settings_newgame.game_creation.landscape + SGI_TEMPERATE_LANDSCAPE); - this->SetLandscapeButtons(); + this->OnInvalidateData(); } - void SetLandscapeButtons() + virtual void OnInvalidateData(int data = 0) { this->SetWidgetLoweredState(SGI_TEMPERATE_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TEMPERATE); this->SetWidgetLoweredState(SGI_ARCTIC_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_ARCTIC); @@ -129,9 +122,7 @@ struct SelectGameWindow : public Window { case SGI_TEMPERATE_LANDSCAPE: case SGI_ARCTIC_LANDSCAPE: case SGI_TROPIC_LANDSCAPE: case SGI_TOYLAND_LANDSCAPE: - this->RaiseWidget(_settings_newgame.game_creation.landscape + SGI_TEMPERATE_LANDSCAPE); SetNewLandscapeType(widget - SGI_TEMPERATE_LANDSCAPE); - this->SetLandscapeButtons(); break; case SGI_OPTIONS: ShowGameOptions(); break;