Mercurial > hg > openttd
changeset 19926:276a44b0c772 draft
(svn r24860) -Codechange: Add SettingDesc::GetType().
author | frosch <frosch@openttd.org> |
---|---|
date | Wed, 26 Dec 2012 17:43:35 +0000 |
parents | dedb5921ec63 |
children | 9a4e5c5449b0 |
files | src/settings.cpp src/settings_gui.cpp src/settings_internal.h |
diffstat | 3 files changed, 24 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/settings.cpp +++ b/src/settings.cpp @@ -748,6 +748,16 @@ 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. */
--- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1856,12 +1856,11 @@ 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;
--- a/src/settings_internal.h +++ b/src/settings_internal.h @@ -76,6 +76,14 @@ 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 @@ 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