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;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
|
|
|
enum
|
2010-05-29 07:25:38 +00:00
|
|
|
{
|
2010-05-30 12:01:11 +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];
|
2011-02-12 10:40:36 +00:00
|
|
|
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];
|
2010-12-16 01:31:12 +00:00
|
|
|
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,
|
2012-01-06 18:47:49 +00:00
|
|
|
|
|
|
|
CHAT_SERVER=0,
|
|
|
|
CHAT_HIGHLIGHT,
|
|
|
|
CHAT_CLIENT,
|
|
|
|
CHAT_NUM,
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int m_Mode;
|
2010-05-30 12:01:11 +00:00
|
|
|
bool m_Show;
|
2010-10-11 00:29:30 +00:00
|
|
|
bool m_InputUpdate;
|
|
|
|
int m_ChatStringOffset;
|
2010-10-11 10:31:45 +00:00
|
|
|
int m_OldChatStringLength;
|
2010-12-16 01:31:12 +00:00
|
|
|
int m_CompletionChosen;
|
|
|
|
char m_aCompletionBuffer[256];
|
|
|
|
int m_PlaceholderOffset;
|
|
|
|
int m_PlaceholderLength;
|
2014-10-06 11:02:55 +00:00
|
|
|
|
|
|
|
bool m_ReverseTAB;
|
2012-01-09 22:13:51 +00:00
|
|
|
|
|
|
|
struct CHistoryEntry
|
|
|
|
{
|
|
|
|
int m_Team;
|
|
|
|
char m_aText[1];
|
|
|
|
};
|
|
|
|
CHistoryEntry *m_pHistoryEntry;
|
|
|
|
TStaticRingBuffer<CHistoryEntry, 64*1024, CRingBufferBase::FLAG_RECYCLE> m_History;
|
|
|
|
int m_PendingChatCounter;
|
|
|
|
int64 m_LastChatSend;
|
2012-01-06 18:47:49 +00:00
|
|
|
int64 m_aLastSoundPlayed[CHAT_NUM];
|
2011-04-13 18:37:12 +00:00
|
|
|
|
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);
|
2010-05-30 12:01:11 +00:00
|
|
|
static void ConShowChat(IConsole::IResult *pResult, void *pUserData);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
public:
|
|
|
|
CChat();
|
|
|
|
|
|
|
|
bool IsActive() const { return m_Mode != MODE_NONE; }
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-02-12 10:40:36 +00:00
|
|
|
void AddLine(int ClientID, int Team, const char *pLine);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void EnableMode(int Team);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void Say(int Team, const char *pLine);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void OnReset();
|
|
|
|
virtual void OnConsoleInit();
|
|
|
|
virtual void OnStateChange(int NewState, int OldState);
|
|
|
|
virtual void OnRender();
|
2010-09-12 10:43:03 +00:00
|
|
|
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
|