show alpha2 country code strings next to the flag in the country code selectors....
[twcon.git] / src / engine / console.h
blob0abf4ad24c38f261ed31155153d475486af1e10e
1 /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2 /* If you are missing that file, acquire a complete release at teeworlds.com. */
3 #ifndef ENGINE_CONSOLE_H
4 #define ENGINE_CONSOLE_H
6 #include "kernel.h"
8 class IConsole : public IInterface
10 MACRO_INTERFACE("console", 0)
11 public:
13 // TODO: rework/cleanup
14 enum
16 OUTPUT_LEVEL_STANDARD=0,
17 OUTPUT_LEVEL_ADDINFO,
18 OUTPUT_LEVEL_DEBUG,
20 ACCESS_LEVEL_ADMIN=0,
21 ACCESS_LEVEL_MOD,
23 TEMPCMD_NAME_LENGTH=32,
24 TEMPCMD_HELP_LENGTH=96,
25 TEMPCMD_PARAMS_LENGTH=16,
27 MAX_PRINT_CB=4,
30 // TODO: rework this interface to reduce the amount of virtual calls
31 class IResult
33 protected:
34 unsigned m_NumArgs;
35 public:
36 IResult() { m_NumArgs = 0; }
37 virtual ~IResult() {}
39 virtual int GetInteger(unsigned Index) = 0;
40 virtual float GetFloat(unsigned Index) = 0;
41 virtual const char *GetString(unsigned Index) = 0;
43 int NumArguments() const { return m_NumArgs; }
46 class CCommandInfo
48 protected:
49 int m_AccessLevel;
50 public:
51 CCommandInfo() { m_AccessLevel = ACCESS_LEVEL_ADMIN; }
52 virtual ~CCommandInfo() {}
53 const char *m_pName;
54 const char *m_pHelp;
55 const char *m_pParams;
57 virtual const CCommandInfo *NextCommandInfo(int AccessLevel, int FlagMask) const = 0;
59 int GetAccessLevel() const { return m_AccessLevel; }
62 typedef void (*FPrintCallback)(const char *pStr, void *pUser);
63 typedef void (*FPossibleCallback)(const char *pCmd, void *pUser);
64 typedef void (*FCommandCallback)(IResult *pResult, void *pUserData);
65 typedef void (*FChainCommandCallback)(IResult *pResult, void *pUserData, FCommandCallback pfnCallback, void *pCallbackUserData);
67 virtual const CCommandInfo *FirstCommandInfo(int AccessLevel, int Flagmask) const = 0;
68 virtual const CCommandInfo *GetCommandInfo(const char *pName, int FlagMask, bool Temp) = 0;
69 virtual void PossibleCommands(const char *pStr, int FlagMask, bool Temp, FPossibleCallback pfnCallback, void *pUser) = 0;
70 virtual void ParseArguments(int NumArgs, const char **ppArguments) = 0;
72 virtual void Register(const char *pName, const char *pParams, int Flags, FCommandCallback pfnFunc, void *pUser, const char *pHelp) = 0;
73 virtual void RegisterTemp(const char *pName, const char *pParams, int Flags, const char *pHelp) = 0;
74 virtual void DeregisterTemp(const char *pName) = 0;
75 virtual void DeregisterTempAll() = 0;
76 virtual void Chain(const char *pName, FChainCommandCallback pfnChainFunc, void *pUser) = 0;
77 virtual void StoreCommands(bool Store) = 0;
79 virtual bool LineIsValid(const char *pStr) = 0;
80 virtual void ExecuteLine(const char *Sptr) = 0;
81 virtual void ExecuteLineStroked(int Stroke, const char *pStr) = 0;
82 virtual void ExecuteFile(const char *pFilename) = 0;
84 virtual int RegisterPrintCallback(int OutputLevel, FPrintCallback pfnPrintCallback, void *pUserData) = 0;
85 virtual void SetPrintOutputLevel(int Index, int OutputLevel) = 0;
86 virtual void Print(int Level, const char *pFrom, const char *pStr) = 0;
88 virtual void SetAccessLevel(int AccessLevel) = 0;
91 extern IConsole *CreateConsole(int FlagMask);
93 #endif // FILE_ENGINE_CONSOLE_H