2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
#ifndef SETTINGS_H
|
|
|
|
#define SETTINGS_H
|
|
|
|
|
(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.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
|
|
|
#include "saveload.h"
|
|
|
|
|
|
|
|
/** Convention/Type of settings. This is then further specified if necessary
|
|
|
|
* with the SLE_ (SLE_VAR/SLE_FILE) enums in saveload.h
|
|
|
|
* @see VarTypes
|
|
|
|
* @see SettingDescBase */
|
2004-12-04 17:54:56 +00:00
|
|
|
enum SettingDescType {
|
2006-02-04 22:48:57 +00:00
|
|
|
/* 4 bytes allocated a maximum of 16 types for GenericType */
|
(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.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
|
|
|
SDT_NUMX = 0, // any number-type
|
|
|
|
SDT_BOOLX = 1, // a boolean number
|
|
|
|
SDT_ONEOFMANY = 2, // bitmasked number where only ONE bit may be set
|
|
|
|
SDT_MANYOFMANY = 3, // bitmasked number where MULTIPLE bits may be set
|
|
|
|
SDT_INTLIST = 4, // list of integers seperated by a comma ','
|
|
|
|
SDT_STRING = 5, // string with a pre-allocated buffer
|
|
|
|
/* 10 more possible primitives */
|
|
|
|
};
|
2004-12-04 17:54:56 +00:00
|
|
|
|
(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.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
|
|
|
enum SettingGuiFlag {
|
|
|
|
/* 8 bytes allocated for a maximum of 8 flags
|
|
|
|
* Flags directing saving/loading of a variable */
|
|
|
|
SGF_0ISDISABLED = 1 << 0, ///< a value of zero means the feature is disabled
|
|
|
|
SGF_NOCOMMA = 1 << 1, ///< number without any thousand seperators (no formatting)
|
|
|
|
SGF_MULTISTRING = 1 << 2, ///< the value represents a limited number of string-options (internally integer)
|
|
|
|
SGF_NETWORK_ONLY = 1 << 3, ///< this setting only applies to network games
|
|
|
|
SGF_CURRENCY = 1 << 4, ///< the number represents money, so when reading value multiply by exchange rate
|
|
|
|
/* 3 more possible flags */
|
|
|
|
};
|
2004-12-04 17:54:56 +00:00
|
|
|
|
(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.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
|
|
|
typedef int32 OnChange(int32 var);
|
|
|
|
typedef byte SettingDescType;
|
|
|
|
typedef byte SettingGuiFlag;
|
2006-02-04 22:48:57 +00:00
|
|
|
|
(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.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
|
|
|
typedef struct SettingDescBase {
|
|
|
|
const char *name; ///< name of the setting. Used in configuration file and for console
|
|
|
|
const void *def; ///< default value given when none is present
|
|
|
|
SettingDescType cmd; ///< various flags for the variable
|
|
|
|
SettingGuiFlag flags; ///< handles how a setting would show up in the GUI (text/currency, etc.)
|
|
|
|
int32 min, max; ///< minimum and maximum values
|
2006-08-28 09:13:33 +00:00
|
|
|
int32 interval; ///< the interval to use between settings in the 'patches' window. If interval is '0' the interval is dynamically determined
|
(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.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
|
|
|
const char *many; ///< ONE/MANY_OF_MANY: string of possible values for this type
|
|
|
|
StringID str; ///< (translated) string with descriptive text; gui and console
|
|
|
|
OnChange *proc; ///< callback procedure for when the value is changed
|
|
|
|
} SettingDescBase;
|
|
|
|
|
|
|
|
typedef struct SettingDesc {
|
2006-03-02 00:07:41 +00:00
|
|
|
SettingDescBase desc; ///< Settings structure (going to configuration file)
|
(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.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
|
|
|
SaveLoad save; ///< Internal structure (going to savegame, parts to config)
|
|
|
|
} SettingDesc;
|
|
|
|
|
|
|
|
/* NOTE: The only difference between SettingDesc and SettingDescGlob is
|
|
|
|
* that one uses global variables as a source and the other offsets
|
|
|
|
* in a struct which are bound to a certain variable during runtime.
|
|
|
|
* The only way to differentiate between these two is to check if an object
|
|
|
|
* has been passed to the function or not. If not, then it is a global variable
|
|
|
|
* and save->variable has its address, otherwise save->variable only holds the
|
|
|
|
* offset in a certain struct */
|
|
|
|
typedef SettingDesc SettingDescGlobVarList;
|
2004-12-04 17:54:56 +00:00
|
|
|
|
2004-12-18 16:00:10 +00:00
|
|
|
typedef enum {
|
(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.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
|
|
|
IGT_VARIABLES = 0, ///< values of the form "landscape = hilly"
|
2006-08-22 14:38:37 +00:00
|
|
|
IGT_LIST = 1, ///< a list of values, seperated by \n and terminated by the next group block
|
2004-12-18 16:00:10 +00:00
|
|
|
} IniGroupType;
|
|
|
|
|
(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.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
|
|
|
/** Get the address of the variable. Which one to pick depends on the object
|
|
|
|
* pointer. If it is NULL we are dealing with global variables so the address
|
|
|
|
* is taken. If non-null only the offset is stored in the union and we need
|
|
|
|
* to add this to the address of the object */
|
|
|
|
static inline void *ini_get_variable(const SaveLoad *sld, const void *object)
|
|
|
|
{
|
2006-04-18 18:02:52 +00:00
|
|
|
return (object == NULL) ? sld->address : (byte*)object + (ptrdiff_t)sld->address;
|
(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.
- This unified structure consists of a SaveLoad type which stores all data relevant about the variable internals such as type, mem/filesize, address, version-control. The SettingDesc type is concerned more about the representation. Things like default value, string-name, minimum/maximum values, gui-behaviour etc.
- The SaveLoad type has received a few flags controlling saving/loading. These are:
SLF_SAVE_NO: the setting is not saved with the savegame, effectively making this setting player-based. Eg. it will NOT be overwritten when joining a network-game
SLF_CONFIG_NO: the setting is not saved to the configuration file so you cannot overwrite it ingame.
SLF_NETWORK_NO: the setting is not synchronised with the local settings when the game is loaded during network-play. Note that when SLF_SAVE_NO is set, SLF_NETWORK_NO is also set (which is logical), at least if the proper macros are used (in [2/4]).
- NOTE! The game is not compilable after this commit.
2006-03-01 23:53:20 +00:00
|
|
|
}
|
2004-12-04 17:54:56 +00:00
|
|
|
|
2006-05-22 09:59:09 +00:00
|
|
|
/** The patch values that are used for new games and/or modified in config file */
|
|
|
|
extern Patches _patches_newgame;
|
|
|
|
|
2006-08-15 07:37:01 +00:00
|
|
|
void IConsoleSetPatchSetting(const char *name, int32 value);
|
2005-05-02 15:52:19 +00:00
|
|
|
void IConsoleGetPatchSetting(const char *name);
|
2006-03-17 22:47:52 +00:00
|
|
|
const SettingDesc *GetPatchFromName(const char *name, uint *i);
|
2006-03-02 01:41:25 +00:00
|
|
|
void SetPatchValue(uint index, const Patches *object, int32 value);
|
2005-05-02 15:52:19 +00:00
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
#endif /* SETTINGS_H */
|