mirror of https://github.com/OpenTTD/OpenTTD
(svn r24860) -Codechange: Add SettingDesc::GetType().
parent
9bce12a0ce
commit
0efd29b71b
|
@ -748,6 +748,16 @@ bool SettingDesc::IsEditable(bool do_command) const
|
||||||
return true;
|
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. */
|
/* Begin - Callback Functions for the various settings. */
|
||||||
|
|
||||||
/** Reposition the main toolbar as the setting changed. */
|
/** Reposition the main toolbar as the setting changed. */
|
||||||
|
|
|
@ -1856,12 +1856,11 @@ struct GameSettingsWindow : Window {
|
||||||
const SettingDesc *sd = this->last_clicked->d.entry.setting;
|
const SettingDesc *sd = this->last_clicked->d.entry.setting;
|
||||||
|
|
||||||
int y = r.top;
|
int y = r.top;
|
||||||
if (sd->desc.flags & SGF_PER_COMPANY) {
|
switch (sd->GetType()) {
|
||||||
SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_COMPANY_INGAME);
|
case ST_COMPANY: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_COMPANY_INGAME); break;
|
||||||
} else if (sd->save.conv & SLF_NOT_IN_SAVE) {
|
case ST_CLIENT: SetDParam(0, STR_CONFIG_SETTING_TYPE_CLIENT); break;
|
||||||
SetDParam(0, STR_CONFIG_SETTING_TYPE_CLIENT);
|
case ST_GAME: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_GAME_MENU : STR_CONFIG_SETTING_TYPE_GAME_INGAME); break;
|
||||||
} else {
|
default: NOT_REACHED();
|
||||||
SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_GAME_MENU : STR_CONFIG_SETTING_TYPE_GAME_INGAME);
|
|
||||||
}
|
}
|
||||||
DrawString(r.left, r.right, y, STR_CONFIG_SETTING_TYPE);
|
DrawString(r.left, r.right, y, STR_CONFIG_SETTING_TYPE);
|
||||||
y += FONT_HEIGHT_NORMAL;
|
y += FONT_HEIGHT_NORMAL;
|
||||||
|
|
|
@ -76,6 +76,14 @@ enum SettingCategory {
|
||||||
SC_END,
|
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 bool OnChange(int32 var); ///< callback prototype on data modification
|
||||||
typedef size_t OnConvert(const char *value); ///< callback prototype for convertion error
|
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)
|
SaveLoad save; ///< Internal structure (going to savegame, parts to config)
|
||||||
|
|
||||||
bool IsEditable(bool do_command = false) const;
|
bool IsEditable(bool do_command = false) const;
|
||||||
|
SettingType GetType() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* NOTE: The only difference between SettingDesc and SettingDescGlob is
|
/* NOTE: The only difference between SettingDesc and SettingDescGlob is
|
||||||
|
|
Loading…
Reference in New Issue