OpenTTD Source  12.0-beta2
SettingDesc Struct Referenceabstract

Properties of config file settings. More...

#include <settings_internal.h>

Inheritance diagram for SettingDesc:
IntSettingDesc ListSettingDesc NullSettingDesc StringSettingDesc BoolSettingDesc OneOfManySettingDesc ManyOfManySettingDesc

Public Member Functions

 SettingDesc (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 IntSettingDescAsIntSetting () const
 Get the setting description of this setting as an integer setting. More...
 
const struct StringSettingDescAsStringSetting () const
 Get the setting description of this setting as a string setting. More...
 
virtual void FormatValue (char *buf, const char *last, 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...
 

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).
 

Detailed Description

Properties of config file settings.

Definition at line 72 of file settings_internal.h.

Member Function Documentation

◆ AsIntSetting()

const IntSettingDesc * SettingDesc::AsIntSetting ( ) const

Get the setting description of this setting as an integer setting.

Returns
The integer setting description.

Definition at line 827 of file settings.cpp.

References IsIntSetting().

Referenced by CmdChangeCompanySetting(), CmdChangeSetting(), NewsTypeData::GetDisplay(), SettingEntry::Init(), LoadSettings(), and SetSettingValue().

◆ AsStringSetting()

const StringSettingDesc * SettingDesc::AsStringSetting ( ) const

Get the setting description of this setting as a string setting.

Returns
The string setting description.

Definition at line 837 of file settings.cpp.

References IsStringSetting().

◆ FormatValue()

virtual void SettingDesc::FormatValue ( char *  buf,
const char *  last,
const void *  object 
) const
pure virtual

Format the value of the setting associated with this object.

Parameters
bufThe before of the buffer to format into.
lastThe end of the buffer to format into.
objectThe object the setting is in.

Implemented in NullSettingDesc, ListSettingDesc, StringSettingDesc, ManyOfManySettingDesc, OneOfManySettingDesc, BoolSettingDesc, and IntSettingDesc.

Referenced by IniSaveSettings().

◆ GetName()

constexpr const std::string& SettingDesc::GetName ( ) const
inlineconstexpr

◆ GetType()

SettingType SettingDesc::GetType ( ) const

Return the type of the setting.

Returns
type of setting

Definition at line 817 of file settings.cpp.

References flags, SF_NOT_IN_SAVE, SF_PER_COMPANY, ST_CLIENT, ST_COMPANY, and ST_GAME.

Referenced by SettingEntry::UpdateFilterState().

◆ IsEditable()

bool SettingDesc::IsEditable ( bool  do_command = false) const

Check whether the setting is editable in the current gamemode.

Parameters
do_commandtrue if this is about checking a command from the server.
Returns
true if editable.

Definition at line 801 of file settings.cpp.

References _network_server, _networking, flags, SF_NETWORK_ONLY, SF_NO_NETWORK_SYNC, and SF_PER_COMPANY.

Referenced by CmdChangeSetting().

◆ IsIntSetting()

virtual bool SettingDesc::IsIntSetting ( ) const
inlinevirtual

Check whether this setting is an integer type setting.

Returns
True when the underlying type is an integer.

Reimplemented in IntSettingDesc.

Definition at line 97 of file settings_internal.h.

Referenced by AsIntSetting(), CmdChangeCompanySetting(), CmdChangeSetting(), NewsTypeData::GetDisplay(), and LoadSettings().

◆ IsSameValue()

virtual bool SettingDesc::IsSameValue ( const IniItem item,
void *  object 
) const
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.

Parameters
itemThe Ini item with the content of this setting.
objectThe object the setting is in.
Returns
True if the value is definitely the same (might be false when the same).

Implemented in NullSettingDesc, ListSettingDesc, StringSettingDesc, and IntSettingDesc.

Referenced by IniSaveSettings().

◆ IsStringSetting()

virtual bool SettingDesc::IsStringSetting ( ) const
inlinevirtual

Check whether this setting is an string type setting.

Returns
True when the underlying type is a string.

Reimplemented in StringSettingDesc.

Definition at line 103 of file settings_internal.h.

Referenced by AsStringSetting().

◆ ParseValue()

virtual void SettingDesc::ParseValue ( const IniItem item,
void *  object 
) const
pure virtual

Parse/read the value from the Ini item into the setting associated with this object.

Parameters
itemThe Ini item with the content of this setting.
objectThe object the setting is in.

Implemented in NullSettingDesc, ListSettingDesc, StringSettingDesc, and IntSettingDesc.

Referenced by IniLoadSettings().


The documentation for this struct was generated from the following files: