settings_internal.h

Go to the documentation of this file.
00001 /* $Id: settings_internal.h 15410 2009-02-08 12:25:13Z rubidium $ */
00002 
00005 #ifndef SETTINGS_INTERNAL_H
00006 #define SETTINGS_INTERNAL_H
00007 
00008 #include "saveload/saveload.h"
00009 #include "settings_type.h"
00010 
00015 enum SettingDescTypeLong {
00016   /* 4 bytes allocated a maximum of 16 types for GenericType */
00017   SDT_BEGIN       = 0,
00018   SDT_NUMX        = 0, 
00019   SDT_BOOLX       = 1, 
00020   SDT_ONEOFMANY   = 2, 
00021   SDT_MANYOFMANY  = 3, 
00022   SDT_INTLIST     = 4, 
00023   SDT_STRING      = 5, 
00024   SDT_END,
00025   /* 10 more possible primitives */
00026 };
00027 
00028 template <> struct EnumPropsT<SettingDescTypeLong> : MakeEnumPropsT<SettingDescTypeLong, byte, SDT_BEGIN, SDT_END, SDT_END> {};
00029 typedef TinyEnumT<SettingDescTypeLong> SettingDescType;
00030 
00031 
00032 enum SettingGuiFlagLong {
00033   /* 8 bytes allocated for a maximum of 8 flags
00034    * Flags directing saving/loading of a variable */
00035   SGF_NONE = 0,
00036   SGF_0ISDISABLED  = 1 << 0, 
00037   SGF_NOCOMMA      = 1 << 1, 
00038   SGF_MULTISTRING  = 1 << 2, 
00039   SGF_NETWORK_ONLY = 1 << 3, 
00040   SGF_CURRENCY     = 1 << 4, 
00041   SGF_NO_NETWORK   = 1 << 5, 
00042   SGF_NEWGAME_ONLY = 1 << 6, 
00043   SGF_END          = 1 << 7,
00044 };
00045 
00046 DECLARE_ENUM_AS_BIT_SET(SettingGuiFlagLong);
00047 template <> struct EnumPropsT<SettingGuiFlagLong> : MakeEnumPropsT<SettingGuiFlagLong, byte, SGF_NONE, SGF_END, SGF_END> {};
00048 typedef TinyEnumT<SettingGuiFlagLong> SettingGuiFlag;
00049 
00050 
00051 typedef bool OnChange(int32 var);           
00052 typedef int32 OnConvert(const char *value); 
00053 
00054 struct SettingDescBase {
00055   const char *name;       
00056   const void *def;        
00057   SettingDescType cmd;    
00058   SettingGuiFlag flags;   
00059   int32 min, max;         
00060   int32 interval;         
00061   const char *many;       
00062   StringID str;           
00063   OnChange *proc;         
00064   OnConvert *proc_cnvt;   
00065 };
00066 
00067 struct SettingDesc {
00068   SettingDescBase desc;   
00069   SaveLoad save;          
00070 };
00071 
00072 /* NOTE: The only difference between SettingDesc and SettingDescGlob is
00073  * that one uses global variables as a source and the other offsets
00074  * in a struct which are bound to a certain variable during runtime.
00075  * The only way to differentiate between these two is to check if an object
00076  * has been passed to the function or not. If not, then it is a global variable
00077  * and save->variable has its address, otherwise save->variable only holds the
00078  * offset in a certain struct */
00079 typedef SettingDesc SettingDescGlobVarList;
00080 
00081 const SettingDesc *GetSettingFromName(const char *name, uint *i);
00082 bool SetSettingValue(uint index, int32 value);
00083 bool SetSettingValue(uint index, const char *value);
00084 
00085 #endif /* SETTINGS_H */

Generated on Mon Mar 9 23:33:50 2009 for openttd by  doxygen 1.5.6