OpenTTD Source 20241224-master-gf74b0cf984
|
Properties of config file settings. More...
#include <settings_internal.h>
Public Member Functions | |
SettingDesc (const SaveLoad &save, SettingFlag flags, bool startup) | |
bool | IsEditable (bool do_command=false) const |
Check whether the setting is editable in the current gamemode. | |
SettingType | GetType () const |
Return the type of the setting. | |
constexpr const std::string & | GetName () const |
Get the name of this setting. | |
virtual bool | IsIntSetting () const |
Check whether this setting is an integer type setting. | |
virtual bool | IsStringSetting () const |
Check whether this setting is an string type setting. | |
const struct IntSettingDesc * | AsIntSetting () const |
Get the setting description of this setting as an integer setting. | |
const struct StringSettingDesc * | AsStringSetting () const |
Get the setting description of this setting as a string setting. | |
virtual std::string | FormatValue (const void *object) const =0 |
Format the value of the setting associated with this object. | |
virtual void | ParseValue (const IniItem *item, void *object) const =0 |
Parse/read the value from the Ini item into the setting associated with this object. | |
virtual bool | IsSameValue (const IniItem *item, void *object) const =0 |
Check whether the value in the Ini item is the same as is saved in this setting in the object. | |
virtual bool | IsDefaultValue (void *object) const =0 |
Check whether the value is the same as the default value. | |
virtual void | ResetToDefault (void *object) const =0 |
Reset the setting to its default value. | |
Data Fields | |
SettingFlag | flags |
Handles how a setting would show up in the GUI (text/currency, etc.). | |
bool | startup |
Setting has to be loaded directly at startup?. | |
SaveLoad | save |
Internal structure (going to savegame, parts to config). | |
Properties of config file settings.
Definition at line 71 of file settings_internal.h.
|
inline |
Definition at line 72 of file settings_internal.h.
const IntSettingDesc * SettingDesc::AsIntSetting | ( | ) | const |
Get the setting description of this setting as an integer setting.
Definition at line 910 of file settings.cpp.
References IsIntSetting().
Referenced by CmdChangeCompanySetting(), CmdChangeSetting(), NewsTypeData::GetDisplay(), HandleOldDiffCustom(), IConsoleGetSetting(), SettingEntry::Init(), LoadSettings(), SetDefaultCompanySettings(), SetSettingValue(), and SyncCompanySettings().
const StringSettingDesc * SettingDesc::AsStringSetting | ( | ) | const |
Get the setting description of this setting as a string setting.
Definition at line 920 of file settings.cpp.
References IsStringSetting().
Referenced by IConsoleGetSetting(), and SetSettingValue().
|
pure virtual |
Format the value of the setting associated with this object.
buf | The before of the buffer to format into. |
last | The end of the buffer to format into. |
object | The object the setting is in. |
Implemented in NullSettingDesc, IntSettingDesc, BoolSettingDesc, OneOfManySettingDesc, ManyOfManySettingDesc, StringSettingDesc, and ListSettingDesc.
Referenced by IConsoleGetSetting(), IniSaveSettings(), and SurveySettingsTable().
|
inlineconstexpr |
Get the name of this setting.
Definition at line 87 of file settings_internal.h.
References SaveLoad::name.
Referenced by IntSettingDesc::ChangeValue(), GetSettingFromName(), GetSettingsDesc(), IConsoleGetSetting(), IniLoadSettings(), IniSaveSettings(), IntSettingDesc::ParseValue(), BoolSettingDesc::ParseValue(), OneOfManySettingDesc::ParseValue(), ManyOfManySettingDesc::ParseValue(), ListSettingDesc::ParseValue(), RemoveEntriesFromIni(), SetSettingValue(), SurveySettingsTable(), and SyncCompanySettings().
SettingType SettingDesc::GetType | ( | ) | const |
Return the type of the setting.
Definition at line 900 of file settings.cpp.
References flags, SF_NOT_IN_SAVE, SF_PER_COMPANY, ST_CLIENT, ST_COMPANY, and ST_GAME.
Referenced by SettingEntry::UpdateFilterState().
|
pure virtual |
Check whether the value is the same as the default value.
object | The object the setting is in. |
Implemented in NullSettingDesc, IntSettingDesc, StringSettingDesc, and ListSettingDesc.
Referenced by SurveySettingsTable().
bool SettingDesc::IsEditable | ( | bool | do_command = false | ) | const |
Check whether the setting is editable in the current gamemode.
do_command | true if this is about checking a command from the server. |
Definition at line 883 of file settings.cpp.
References _network_server, _networking, flags, SF_NETWORK_ONLY, SF_NEWGAME_ONLY, SF_NO_NETWORK, SF_NO_NETWORK_SYNC, SF_PER_COMPANY, SF_SCENEDIT_ONLY, and SF_SCENEDIT_TOO.
Referenced by CmdChangeSetting(), and SettingEntry::DrawSetting().
|
inlinevirtual |
Check whether this setting is an integer type setting.
Reimplemented in IntSettingDesc.
Definition at line 96 of file settings_internal.h.
Referenced by AsIntSetting(), CmdChangeCompanySetting(), CmdChangeSetting(), NewsTypeData::GetDisplay(), IConsoleGetSetting(), and LoadSettings().
|
pure virtual |
Check whether the value in the Ini item is the same as is saved in this setting in the object.
It might be that determining whether the value is the same is way more expensive than just writing the value. In those cases this function may unconditionally return false even though the value might be the same as in the Ini item.
item | The Ini item with the content of this setting. |
object | The object the setting is in. |
Implemented in NullSettingDesc, IntSettingDesc, StringSettingDesc, and ListSettingDesc.
Referenced by IniSaveSettings().
|
inlinevirtual |
Check whether this setting is an string type setting.
Reimplemented in StringSettingDesc.
Definition at line 102 of file settings_internal.h.
Referenced by AsStringSetting(), and IConsoleGetSetting().
|
pure virtual |
Parse/read the value from the Ini item into the setting associated with this object.
item | The Ini item with the content of this setting. |
object | The object the setting is in. |
Implemented in NullSettingDesc, IntSettingDesc, StringSettingDesc, and ListSettingDesc.
Referenced by IniLoadSettings().
|
pure virtual |
Reset the setting to its default value.
Implemented in NullSettingDesc, IntSettingDesc, StringSettingDesc, and ListSettingDesc.
Referenced by PATSChunkHandler::Load().
SettingFlag SettingDesc::flags |
Handles how a setting would show up in the GUI (text/currency, etc.).
Definition at line 76 of file settings_internal.h.
Referenced by IntSettingDesc::ChangeValue(), SettingEntry::DrawSetting(), GetSettingsDesc(), GetType(), IConsoleGetSetting(), IniSaveSettings(), IsEditable(), PATSChunkHandler::Load(), LoadSettings(), IntSettingDesc::MakeValueValid(), SetSettingValue(), SetSettingValue(), and IntSettingDesc::SetValueDParams().
SaveLoad SettingDesc::save |
Internal structure (going to savegame, parts to config).
Definition at line 78 of file settings_internal.h.
Referenced by CmdChangeSetting(), IntSettingDesc::FormatValue(), StringSettingDesc::FormatValue(), ListSettingDesc::FormatValue(), GetSaveLoadFromSettingTable(), GetSettingFromName(), GetSettingsDesc(), IniLoadSettings(), IniSaveSettings(), StringSettingDesc::IsSameValue(), LoadSettings(), IntSettingDesc::MakeValueValid(), ListSettingDesc::ParseValue(), IntSettingDesc::Read(), StringSettingDesc::Read(), SetSettingValue(), SurveySettingsTable(), StringSettingDesc::Write(), and IntSettingDesc::Write().
bool SettingDesc::startup |
Setting has to be loaded directly at startup?.
Definition at line 77 of file settings_internal.h.
Referenced by IniLoadSettings().