OpenTTD Source 20260206-master-g4d4e37dbf1
ListSettingDesc Struct Reference

List/array settings. More...

#include <settings_internal.h>

Inheritance diagram for ListSettingDesc:
SettingDesc

Public Member Functions

 ListSettingDesc (const SaveLoad &save, SettingFlags flags, bool startup, std::string_view def)
std::string FormatValue (const void *object) const override
 Convert a list to a string representation.
void ParseValue (const IniItem *item, void *object) const override
 Parse/read the value from the Ini item into the setting associated with this object.
bool IsSameValue (const IniItem *item, void *object) const override
 Check whether the value in the Ini item is the same as is saved in this setting in the object.
bool IsDefaultValue (void *object) const override
 Check whether the value is the same as the default value.
void ResetToDefault (void *object) const override
 Reset the setting to its default value.
Public Member Functions inherited from SettingDesc
 SettingDesc (const SaveLoad &save, SettingFlags 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 IntSettingDescAsIntSetting () const
 Get the setting description of this setting as an integer setting.
const struct StringSettingDescAsStringSetting () const
 Get the setting description of this setting as a string setting.

Data Fields

std::string_view def
 default value given when none is present
Data Fields inherited from SettingDesc
SettingFlags 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

List/array settings.

Definition at line 370 of file settings_internal.h.

Constructor & Destructor Documentation

◆ ListSettingDesc()

ListSettingDesc::ListSettingDesc ( const SaveLoad & save,
SettingFlags flags,
bool startup,
std::string_view def )
inline

Definition at line 371 of file settings_internal.h.

Member Function Documentation

◆ FormatValue()

std::string ListSettingDesc::FormatValue ( const void * object) const
overridevirtual

Convert a list to a string representation.

Each value is separated by a comma or a space character

Parameters
objectThe object to read the list from.
Returns
The string representation of the list.

Implements SettingDesc.

Definition at line 307 of file settings.cpp.

References GetVariableAddress(), GetVarMemType(), and SettingDesc::save.

◆ IsDefaultValue()

bool ListSettingDesc::IsDefaultValue ( void * object) const
overridevirtual

Check whether the value is the same as the default value.

Parameters
objectThe object the setting is in.
Returns
true iff the value is the default value.

Implements SettingDesc.

Definition at line 811 of file settings.cpp.

◆ IsSameValue()

bool ListSettingDesc::IsSameValue ( const IniItem * item,
void * object ) const
overridevirtual

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

Implements SettingDesc.

Definition at line 805 of file settings.cpp.

◆ ParseValue()

void ListSettingDesc::ParseValue ( const IniItem * item,
void * object ) const
overridevirtual

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.

Implements SettingDesc.

Definition at line 671 of file settings.cpp.

References _settings_error_list, def, GetEncodedString(), SettingDesc::GetName(), GetVariableAddress(), GetVarMemType(), LoadIntList(), SettingDesc::save, and IniItem::value.

◆ ResetToDefault()

void ListSettingDesc::ResetToDefault ( void * object) const
overridevirtual

Reset the setting to its default value.

Implements SettingDesc.

Definition at line 817 of file settings.cpp.

Field Documentation

◆ def

std::string_view ListSettingDesc::def

default value given when none is present

Definition at line 374 of file settings_internal.h.

Referenced by ParseValue().


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