2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-01-07 00:19:09 +00:00
|
|
|
/** @file settings_internal.h Functions and types used internally for the settings configurations. */
|
2007-04-04 01:35:16 +00:00
|
|
|
|
2008-01-07 00:19:09 +00:00
|
|
|
#ifndef SETTINGS_INTERNAL_H
|
|
|
|
#define SETTINGS_INTERNAL_H
|
2004-12-04 17:54:56 +00:00
|
|
|
|
2009-01-04 15:32:25 +00:00
|
|
|
#include "saveload/saveload.h"
|
2008-01-13 14:37:30 +00:00
|
|
|
#include "settings_type.h"
|
2010-01-15 16:41:15 +00:00
|
|
|
#include "strings_type.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
|
|
|
|
2010-08-01 19:22:34 +00:00
|
|
|
/**
|
|
|
|
* Convention/Type of settings. This is then further specified if necessary
|
(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
|
|
|
* with the SLE_ (SLE_VAR/SLE_FILE) enums in saveload.h
|
|
|
|
* @see VarTypes
|
2010-08-01 19:44:49 +00:00
|
|
|
* @see SettingDescBase
|
|
|
|
*/
|
2007-01-10 18:56:51 +00:00
|
|
|
enum SettingDescTypeLong {
|
2006-02-04 22:48:57 +00:00
|
|
|
/* 4 bytes allocated a maximum of 16 types for GenericType */
|
2007-01-10 18:56:51 +00:00
|
|
|
SDT_BEGIN = 0,
|
2007-04-04 01:35:16 +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
|
2007-01-10 18:56:51 +00:00
|
|
|
SDT_END,
|
(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
|
|
|
/* 10 more possible primitives */
|
|
|
|
};
|
2009-05-26 11:19:04 +00:00
|
|
|
typedef SimpleTinyEnumT<SettingDescTypeLong, byte> SettingDescType;
|
2007-01-10 18:56:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
enum SettingGuiFlagLong {
|
2009-05-26 11:40:14 +00:00
|
|
|
/* 1 byte allocated for a maximum of 8 flags
|
(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
|
|
|
* Flags directing saving/loading of a variable */
|
2007-01-10 18:56:51 +00:00
|
|
|
SGF_NONE = 0,
|
(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
|
|
|
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
|
2007-11-17 22:25:16 +00:00
|
|
|
SGF_NO_NETWORK = 1 << 5, ///< this setting does not apply to network games; it may not be changed during the game
|
2009-09-26 17:43:06 +00:00
|
|
|
SGF_NEWGAME_ONLY = 1 << 6, ///< this setting cannot be changed in a game
|
|
|
|
SGF_SCENEDIT_TOO = 1 << 7, ///< this setting can be changed in the scenario editor (only makes sense when SGF_NEWGAME_ONLY is set)
|
|
|
|
SGF_PER_COMPANY = 1 << 8, ///< this setting can be different for each company (saved in company struct)
|
(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
|
|
|
};
|
2010-03-23 22:25:43 +00:00
|
|
|
DECLARE_ENUM_AS_BIT_SET(SettingGuiFlagLong)
|
2009-09-26 17:43:06 +00:00
|
|
|
typedef SimpleTinyEnumT<SettingGuiFlagLong, uint16> SettingGuiFlag;
|
2007-01-10 18:56:51 +00:00
|
|
|
|
|
|
|
|
2009-02-04 15:01:37 +00:00
|
|
|
typedef bool OnChange(int32 var); ///< callback prototype on data modification
|
2007-03-22 03:15:58 +00:00
|
|
|
typedef int32 OnConvert(const char *value); ///< callback prototype for convertion error
|
2006-02-04 22:48:57 +00:00
|
|
|
|
2010-12-11 15:14:28 +00:00
|
|
|
/** Properties of config file settings. */
|
2007-03-07 12:11:48 +00:00
|
|
|
struct SettingDescBase {
|
(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 *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.)
|
2009-05-13 17:39:00 +00:00
|
|
|
int32 min; ///< minimum values
|
|
|
|
uint32 max; ///< maximum values
|
2009-02-08 12:25:13 +00:00
|
|
|
int32 interval; ///< the interval to use between settings in the 'settings' 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
|
2011-03-06 15:51:44 +00:00
|
|
|
StringID val_str; ///< (translated) first string describing the value.
|
(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
|
|
|
OnChange *proc; ///< callback procedure for when the value is changed
|
2007-03-22 03:15:58 +00:00
|
|
|
OnConvert *proc_cnvt; ///< callback procedure when loading value mechanism fails
|
2007-03-07 12:11:48 +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
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
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)
|
2007-03-07 12:11:48 +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
|
|
|
|
|
|
|
/* 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
|
|
|
|
2009-02-08 12:25:13 +00:00
|
|
|
const SettingDesc *GetSettingFromName(const char *name, uint *i);
|
2010-01-28 23:17:28 +00:00
|
|
|
bool SetSettingValue(uint index, int32 value, bool force_newgame = false);
|
2010-05-20 15:14:10 +00:00
|
|
|
bool SetSettingValue(uint index, const char *value, bool force_newgame = false);
|
2009-05-26 11:40:14 +00:00
|
|
|
void SetCompanySetting(uint index, int32 value);
|
2005-05-02 15:52:19 +00:00
|
|
|
|
2009-05-26 21:59:49 +00:00
|
|
|
extern VehicleDefaultSettings _old_vds;
|
|
|
|
|
2010-12-22 10:50:32 +00:00
|
|
|
#endif /* SETTINGS_INTERNAL_H */
|