ddnet/src/game/client/components/console.h

103 lines
3 KiB
C
Raw Normal View History

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 GAME_CLIENT_COMPONENTS_CONSOLE_H
#define GAME_CLIENT_COMPONENTS_CONSOLE_H
#include <engine/shared/ringbuffer.h>
#include <game/client/component.h>
#include <game/client/lineinput.h>
class CGameConsole : public CComponent
{
class CInstance
{
public:
2010-10-16 08:32:56 +00:00
struct CBacklogEntry
{
float m_YOffset;
char m_aText[1];
};
TStaticRingBuffer<CBacklogEntry, 64*1024, CRingBufferBase::FLAG_RECYCLE> m_Backlog;
2010-05-29 07:25:38 +00:00
TStaticRingBuffer<char, 64*1024, CRingBufferBase::FLAG_RECYCLE> m_History;
char *m_pHistoryEntry;
CLineInput m_Input;
int m_Type;
int m_CompletionEnumerationCount;
int m_BacklogActPage;
2010-05-29 07:25:38 +00:00
public:
CGameConsole *m_pGameConsole;
2010-05-29 07:25:38 +00:00
char m_aCompletionBuffer[128];
int m_CompletionChosen;
int m_CompletionFlagmask;
float m_CompletionRenderOffset;
2014-10-06 21:37:35 +00:00
bool m_ReverseTAB;
bool m_IsCommand;
char m_aCommandName[IConsole::TEMPCMD_NAME_LENGTH];
char m_aCommandHelp[IConsole::TEMPCMD_HELP_LENGTH];
char m_aCommandParams[IConsole::TEMPCMD_PARAMS_LENGTH];
2010-05-29 07:25:38 +00:00
CInstance(int t);
void Init(CGameConsole *pGameConsole);
2010-05-29 07:25:38 +00:00
void ClearBacklog();
void ClearHistory();
2010-05-29 07:25:38 +00:00
void ExecuteLine(const char *pLine);
2010-05-29 07:25:38 +00:00
void OnInput(IInput::CEvent Event);
void PrintLine(const char *pLine);
2010-05-29 07:25:38 +00:00
const char *GetString() const { return m_Input.GetString(); }
static void PossibleCommandsCompleteCallback(const char *pStr, void *pUser);
};
2010-05-29 07:25:38 +00:00
class IConsole *m_pConsole;
2010-05-29 07:25:38 +00:00
CInstance m_LocalConsole;
CInstance m_RemoteConsole;
2010-05-29 07:25:38 +00:00
CInstance *CurrentConsole();
float TimeNow();
2011-07-30 11:40:01 +00:00
int m_PrintCBIndex;
2010-05-29 07:25:38 +00:00
int m_ConsoleType;
int m_ConsoleState;
float m_StateChangeEnd;
float m_StateChangeDuration;
void Toggle(int Type);
void Dump(int Type);
2010-05-29 07:25:38 +00:00
static void PossibleCommandsRenderCallback(const char *pStr, void *pUser);
static void ClientConsolePrintCallback(const char *pStr, void *pUserData);
static void ConToggleLocalConsole(IConsole::IResult *pResult, void *pUserData);
static void ConToggleRemoteConsole(IConsole::IResult *pResult, void *pUserData);
static void ConClearLocalConsole(IConsole::IResult *pResult, void *pUserData);
static void ConClearRemoteConsole(IConsole::IResult *pResult, void *pUserData);
static void ConDumpLocalConsole(IConsole::IResult *pResult, void *pUserData);
static void ConDumpRemoteConsole(IConsole::IResult *pResult, void *pUserData);
2011-07-30 11:40:01 +00:00
static void ConchainConsoleOutputLevelUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
2010-05-29 07:25:38 +00:00
public:
enum
{
CONSOLETYPE_LOCAL=0,
CONSOLETYPE_REMOTE,
};
2010-05-29 07:25:38 +00:00
CGameConsole();
void PrintLine(int Type, const char *pLine);
virtual void OnStateChange(int NewState, int OldState);
2010-05-29 07:25:38 +00:00
virtual void OnConsoleInit();
virtual void OnReset();
virtual void OnRender();
virtual void OnMessage(int MsgType, void *pRawMsg);
virtual bool OnInput(IInput::CEvent Events);
};
#endif