summaryrefslogtreecommitdiff
path: root/src/genworld_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-12-21 16:16:37 +0000
committerrubidium <rubidium@openttd.org>2009-12-21 16:16:37 +0000
commitcc40883ad8dbaf03b68cb332ff1b50a6732939fe (patch)
tree8d88cce9bd9016e4824924a860a77da330b7fd64 /src/genworld_gui.cpp
parentabb601f682775de2f0670482f0b4b773300c9949 (diff)
downloadopenttd-cc40883ad8dbaf03b68cb332ff1b50a6732939fe.tar.xz
(svn r18586) -Fix [FS#3398]: pressing default for the starting year/snow line height edit boxes of the world generation windows didn't work.
Diffstat (limited to 'src/genworld_gui.cpp')
-rw-r--r--src/genworld_gui.cpp39
1 files changed, 24 insertions, 15 deletions
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index adb59522f..517e33d5b 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -732,27 +732,36 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
virtual void OnQueryTextFinished(char *str)
{
+ int32 value;
if (!StrEmpty(str)) {
- int32 value = atoi(str);
-
+ value = atoi(str);
+ } else {
+ /* An empty string means revert to the default */
switch (this->widget_id) {
- case GLAND_START_DATE_TEXT:
- this->SetWidgetDirty(GLAND_START_DATE_TEXT);
- _settings_newgame.game_creation.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
- break;
+ case GLAND_START_DATE_TEXT: value = DEF_START_YEAR; break;
+ case GLAND_SNOW_LEVEL_TEXT: value = DEF_SNOWLINE_HEIGHT; break;
+ case GLAND_TOWN_PULLDOWN: value = 1; break; // There's not really a default
+ default: NOT_REACHED();
+ }
+ }
- 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);
- break;
+ switch (this->widget_id) {
+ case GLAND_START_DATE_TEXT:
+ this->SetWidgetDirty(GLAND_START_DATE_TEXT);
+ _settings_newgame.game_creation.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
+ break;
- case GLAND_TOWN_PULLDOWN:
- _settings_newgame.game_creation.custom_town_number = Clamp(value, 1, CUSTOM_TOWN_MAX_NUMBER);
- 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);
+ break;
- this->SetDirty();
+ case GLAND_TOWN_PULLDOWN:
+ _settings_newgame.game_creation.custom_town_number = Clamp(value, 1, CUSTOM_TOWN_MAX_NUMBER);
+ break;
}
+
+ this->SetDirty();
}
};