tron@2186: /* $Id$ */ tron@2186: rubidium@8704: /** @file settings_internal.h Functions and types used internally for the settings configurations. */ belugas@6916: rubidium@8704: #ifndef SETTINGS_INTERNAL_H rubidium@8704: #define SETTINGS_INTERNAL_H truelight@543: Darkvater@3115: #include "saveload.h" rubidium@8766: #include "settings_type.h" Darkvater@3115: Darkvater@3115: /** Convention/Type of settings. This is then further specified if necessary Darkvater@3115: * with the SLE_ (SLE_VAR/SLE_FILE) enums in saveload.h Darkvater@3115: * @see VarTypes Darkvater@3115: * @see SettingDescBase */ rubidium@5838: enum SettingDescTypeLong { Darkvater@2972: /* 4 bytes allocated a maximum of 16 types for GenericType */ rubidium@5838: SDT_BEGIN = 0, belugas@6916: SDT_NUMX = 0, ///< any number-type belugas@6916: SDT_BOOLX = 1, ///< a boolean number belugas@6916: SDT_ONEOFMANY = 2, ///< bitmasked number where only ONE bit may be set belugas@6916: SDT_MANYOFMANY = 3, ///< bitmasked number where MULTIPLE bits may be set belugas@6916: SDT_INTLIST = 4, ///< list of integers seperated by a comma ',' belugas@6916: SDT_STRING = 5, ///< string with a pre-allocated buffer rubidium@5838: SDT_END, Darkvater@3115: /* 10 more possible primitives */ truelight@543: }; truelight@543: rubidium@5838: template <> struct EnumPropsT : MakeEnumPropsT {}; rubidium@5838: typedef TinyEnumT SettingDescType; rubidium@5838: rubidium@5838: rubidium@5838: enum SettingGuiFlagLong { Darkvater@3115: /* 8 bytes allocated for a maximum of 8 flags Darkvater@3115: * Flags directing saving/loading of a variable */ rubidium@5838: SGF_NONE = 0, Darkvater@3115: SGF_0ISDISABLED = 1 << 0, ///< a value of zero means the feature is disabled Darkvater@3115: SGF_NOCOMMA = 1 << 1, ///< number without any thousand seperators (no formatting) Darkvater@3115: SGF_MULTISTRING = 1 << 2, ///< the value represents a limited number of string-options (internally integer) Darkvater@3115: SGF_NETWORK_ONLY = 1 << 3, ///< this setting only applies to network games Darkvater@3115: SGF_CURRENCY = 1 << 4, ///< the number represents money, so when reading value multiply by exchange rate rubidium@8397: SGF_NO_NETWORK = 1 << 5, ///< this setting does not apply to network games; it may not be changed during the game rubidium@8397: SGF_END = 1 << 6, Darkvater@3115: /* 3 more possible flags */ Darkvater@3115: }; Darkvater@3115: rubidium@5838: DECLARE_ENUM_AS_BIT_SET(SettingGuiFlagLong); rubidium@5838: template <> struct EnumPropsT : MakeEnumPropsT {}; rubidium@5838: typedef TinyEnumT SettingGuiFlag; rubidium@5838: rubidium@5838: belugas@6681: typedef int32 OnChange(int32 var); ///< callback prototype on data modification belugas@6681: typedef int32 OnConvert(const char *value); ///< callback prototype for convertion error Darkvater@3115: rubidium@6574: struct SettingDescBase { Darkvater@3115: const char *name; ///< name of the setting. Used in configuration file and for console Darkvater@3115: const void *def; ///< default value given when none is present Darkvater@3115: SettingDescType cmd; ///< various flags for the variable Darkvater@3115: SettingGuiFlag flags; ///< handles how a setting would show up in the GUI (text/currency, etc.) Darkvater@3115: int32 min, max; ///< minimum and maximum values rubidium@4431: int32 interval; ///< the interval to use between settings in the 'patches' window. If interval is '0' the interval is dynamically determined Darkvater@3115: const char *many; ///< ONE/MANY_OF_MANY: string of possible values for this type Darkvater@3115: StringID str; ///< (translated) string with descriptive text; gui and console Darkvater@3115: OnChange *proc; ///< callback procedure for when the value is changed belugas@6681: OnConvert *proc_cnvt; ///< callback procedure when loading value mechanism fails rubidium@6574: }; dominik@705: rubidium@6574: struct SettingDesc { Darkvater@3116: SettingDescBase desc; ///< Settings structure (going to configuration file) Darkvater@3115: SaveLoad save; ///< Internal structure (going to savegame, parts to config) rubidium@6574: }; truelight@543: Darkvater@3115: /* NOTE: The only difference between SettingDesc and SettingDescGlob is Darkvater@3115: * that one uses global variables as a source and the other offsets Darkvater@3115: * in a struct which are bound to a certain variable during runtime. Darkvater@3115: * The only way to differentiate between these two is to check if an object Darkvater@3115: * has been passed to the function or not. If not, then it is a global variable Darkvater@3115: * and save->variable has its address, otherwise save->variable only holds the Darkvater@3115: * offset in a certain struct */ Darkvater@3115: typedef SettingDesc SettingDescGlobVarList; Darkvater@3115: rubidium@6574: enum IniGroupType { Darkvater@3115: IGT_VARIABLES = 0, ///< values of the form "landscape = hilly" rubidium@4344: IGT_LIST = 1, ///< a list of values, seperated by \n and terminated by the next group block rubidium@6574: }; Darkvater@3115: Darkvater@3247: const SettingDesc *GetPatchFromName(const char *name, uint *i); Darkvater@4600: bool SetPatchValue(uint index, const Patches *object, int32 value); Darkvater@1739: truelight@543: #endif /* SETTINGS_H */