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

78 lines
1.8 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_CHAT_H
#define GAME_CLIENT_COMPONENTS_CHAT_H
2011-03-20 15:17:06 +00:00
#include <engine/shared/ringbuffer.h>
2010-05-29 07:25:38 +00:00
#include <game/client/component.h>
#include <game/client/lineinput.h>
class CChat : public CComponent
{
CLineInput m_Input;
enum
2010-05-29 07:25:38 +00:00
{
MAX_LINES = 25,
2010-05-29 07:25:38 +00:00
};
struct CLine
{
int64 m_Time;
2010-10-15 17:26:20 +00:00
float m_YOffset[2];
int m_ClientID;
2010-05-29 07:25:38 +00:00
int m_Team;
int m_NameColor;
char m_aName[64];
char m_aText[512];
bool m_Highlighted;
2010-05-29 07:25:38 +00:00
};
CLine m_aLines[MAX_LINES];
int m_CurrentLine;
// chat
enum
{
MODE_NONE=0,
MODE_ALL,
MODE_TEAM,
};
int m_Mode;
bool m_Show;
bool m_InputUpdate;
int m_ChatStringOffset;
int m_OldChatStringLength;
int m_CompletionChosen;
char m_aCompletionBuffer[256];
int m_PlaceholderOffset;
int m_PlaceholderLength;
2011-03-20 15:17:06 +00:00
char *m_pHistoryEntry;
TStaticRingBuffer<char, 64*1024, CRingBufferBase::FLAG_RECYCLE> m_History;
2010-05-29 07:25:38 +00:00
static void ConSay(IConsole::IResult *pResult, void *pUserData);
static void ConSayTeam(IConsole::IResult *pResult, void *pUserData);
static void ConChat(IConsole::IResult *pResult, void *pUserData);
static void ConShowChat(IConsole::IResult *pResult, void *pUserData);
2010-05-29 07:25:38 +00:00
public:
CChat();
bool IsActive() const { return m_Mode != MODE_NONE; }
void AddLine(int ClientID, int Team, const char *pLine);
2010-05-29 07:25:38 +00:00
void EnableMode(int Team);
2010-05-29 07:25:38 +00:00
void Say(int Team, const char *pLine);
2010-05-29 07:25:38 +00:00
virtual void OnReset();
virtual void OnConsoleInit();
virtual void OnStateChange(int NewState, int OldState);
virtual void OnRender();
virtual void OnRelease();
2010-05-29 07:25:38 +00:00
virtual void OnMessage(int MsgType, void *pRawMsg);
virtual bool OnInput(IInput::CEvent Event);
};
#endif