OpenTTD Source: src/settings_internal.h Source File

OpenTTD Source 14.0-beta3

settings_internal.h
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10 #ifndef SETTINGS_INTERNAL_H
11 #define SETTINGS_INTERNAL_H
12
13 #include <variant>
14 #include "saveload/saveload.h"
15
16 enum SettingFlag : uint16_t {
17 SF_NONE = 0,
18 SF_GUI_0_IS_SPECIAL = 1 << 0,
19 SF_GUI_DROPDOWN = 1 << 2,
20 SF_GUI_CURRENCY = 1 << 3,
21 SF_NETWORK_ONLY = 1 << 4,
22 SF_NO_NETWORK = 1 << 5,
23 SF_NEWGAME_ONLY = 1 << 6,
24 SF_SCENEDIT_TOO = 1 << 7,
25 SF_SCENEDIT_ONLY = 1 << 8,
26 SF_PER_COMPANY = 1 << 9,
27 SF_NOT_IN_SAVE = 1 << 10,
28 SF_NOT_IN_CONFIG = 1 << 11,
29 SF_NO_NETWORK_SYNC = 1 << 12,
30 };
31 DECLARE_ENUM_AS_BIT_SET(SettingFlag)
32
33
41 enum SettingCategory {
42 SC_NONE = 0,
43
44 /* Filters for the list */
45 SC_BASIC_LIST = 1 << 0,
46 SC_ADVANCED_LIST = 1 << 1,
47 SC_EXPERT_LIST = 1 << 2,
48
49 /* Setting classification */
50 SC_BASIC = SC_BASIC_LIST | SC_ADVANCED_LIST | SC_EXPERT_LIST,
51 SC_ADVANCED = SC_ADVANCED_LIST | SC_EXPERT_LIST,
52 SC_EXPERT = SC_EXPERT_LIST,
53
54 SC_END,
55 };
56
60 enum SettingType {
61 ST_GAME,
62 ST_COMPANY,
63 ST_CLIENT,
64
65 ST_ALL,
66 };
67
68 struct IniItem;
69
71 struct SettingDesc {
72 SettingDesc(const SaveLoad &save, SettingFlag flags, bool startup) :
73 flags(flags), startup(startup), save(save) {}
74 virtual ~SettingDesc() = default;
75
76 SettingFlag flags;
77 bool startup;
78 SaveLoad save;
79
80 bool IsEditable(bool do_command = false) const;
81 SettingType GetType() const;
82
87 constexpr const std::string &GetName() const
88 {
89 return this->save.name;
90 }
91
96 virtual bool IsIntSetting() const { return false; }
97
102 virtual bool IsStringSetting() const { return false; }
103
104 const struct IntSettingDesc *AsIntSetting() const;
105 const struct StringSettingDesc *AsStringSetting() const;
106
113 virtual std::string FormatValue(const void *object) const = 0;
114
120 virtual void ParseValue(const IniItem *item, void *object) const = 0;
121
131 virtual bool IsSameValue(const IniItem *item, void *object) const = 0;
132
139 virtual bool IsDefaultValue(void *object) const = 0;
140 };
141
143 struct IntSettingDesc : SettingDesc {
144 typedef StringID GetTitleCallback(const IntSettingDesc &sd);
145 typedef StringID GetHelpCallback(const IntSettingDesc &sd);
146 typedef void SetValueDParamsCallback(const IntSettingDesc &sd, uint first_param, int32_t value);
147
156 typedef bool PreChangeCheck(int32_t &value);
161 typedef void PostChangeCallback(int32_t value);
162
163 template <
164 typename Tdef,
165 typename Tmin,
166 typename Tmax,
167 typename Tinterval,
168 std::enable_if_t<std::disjunction_v<std::is_convertible<Tdef, int32_t>, std::is_base_of<StrongTypedefBase, Tdef>>, int> = 0,
169 std::enable_if_t<std::disjunction_v<std::is_convertible<Tmin, int32_t>, std::is_base_of<StrongTypedefBase, Tmin>>, int> = 0,
170 std::enable_if_t<std::disjunction_v<std::is_convertible<Tmax, uint32_t>, std::is_base_of<StrongTypedefBase, Tmax>>, int> = 0,
171 std::enable_if_t<std::disjunction_v<std::is_convertible<Tinterval, int32_t>, std::is_base_of<StrongTypedefBase, Tinterval>>, int> = 0
172 >
173 IntSettingDesc(const SaveLoad &save, SettingFlag flags, bool startup, Tdef def,
174 Tmin min, Tmax max, Tinterval interval, StringID str, StringID str_help, StringID str_val,
175 SettingCategory cat, PreChangeCheck pre_check, PostChangeCallback post_callback,
176 GetTitleCallback get_title_cb, GetHelpCallback get_help_cb, SetValueDParamsCallback set_value_dparams_cb) :
177 SettingDesc(save, flags, startup),
178 str(str), str_help(str_help), str_val(str_val), cat(cat), pre_check(pre_check),
179 post_callback(post_callback),
180 get_title_cb(get_title_cb), get_help_cb(get_help_cb), set_value_dparams_cb(set_value_dparams_cb) {
181 if constexpr (std::is_base_of_v<StrongTypedefBase, Tdef>) {
182 this->def = def.base();
183 } else {
184 this->def = def;
185 }
186
187 if constexpr (std::is_base_of_v<StrongTypedefBase, Tmin>) {
188 this->min = min.base();
189 } else {
190 this->min = min;
191 }
192
193 if constexpr (std::is_base_of_v<StrongTypedefBase, Tmax>) {
194 this->max = max.base();
195 } else {
196 this->max = max;
197 }
198
199 if constexpr (std::is_base_of_v<StrongTypedefBase, Tinterval>) {
200 this->interval = interval.base();
201 } else {
202 this->interval = interval;
203 }
204 }
205
206 int32_t def;
207 int32_t min;
208 uint32_t max;
209 int32_t interval;
210 StringID str;
211 StringID str_help;
212 StringID str_val;
213 SettingCategory cat;
214 PreChangeCheck *pre_check;
215 PostChangeCallback *post_callback;
216 GetTitleCallback *get_title_cb;
217 GetHelpCallback *get_help_cb;
218 SetValueDParamsCallback *set_value_dparams_cb;
219
220 StringID GetTitle() const;
221 StringID GetHelp() const;
222 void SetValueDParams(uint first_param, int32_t value) const;
223
228 virtual bool IsBoolSetting() const { return false; }
229 bool IsIntSetting() const override { return true; }
230
231 void ChangeValue(const void *object, int32_t newvalue) const;
232 void MakeValueValidAndWrite(const void *object, int32_t value) const;
233
234 virtual size_t ParseValue(const char *str) const;
235 std::string FormatValue(const void *object) const override;
236 void ParseValue(const IniItem *item, void *object) const override;
237 bool IsSameValue(const IniItem *item, void *object) const override;
238 bool IsDefaultValue(void *object) const override;
239 int32_t Read(const void *object) const;
240
241 private:
242 void MakeValueValid(int32_t &value) const;
243 void Write(const void *object, int32_t value) const;
244 };
245
247 struct BoolSettingDesc : IntSettingDesc {
248 BoolSettingDesc(const SaveLoad &save, SettingFlag flags, bool startup, bool def,
249 StringID str, StringID str_help, StringID str_val, SettingCategory cat,
250 PreChangeCheck pre_check, PostChangeCallback post_callback,
251 GetTitleCallback get_title_cb, GetHelpCallback get_help_cb, SetValueDParamsCallback set_value_dparams_cb) :
252 IntSettingDesc(save, flags, startup, def ? 1 : 0, 0, 1, 0, str, str_help, str_val, cat,
253 pre_check, post_callback, get_title_cb, get_help_cb, set_value_dparams_cb) {}
254
255 static std::optional<bool> ParseSingleValue(const char *str);
256
257 bool IsBoolSetting() const override { return true; }
258 size_t ParseValue(const char *str) const override;
259 std::string FormatValue(const void *object) const override;
260 };
261
263 struct OneOfManySettingDesc : IntSettingDesc {
264 typedef size_t OnConvert(const char *value);
265
266 OneOfManySettingDesc(const SaveLoad &save, SettingFlag flags, bool startup, int32_t def,
267 int32_t max, StringID str, StringID str_help, StringID str_val, SettingCategory cat,
268 PreChangeCheck pre_check, PostChangeCallback post_callback,
269 GetTitleCallback get_title_cb, GetHelpCallback get_help_cb, SetValueDParamsCallback set_value_dparams_cb,
270 std::initializer_list<const char *> many, OnConvert *many_cnvt) :
271 IntSettingDesc(save, flags, startup, def, 0, max, 0, str, str_help, str_val, cat,
272 pre_check, post_callback, get_title_cb, get_help_cb, set_value_dparams_cb), many_cnvt(many_cnvt)
273 {
274 for (auto one : many) this->many.push_back(one);
275 }
276
277 std::vector<std::string> many;
278 OnConvert *many_cnvt;
279
280 static size_t ParseSingleValue(const char *str, size_t len, const std::vector<std::string> &many);
281 std::string FormatSingleValue(uint id) const;
282
283 size_t ParseValue(const char *str) const override;
284 std::string FormatValue(const void *object) const override;
285 };
286
288 struct ManyOfManySettingDesc : OneOfManySettingDesc {
289 ManyOfManySettingDesc(const SaveLoad &save, SettingFlag flags, bool startup,
290 int32_t def, StringID str, StringID str_help, StringID str_val, SettingCategory cat,
291 PreChangeCheck pre_check, PostChangeCallback post_callback,
292 GetTitleCallback get_title_cb, GetHelpCallback get_help_cb, SetValueDParamsCallback set_value_dparams_cb,
293 std::initializer_list<const char *> many, OnConvert *many_cnvt) :
294 OneOfManySettingDesc(save, flags, startup, def, (1 << many.size()) - 1, str, str_help,
295 str_val, cat, pre_check, post_callback, get_title_cb, get_help_cb, set_value_dparams_cb, many, many_cnvt) {}
296
297 size_t ParseValue(const char *str) const override;
298 std::string FormatValue(const void *object) const override;
299 };
300
302 struct StringSettingDesc : SettingDesc {
311 typedef bool PreChangeCheck(std::string &value);
316 typedef void PostChangeCallback(const std::string &value);
317
318 StringSettingDesc(const SaveLoad &save, SettingFlag flags, bool startup, const char *def,
319 uint32_t max_length, PreChangeCheck pre_check, PostChangeCallback post_callback) :
320 SettingDesc(save, flags, startup), def(def == nullptr ? "" : def), max_length(max_length),
321 pre_check(pre_check), post_callback(post_callback) {}
322
323 std::string def;
324 uint32_t max_length;
325 PreChangeCheck *pre_check;
326 PostChangeCallback *post_callback;
327
328 bool IsStringSetting() const override { return true; }
329 void ChangeValue(const void *object, std::string &newval) const;
330
331 std::string FormatValue(const void *object) const override;
332 void ParseValue(const IniItem *item, void *object) const override;
333 bool IsSameValue(const IniItem *item, void *object) const override;
334 bool IsDefaultValue(void *object) const override;
335 const std::string &Read(const void *object) const;
336
337 private:
338 void MakeValueValid(std::string &str) const;
339 void Write(const void *object, const std::string &str) const;
340 };
341
343 struct ListSettingDesc : SettingDesc {
344 ListSettingDesc(const SaveLoad &save, SettingFlag flags, bool startup, const char *def) :
345 SettingDesc(save, flags, startup), def(def) {}
346
347 const char *def;
348
349 std::string FormatValue(const void *object) const override;
350 void ParseValue(const IniItem *item, void *object) const override;
351 bool IsSameValue(const IniItem *item, void *object) const override;
352 bool IsDefaultValue(void *object) const override;
353 };
354
356 struct NullSettingDesc : SettingDesc {
357 NullSettingDesc(const SaveLoad &save) :
358 SettingDesc(save, SF_NOT_IN_CONFIG, false) {}
359
360 std::string FormatValue(const void *) const override { NOT_REACHED(); }
361 void ParseValue(const IniItem *, void *) const override { NOT_REACHED(); }
362 bool IsSameValue(const IniItem *, void *) const override { NOT_REACHED(); }
363 bool IsDefaultValue(void *) const override { NOT_REACHED(); }
364 };
365
366 typedef std::variant<IntSettingDesc, BoolSettingDesc, OneOfManySettingDesc, ManyOfManySettingDesc, StringSettingDesc, ListSettingDesc, NullSettingDesc> SettingVariant;
367
373 static constexpr const SettingDesc *GetSettingDesc(const SettingVariant &desc)
374 {
375 return std::visit([](auto&& arg) -> const SettingDesc * { return &arg; }, desc);
376 }
377
378 typedef std::span<const SettingVariant> SettingTable;
379
380 const SettingDesc *GetSettingFromName(const std::string_view name);
381 void GetSaveLoadFromSettingTable(SettingTable settings, std::vector<SaveLoad> &saveloads);
382 bool SetSettingValue(const IntSettingDesc *sd, int32_t value, bool force_newgame = false);
383 bool SetSettingValue(const StringSettingDesc *sd, const std::string value, bool force_newgame = false);
384
385 #endif /* SETTINGS_INTERNAL_H */
ManyOfManySettingDesc
Many of many setting.
Definition: settings_internal.h:288
OneOfManySettingDesc
One of many setting.
Definition: settings_internal.h:263
StringSettingDesc::MakeValueValid
void MakeValueValid(std::string &str) const
Make the value valid given the limitations of this setting.
Definition: settings.cpp:590
SetSettingValue
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.
Definition: settings.cpp:1747
SettingDesc::IsDefaultValue
virtual bool IsDefaultValue(void *object) const =0
Check whether the value is the same as the default value.
SF_SCENEDIT_TOO
@ SF_SCENEDIT_TOO
This setting can be changed in the scenario editor (only makes sense when SF_NEWGAME_ONLY is set).
Definition: settings_internal.h:24
StringSettingDesc::PreChangeCheck
bool PreChangeCheck(std::string &value)
A check to be performed before the setting gets changed.
Definition: settings_internal.h:311
IntSettingDesc::PreChangeCheck
bool PreChangeCheck(int32_t &value)
A check to be performed before the setting gets changed.
Definition: settings_internal.h:156
StringSettingDesc::pre_check
PreChangeCheck * pre_check
Callback to check for the validity of the setting.
Definition: settings_internal.h:325
SC_EXPERT_LIST
@ SC_EXPERT_LIST
Settings displayed in the list of expert settings.
Definition: settings_internal.h:47
StringSettingDesc::IsSameValue
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.
Definition: settings.cpp:787
IntSettingDesc::cat
SettingCategory cat
assigned categories of the setting
Definition: settings_internal.h:213
StringSettingDesc::PostChangeCallback
void PostChangeCallback(const std::string &value)
A callback to denote that a setting has been changed.
Definition: settings_internal.h:316
NullSettingDesc
Placeholder for settings that have been removed, but might still linger in the savegame.
Definition: settings_internal.h:356
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
ST_GAME
@ ST_GAME
Game setting.
Definition: settings_internal.h:61
IniItem
A single "line" in an ini file.
Definition: ini_type.h:23
SettingDesc::save
SaveLoad save
Internal structure (going to savegame, parts to config).
Definition: settings_internal.h:78
SettingDesc::GetType
SettingType GetType() const
Return the type of the setting.
Definition: settings.cpp:900
SettingDesc::IsEditable
bool IsEditable(bool do_command=false) const
Check whether the setting is editable in the current gamemode.
Definition: settings.cpp:883
SF_SCENEDIT_ONLY
@ SF_SCENEDIT_ONLY
This setting can only be changed in the scenario editor.
Definition: settings_internal.h:25
ST_CLIENT
@ ST_CLIENT
Client setting.
Definition: settings_internal.h:63
saveload.h
ST_COMPANY
@ ST_COMPANY
Company setting.
Definition: settings_internal.h:62
GetSaveLoadFromSettingTable
void GetSaveLoadFromSettingTable(SettingTable settings, std::vector< SaveLoad > &saveloads)
Get the SaveLoad for all settings in the settings table.
Definition: settings.cpp:1644
BoolSettingDesc::FormatValue
std::string FormatValue(const void *object) const override
Format the value of the setting associated with this object.
Definition: settings.cpp:752
StringSettingDesc::Read
const std::string & Read(const void *object) const
Read the string from the the actual setting.
Definition: settings.cpp:616
StringSettingDesc::post_callback
PostChangeCallback * post_callback
Callback when the setting has been changed.
Definition: settings_internal.h:326
SettingDesc::flags
SettingFlag flags
Handles how a setting would show up in the GUI (text/currency, etc.).
Definition: settings_internal.h:76
SettingDesc::IsSameValue
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.
StringSettingDesc::FormatValue
std::string FormatValue(const void *object) const override
Format the value of the setting associated with this object.
Definition: settings.cpp:771
IntSettingDesc::pre_check
PreChangeCheck * pre_check
Callback to check for the validity of the setting.
Definition: settings_internal.h:214
SettingDesc::AsStringSetting
const struct StringSettingDesc * AsStringSetting() const
Get the setting description of this setting as a string setting.
Definition: settings.cpp:920
ManyOfManySettingDesc::ParseValue
size_t ParseValue(const char *str) const override
Convert a string representation (external) of an integer-like setting to an integer.
Definition: settings.cpp:429
IntSettingDesc::IsIntSetting
bool IsIntSetting() const override
Check whether this setting is an integer type setting.
Definition: settings_internal.h:229
SettingDesc::ParseValue
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.
StringSettingDesc
String settings.
Definition: settings_internal.h:302
ListSettingDesc::ParseValue
void ParseValue(const IniItem *item, void *object) const override
Parse/read the value from the Ini item into the setting associated with this object.
Definition: settings.cpp:684
SettingType
SettingType
Type of settings for filtering.
Definition: settings_internal.h:60
SF_GUI_CURRENCY
@ SF_GUI_CURRENCY
The number represents money, so when reading value multiply by exchange rate.
Definition: settings_internal.h:20
StringSettingDesc::ChangeValue
void ChangeValue(const void *object, std::string &newval) const
Handle changing a string value.
Definition: settings.cpp:1836
SF_GUI_0_IS_SPECIAL
@ SF_GUI_0_IS_SPECIAL
A value of zero is possible and has a custom string (the one after "strval").
Definition: settings_internal.h:18
StringSettingDesc::IsStringSetting
bool IsStringSetting() const override
Check whether this setting is an string type setting.
Definition: settings_internal.h:328
IntSettingDesc::str_val
StringID str_val
(Translated) first string describing the value.
Definition: settings_internal.h:212
IntSettingDesc::MakeValueValidAndWrite
void MakeValueValidAndWrite(const void *object, int32_t value) const
Make the value valid and then write it to the setting.
Definition: settings.cpp:498
IntSettingDesc::MakeValueValid
void MakeValueValid(int32_t &value) const
Make the value valid given the limitations of this setting.
Definition: settings.cpp:513
BoolSettingDesc::IsBoolSetting
bool IsBoolSetting() const override
Check whether this setting is a boolean type setting.
Definition: settings_internal.h:257
SettingDesc::startup
bool startup
Setting has to be loaded directly at startup?.
Definition: settings_internal.h:77
IntSettingDesc
Base integer type, including boolean, settings.
Definition: settings_internal.h:143
SC_ADVANCED
@ SC_ADVANCED
Advanced settings are part of advanced and expert list.
Definition: settings_internal.h:51
SettingDesc::GetName
constexpr const std::string & GetName() const
Get the name of this setting.
Definition: settings_internal.h:87
SF_NETWORK_ONLY
@ SF_NETWORK_ONLY
This setting only applies to network games.
Definition: settings_internal.h:21
SettingDesc::FormatValue
virtual std::string FormatValue(const void *object) const =0
Format the value of the setting associated with this object.
IntSettingDesc::def
int32_t def
default value given when none is present
Definition: settings_internal.h:206
StringSettingDesc::ParseValue
void ParseValue(const IniItem *item, void *object) const override
Parse/read the value from the Ini item into the setting associated with this object.
Definition: settings.cpp:677
IntSettingDesc::min
int32_t min
minimum values
Definition: settings_internal.h:207
IntSettingDesc::Write
void Write(const void *object, int32_t value) const
Set the value of a setting.
Definition: settings.cpp:566
IntSettingDesc::PostChangeCallback
void PostChangeCallback(int32_t value)
A callback to denote that a setting has been changed.
Definition: settings_internal.h:161
SF_NO_NETWORK_SYNC
@ SF_NO_NETWORK_SYNC
Do not synchronize over network (but it is saved if SF_NOT_IN_SAVE is not set).
Definition: settings_internal.h:29
settings
fluid_settings_t * settings
FluidSynth settings handle.
Definition: fluidsynth.cpp:21
OneOfManySettingDesc::many_cnvt
OnConvert * many_cnvt
callback procedure when loading value mechanism fails
Definition: settings_internal.h:278
GetSettingDesc
static constexpr const SettingDesc * GetSettingDesc(const SettingVariant &desc)
Helper to convert the type of the iterated settings description to a pointer to it.
Definition: settings_internal.h:373
ListSettingDesc
List/array settings.
Definition: settings_internal.h:343
IntSettingDesc::ChangeValue
void ChangeValue(const void *object, int32_t newvalue) const
Handle changing a value.
Definition: settings.cpp:1591
OneOfManySettingDesc::FormatValue
std::string FormatValue(const void *object) const override
Format the value of the setting associated with this object.
Definition: settings.cpp:369
IntSettingDesc::GetHelp
StringID GetHelp() const
Get the help text of the setting.
Definition: settings.cpp:466
ManyOfManySettingDesc::FormatValue
std::string FormatValue(const void *object) const override
Format the value of the setting associated with this object.
Definition: settings.cpp:375
OneOfManySettingDesc::ParseValue
size_t ParseValue(const char *str) const override
Convert a string representation (external) of an integer-like setting to an integer.
Definition: settings.cpp:414
SettingDesc::IsStringSetting
virtual bool IsStringSetting() const
Check whether this setting is an string type setting.
Definition: settings_internal.h:102
OneOfManySettingDesc::many
std::vector< std::string > many
possible values for this type
Definition: settings_internal.h:277
SC_BASIC
@ SC_BASIC
Basic settings are part of all lists.
Definition: settings_internal.h:50
BoolSettingDesc::ParseValue
size_t ParseValue(const char *str) const override
Convert a string representation (external) of an integer-like setting to an integer.
Definition: settings.cpp:440
BoolSettingDesc::ParseSingleValue
static std::optional< bool > ParseSingleValue(const char *str)
Find whether a string was a boolean true or a boolean false.
Definition: settings.cpp:199
IntSettingDesc::str_help
StringID str_help
(Translated) string with help text; gui only.
Definition: settings_internal.h:211
IntSettingDesc::GetTitle
StringID GetTitle() const
Get the title of the setting.
Definition: settings.cpp:457
IntSettingDesc::interval
int32_t interval
the interval to use between settings in the 'settings' window. If interval is '0' the interval is dyn...
Definition: settings_internal.h:209
IntSettingDesc::IsSameValue
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.
Definition: settings.cpp:758
SF_NO_NETWORK
@ SF_NO_NETWORK
This setting does not apply to network games; it may not be changed during the game.
Definition: settings_internal.h:22
SettingDesc
Properties of config file settings.
Definition: settings_internal.h:71
SettingFlag
SettingFlag
Definition: settings_internal.h:16
SC_BASIC_LIST
@ SC_BASIC_LIST
Settings displayed in the list of basic settings.
Definition: settings_internal.h:45
GetSettingFromName
const SettingDesc * GetSettingFromName(const std::string_view name)
Given a name of any setting, return any setting description of it.
Definition: settings.cpp:1672
IntSettingDesc::max
uint32_t max
maximum values
Definition: settings_internal.h:208
SF_NEWGAME_ONLY
@ SF_NEWGAME_ONLY
This setting cannot be changed in a game.
Definition: settings_internal.h:23
IntSettingDesc::str
StringID str
(translated) string with descriptive text; gui and console
Definition: settings_internal.h:210
IntSettingDesc::Read
int32_t Read(const void *object) const
Read the integer from the the actual setting.
Definition: settings.cpp:577
ListSettingDesc::def
const char * def
default value given when none is present
Definition: settings_internal.h:347
IntSettingDesc::IsBoolSetting
virtual bool IsBoolSetting() const
Check whether this setting is a boolean type setting.
Definition: settings_internal.h:228
StringSettingDesc::max_length
uint32_t max_length
Maximum length of the string, 0 means no maximum length.
Definition: settings_internal.h:324
IntSettingDesc::SetValueDParams
void SetValueDParams(uint first_param, int32_t value) const
Set the DParams for drawing the value of the setting.
Definition: settings.cpp:476
IntSettingDesc::FormatValue
std::string FormatValue(const void *object) const override
Format the value of the setting associated with this object.
Definition: settings.cpp:741
ListSettingDesc::IsSameValue
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.
Definition: settings.cpp:803
NullSettingDesc::ParseValue
void ParseValue(const IniItem *, void *) const override
Parse/read the value from the Ini item into the setting associated with this object.
Definition: settings_internal.h:361
IntSettingDesc::ParseValue
virtual size_t ParseValue(const char *str) const
Convert a string representation (external) of an integer-like setting to an integer.
Definition: settings.cpp:395
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:29
BoolSettingDesc
Boolean setting.
Definition: settings_internal.h:247
StringSettingDesc::Write
void Write(const void *object, const std::string &str) const
Write a string to the actual setting.
Definition: settings.cpp:606
StringSettingDesc::def
std::string def
Default value given when none is present.
Definition: settings_internal.h:323
SF_NOT_IN_SAVE
@ SF_NOT_IN_SAVE
Do not save with savegame, basically client-based.
Definition: settings_internal.h:27
NullSettingDesc::IsSameValue
bool IsSameValue(const IniItem *, void *) const override
Check whether the value in the Ini item is the same as is saved in this setting in the object.
Definition: settings_internal.h:362
ListSettingDesc::FormatValue
std::string FormatValue(const void *object) const override
Convert an integer-array (intlist) to a string representation.
Definition: settings.cpp:338
IntSettingDesc::post_callback
PostChangeCallback * post_callback
Callback when the setting has been changed.
Definition: settings_internal.h:215
SettingCategory
SettingCategory
A SettingCategory defines a grouping of the settings.
Definition: settings_internal.h:41
ST_ALL
@ ST_ALL
Used in setting filter to match all types.
Definition: settings_internal.h:65
ListSettingDesc::IsDefaultValue
bool IsDefaultValue(void *object) const override
Check whether the value is the same as the default value.
Definition: settings.cpp:809
SC_ADVANCED_LIST
@ SC_ADVANCED_LIST
Settings displayed in the list of advanced settings.
Definition: settings_internal.h:46
SF_GUI_DROPDOWN
@ SF_GUI_DROPDOWN
The value represents a limited number of string-options (internally integer) presented as dropdown.
Definition: settings_internal.h:19
SaveLoad::name
std::string name
Name of this field (optional, used for tables).
Definition: saveload.h:695
IntSettingDesc::IsDefaultValue
bool IsDefaultValue(void *object) const override
Check whether the value is the same as the default value.
Definition: settings.cpp:765
NullSettingDesc::IsDefaultValue
bool IsDefaultValue(void *) const override
Check whether the value is the same as the default value.
Definition: settings_internal.h:363
SC_EXPERT
@ SC_EXPERT
Expert settings can only be seen in the expert list.
Definition: settings_internal.h:52
SettingDesc::IsIntSetting
virtual bool IsIntSetting() const
Check whether this setting is an integer type setting.
Definition: settings_internal.h:96
SaveLoad
SaveLoad type struct.
Definition: saveload.h:694
SF_PER_COMPANY
@ SF_PER_COMPANY
This setting can be different for each company (saved in company struct).
Definition: settings_internal.h:26
StringSettingDesc::IsDefaultValue
bool IsDefaultValue(void *object) const override
Check whether the value is the same as the default value.
Definition: settings.cpp:797
NullSettingDesc::FormatValue
std::string FormatValue(const void *) const override
Format the value of the setting associated with this object.
Definition: settings_internal.h:360
OneOfManySettingDesc::OnConvert
size_t OnConvert(const char *value)
callback prototype for conversion error
Definition: settings_internal.h:264
OneOfManySettingDesc::ParseSingleValue
static size_t ParseSingleValue(const char *str, size_t len, const std::vector< std::string > &many)
Find the index value of a ONEofMANY type in a string separated by |.
Definition: settings.cpp:179
SettingDesc::AsIntSetting
const struct IntSettingDesc * AsIntSetting() const
Get the setting description of this setting as an integer setting.
Definition: settings.cpp:910
SF_NOT_IN_CONFIG
@ SF_NOT_IN_CONFIG
Do not save to config file.
Definition: settings_internal.h:28