author | truebrain |
Mon, 30 Jun 2008 13:51:28 +0000 | |
branch | noai |
changeset 11102 | aacdde10b4ad |
parent 10829 | 8a0ec0f0f928 |
permissions | -rw-r--r-- |
9723 | 1 |
/* $Id$ */ |
2 |
||
3 |
/** @file settings_internal.h Functions and types used internally for the settings configurations. */ |
|
4 |
||
5 |
#ifndef SETTINGS_INTERNAL_H |
|
6 |
#define SETTINGS_INTERNAL_H |
|
7 |
||
8 |
#include "saveload.h" |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
9 |
#include "settings_type.h" |
9723 | 10 |
|
11 |
/** Convention/Type of settings. This is then further specified if necessary |
|
12 |
* with the SLE_ (SLE_VAR/SLE_FILE) enums in saveload.h |
|
13 |
* @see VarTypes |
|
14 |
* @see SettingDescBase */ |
|
15 |
enum SettingDescTypeLong { |
|
16 |
/* 4 bytes allocated a maximum of 16 types for GenericType */ |
|
17 |
SDT_BEGIN = 0, |
|
18 |
SDT_NUMX = 0, ///< any number-type |
|
19 |
SDT_BOOLX = 1, ///< a boolean number |
|
20 |
SDT_ONEOFMANY = 2, ///< bitmasked number where only ONE bit may be set |
|
21 |
SDT_MANYOFMANY = 3, ///< bitmasked number where MULTIPLE bits may be set |
|
22 |
SDT_INTLIST = 4, ///< list of integers seperated by a comma ',' |
|
23 |
SDT_STRING = 5, ///< string with a pre-allocated buffer |
|
24 |
SDT_END, |
|
25 |
/* 10 more possible primitives */ |
|
26 |
}; |
|
27 |
||
28 |
template <> struct EnumPropsT<SettingDescTypeLong> : MakeEnumPropsT<SettingDescTypeLong, byte, SDT_BEGIN, SDT_END, SDT_END> {}; |
|
29 |
typedef TinyEnumT<SettingDescTypeLong> SettingDescType; |
|
30 |
||
31 |
||
32 |
enum SettingGuiFlagLong { |
|
33 |
/* 8 bytes allocated for a maximum of 8 flags |
|
34 |
* Flags directing saving/loading of a variable */ |
|
35 |
SGF_NONE = 0, |
|
36 |
SGF_0ISDISABLED = 1 << 0, ///< a value of zero means the feature is disabled |
|
37 |
SGF_NOCOMMA = 1 << 1, ///< number without any thousand seperators (no formatting) |
|
38 |
SGF_MULTISTRING = 1 << 2, ///< the value represents a limited number of string-options (internally integer) |
|
39 |
SGF_NETWORK_ONLY = 1 << 3, ///< this setting only applies to network games |
|
40 |
SGF_CURRENCY = 1 << 4, ///< the number represents money, so when reading value multiply by exchange rate |
|
41 |
SGF_NO_NETWORK = 1 << 5, ///< this setting does not apply to network games; it may not be changed during the game |
|
10715
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
9724
diff
changeset
|
42 |
SGF_NEWGAME_ONLY = 1 << 6, ///< this setting cannot be changed in inside a game |
6bdf79ffb022
(svn r13265) [NoAI] -Sync with trunk r13185:13264.
rubidium
parents:
9724
diff
changeset
|
43 |
SGF_END = 1 << 7, |
9723 | 44 |
}; |
45 |
||
46 |
DECLARE_ENUM_AS_BIT_SET(SettingGuiFlagLong); |
|
47 |
template <> struct EnumPropsT<SettingGuiFlagLong> : MakeEnumPropsT<SettingGuiFlagLong, byte, SGF_NONE, SGF_END, SGF_END> {}; |
|
48 |
typedef TinyEnumT<SettingGuiFlagLong> SettingGuiFlag; |
|
49 |
||
50 |
||
51 |
typedef int32 OnChange(int32 var); ///< callback prototype on data modification |
|
52 |
typedef int32 OnConvert(const char *value); ///< callback prototype for convertion error |
|
53 |
||
54 |
struct SettingDescBase { |
|
55 |
const char *name; ///< name of the setting. Used in configuration file and for console |
|
56 |
const void *def; ///< default value given when none is present |
|
57 |
SettingDescType cmd; ///< various flags for the variable |
|
58 |
SettingGuiFlag flags; ///< handles how a setting would show up in the GUI (text/currency, etc.) |
|
59 |
int32 min, max; ///< minimum and maximum values |
|
60 |
int32 interval; ///< the interval to use between settings in the 'patches' window. If interval is '0' the interval is dynamically determined |
|
61 |
const char *many; ///< ONE/MANY_OF_MANY: string of possible values for this type |
|
62 |
StringID str; ///< (translated) string with descriptive text; gui and console |
|
63 |
OnChange *proc; ///< callback procedure for when the value is changed |
|
64 |
OnConvert *proc_cnvt; ///< callback procedure when loading value mechanism fails |
|
65 |
}; |
|
66 |
||
67 |
struct SettingDesc { |
|
68 |
SettingDescBase desc; ///< Settings structure (going to configuration file) |
|
69 |
SaveLoad save; ///< Internal structure (going to savegame, parts to config) |
|
70 |
}; |
|
71 |
||
72 |
/* NOTE: The only difference between SettingDesc and SettingDescGlob is |
|
73 |
* that one uses global variables as a source and the other offsets |
|
74 |
* in a struct which are bound to a certain variable during runtime. |
|
75 |
* The only way to differentiate between these two is to check if an object |
|
76 |
* has been passed to the function or not. If not, then it is a global variable |
|
77 |
* and save->variable has its address, otherwise save->variable only holds the |
|
78 |
* offset in a certain struct */ |
|
79 |
typedef SettingDesc SettingDescGlobVarList; |
|
80 |
||
81 |
enum IniGroupType { |
|
82 |
IGT_VARIABLES = 0, ///< values of the form "landscape = hilly" |
|
83 |
IGT_LIST = 1, ///< a list of values, seperated by \n and terminated by the next group block |
|
84 |
}; |
|
85 |
||
86 |
const SettingDesc *GetPatchFromName(const char *name, uint *i); |
|
10776 | 87 |
bool SetPatchValue(uint index, int32 value); |
10829 | 88 |
bool SetPatchValue(uint index, const char *value); |
9723 | 89 |
|
90 |
#endif /* SETTINGS_H */ |