diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/settings_gui.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index f4570624d..ef1024278 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -74,7 +74,7 @@ static const StringID _font_zoom_dropdown[] = { static Dimension _circle_size; ///< Dimension of the circle +/- icon. This is here as not all users are within the class of the settings window. -static const void *ResolveVariableAddress(const GameSettings *settings_ptr, const SettingDesc *sd); +static const void *ResolveVariableAddress(const GameSettings *settings_ptr, const IntSettingDesc *sd); /** * Get index of the current screen resolution. @@ -824,8 +824,8 @@ protected: /** Standard setting */ struct SettingEntry : BaseSettingEntry { - const char *name; ///< Name of the setting - const SettingDesc *setting; ///< Setting description of the setting + const char *name; ///< Name of the setting + const IntSettingDesc *setting; ///< Setting description of the setting SettingEntry(const char *name); @@ -1029,8 +1029,7 @@ SettingEntry::SettingEntry(const char *name) void SettingEntry::Init(byte level) { BaseSettingEntry::Init(level); - this->setting = GetSettingFromName(this->name); - assert(this->setting != nullptr); + this->setting = GetSettingFromName(this->name)->AsIntSetting(); } /* Sets the given setting entry to its default value */ @@ -1078,7 +1077,7 @@ bool SettingEntry::IsVisibleByRestrictionMode(RestrictionMode mode) const if (mode == RM_ALL) return true; GameSettings *settings_ptr = &GetGameSettings(); - const SettingDesc *sd = this->setting; + const IntSettingDesc *sd = this->setting; if (mode == RM_BASIC) return (this->setting->cat & SC_BASIC_LIST) != 0; if (mode == RM_ADVANCED) return (this->setting->cat & SC_ADVANCED_LIST) != 0; @@ -1122,7 +1121,7 @@ bool SettingEntry::UpdateFilterState(SettingFilter &filter, bool force_visible) bool visible = true; - const SettingDesc *sd = this->setting; + const IntSettingDesc *sd = this->setting; if (!force_visible && !filter.string.IsEmpty()) { /* Process the search text filter for this item. */ filter.string.ResetState(); @@ -1149,7 +1148,7 @@ bool SettingEntry::UpdateFilterState(SettingFilter &filter, bool force_visible) return visible; } -static const void *ResolveVariableAddress(const GameSettings *settings_ptr, const SettingDesc *sd) +static const void *ResolveVariableAddress(const GameSettings *settings_ptr, const IntSettingDesc *sd) { if ((sd->flags & SGF_PER_COMPANY) != 0) { if (Company::IsValidID(_local_company) && _game_mode != GM_MENU) { @@ -1194,7 +1193,7 @@ void SettingEntry::SetValueDParams(uint first_param, int32 value) const */ void SettingEntry::DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const { - const SettingDesc *sd = this->setting; + const IntSettingDesc *sd = this->setting; const void *var = ResolveVariableAddress(settings_ptr, sd); int state = this->flags & SEF_BUTTONS_MASK; @@ -2075,7 +2074,7 @@ struct GameSettingsWindow : Window { case WID_GS_HELP_TEXT: if (this->last_clicked != nullptr) { - const SettingDesc *sd = this->last_clicked->setting; + const IntSettingDesc *sd = this->last_clicked->setting; int y = r.top; switch (sd->GetType()) { @@ -2179,7 +2178,7 @@ struct GameSettingsWindow : Window { SettingEntry *pe = dynamic_cast<SettingEntry*>(clicked_entry); assert(pe != nullptr); - const SettingDesc *sd = pe->setting; + const IntSettingDesc *sd = pe->setting; /* return if action is only active in network, or only settable by server */ if (!sd->IsEditable()) { @@ -2314,7 +2313,7 @@ struct GameSettingsWindow : Window { if (str == nullptr) return; assert(this->valuewindow_entry != nullptr); - const SettingDesc *sd = this->valuewindow_entry->setting; + const IntSettingDesc *sd = this->valuewindow_entry->setting; int32 value; if (!StrEmpty(str)) { @@ -2361,7 +2360,7 @@ struct GameSettingsWindow : Window { if (widget < 0) { /* Deal with drop down boxes on the panel. */ assert(this->valuedropdown_entry != nullptr); - const SettingDesc *sd = this->valuedropdown_entry->setting; + const IntSettingDesc *sd = this->valuedropdown_entry->setting; assert(sd->flags & SGF_MULTISTRING); SetSettingValue(sd, index); |