OpenTTD Source
20241108-master-g80f628063a
|
Functions and types used internally for the settings configurations. More...
Go to the source code of this file.
Data Structures | |
struct | SettingDesc |
Properties of config file settings. More... | |
struct | IntSettingDesc |
Base integer type, including boolean, settings. More... | |
struct | BoolSettingDesc |
Boolean setting. More... | |
struct | OneOfManySettingDesc |
One of many setting. More... | |
struct | ManyOfManySettingDesc |
Many of many setting. More... | |
struct | StringSettingDesc |
String settings. More... | |
struct | ListSettingDesc |
List/array settings. More... | |
struct | NullSettingDesc |
Placeholder for settings that have been removed, but might still linger in the savegame. More... | |
Typedefs | |
typedef std::variant< IntSettingDesc, BoolSettingDesc, OneOfManySettingDesc, ManyOfManySettingDesc, StringSettingDesc, ListSettingDesc, NullSettingDesc > | SettingVariant |
typedef std::span< const SettingVariant > | SettingTable |
Enumerations | |
enum | SettingFlag : uint16_t { SF_NONE = 0 , SF_GUI_0_IS_SPECIAL = 1 << 0 , SF_GUI_DROPDOWN = 1 << 2 , SF_GUI_CURRENCY = 1 << 3 , SF_NETWORK_ONLY = 1 << 4 , SF_NO_NETWORK = 1 << 5 , SF_NEWGAME_ONLY = 1 << 6 , SF_SCENEDIT_TOO = 1 << 7 , SF_SCENEDIT_ONLY = 1 << 8 , SF_PER_COMPANY = 1 << 9 , SF_NOT_IN_SAVE = 1 << 10 , SF_NOT_IN_CONFIG = 1 << 11 , SF_NO_NETWORK_SYNC = 1 << 12 } |
enum | SettingCategory { SC_NONE = 0 , SC_BASIC_LIST = 1 << 0 , SC_ADVANCED_LIST = 1 << 1 , SC_EXPERT_LIST = 1 << 2 , SC_BASIC = SC_BASIC_LIST | SC_ADVANCED_LIST | SC_EXPERT_LIST , SC_ADVANCED = SC_ADVANCED_LIST | SC_EXPERT_LIST , SC_EXPERT = SC_EXPERT_LIST , SC_END } |
A SettingCategory defines a grouping of the settings. More... | |
enum | SettingType { ST_GAME , ST_COMPANY , ST_CLIENT , ST_ALL } |
Type of settings for filtering. More... | |
Functions | |
static constexpr const SettingDesc * | GetSettingDesc (const SettingVariant &desc) |
Helper to convert the type of the iterated settings description to a pointer to it. More... | |
const SettingDesc * | GetSettingFromName (const std::string_view name) |
Given a name of any setting, return any setting description of it. More... | |
void | GetSaveLoadFromSettingTable (SettingTable settings, std::vector< SaveLoad > &saveloads) |
Get the SaveLoad for all settings in the settings table. More... | |
bool | SetSettingValue (const IntSettingDesc *sd, int32_t value, bool force_newgame=false) |
Top function to save the new value of an element of the Settings struct. More... | |
bool | SetSettingValue (const StringSettingDesc *sd, const std::string value, bool force_newgame=false) |
Set a setting value with a string. More... | |
Functions and types used internally for the settings configurations.
Definition in file settings_internal.h.
enum SettingCategory |
A SettingCategory defines a grouping of the settings.
The group SC_BASIC is intended for settings which also a novice player would like to change and is able to understand. The group SC_ADVANCED is intended for settings which an experienced player would like to use. This is the case for most settings. Finally SC_EXPERT settings only few people want to see in rare cases. The grouping is meant to be inclusive, i.e. all settings in SC_BASIC also will be included in the set of settings in SC_ADVANCED. The group SC_EXPERT contains all settings.
Definition at line 41 of file settings_internal.h.
enum SettingFlag : uint16_t |
Definition at line 16 of file settings_internal.h.
enum SettingType |
Type of settings for filtering.
Enumerator | |
---|---|
ST_GAME | Game setting. |
ST_COMPANY | Company setting. |
ST_CLIENT | Client setting. |
ST_ALL | Used in setting filter to match all types. |
Definition at line 60 of file settings_internal.h.
void GetSaveLoadFromSettingTable | ( | SettingTable | settings, |
std::vector< SaveLoad > & | saveloads | ||
) |
Get the SaveLoad for all settings in the settings table.
settings | The settings table to get the SaveLoad objects from. |
saveloads | A vector to store the result in. |
Definition at line 1641 of file settings.cpp.
References GetSettingDesc(), SettingDesc::save, settings, SlIsObjectCurrentlyValid(), SaveLoad::version_from, and SaveLoad::version_to.
|
staticconstexpr |
Helper to convert the type of the iterated settings description to a pointer to it.
desc | The type of the iterator of the value in SettingTable. |
Definition at line 392 of file settings_internal.h.
Referenced by GetSaveLoadFromSettingTable(), GetSettingFromName(), GetSettingsDesc(), IniLoadSettings(), IniSaveSettings(), PATSChunkHandler::Load(), LoadSettings(), RemoveEntriesFromIni(), and SurveySettingsTable().
const SettingDesc* GetSettingFromName | ( | const std::string_view | name | ) |
Given a name of any setting, return any setting description of it.
name | Name of the setting to return a setting description of. |
nullptr
indicates failure to obtain the description. Definition at line 1669 of file settings.cpp.
References GenericSettingTables(), GetCompanySettingFromName(), GetSettingFromName(), PrivateSettingTables(), and SecretSettingTables().
bool SetSettingValue | ( | const IntSettingDesc * | sd, |
int32_t | value, | ||
bool | force_newgame | ||
) |
Top function to save the new value of an element of the Settings struct.
index | offset in the SettingDesc array of the Settings struct which identifies the setting member we want to change |
value | new value of the setting |
force_newgame | force the newgame settings |
Definition at line 1744 of file settings.cpp.
References _local_company, SettingDesc::AsIntSetting(), SettingDesc::flags, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), and SF_PER_COMPANY.
bool SetSettingValue | ( | const StringSettingDesc * | sd, |
std::string | value, | ||
bool | force_newgame | ||
) |
Set a setting value with a string.
sd | the setting to change. |
value | the value to write |
force_newgame | force the newgame settings |
Definition at line 1819 of file settings.cpp.
References SaveLoad::conv, SettingDesc::flags, GetVarMemType(), SettingDesc::save, SF_NO_NETWORK_SYNC, and SLE_VAR_STRQ.