summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/settings.cpp10
-rw-r--r--src/settings_gui.cpp11
-rw-r--r--src/settings_internal.h9
3 files changed, 24 insertions, 6 deletions
diff --git a/src/settings.cpp b/src/settings.cpp
index e1649b269..5a80b9bbd 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -748,6 +748,16 @@ bool SettingDesc::IsEditable(bool do_command) const
return true;
}
+/**
+ * Return the type of the setting.
+ * @return type of setting
+ */
+SettingType SettingDesc::GetType() const
+{
+ if (this->desc.flags & SGF_PER_COMPANY) return ST_COMPANY;
+ return (this->save.conv & SLF_NOT_IN_SAVE) ? ST_CLIENT : ST_GAME;
+}
+
/* Begin - Callback Functions for the various settings. */
/** Reposition the main toolbar as the setting changed. */
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 4164e50a9..30daf610d 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1856,12 +1856,11 @@ struct GameSettingsWindow : Window {
const SettingDesc *sd = this->last_clicked->d.entry.setting;
int y = r.top;
- if (sd->desc.flags & SGF_PER_COMPANY) {
- SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_COMPANY_INGAME);
- } else if (sd->save.conv & SLF_NOT_IN_SAVE) {
- SetDParam(0, STR_CONFIG_SETTING_TYPE_CLIENT);
- } else {
- SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_GAME_MENU : STR_CONFIG_SETTING_TYPE_GAME_INGAME);
+ switch (sd->GetType()) {
+ case ST_COMPANY: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_COMPANY_INGAME); break;
+ case ST_CLIENT: SetDParam(0, STR_CONFIG_SETTING_TYPE_CLIENT); break;
+ case ST_GAME: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_GAME_MENU : STR_CONFIG_SETTING_TYPE_GAME_INGAME); break;
+ default: NOT_REACHED();
}
DrawString(r.left, r.right, y, STR_CONFIG_SETTING_TYPE);
y += FONT_HEIGHT_NORMAL;
diff --git a/src/settings_internal.h b/src/settings_internal.h
index 9bda96fef..a6953e36d 100644
--- a/src/settings_internal.h
+++ b/src/settings_internal.h
@@ -76,6 +76,14 @@ enum SettingCategory {
SC_END,
};
+/**
+ * Type of settings for filtering.
+ */
+enum SettingType {
+ ST_GAME, ///< Game setting.
+ ST_COMPANY, ///< Company setting.
+ ST_CLIENT, ///< Client setting.
+};
typedef bool OnChange(int32 var); ///< callback prototype on data modification
typedef size_t OnConvert(const char *value); ///< callback prototype for convertion error
@@ -103,6 +111,7 @@ struct SettingDesc {
SaveLoad save; ///< Internal structure (going to savegame, parts to config)
bool IsEditable(bool do_command = false) const;
+ SettingType GetType() const;
};
/* NOTE: The only difference between SettingDesc and SettingDescGlob is