|
OpenTTD Source 20251104-master-g3befbdd52f
|
One of many setting. More...
#include <settings_internal.h>
Public Types | |
| typedef std::optional< uint32_t > | OnConvert(std::string_view value) |
| callback prototype for conversion error | |
Public Types inherited from IntSettingDesc | |
| using | GetTitleCallback = StringID(const IntSettingDesc &sd) |
| using | GetHelpCallback = StringID(const IntSettingDesc &sd) |
| using | GetValueParamsCallback = std::pair< StringParameter, StringParameter >(const IntSettingDesc &sd, int32_t value) |
| using | GetDefaultValueCallback = int32_t(const IntSettingDesc &sd) |
| using | GetRangeCallback = std::tuple< int32_t, uint32_t >(const IntSettingDesc &sd) |
| using | PreChangeCheck = bool(int32_t &value) |
| A check to be performed before the setting gets changed. | |
| using | PostChangeCallback = void(int32_t value) |
| A callback to denote that a setting has been changed. | |
Public Member Functions | |
| template<ConvertibleThroughBaseOrTo< int32_t > Tdef, ConvertibleThroughBaseOrTo< uint32_t > Tmax> | |
| OneOfManySettingDesc (const SaveLoad &save, SettingFlags flags, bool startup, Tdef def, Tmax max, StringID str, StringID str_help, StringID str_val, SettingCategory cat, PreChangeCheck pre_check, PostChangeCallback post_callback, GetTitleCallback get_title_cb, GetHelpCallback get_help_cb, GetValueParamsCallback get_value_params_cb, GetDefaultValueCallback get_def_cb, std::initializer_list< std::string_view > many, OnConvert *many_cnvt) | |
| std::string | FormatSingleValue (uint id) const |
| int32_t | ParseValue (std::string_view str) const override |
| Convert a string representation (external) of an integer-like setting to an integer. | |
| std::string | FormatValue (const void *object) const override |
| Format the value of the setting associated with this object. | |
Public Member Functions inherited from IntSettingDesc | |
| template<ConvertibleThroughBaseOrTo< int32_t > Tdef, ConvertibleThroughBaseOrTo< int32_t > Tmin, ConvertibleThroughBaseOrTo< uint32_t > Tmax, ConvertibleThroughBaseOrTo< int32_t > Tinterval> | |
| IntSettingDesc (const SaveLoad &save, SettingFlags flags, bool startup, Tdef def, Tmin min, Tmax max, Tinterval interval, StringID str, StringID str_help, StringID str_val, SettingCategory cat, PreChangeCheck pre_check, PostChangeCallback post_callback, GetTitleCallback get_title_cb, GetHelpCallback get_help_cb, GetValueParamsCallback get_value_params_cb, GetDefaultValueCallback get_def_cb, GetRangeCallback get_range_cb) | |
| StringID | GetTitle () const |
| Get the title of the setting. | |
| StringID | GetHelp () const |
| Get the help text of the setting. | |
| std::pair< StringParameter, StringParameter > | GetValueParams (int32_t value) const |
| Get parameters for drawing the value of the setting. | |
| int32_t | GetDefaultValue () const |
| Get the default value of the setting. | |
| std::tuple< int32_t, uint32_t > | GetRange () const |
| Get the min/max range for the setting. | |
| virtual bool | IsBoolSetting () const |
| Check whether this setting is a boolean type setting. | |
| bool | IsIntSetting () const override |
| Check whether this setting is an integer type setting. | |
| void | ChangeValue (const void *object, int32_t newvalue) const |
| Handle changing a value. | |
| void | MakeValueValidAndWrite (const void *object, int32_t value) const |
| Make the value valid and then write it to the setting. | |
| 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. | |
| int32_t | Read (const void *object) const |
| Read the integer from the the actual setting. | |
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 | 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. | |
Static Public Member Functions | |
| static std::optional< uint32_t > | ParseSingleValue (std::string_view str, std::span< const std::string_view > many) |
| Find the index value of a ONEofMANY type in a string. | |
Data Fields | |
| std::vector< std::string_view > | many |
| possible values for this type | |
| OnConvert * | many_cnvt |
| callback procedure when loading value mechanism fails | |
Data Fields inherited from IntSettingDesc | |
| int32_t | def |
| default value given when none is present | |
| int32_t | min |
| minimum values | |
| uint32_t | max |
| maximum values | |
| int32_t | interval |
| the interval to use between settings in the 'settings' window. If interval is '0' the interval is dynamically determined | |
| StringID | str |
| (translated) string with descriptive text; gui and console | |
| StringID | str_help |
| (Translated) string with help text; gui only. | |
| StringID | str_val |
| (Translated) first string describing the value. | |
| SettingCategory | cat |
| assigned categories of the setting | |
| PreChangeCheck * | pre_check |
| Callback to check for the validity of the setting. | |
| PostChangeCallback * | post_callback |
| Callback when the setting has been changed. | |
| GetTitleCallback * | get_title_cb |
| GetHelpCallback * | get_help_cb |
| GetValueParamsCallback * | get_value_params_cb |
| GetDefaultValueCallback * | get_def_cb |
| Callback to set the correct default value. | |
| GetRangeCallback * | get_range_cb |
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). | |
One of many setting.
Definition at line 269 of file settings_internal.h.
| typedef std::optional< uint32_t > OneOfManySettingDesc::OnConvert(std::string_view value) |
callback prototype for conversion error
Definition at line 270 of file settings_internal.h.
|
inline |
Definition at line 273 of file settings_internal.h.
| std::string OneOfManySettingDesc::FormatSingleValue | ( | uint | id | ) | const |
Definition at line 333 of file settings.cpp.
|
overridevirtual |
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. |
Reimplemented from IntSettingDesc.
Definition at line 341 of file settings.cpp.
References IntSettingDesc::Read().
|
static |
Find the index value of a ONEofMANY type in a string.
| str | the current value of the setting for which a value needs found |
| many | full domain of values the ONEofMANY setting can have |
Definition at line 188 of file settings.cpp.
References many, IntSettingDesc::str, and StringConsumer::TryReadIntegerBase().
Referenced by ConvertLandscape(), LoadFromConfig(), LookupManyOfMany(), and ParseValue().
|
overridevirtual |
Convert a string representation (external) of an integer-like setting to an integer.
| str | Input string that will be parsed based on the type of desc. |
Reimplemented from IntSettingDesc.
Definition at line 386 of file settings.cpp.
References _settings_error_list, IntSettingDesc::GetDefaultValue(), GetEncodedString(), SettingDesc::GetName(), many, many_cnvt, ParseSingleValue(), and IntSettingDesc::str.
| std::vector<std::string_view> OneOfManySettingDesc::many |
possible values for this type
Definition at line 284 of file settings_internal.h.
Referenced by ParseSingleValue(), ParseValue(), and ManyOfManySettingDesc::ParseValue().
| OnConvert* OneOfManySettingDesc::many_cnvt |
callback procedure when loading value mechanism fails
Definition at line 285 of file settings_internal.h.
Referenced by ParseValue().