author | Darkvater |
Thu, 02 Mar 2006 00:07:41 +0000 | |
changeset 3116 | 031230112b25 |
parent 3115 | 1f4949f5dc5d |
child 3118 | 99926945ccb1 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
3 |
#ifndef SETTINGS_H |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
4 |
#define SETTINGS_H |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
5 |
|
3115
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
6 |
#include "saveload.h" |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
7 |
|
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
8 |
/** Convention/Type of settings. This is then further specified if necessary |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
9 |
* with the SLE_ (SLE_VAR/SLE_FILE) enums in saveload.h |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
10 |
* @see VarTypes |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
11 |
* @see SettingDescBase */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
12 |
enum SettingDescType { |
2972
f9fcee7f3815
(svn r3547) - [Patches]: do some general cleanup, commentarization before starting actual work. This patch contains no functional changes (I hope). It might break GPMI-builds though when trying to join a trunk/ network game or vice versa. To solve, you can change the order of the first 8 enums in SettingDescType. I think that'll work.
Darkvater
parents:
2307
diff
changeset
|
13 |
/* 4 bytes allocated a maximum of 16 types for GenericType */ |
3115
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
14 |
SDT_NUMX = 0, // any number-type |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
15 |
SDT_BOOLX = 1, // a boolean number |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
16 |
SDT_ONEOFMANY = 2, // bitmasked number where only ONE bit may be set |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
17 |
SDT_MANYOFMANY = 3, // bitmasked number where MULTIPLE bits may be set |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
18 |
SDT_INTLIST = 4, // list of integers seperated by a comma ',' |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
19 |
SDT_STRING = 5, // string with a pre-allocated buffer |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
20 |
/* 10 more possible primitives */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
21 |
}; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
22 |
|
3115
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
23 |
enum SettingGuiFlag { |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
24 |
/* 8 bytes allocated for a maximum of 8 flags |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
25 |
* Flags directing saving/loading of a variable */ |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
26 |
SGF_0ISDISABLED = 1 << 0, ///< a value of zero means the feature is disabled |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
27 |
SGF_NOCOMMA = 1 << 1, ///< number without any thousand seperators (no formatting) |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
28 |
SGF_MULTISTRING = 1 << 2, ///< the value represents a limited number of string-options (internally integer) |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
29 |
SGF_NETWORK_ONLY = 1 << 3, ///< this setting only applies to network games |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
30 |
SGF_CURRENCY = 1 << 4, ///< the number represents money, so when reading value multiply by exchange rate |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
31 |
/* 3 more possible flags */ |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
32 |
}; |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
33 |
|
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
34 |
typedef int32 OnChange(int32 var); |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
35 |
typedef byte SettingDescType; |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
36 |
typedef byte SettingGuiFlag; |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
37 |
|
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
38 |
typedef struct SettingDescBase { |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
39 |
const char *name; ///< name of the setting. Used in configuration file and for console |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
40 |
const void *def; ///< default value given when none is present |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
41 |
SettingDescType cmd; ///< various flags for the variable |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
42 |
SettingGuiFlag flags; ///< handles how a setting would show up in the GUI (text/currency, etc.) |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
43 |
int32 min, max; ///< minimum and maximum values |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
44 |
const char *many; ///< ONE/MANY_OF_MANY: string of possible values for this type |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
45 |
StringID str; ///< (translated) string with descriptive text; gui and console |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
46 |
OnChange *proc; ///< callback procedure for when the value is changed |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
47 |
} SettingDescBase; |
705
e213445d82ec
(svn r1157) Enhanced the config file (openttd.cfg) to use another section type. "List sections" as opposed to "variable sections" contain a list of values, separated by a new line. This is now used for the [newgrf] group. You have to edit each line in this section from e.g. "0 = firstset.grf" to only "firstset.grf".
dominik
parents:
543
diff
changeset
|
48 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
49 |
typedef struct SettingDesc { |
3116
031230112b25
(svn r3720) - [2/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This second part gets rid of the old SettingDesc structures and updates them with the unified types. These new settings are heavily macro'd, which should make it easy to add/edit entries within sections.
Darkvater
parents:
3115
diff
changeset
|
50 |
SettingDescBase desc; ///< Settings structure (going to configuration file) |
3115
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
51 |
SaveLoad save; ///< Internal structure (going to savegame, parts to config) |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
52 |
} SettingDesc; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
53 |
|
3115
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
54 |
/* NOTE: The only difference between SettingDesc and SettingDescGlob is |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
55 |
* that one uses global variables as a source and the other offsets |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
56 |
* in a struct which are bound to a certain variable during runtime. |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
57 |
* The only way to differentiate between these two is to check if an object |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
58 |
* has been passed to the function or not. If not, then it is a global variable |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
59 |
* and save->variable has its address, otherwise save->variable only holds the |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
60 |
* offset in a certain struct */ |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
61 |
typedef SettingDesc SettingDescGlobVarList; |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
62 |
|
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
63 |
typedef enum { |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
64 |
IGT_VARIABLES = 0, ///< values of the form "landscape = hilly" |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
65 |
IGT_LIST = 1, ///< a list of values, seperated by \n and terminated by the next group block |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
66 |
} IniGroupType; |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
67 |
|
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
68 |
/** Get the address of the variable. Which one to pick depends on the object |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
69 |
* pointer. If it is NULL we are dealing with global variables so the address |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
70 |
* is taken. If non-null only the offset is stored in the union and we need |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
71 |
* to add this to the address of the object */ |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
72 |
static inline void *ini_get_variable(const SaveLoad *sld, const void *object) |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
73 |
{ |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
74 |
return (object == NULL) ? sld->address : (byte*)object + (unsigned long)sld->address; |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
75 |
} |
1f4949f5dc5d
(svn r3719) - [1/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. This first part rewrites the configuration section to use the SaveLoad VarType in general.
Darkvater
parents:
3020
diff
changeset
|
76 |
|
1739
4f3082735fbc
(svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents:
759
diff
changeset
|
77 |
void IConsoleSetPatchSetting(const char *name, const char *value); |
4f3082735fbc
(svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents:
759
diff
changeset
|
78 |
void IConsoleGetPatchSetting(const char *name); |
4f3082735fbc
(svn r2243) -Fix: Rework of console. Use 'help command|variable' to get help about it. You can assign variables with =, ++, --, or just new value. Console parser is now lenient towards typed spaces, and more robust in general (at least readable). Removed the 'set' command, instead implemented all such variables as 'variables'.
Darkvater
parents:
759
diff
changeset
|
79 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
diff
changeset
|
80 |
#endif /* SETTINGS_H */ |