OpenTTD Source: SettingDesc Struct Reference

OpenTTD Source 15.0-RC2

Public Member Functions | Data Fields
SettingDesc Struct Referenceabstract

Properties of config file settings. More...

`#include <settings_internal.h>`

Inheritance diagram for SettingDesc:

## Public Member Functions
| 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 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
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

Properties of config file settings.

Definition at line 71 of file settings_internal.h.

## Constructor & Destructor Documentation

## ◆ SettingDesc()

SettingDesc::SettingDesc | ( | const SaveLoad & | save,
|  | SettingFlags | flags,
|  | bool | startup
| ) |  |
| inline

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 921 of file settings.cpp.

References IsIntSetting().

Referenced by CmdChangeCompanySetting(), CmdChangeSetting(), NewsTypeData::GetDisplay(), HandleOldDiffCustom(), IConsoleGetSetting(), SettingEntry::Init(), LoadSettings(), CheatWindow::OnQueryTextFinished(), CheatWindow::OnTooltip(), SetDefaultCompanySettings(), SetSettingValue(), and SyncCompanySettings().

## ◆ 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 931 of file settings.cpp.

References IsStringSetting().

Referenced by IConsoleGetSetting(), and SetSettingValue().

## ◆ FormatValue()

virtual std::string SettingDesc::FormatValue | ( | const void * | object | ) | const
| pure virtual

Format the value of the setting associated with this object.

Parameters

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

## ◆ GetName()

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

Get the name of this setting.

Returns
  The name of the setting.

Definition at line 87 of file settings_internal.h.

References SaveLoad::name.

Referenced by IntSettingDesc::ChangeValue(), GetSettingFromName(), GetSettingsDesc(), IConsoleGetSetting(), IniLoadSettings(), IniSaveSettings(), ListSettingDesc::ParseValue(), IntSettingDesc::ParseValue(), BoolSettingDesc::ParseValue(), OneOfManySettingDesc::ParseValue(), ManyOfManySettingDesc::ParseValue(), RemoveEntriesFromIni(), SetSettingValue(), SurveySettingsTable(), and SyncCompanySettings().

## ◆ GetType()

SettingType SettingDesc::GetType | ( |  | ) | const

Return the type of the setting.

Returns
  type of setting

Definition at line 911 of file settings.cpp.

References flags, NotInSave, PerCompany, ST_CLIENT, ST_COMPANY, ST_GAME, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

Referenced by GameOptionsWindow::DrawWidget(), and SettingEntry::UpdateFilterState().

## ◆ IsDefaultValue()

virtual bool SettingDesc::IsDefaultValue | ( | void * | object | ) | const
| pure virtual

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

Parameters

  object | The object the setting is in.

Returns
  true iff the value is the default value.

Implemented in NullSettingDesc, IntSettingDesc, StringSettingDesc, and ListSettingDesc.

Referenced by SurveySettingsTable().

## ◆ IsEditable()

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

Check whether the setting is editable in the current gamemode.

Parameters

  do_command | true if this is about checking a command from the server.

Returns
  true if editable.

Definition at line 894 of file settings.cpp.

References _network_server, _networking, flags, NetworkOnly, NewgameOnly, NoNetwork, NoNetworkSync, PerCompany, SceneditOnly, SceneditToo, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

Referenced by CmdChangeSetting(), and SettingEntry::DrawSetting().

## ◆ 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 96 of file settings_internal.h.

Referenced by AsIntSetting(), CmdChangeCompanySetting(), CmdChangeSetting(), NewsTypeData::GetDisplay(), IConsoleGetSetting(), 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

  item | The Ini item with the content of this setting.
  object | The object the setting is in.

Returns
  True if the value is definitely the same (might be false when the same).

Implemented in NullSettingDesc, IntSettingDesc, StringSettingDesc, and ListSettingDesc.

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 102 of file settings_internal.h.

Referenced by AsStringSetting(), and IConsoleGetSetting().

## ◆ 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

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

## ◆ ResetToDefault()

virtual void SettingDesc::ResetToDefault | ( | void * | object | ) | const
| pure virtual

Reset the setting to its default value.

Implemented in NullSettingDesc, IntSettingDesc, StringSettingDesc, and ListSettingDesc.

Referenced by ResetSettings().

## Field Documentation

## ◆ flags

SettingFlags 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(), IntSettingDesc::GetValueParams(), IConsoleGetSetting(), IniSaveSettings(), IsEditable(), LoadSettings(), IntSettingDesc::MakeValueValid(), GameOptionsWindow::OnDropdownSelect(), CheatWindow::OnQueryTextFinished(), GameOptionsWindow::OnQueryTextFinished(), ResetSettings(), SetSettingValue(), and SetSettingValue().

## ◆ save

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(), IntSettingDesc::Write(), and StringSettingDesc::Write().

## ◆ startup

bool SettingDesc::startup

Setting has to be loaded directly at startup?.

Definition at line 77 of file settings_internal.h.

Referenced by IniLoadSettings().

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

- src/settings_internal.h
- src/settings.cpp