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)
15 OUTPUT_LEVEL_STANDARD
=0,
23 // TODO: rework this interface to reduce the amount of virtual calls
29 IResult() { m_NumArgs
= 0; }
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
; }
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