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
8 class IConsole
: public IInterface
10 MACRO_INTERFACE("console", 0)
13 // TODO: rework/cleanup
16 OUTPUT_LEVEL_STANDARD
=0,
23 TEMPCMD_NAME_LENGTH
=32,
24 TEMPCMD_HELP_LENGTH
=96,
25 TEMPCMD_PARAMS_LENGTH
=16,
30 // TODO: rework this interface to reduce the amount of virtual calls
36 IResult() { m_NumArgs
= 0; }
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
; }
51 CCommandInfo() { m_AccessLevel
= ACCESS_LEVEL_ADMIN
; }
52 virtual ~CCommandInfo() {}
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