diff -r f531819ae921 src/genworld_gui.cpp --- a/src/genworld_gui.cpp Wed May 19 17:04:02 2010 +0000 +++ b/src/genworld_gui.cpp Thu May 20 22:18:36 2010 +0200 @@ -362,6 +362,13 @@ this->caption = STR_NULL; this->afilter = CS_NUMERAL; + /* Disable town, industry and trees in SE */ + this->SetWidgetDisabledState(GLAND_TOWN_PULLDOWN, _game_mode == GM_EDITOR); + this->SetWidgetDisabledState(GLAND_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR); + this->SetWidgetDisabledState(GLAND_TREE_PULLDOWN, _game_mode == GM_EDITOR); + + UpdateWidgetStatus(); + this->mode = (GenenerateLandscapeWindowMode)this->window_number; } @@ -400,6 +407,36 @@ } } + virtual void UpdateWidgetStatus() { + /* Disable snowline if not arctic */ + this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_TEXT, _settings_newgame.game_creation.landscape != LT_ARCTIC); + 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); + + /* Disable date up / down buttons, if at limit */ + this->SetWidgetDisabledState(GLAND_START_DATE_DOWN, _settings_newgame.game_creation.starting_year <= MIN_YEAR); + this->SetWidgetDisabledState(GLAND_START_DATE_UP, _settings_newgame.game_creation.starting_year >= MAX_YEAR); + + /* You can't select smoothness / non-water borders if not terragenesis */ + if (mode == GLWM_GENERATE) { + this->SetWidgetDisabledState(GLAND_SMOOTHNESS_PULLDOWN, _settings_newgame.game_creation.land_generator == 0); + this->SetWidgetDisabledState(GLAND_VARIETY_PULLDOWN, _settings_newgame.game_creation.land_generator == 0); + this->SetWidgetDisabledState(GLAND_BORDERS_RANDOM, _settings_newgame.game_creation.land_generator == 0 || !_settings_newgame.construction.freeform_edges); + this->SetWidgetsDisabledState(_settings_newgame.game_creation.land_generator == 0 || !_settings_newgame.construction.freeform_edges || _settings_newgame.game_creation.water_borders == BORDERS_RANDOM, + GLAND_WATER_NW, GLAND_WATER_NE, GLAND_WATER_SE, GLAND_WATER_SW, WIDGET_LIST_END); + + this->SetWidgetLoweredState(GLAND_BORDERS_RANDOM, _settings_newgame.game_creation.water_borders == BORDERS_RANDOM); + + this->SetWidgetLoweredState(GLAND_WATER_NW, HasBit(_settings_newgame.game_creation.water_borders, BORDER_NW)); + this->SetWidgetLoweredState(GLAND_WATER_NE, HasBit(_settings_newgame.game_creation.water_borders, BORDER_NE)); + this->SetWidgetLoweredState(GLAND_WATER_SE, HasBit(_settings_newgame.game_creation.water_borders, BORDER_SE)); + this->SetWidgetLoweredState(GLAND_WATER_SW, HasBit(_settings_newgame.game_creation.water_borders, BORDER_SW)); + + this->SetWidgetsDisabledState(_settings_newgame.game_creation.land_generator == 0 && (_settings_newgame.game_creation.landscape == LT_ARCTIC || _settings_newgame.game_creation.landscape == LT_TROPIC), + GLAND_TERRAIN_PULLDOWN, GLAND_WATER_PULLDOWN, WIDGET_LIST_END); + } + } + virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) { const StringID *strs = NULL; @@ -479,43 +516,7 @@ virtual void OnPaint() { - /* You can't select smoothness / non-water borders if not terragenesis */ - if (mode == GLWM_GENERATE) { - this->SetWidgetDisabledState(GLAND_SMOOTHNESS_PULLDOWN, _settings_newgame.game_creation.land_generator == 0); - this->SetWidgetDisabledState(GLAND_VARIETY_PULLDOWN, _settings_newgame.game_creation.land_generator == 0); - this->SetWidgetDisabledState(GLAND_BORDERS_RANDOM, _settings_newgame.game_creation.land_generator == 0 || !_settings_newgame.construction.freeform_edges); - this->SetWidgetsDisabledState(_settings_newgame.game_creation.land_generator == 0 || !_settings_newgame.construction.freeform_edges || _settings_newgame.game_creation.water_borders == BORDERS_RANDOM, - GLAND_WATER_NW, GLAND_WATER_NE, GLAND_WATER_SE, GLAND_WATER_SW, WIDGET_LIST_END); - - this->SetWidgetLoweredState(GLAND_BORDERS_RANDOM, _settings_newgame.game_creation.water_borders == BORDERS_RANDOM); - - this->SetWidgetLoweredState(GLAND_WATER_NW, HasBit(_settings_newgame.game_creation.water_borders, BORDER_NW)); - this->SetWidgetLoweredState(GLAND_WATER_NE, HasBit(_settings_newgame.game_creation.water_borders, BORDER_NE)); - this->SetWidgetLoweredState(GLAND_WATER_SE, HasBit(_settings_newgame.game_creation.water_borders, BORDER_SE)); - this->SetWidgetLoweredState(GLAND_WATER_SW, HasBit(_settings_newgame.game_creation.water_borders, BORDER_SW)); - - this->SetWidgetsDisabledState(_settings_newgame.game_creation.land_generator == 0 && (_settings_newgame.game_creation.landscape == LT_ARCTIC || _settings_newgame.game_creation.landscape == LT_TROPIC), - GLAND_TERRAIN_PULLDOWN, GLAND_WATER_PULLDOWN, WIDGET_LIST_END); - } - /* Disable snowline if not hilly */ - this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_TEXT, _settings_newgame.game_creation.landscape != LT_ARCTIC); - /* Disable town, industry and trees in SE */ - this->SetWidgetDisabledState(GLAND_TOWN_PULLDOWN, _game_mode == GM_EDITOR); - this->SetWidgetDisabledState(GLAND_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR); - this->SetWidgetDisabledState(GLAND_TREE_PULLDOWN, _game_mode == GM_EDITOR); - - this->SetWidgetDisabledState(GLAND_START_DATE_DOWN, _settings_newgame.game_creation.starting_year <= MIN_YEAR); - this->SetWidgetDisabledState(GLAND_START_DATE_UP, _settings_newgame.game_creation.starting_year >= MAX_YEAR); - 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); } @@ -528,6 +529,12 @@ case GLAND_TOYLAND: this->RaiseWidget(_settings_newgame.game_creation.landscape + GLAND_TEMPERATE); SetNewLandscapeType(widget - GLAND_TEMPERATE); + 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); + + UpdateWidgetStatus(); break; case GLAND_MAPSIZE_X_PULLDOWN: // Mapsize X @@ -580,6 +587,7 @@ _settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + widget - GLAND_START_DATE_TEXT, MIN_YEAR, MAX_YEAR); } + UpdateWidgetStatus(); _left_button_clicked = false; break; @@ -587,6 +595,7 @@ this->widget_id = GLAND_START_DATE_TEXT; SetDParam(0, _settings_newgame.game_creation.starting_year); ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, 100, this, CS_NUMERAL, QSF_ENABLE_DEFAULT); + UpdateWidgetStatus(); break; case GLAND_SNOW_LEVEL_DOWN: @@ -597,7 +606,8 @@ this->SetDirty(); _settings_newgame.game_creation.snow_line_height = Clamp(_settings_newgame.game_creation.snow_line_height + widget - GLAND_SNOW_LEVEL_TEXT, MIN_SNOWLINE_HEIGHT, MAX_SNOWLINE_HEIGHT); - } + UpdateWidgetStatus(); + } _left_button_clicked = false; break; @@ -613,6 +623,7 @@ case GLAND_LANDSCAPE_PULLDOWN: // Landscape generator ShowDropDownMenu(this, _landscape, _settings_newgame.game_creation.land_generator, GLAND_LANDSCAPE_PULLDOWN, 0, 0); + UpdateWidgetStatus(); break; case GLAND_HEIGHTMAP_ROTATION_PULLDOWN: // Heightmap rotation @@ -695,8 +706,11 @@ case GLAND_TREE_PULLDOWN: _settings_newgame.game_creation.tree_placer = index; break; case GLAND_SMOOTHNESS_PULLDOWN: _settings_newgame.game_creation.tgen_smoothness = index; break; case GLAND_VARIETY_PULLDOWN: _settings_newgame.game_creation.variety = index; break; - case GLAND_LANDSCAPE_PULLDOWN: _settings_newgame.game_creation.land_generator = index; break; case GLAND_HEIGHTMAP_ROTATION_PULLDOWN: _settings_newgame.game_creation.heightmap_rotation = index; break; + case GLAND_LANDSCAPE_PULLDOWN: + _settings_newgame.game_creation.land_generator = index; + UpdateWidgetStatus(); + break; case GLAND_TOWN_PULLDOWN: if ((uint)index == CUSTOM_TOWN_NUMBER_DIFFICULTY) { @@ -751,11 +765,13 @@ case GLAND_START_DATE_TEXT: this->SetWidgetDirty(GLAND_START_DATE_TEXT); _settings_newgame.game_creation.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR); + UpdateWidgetStatus(); break; case GLAND_SNOW_LEVEL_TEXT: this->SetWidgetDirty(GLAND_SNOW_LEVEL_TEXT); _settings_newgame.game_creation.snow_line_height = Clamp(value, MIN_SNOWLINE_HEIGHT, MAX_SNOWLINE_HEIGHT); + UpdateWidgetStatus(); break; case GLAND_TOWN_PULLDOWN: