# HG changeset patch # Parent 78b5ea06a08f75691630703c2f14a5ab3ce20393 - Fix: Update climate indicators between main menu and newgame window diff -r 78b5ea06a08f src/genworld.h --- a/src/genworld.h Thu May 20 18:54:14 2010 +0000 +++ b/src/genworld.h Fri May 21 07:49:43 2010 +0200 @@ -87,6 +87,7 @@ void HandleGeneratingWorldAbortion(); /* genworld_gui.cpp */ +void SetNewLandscapeType(byte landscape); void SetGeneratingWorldProgress(GenWorldProgress cls, uint total); void IncreaseGeneratingWorldProgress(GenWorldProgress cls); void PrepareGenerateWorldProgress(); diff -r 78b5ea06a08f src/genworld_gui.cpp --- a/src/genworld_gui.cpp Thu May 20 18:54:14 2010 +0000 +++ b/src/genworld_gui.cpp Fri May 21 07:49:43 2010 +0200 @@ -52,11 +52,11 @@ * 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 */ @@ -362,6 +362,8 @@ this->caption = STR_NULL; this->afilter = CS_NUMERAL; + this->OnInvalidateData(); + this->mode = (GenenerateLandscapeWindowMode)this->window_number; } @@ -400,6 +402,15 @@ } } + 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 @@ 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 -r 78b5ea06a08f src/intro_gui.cpp --- a/src/intro_gui.cpp Thu May 20 18:54:14 2010 +0000 +++ b/src/intro_gui.cpp Fri May 21 07:49:43 2010 +0200 @@ -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, @@ -62,10 +56,10 @@ { 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); @@ -131,7 +125,6 @@ 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;