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 */