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
7#include <game/client/component.h>
8#include <game/client/render.h>
9class CInfoMessages : public CComponent
10{
11 int m_SpriteQuadContainerIndex = -1;
12 int m_QuadOffsetRaceFlag = -1;
13
14 enum
15 {
16 MAX_INFOMSGS = 5,
17 MAX_KILLMSG_TEAM_MEMBERS = 4,
18 };
19
20 enum EType
21 {
22 TYPE_KILL,
23 TYPE_FINISH,
24 };
25
26 struct CInfoMsg
27 {
28 EType m_Type;
29 int m_Tick;
30
31 int m_aVictimIds[MAX_KILLMSG_TEAM_MEMBERS];
32 int m_VictimDDTeam;
33 char m_aVictimName[64];
34 STextContainerIndex m_VictimTextContainerIndex;
35 std::shared_ptr<CManagedTeeRenderInfo> m_apVictimManagedTeeRenderInfos[MAX_KILLMSG_TEAM_MEMBERS];
36 int m_KillerId;
37 char m_aKillerName[64];
38 STextContainerIndex m_KillerTextContainerIndex;
39 std::shared_ptr<CManagedTeeRenderInfo> m_pKillerManagedTeeRenderInfo;
40
41 // kill msg
42 int m_Weapon;
43 int m_ModeSpecial; // for CTF, if the guy is carrying a flag for example
44 int m_FlagCarrierBlue;
45 int m_TeamSize;
46
47 // finish msg
48 int m_Diff;
49 char m_aTimeText[32];
50 char m_aDiffText[32];
51 STextContainerIndex m_TimeTextContainerIndex;
52 STextContainerIndex m_DiffTextContainerIndex;
53 bool m_RecordPersonal;
54 };
55
56 CInfoMsg m_aInfoMsgs[MAX_INFOMSGS];
57 int m_InfoMsgCurrent;
58
59 CInfoMsg CreateInfoMsg(EType Type);
60 void AddInfoMsg(const CInfoMsg &InfoMsg);
61 void RenderKillMsg(const CInfoMsg &InfoMsg, float x, float y);
62 void RenderFinishMsg(const CInfoMsg &InfoMsg, float x, float y);
63
64 void OnTeamKillMessage(const struct CNetMsg_Sv_KillMsgTeam *pMsg);
65 void OnKillMessage(const struct CNetMsg_Sv_KillMsg *pMsg);
66 void OnRaceFinishMessage(const struct CNetMsg_Sv_RaceFinish *pMsg);
67
68 void CreateTextContainersIfNotCreated(CInfoMsg &InfoMsg);
69 void DeleteTextContainers(CInfoMsg &InfoMsg);
70 void ResetMessage(CInfoMsg &InfoMsg);
71
72public:
73 int Sizeof() const override { return sizeof(*this); }
74 void OnWindowResize() override;
75 void OnReset() override;
76 void OnRender() override;
77 void OnMessage(int MsgType, void *pRawMsg) override;
78 void OnInit() override;
79};
80
81#endif
82