1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/* (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. */
#ifndef GAME_CLIENT_COMPONENTS_CHAT_H
#define GAME_CLIENT_COMPONENTS_CHAT_H
#include <engine/shared/ringbuffer.h>
#include <game/client/component.h>
#include <game/client/lineinput.h>
class CChat : public CComponent
{
CLineInput m_Input;
enum
{
MAX_LINES = 25,
};
struct CLine
{
int64 m_Time;
float m_YOffset[2];
int m_ClientID;
int m_Team;
int m_NameColor;
char m_aName[64];
char m_aText[512];
bool m_Highlighted;
};
CLine m_aLines[MAX_LINES];
int m_CurrentLine;
// chat
enum
{
MODE_NONE=0,
MODE_ALL,
MODE_TEAM,
CHAT_SERVER=0,
CHAT_HIGHLIGHT,
CHAT_CLIENT,
CHAT_NUM,
};
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;
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;
int64 m_aLastSoundPlayed[CHAT_NUM];
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);
public:
CChat();
bool IsActive() const { return m_Mode != MODE_NONE; }
void AddLine(int ClientID, int Team, const char *pLine);
void EnableMode(int Team);
void Say(int Team, const char *pLine);
virtual void OnReset();
virtual void OnConsoleInit();
virtual void OnStateChange(int NewState, int OldState);
virtual void OnRender();
virtual void OnRelease();
virtual void OnMessage(int MsgType, void *pRawMsg);
virtual bool OnInput(IInput::CEvent Event);
};
#endif
|