OpenTTD Source
20241120-master-g6d3adc6169
|
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. More... | |
SettingType | GetType () const |
Return the type of the setting. More... | |
constexpr const std::string & | GetName () const |
Get the name of this setting. More... | |
virtual bool | IsIntSetting () const |
Check whether this setting is an integer type setting. More... | |
virtual bool | IsStringSetting () const |
Check whether this setting is an string type setting. More... | |
const struct IntSettingDesc * | AsIntSetting () const |
Get the setting description of this setting as an integer setting. More... | |
const struct StringSettingDesc * | AsStringSetting () const |
Get the setting description of this setting as a string setting. More... | |
virtual std::string | FormatValue (const void *object) const =0 |
Format the value of the setting associated with this object. More... | |
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. More... | |
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. More... | |
virtual bool | IsDefaultValue (void *object) const =0 |
Check whether the value is the same as the default value. More... | |
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.
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(), SettingEntry::Init(), LoadSettings(), and SetSettingValue().
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().
|
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 ListSettingDesc, StringSettingDesc, ManyOfManySettingDesc, OneOfManySettingDesc, BoolSettingDesc, IntSettingDesc, and NullSettingDesc.
Referenced by 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(), IniLoadSettings(), IniSaveSettings(), IntSettingDesc::ParseValue(), BoolSettingDesc::ParseValue(), OneOfManySettingDesc::ParseValue(), ManyOfManySettingDesc::ParseValue(), ListSettingDesc::ParseValue(), RemoveEntriesFromIni(), and SurveySettingsTable().
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 ListSettingDesc, StringSettingDesc, IntSettingDesc, and NullSettingDesc.
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_NO_NETWORK_SYNC, and SF_PER_COMPANY.
Referenced by CmdChangeSetting().
|
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(), 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 ListSettingDesc, StringSettingDesc, IntSettingDesc, and NullSettingDesc.
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().
|
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 ListSettingDesc, StringSettingDesc, IntSettingDesc, and NullSettingDesc.
Referenced by IniLoadSettings().