added moderator support for the remote console. #518
[twcon.git] / src / engine / console.h
blobe650ac47fb53d8b721f7b5f505b0e8b8116eaa2d
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 enum
15 OUTPUT_LEVEL_STANDARD=0,
16 OUTPUT_LEVEL_ADDINFO,
17 OUTPUT_LEVEL_DEBUG,
19 ACCESS_LEVEL_ADMIN=0,
20 ACCESS_LEVEL_MOD,
23 // TODO: rework this interface to reduce the amount of virtual calls
24 class IResult
26 protected:
27 unsigned m_NumArgs;
28 public:
29 IResult() { m_NumArgs = 0; }
30 virtual ~IResult() {}
32 virtual int GetInteger(unsigned Index) = 0;
33 virtual float GetFloat(unsigned Index) = 0;
34 virtual const char *GetString(unsigned Index) = 0;
36 int NumArguments() const { return m_NumArgs; }
39 class CCommandInfo
41 public:
42 const char *m_pName;
43 const char *m_pHelp;
44 const char *m_pParams;
47 typedef void (*FPrintCallback)(const char *pStr, void *pUser);
48 typedef void (*FPossibleCallback)(const char *pCmd, void *pUser);
49 typedef void (*FCommandCallback)(IResult *pResult, void *pUserData);
50 typedef void (*FChainCommandCallback)(IResult *pResult, void *pUserData, FCommandCallback pfnCallback, void *pCallbackUserData);
52 virtual CCommandInfo *GetCommandInfo(const char *pName, int FlagMask) = 0;
53 virtual void PossibleCommands(const char *pStr, int FlagMask, FPossibleCallback pfnCallback, void *pUser) = 0;
54 virtual void ParseArguments(int NumArgs, const char **ppArguments) = 0;
56 virtual void Register(const char *pName, const char *pParams,
57 int Flags, FCommandCallback pfnFunc, void *pUser, const char *pHelp) = 0;
58 virtual void Chain(const char *pName, FChainCommandCallback pfnChainFunc, void *pUser) = 0;
59 virtual void StoreCommands(bool Store) = 0;
61 virtual bool LineIsValid(const char *pStr) = 0;
62 virtual void ExecuteLine(const char *Sptr) = 0;
63 virtual void ExecuteLineStroked(int Stroke, const char *pStr) = 0;
64 virtual void ExecuteFile(const char *pFilename) = 0;
66 virtual void RegisterPrintCallback(FPrintCallback pfnPrintCallback, void *pUserData) = 0;
67 virtual void Print(int Level, const char *pFrom, const char *pStr) = 0;
69 virtual void SetAccessLevel(int AccessLevel) = 0;
72 extern IConsole *CreateConsole(int FlagMask);
74 #endif // FILE_ENGINE_CONSOLE_H