1/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2/* If you are missing that file, acquire a complete release at teeworlds.com. */
3#ifndef GAME_CLIENT_COMPONENTS_INFOMESSAGES_H
4#define GAME_CLIENT_COMPONENTS_INFOMESSAGES_H
5#include <engine/textrender.h>
6#include <game/client/component.h>
7
8#include <game/client/render.h>
9class CInfoMessages : public CComponent
10{
11 int m_SpriteQuadContainerIndex;
12
13 enum
14 {
15 MAX_INFOMSGS = 5,
16 MAX_KILLMSG_TEAM_MEMBERS = 4,
17 };
18
19 enum EType
20 {
21 TYPE_KILL,
22 TYPE_FINISH,
23 };
24
25 struct CInfoMsg
26 {
27 EType m_Type;
28 int m_Tick;
29
30 int m_aVictimIds[MAX_KILLMSG_TEAM_MEMBERS];
31 int m_VictimDDTeam;
32 char m_aVictimName[64];
33 STextContainerIndex m_VictimTextContainerIndex;
34 CTeeRenderInfo m_aVictimRenderInfo[MAX_KILLMSG_TEAM_MEMBERS];
35 int m_KillerId;
36 char m_aKillerName[64];
37 STextContainerIndex m_KillerTextContainerIndex;
38 CTeeRenderInfo m_KillerRenderInfo;
39
40 // kill msg
41 int m_Weapon;
42 int m_ModeSpecial; // for CTF, if the guy is carrying a flag for example
43 int m_FlagCarrierBlue;
44 int m_TeamSize;
45
46 // finish msg
47 int m_Diff;
48 char m_aTimeText[32];
49 char m_aDiffText[32];
50 STextContainerIndex m_TimeTextContainerIndex;
51 STextContainerIndex m_DiffTextContainerIndex;
52 bool m_RecordPersonal;
53 };
54
55 CInfoMsg m_aInfoMsgs[MAX_INFOMSGS];
56 int m_InfoMsgCurrent;
57
58 CInfoMsg CreateInfoMsg(EType Type);
59 void AddInfoMsg(const CInfoMsg &InfoMsg);
60 void RenderKillMsg(const CInfoMsg &InfoMsg, float x, float y);
61 void RenderFinishMsg(const CInfoMsg &InfoMsg, float x, float y);
62
63 void OnTeamKillMessage(const struct CNetMsg_Sv_KillMsgTeam *pMsg);
64 void OnKillMessage(const struct CNetMsg_Sv_KillMsg *pMsg);
65 void OnRaceFinishMessage(const struct CNetMsg_Sv_RaceFinish *pMsg);
66
67 void CreateTextContainersIfNotCreated(CInfoMsg &InfoMsg);
68 void DeleteTextContainers(CInfoMsg &InfoMsg);
69
70public:
71 virtual int Sizeof() const override { return sizeof(*this); }
72 virtual void OnWindowResize() override;
73 virtual void OnRefreshSkins() override;
74 virtual void OnReset() override;
75 virtual void OnRender() override;
76 virtual void OnMessage(int MsgType, void *pRawMsg) override;
77 virtual void OnInit() override;
78};
79
80#endif
81