OpenTTD
settings_internal.h
Go to the documentation of this file.
1 /* $Id: settings_internal.h 24900 2013-01-08 22:46:42Z planetmaker $ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * 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.
6  * 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.
7  * 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/>.
8  */
9 
12 #ifndef SETTINGS_INTERNAL_H
13 #define SETTINGS_INTERNAL_H
14 
15 #include "saveload/saveload.h"
16 
24  /* 4 bytes allocated a maximum of 16 types for GenericType */
25  SDT_BEGIN = 0,
26  SDT_NUMX = 0,
27  SDT_BOOLX = 1,
31  SDT_STRING = 5,
32  SDT_END,
33  /* 10 more possible primitives */
34 };
36 
37 
39  /* 1 byte allocated for a maximum of 8 flags
40  * Flags directing saving/loading of a variable */
41  SGF_NONE = 0,
42  SGF_0ISDISABLED = 1 << 0,
43  SGF_DISPLAY_ABS = 1 << 1,
44  SGF_MULTISTRING = 1 << 2,
45  SGF_NETWORK_ONLY = 1 << 3,
46  SGF_CURRENCY = 1 << 4,
47  SGF_NO_NETWORK = 1 << 5,
48  SGF_NEWGAME_ONLY = 1 << 6,
49  SGF_SCENEDIT_TOO = 1 << 7,
50  SGF_PER_COMPANY = 1 << 8,
51 };
54 
64  SC_NONE = 0,
65 
66  /* Filters for the list */
67  SC_BASIC_LIST = 1 << 0,
68  SC_ADVANCED_LIST = 1 << 1,
69  SC_EXPERT_LIST = 1 << 2,
70 
71  /* Setting classification */
75 
76  SC_END,
77 };
78 
86 
88 };
89 
90 typedef bool OnChange(int32 var);
91 typedef size_t OnConvert(const char *value);
92 
95  const char *name;
96  const void *def;
99  int32 min;
100  uint32 max;
101  int32 interval;
102  const char *many;
109 };
110 
111 struct SettingDesc {
114 
115  bool IsEditable(bool do_command = false) const;
116  SettingType GetType() const;
117 };
118 
119 /* NOTE: The only difference between SettingDesc and SettingDescGlob is
120  * that one uses global variables as a source and the other offsets
121  * in a struct which are bound to a certain variable during runtime.
122  * The only way to differentiate between these two is to check if an object
123  * has been passed to the function or not. If not, then it is a global variable
124  * and save->variable has its address, otherwise save->variable only holds the
125  * offset in a certain struct */
127 
128 const SettingDesc *GetSettingFromName(const char *name, uint *i);
129 bool SetSettingValue(uint index, int32 value, bool force_newgame = false);
130 bool SetSettingValue(uint index, const char *value, bool force_newgame = false);
131 void SetCompanySetting(uint index, int32 value);
132 
133 #endif /* SETTINGS_INTERNAL_H */
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
this setting can be changed in the scenario editor (only makes sense when SGF_NEWGAME_ONLY is set) ...
const void * def
default value given when none is present
bitmasked number where MULTIPLE bits may be set
this setting can be different for each company (saved in company struct)
this setting cannot be changed in a game
SettingGuiFlag flags
handles how a setting would show up in the GUI (text/currency, etc.)
SettingGuiFlagLong
the number represents money, so when reading value multiply by exchange rate
list of integers separated by a comma &#39;,&#39;
Properties of config file settings.
Settings displayed in the list of basic settings.
Settings displayed in the list of advanced settings.
Advanced settings are part of advanced and expert list.
the value represents a limited number of string-options (internally integer)
this setting only applies to network games
const char * name
name of the setting. Used in configuration file and for console
OnChange * proc
callback procedure for when the value is changed
any number-type
Expert settings can only be seen in the expert list.
SaveLoad save
Internal structure (going to savegame, parts to config)
const SettingDesc * GetSettingFromName(const char *name, uint *i)
Given a name of setting, return a setting description of it.
Definition: settings.cpp:2048
size_t OnConvert(const char *value)
callback prototype for conversion error
Functions/types related to saving and loading games.
Used in setting filter to match all types.
display absolute value of the setting
SettingCategory
A SettingCategory defines a grouping of the settings.
StringID str_help
(Translated) string with help text; gui only.
OnConvert * proc_cnvt
callback procedure when loading value mechanism fails
this setting does not apply to network games; it may not be changed during the game ...
bool SetSettingValue(uint index, int32 value, bool force_newgame=false)
Top function to save the new value of an element of the Settings struct.
Definition: settings.cpp:1919
bool OnChange(int32 var)
callback prototype on data modification
SettingCategory cat
assigned categories of the setting
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
string with a pre-allocated buffer
StringID str_val
(Translated) first string describing the value.
a value of zero means the feature is disabled
bitmasked number where only ONE bit may be set
Game setting.
SettingDescType cmd
various flags for the variable
const char * many
ONE/MANY_OF_MANY: string of possible values for this type.
StringID str
(translated) string with descriptive text; gui and console
Company setting.
int32 min
minimum values
SettingDescTypeLong
Convention/Type of settings.
SaveLoad type struct.
Definition: saveload.h:208
Client setting.
SettingType
Type of settings for filtering.
void SetCompanySetting(uint index, int32 value)
Top function to save the new value of an element of the Settings struct.
Definition: settings.cpp:1960
uint32 max
maximum values
int32 interval
the interval to use between settings in the &#39;settings&#39; window. If interval is &#39;0&#39; the interval is dyn...
SettingDescBase desc
Settings structure (going to configuration file)
Settings displayed in the list of expert settings.
Basic settings are part of all lists.
a boolean number