2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#ifndef ENGINE_CONSOLE_H
|
|
|
|
#define ENGINE_CONSOLE_H
|
|
|
|
|
|
|
|
#include "kernel.h"
|
|
|
|
|
|
|
|
class IConsole : public IInterface
|
|
|
|
{
|
|
|
|
MACRO_INTERFACE("console", 0)
|
|
|
|
public:
|
|
|
|
|
2010-08-17 22:06:00 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
OUTPUT_LEVEL_STANDARD=0,
|
|
|
|
OUTPUT_LEVEL_ADDINFO,
|
|
|
|
OUTPUT_LEVEL_DEBUG
|
|
|
|
};
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// TODO: rework this interface to reduce the amount of virtual calls
|
|
|
|
class IResult
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
unsigned m_NumArgs;
|
|
|
|
public:
|
|
|
|
IResult() { m_NumArgs = 0; }
|
|
|
|
virtual ~IResult() {}
|
|
|
|
|
|
|
|
virtual int GetInteger(unsigned Index) = 0;
|
|
|
|
virtual float GetFloat(unsigned Index) = 0;
|
|
|
|
virtual const char *GetString(unsigned Index) = 0;
|
2010-11-07 15:29:55 +00:00
|
|
|
virtual int GetVictim() = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
int NumArguments() const { return m_NumArgs; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class CCommandInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
const char *m_pName;
|
|
|
|
const char *m_pHelp;
|
|
|
|
const char *m_pParams;
|
2010-07-29 05:21:18 +00:00
|
|
|
int m_Level;
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef void (*FPrintCallback)(const char *pStr, void *pUser);
|
|
|
|
typedef void (*FPossibleCallback)(const char *pCmd, void *pUser);
|
2010-07-29 05:21:18 +00:00
|
|
|
typedef void (*FCommandCallback)(IResult *pResult, void *pUserData, int ClientId);
|
2010-05-29 07:25:38 +00:00
|
|
|
typedef void (*FChainCommandCallback)(IResult *pResult, void *pUserData, FCommandCallback pfnCallback, void *pCallbackUserData);
|
2010-11-07 15:29:55 +00:00
|
|
|
|
|
|
|
typedef bool (*FCompareClientsCallback)(int ClientLevel, int Victim, void *pUserData);
|
|
|
|
typedef bool (*FClientOnlineCallback)(int ClientId, void *pUserData);
|
|
|
|
|
2010-06-18 18:32:52 +00:00
|
|
|
virtual CCommandInfo *GetCommandInfo(const char *pName, int FlagMask) = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void PossibleCommands(const char *pStr, int FlagMask, FPossibleCallback pfnCallback, void *pUser) = 0;
|
|
|
|
virtual void ParseArguments(int NumArgs, const char **ppArguments) = 0;
|
|
|
|
|
2011-01-06 03:46:10 +00:00
|
|
|
virtual void Register(const char *pName, const char *pParams,
|
2010-10-16 19:42:39 +00:00
|
|
|
int Flags, FCommandCallback pfnFunc, void *pUser, const char *pHelp, const int Level) = 0;
|
2010-11-24 21:09:31 +00:00
|
|
|
virtual void List(const int Level, int Flags) = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void Chain(const char *pName, FChainCommandCallback pfnChainFunc, void *pUser) = 0;
|
2010-08-09 14:54:42 +00:00
|
|
|
virtual void StoreCommands(bool Store, int ClientId) = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2010-10-25 16:30:35 +00:00
|
|
|
virtual bool LineIsValid(const char *pStr) = 0;
|
2010-10-10 22:40:07 +00:00
|
|
|
virtual void ExecuteLine(const char *Sptr, const int ClientLevel, const int ClientId, FPrintCallback pfnAlternativePrintCallback = 0, void *pUserData = 0, FPrintCallback pfnAlternativePrintResponseCallback = 0, void *pResponseUserData = 0) = 0;
|
|
|
|
virtual void ExecuteLineStroked(int Stroke, const char *pStr, const int ClientLevel, const int ClientId, FPrintCallback pfnAlternativePrintCallback = 0, void *pUserData = 0, FPrintCallback pfnAlternativePrintResponseCallback = 0, void *pResponseUserData = 0) = 0;
|
2010-11-22 08:27:13 +00:00
|
|
|
virtual void ExecuteFile(const char *pFilename, FPrintCallback pfnAlternativePrintCallback = 0, void *pUserData = 0, FPrintCallback pfnAlternativePrintResponseCallback = 0, void *pResponseUserData = 0, int Level = 3) = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
virtual void RegisterPrintCallback(FPrintCallback pfnPrintCallback, void *pUserData) = 0;
|
2010-10-10 22:40:07 +00:00
|
|
|
virtual void RegisterAlternativePrintCallback(FPrintCallback pfnAlternativePrintCallback, void *pAlternativeUserData) = 0;
|
|
|
|
virtual void ReleaseAlternativePrintCallback() = 0;
|
|
|
|
virtual void RegisterPrintResponseCallback(FPrintCallback pfnPrintResponseCallback, void *pUserData) = 0;
|
|
|
|
virtual void RegisterAlternativePrintResponseCallback(FPrintCallback pfnAlternativePrintCallback, void *pAlternativeUserData) = 0;
|
|
|
|
virtual void ReleaseAlternativePrintResponseCallback() = 0;
|
2010-08-17 22:06:00 +00:00
|
|
|
virtual void Print(int Level, const char *pFrom, const char *pStr) = 0;
|
2010-10-10 22:40:07 +00:00
|
|
|
virtual void PrintResponse(int Level, const char *pFrom, const char *pStr) = 0;
|
2010-11-07 15:29:55 +00:00
|
|
|
|
|
|
|
virtual void RegisterCompareClientsCallback(FCompareClientsCallback pfnCallback, void *pUserData) = 0;
|
|
|
|
virtual void RegisterClientOnlineCallback(FClientOnlineCallback pfnCallback, void *pUserData) = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
2010-06-18 18:32:52 +00:00
|
|
|
extern IConsole *CreateConsole(int FlagMask);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
#endif // FILE_ENGINE_CONSOLE_H
|