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_HUD_H |
4 | #define GAME_CLIENT_COMPONENTS_HUD_H |
5 | #include <engine/client.h> |
6 | #include <engine/shared/protocol.h> |
7 | #include <engine/textrender.h> |
8 | #include <game/client/component.h> |
9 | #include <game/generated/protocol.h> |
10 | |
11 | struct SScoreInfo |
12 | { |
13 | SScoreInfo() |
14 | { |
15 | Reset(); |
16 | } |
17 | |
18 | void Reset() |
19 | { |
20 | m_TextRankContainerIndex.Reset(); |
21 | m_TextScoreContainerIndex.Reset(); |
22 | m_RoundRectQuadContainerIndex = -1; |
23 | m_OptionalNameTextContainerIndex.Reset(); |
24 | m_aScoreText[0] = 0; |
25 | m_aRankText[0] = 0; |
26 | m_aPlayerNameText[0] = 0; |
27 | m_ScoreTextWidth = 0.f; |
28 | m_Initialized = false; |
29 | } |
30 | |
31 | STextContainerIndex ; |
32 | STextContainerIndex m_TextScoreContainerIndex; |
33 | float m_ScoreTextWidth; |
34 | char m_aScoreText[16]; |
35 | char m_aRankText[16]; |
36 | char m_aPlayerNameText[MAX_NAME_LENGTH]; |
37 | int m_RoundRectQuadContainerIndex; |
38 | STextContainerIndex m_OptionalNameTextContainerIndex; |
39 | |
40 | bool m_Initialized; |
41 | }; |
42 | |
43 | class CHud : public CComponent |
44 | { |
45 | float m_Width, m_Height; |
46 | float m_FrameTimeAvg; |
47 | |
48 | int m_HudQuadContainerIndex; |
49 | SScoreInfo m_aScoreInfo[2]; |
50 | STextContainerIndex m_FPSTextContainerIndex; |
51 | STextContainerIndex m_DDRaceEffectsTextContainerIndex; |
52 | |
53 | void RenderCursor(); |
54 | |
55 | void RenderTextInfo(); |
56 | void RenderConnectionWarning(); |
57 | void RenderTeambalanceWarning(); |
58 | void RenderVoting(); |
59 | |
60 | void PrepareAmmoHealthAndArmorQuads(); |
61 | void RenderAmmoHealthAndArmor(const CNetObj_Character *pCharacter); |
62 | |
63 | void PreparePlayerStateQuads(); |
64 | void RenderPlayerState(const int ClientId); |
65 | void RenderDummyActions(); |
66 | void RenderMovementInformation(const int ClientId); |
67 | |
68 | void RenderGameTimer(); |
69 | void RenderPauseNotification(); |
70 | void RenderSuddenDeath(); |
71 | void RenderScoreHud(); |
72 | void RenderSpectatorHud(); |
73 | void RenderWarmupTimer(); |
74 | void RenderLocalTime(float x); |
75 | |
76 | static constexpr float MOVEMENT_INFORMATION_LINE_HEIGHT = 8.0f; |
77 | |
78 | public: |
79 | CHud(); |
80 | virtual int Sizeof() const override { return sizeof(*this); } |
81 | |
82 | void ResetHudContainers(); |
83 | virtual void OnWindowResize() override; |
84 | virtual void OnReset() override; |
85 | virtual void OnRender() override; |
86 | virtual void OnInit() override; |
87 | |
88 | // DDRace |
89 | |
90 | virtual void OnMessage(int MsgType, void *pRawMsg) override; |
91 | void RenderNinjaBarPos(float x, const float y, const float width, const float height, float Progress, float Alpha = 1.0f); |
92 | |
93 | private: |
94 | void RenderRecord(); |
95 | void RenderDDRaceEffects(); |
96 | float m_TimeCpDiff; |
97 | float m_ServerRecord; |
98 | float m_aPlayerRecord[NUM_DUMMIES]; |
99 | float m_FinishTimeDiff; |
100 | int m_DDRaceTime; |
101 | int m_FinishTimeLastReceivedTick; |
102 | int m_TimeCpLastReceivedTick; |
103 | bool m_ShowFinishTime; |
104 | |
105 | inline float GetMovementInformationBoxHeight(); |
106 | inline int GetDigitsIndex(int Value, int Max); |
107 | |
108 | // Quad Offsets |
109 | int m_aAmmoOffset[NUM_WEAPONS]; |
110 | int m_HealthOffset; |
111 | int m_EmptyHealthOffset; |
112 | int m_ArmorOffset; |
113 | int m_EmptyArmorOffset; |
114 | int m_aCursorOffset[NUM_WEAPONS]; |
115 | int m_FlagOffset; |
116 | int m_AirjumpOffset; |
117 | int m_AirjumpEmptyOffset; |
118 | int m_aWeaponOffset[NUM_WEAPONS]; |
119 | int m_EndlessJumpOffset; |
120 | int m_EndlessHookOffset; |
121 | int m_JetpackOffset; |
122 | int m_TeleportGrenadeOffset; |
123 | int m_TeleportGunOffset; |
124 | int m_TeleportLaserOffset; |
125 | int m_SoloOffset; |
126 | int m_CollisionDisabledOffset; |
127 | int m_HookHitDisabledOffset; |
128 | int m_HammerHitDisabledOffset; |
129 | int m_GunHitDisabledOffset; |
130 | int m_ShotgunHitDisabledOffset; |
131 | int m_GrenadeHitDisabledOffset; |
132 | int m_LaserHitDisabledOffset; |
133 | int m_DeepFrozenOffset; |
134 | int m_LiveFrozenOffset; |
135 | int m_DummyHammerOffset; |
136 | int m_DummyCopyOffset; |
137 | int m_PracticeModeOffset; |
138 | int m_Team0ModeOffset; |
139 | int m_LockModeOffset; |
140 | }; |
141 | |
142 | #endif |
143 | |