3#ifndef ENGINE_SHARED_CONFIG_H
4#define ENGINE_SHARED_CONFIG_H
17#define CONFIG_FILE "settings_ddnet.cfg"
18#define AUTOEXEC_FILE "autoexec.cfg"
19#define AUTOEXEC_CLIENT_FILE "autoexec_client.cfg"
20#define AUTOEXEC_SERVER_FILE "autoexec_server.cfg"
25#define MACRO_CONFIG_INT(Name, ScriptName, Def, Min, Max, Flags, Desc) \
26 static constexpr int ms_##Name = Def; \
28#define MACRO_CONFIG_COL(Name, ScriptName, Def, Flags, Desc) \
29 static constexpr unsigned ms_##Name = Def; \
31#define MACRO_CONFIG_STR(Name, ScriptName, Len, Def, Flags, Desc) \
32 static constexpr const char *ms_p##Name = Def; \
35#undef MACRO_CONFIG_INT
36#undef MACRO_CONFIG_COL
37#undef MACRO_CONFIG_STR
93 virtual void Serialize(
char *pOut,
size_t Size)
const = 0;
126 void Serialize(
char *pOut,
size_t Size,
int Value)
const;
127 void Serialize(
char *pOut,
size_t Size)
const override;
168 void Serialize(
char *pOut,
size_t Size,
unsigned Value)
const;
169 void Serialize(
char *pOut,
size_t Size)
const override;
188 void Serialize(
char *pOut,
size_t Size,
const char *pValue)
const;
189 void Serialize(
char *pOut,
size_t Size)
const override;
228 void Init()
override;
229 void Reset(
const char *pScriptName)
override;
231 void SetReadOnly(
const char *pScriptName,
bool ReadOnly)
override;
232 bool Save()
override;
237 void WriteLine(
const char *pLine)
override;
CHeap m_ConfigHeap
Definition: config.h:219
std::vector< SConfigVariable * > m_vpAllVariables
Definition: config.h:216
bool m_Failed
Definition: config.h:201
void ResetGameSettings() override
Definition: config.cpp:346
void StoreUnknownCommand(const char *pCommand) override
Definition: config.cpp:454
std::vector< SCallback > m_vCallbacks
Definition: config.h:214
std::vector< const char * > m_vpUnknownCommands
Definition: config.h:218
static void Con_Toggle(IConsole::IResult *pResult, void *pUserData)
Definition: config.cpp:478
void WriteLine(const char *pLine) override
Definition: config.cpp:444
IOHANDLE m_ConfigFile
Definition: config.h:200
void SetReadOnly(const char *pScriptName, bool ReadOnly) override
Definition: config.cpp:354
IConsole * m_pConsole
Definition: config.h:197
void Init() override
Definition: config.cpp:283
void PossibleConfigVariables(const char *pStr, int FlagMask, POSSIBLECFGFUNC pfnCallback, void *pUserData) override
Definition: config.cpp:459
void RegisterCallback(SAVECALLBACKFUNC pfnFunc, void *pUserData) override
Definition: config.cpp:439
CConfig * Values() override
Definition: config.h:233
void Reset(const char *pScriptName) override
Definition: config.cpp:330
class IStorage * m_pStorage
Definition: config.h:198
static void Con_ToggleStroke(IConsole::IResult *pResult, void *pUserData)
Definition: config.cpp:519
static void Con_Reset(IConsole::IResult *pResult, void *pUserData)
Definition: config.cpp:473
std::vector< SConfigVariable * > m_vpGameVariables
Definition: config.h:217
bool Save() override
Definition: config.cpp:369
CConfigManager()
Definition: config.cpp:275
static constexpr const float DARKEST_LGT7
Definition: color.h:179
static constexpr const float DARKEST_LGT
Definition: color.h:178
void(* SAVECALLBACKFUNC)(IConfigManager *pConfig, void *pUserData)
Definition: config.h:12
void(* POSSIBLECFGFUNC)(const struct SConfigVariable *, void *pUserData)
Definition: config.h:13
void * IOHANDLE
Definition: logger.h:11
CConfig g_Config
Definition: config.cpp:12
@ CFGFLAG_COLLIGHT
Definition: config.h:56
@ CFGFLAG_CLIENT
Definition: config.h:45
@ CFGFLAG_SERVER
Definition: config.h:46
@ CFGFLAG_SAVE
Definition: config.h:44
@ CFGFLAG_ECON
Definition: config.h:49
@ CFGFLAG_CHAT
Definition: config.h:53
@ CMDFLAG_TEST
Definition: config.h:52
@ CFGFLAG_GAME
Definition: config.h:54
@ CFGFLAG_MASTER
Definition: config.h:48
@ CFGFLAG_NONTEEHISTORIC
Definition: config.h:55
@ CFGFLAG_COLALPHA
Definition: config.h:58
@ CFGFLAG_INSENSITIVE
Definition: config.h:59
@ CMDFLAG_PRACTICE
Definition: config.h:60
@ CFGFLAG_COLLIGHT7
Definition: config.h:57
@ CFGFLAG_STORE
Definition: config.h:47
SCallback(SAVECALLBACKFUNC pfnFunc, void *pUserData)
Definition: config.h:208
SAVECALLBACKFUNC m_pfnFunc
Definition: config.h:205
void * m_pUserData
Definition: config.h:206
unsigned * m_pVariable
Definition: config.h:135
bool IsDefault() const override
Definition: config.cpp:161
bool m_Alpha
Definition: config.h:138
float m_DarkestLighting
Definition: config.h:137
void ResetToDefault() override
Definition: config.cpp:185
void SetValue(unsigned Value)
Definition: config.cpp:176
unsigned m_Default
Definition: config.h:136
unsigned m_OldValue
Definition: config.h:139
void ResetToOld() override
Definition: config.cpp:190
void Register() override
Definition: config.cpp:156
void Serialize(char *pOut, size_t Size, unsigned Value) const
Definition: config.cpp:166
SColorConfigVariable(IConsole *pConsole, const char *pScriptName, EVariableType Type, int Flags, const char *pHelp, unsigned *pVariable, unsigned Default)
Definition: config.h:141
static void CommandCallback(IConsole::IResult *pResult, void *pUserData)
Definition: config.cpp:111
~SColorConfigVariable() override=default
EVariableType
Definition: config.h:66
@ VAR_INT
Definition: config.h:67
@ VAR_COLOR
Definition: config.h:68
@ VAR_STRING
Definition: config.h:69
int m_Flags
Definition: config.h:74
const char * m_pHelp
Definition: config.h:75
virtual bool IsDefault() const =0
IConsole * m_pConsole
Definition: config.h:71
bool m_ReadOnly
Definition: config.h:78
EVariableType m_Type
Definition: config.h:73
virtual void ResetToOld()=0
virtual void Register()=0
virtual ~SConfigVariable()=default
const char * m_pScriptName
Definition: config.h:72
virtual void ResetToDefault()=0
SConfigVariable(IConsole *pConsole, const char *pScriptName, EVariableType Type, int Flags, const char *pHelp)
Definition: config.h:80
virtual void Serialize(char *pOut, size_t Size) const =0
bool CheckReadOnly() const
Definition: config.cpp:26
void ExecuteLine(const char *pLine) const
Definition: config.cpp:21
~SIntConfigVariable() override=default
static void CommandCallback(IConsole::IResult *pResult, void *pUserData)
Definition: config.cpp:38
bool IsDefault() const override
Definition: config.cpp:75
void Register() override
Definition: config.cpp:70
int m_OldValue
Definition: config.h:108
int * m_pVariable
Definition: config.h:104
int m_Max
Definition: config.h:107
void Serialize(char *pOut, size_t Size, int Value) const
Definition: config.cpp:80
void SetValue(int Value)
Definition: config.cpp:90
SIntConfigVariable(IConsole *pConsole, const char *pScriptName, EVariableType Type, int Flags, const char *pHelp, int *pVariable, int Default, int Min, int Max)
Definition: config.h:110
void ResetToDefault() override
Definition: config.cpp:99
int m_Min
Definition: config.h:106
void ResetToOld() override
Definition: config.cpp:104
int m_Default
Definition: config.h:105
static void CommandCallback(IConsole::IResult *pResult, void *pUserData)
Definition: config.cpp:208
void SetValue(const char *pValue)
Definition: config.cpp:255
char * m_pStr
Definition: config.h:177
size_t m_MaxSize
Definition: config.h:179
void ResetToDefault() override
Definition: config.cpp:264
~SStringConfigVariable() override=default
const char * m_pDefault
Definition: config.h:178
void ResetToOld() override
Definition: config.cpp:269
void Register() override
Definition: config.cpp:231
SStringConfigVariable(IConsole *pConsole, const char *pScriptName, EVariableType Type, int Flags, const char *pHelp, char *pStr, const char *pDefault, size_t MaxSize, char *pOldValue)
Definition: config.cpp:197
bool IsDefault() const override
Definition: config.cpp:236
char * m_pOldValue
Definition: config.h:180
void Serialize(char *pOut, size_t Size, const char *pValue) const
Definition: config.cpp:241