summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-01-23 19:33:18 +0000
committerrubidium <rubidium@openttd.org>2010-01-23 19:33:18 +0000
commit299d4056802e1fc8647c97a2687da1cbbf43bd70 (patch)
tree3aad9c945b9325c04c9f0fd3fdbd026d3aeb0f12
parentafcce5ed9043f157cf51666ceb795fbb05828d42 (diff)
downloadopenttd-299d4056802e1fc8647c97a2687da1cbbf43bd70.tar.xz
(svn r18902) -Fix [FS#3559]: the default button for the advanced settings didn't work
-rw-r--r--src/settings_gui.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index d9220798b..45e8836a9 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1643,7 +1643,7 @@ struct GameSettingsWindow : Window {
this->valuewindow_entry = pe;
SetDParam(0, value);
- ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 10, 100, this, CS_NUMERAL, QSF_NONE);
+ ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 10, 100, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
}
}
}
@@ -1659,22 +1659,29 @@ struct GameSettingsWindow : Window {
virtual void OnQueryTextFinished(char *str)
{
+ /* The user pressed cancel */
+ if (str == NULL) return;
+
+ assert(this->valuewindow_entry != NULL);
+ assert((this->valuewindow_entry->flags & SEF_KIND_MASK) == SEF_SETTING_KIND);
+ const SettingDesc *sd = this->valuewindow_entry->d.entry.setting;
+
+ int32 value;
if (!StrEmpty(str)) {
- assert(this->valuewindow_entry != NULL);
- assert((this->valuewindow_entry->flags & SEF_KIND_MASK) == SEF_SETTING_KIND);
- const SettingDesc *sd = this->valuewindow_entry->d.entry.setting;
- int32 value = atoi(str);
+ value = atoi(str);
/* Save the correct currency-translated value */
if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate;
+ } else {
+ value = (int32)sd->desc.def;
+ }
- if ((sd->desc.flags & SGF_PER_COMPANY) != 0) {
- SetCompanySetting(this->valuewindow_entry->d.entry.index, value);
- } else {
- SetSettingValue(this->valuewindow_entry->d.entry.index, value);
- }
- this->SetDirty();
+ if ((sd->desc.flags & SGF_PER_COMPANY) != 0) {
+ SetCompanySetting(this->valuewindow_entry->d.entry.index, value);
+ } else {
+ SetSettingValue(this->valuewindow_entry->d.entry.index, value);
}
+ this->SetDirty();
}
virtual void OnResize()