DDraceNetwork Docs
hud.h
Go to the documentation of this file.
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>
7#include <engine/textrender.h>
10
12{
14 {
15 Reset();
16 }
17
18 void Reset()
19 {
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
34 char m_aScoreText[16];
35 char m_aRankText[16];
39
41};
42
43class CHud : public CComponent
44{
47
55 char m_aaPlayerSpeedText[2][128];
57 enum class ESpeedChange
58 {
59 NONE,
60 INCREASE,
61 DECREASE
62 };
66
67 void RenderCursor();
68
69 void RenderTextInfo();
73
75 void RenderAmmoHealthAndArmor(const CNetObj_Character *pCharacter);
76
78 void RenderPlayerState(const int ClientId);
79 void RenderDummyActions();
80 void RenderMovementInformation(const int ClientId);
81
82 void UpdateMovementInformationTextContainer(STextContainerIndex &TextContainer, float FontSize, float Value, char *pPrevValue, size_t Size);
83 void RenderMovementInformationTextContainer(STextContainerIndex &TextContainer, const ColorRGBA &Color, float X, float Y);
84
85 void RenderGameTimer();
87 void RenderSuddenDeath();
88
89 void RenderScoreHud();
91
92 void RenderSpectatorHud();
93 void RenderWarmupTimer();
94 void RenderLocalTime(float x);
95
96 static constexpr float MOVEMENT_INFORMATION_LINE_HEIGHT = 8.0f;
97
98public:
99 CHud();
100 virtual int Sizeof() const override { return sizeof(*this); }
101
102 void ResetHudContainers();
103 virtual void OnWindowResize() override;
104 virtual void OnReset() override;
105 virtual void OnRender() override;
106 virtual void OnInit() override;
107 virtual void OnNewSnapshot() override;
108
109 // DDRace
110
111 virtual void OnMessage(int MsgType, void *pRawMsg) override;
112 void RenderNinjaBarPos(float x, const float y, const float Width, const float Height, float Progress, float Alpha = 1.0f);
113
114private:
115 void RenderRecord();
116 void RenderDDRaceEffects();
125
126 inline float GetMovementInformationBoxHeight();
127 inline int GetDigitsIndex(int Value, int Max);
128
129 // Quad Offsets
161};
162
163#endif
Definition: component.h:20
Definition: hud.h:44
int m_ArmorOffset
Definition: hud.h:133
void RenderVoting()
void RenderPauseNotification()
Definition: hud.cpp:151
void RenderRecord()
Definition: hud.cpp:1693
virtual void OnWindowResize() override
Definition: hud.cpp:64
float m_Width
Definition: hud.h:45
int m_EmptyArmorOffset
Definition: hud.h:134
int m_aAmmoOffset[NUM_WEAPONS]
Definition: hud.h:130
void RenderSuddenDeath()
Definition: hud.cpp:163
void RenderWarmupTimer()
Definition: hud.cpp:491
void RenderConnectionWarning()
Definition: hud.cpp:558
void RenderScoreHud()
Definition: hud.cpp:175
void PreparePlayerStateQuads()
Definition: hud.cpp:717
int m_LockModeOffset
Definition: hud.h:160
int m_HookHitDisabledOffset
Definition: hud.h:148
int m_DeepFrozenOffset
Definition: hud.h:154
int m_EmptyHealthOffset
Definition: hud.h:132
STextContainerIndex m_aPlayerSpeedTextContainers[2]
Definition: hud.h:54
virtual void OnInit() override
Definition: hud.cpp:85
void RenderDDRaceEffects()
Definition: hud.cpp:1599
int m_HammerHitDisabledOffset
Definition: hud.h:149
CHud()
Definition: hud.cpp:27
void RenderMovementInformationTextContainer(STextContainerIndex &TextContainer, const ColorRGBA &Color, float X, float Y)
Definition: hud.cpp:1280
int m_aWeaponOffset[NUM_WEAPONS]
Definition: hud.h:139
int m_DummyHammerOffset
Definition: hud.h:156
void RenderDummyActions()
Definition: hud.cpp:1194
float m_ServerRecord
Definition: hud.h:118
float m_aPlayerRecord[NUM_DUMMIES]
Definition: hud.h:119
void RenderPlayerState(const int ClientId)
Definition: hud.cpp:776
int m_DummyCopyOffset
Definition: hud.h:157
virtual void OnRender() override
Definition: hud.cpp:1480
int m_LaserHitDisabledOffset
Definition: hud.h:153
float m_TimeCpDiff
Definition: hud.h:117
virtual void OnNewSnapshot() override
Definition: hud.cpp:1434
int m_DDRaceTime
Definition: hud.h:121
int m_TeleportGrenadeOffset
Definition: hud.h:143
char m_aaPlayerPositionText[2][128]
Definition: hud.h:65
void ResetHudContainers()
Definition: hud.cpp:42
STextContainerIndex m_FPSTextContainerIndex
Definition: hud.h:50
char m_aPlayerAngleText[128]
Definition: hud.h:53
float m_FrameTimeAvg
Definition: hud.h:46
void RenderMovementInformation(const int ClientId)
Definition: hud.cpp:1288
int m_FinishTimeLastReceivedTick
Definition: hud.h:122
STextContainerIndex m_PlayerAngleTextContainerIndex
Definition: hud.h:52
void RenderCursor()
Definition: hud.cpp:588
int m_FlagOffset
Definition: hud.h:136
ESpeedChange
Definition: hud.h:58
void RenderGameTimer()
Definition: hud.cpp:109
float GetMovementInformationBoxHeight()
Definition: hud.cpp:1256
int m_LiveFrozenOffset
Definition: hud.h:155
int m_EndlessHookOffset
Definition: hud.h:141
SScoreInfo m_aScoreInfo[2]
Definition: hud.h:49
float m_Height
Definition: hud.h:45
float m_FinishTimeDiff
Definition: hud.h:120
int m_aPlayerSpeed[2]
Definition: hud.h:56
int m_SoloOffset
Definition: hud.h:146
int m_ShotgunHitDisabledOffset
Definition: hud.h:151
int m_Team0ModeOffset
Definition: hud.h:159
STextContainerIndex m_DDRaceEffectsTextContainerIndex
Definition: hud.h:51
virtual void OnMessage(int MsgType, void *pRawMsg) override
Definition: hud.cpp:1553
void RenderAmmoHealthAndArmor(const CNetObj_Character *pCharacter)
Definition: hud.cpp:674
int m_AirjumpOffset
Definition: hud.h:137
int m_TeleportGunOffset
Definition: hud.h:144
void RenderTextInfo()
Definition: hud.cpp:511
virtual int Sizeof() const override
Definition: hud.h:100
void RenderNinjaBarPos(float x, const float y, const float Width, const float Height, float Progress, float Alpha=1.0f)
Definition: hud.cpp:1043
virtual void OnReset() override
Definition: hud.cpp:69
int m_TimeCpLastReceivedTick
Definition: hud.h:123
int GetDigitsIndex(int Value, int Max)
Definition: hud.cpp:1238
void UpdateMovementInformationTextContainer(STextContainerIndex &TextContainer, float FontSize, float Value, char *pPrevValue, size_t Size)
Definition: hud.cpp:1266
int m_EndlessJumpOffset
Definition: hud.h:140
int m_LastLocalClientId
Definition: hud.h:90
int m_JetpackOffset
Definition: hud.h:142
int m_GunHitDisabledOffset
Definition: hud.h:150
int m_HudQuadContainerIndex
Definition: hud.h:48
void RenderTeambalanceWarning()
Definition: hud.cpp:568
static constexpr float MOVEMENT_INFORMATION_LINE_HEIGHT
Definition: hud.h:96
int m_HealthOffset
Definition: hud.h:131
int m_aCursorOffset[NUM_WEAPONS]
Definition: hud.h:135
int m_PracticeModeOffset
Definition: hud.h:158
char m_aaPlayerSpeedText[2][128]
Definition: hud.h:55
void RenderSpectatorHud()
Definition: hud.cpp:1398
void RenderLocalTime(float x)
Definition: hud.cpp:1420
int m_CollisionDisabledOffset
Definition: hud.h:147
int m_AirjumpEmptyOffset
Definition: hud.h:138
STextContainerIndex m_aPlayerPositionContainers[2]
Definition: hud.h:64
int m_TeleportLaserOffset
Definition: hud.h:145
bool m_ShowFinishTime
Definition: hud.h:124
void PrepareAmmoHealthAndArmorQuads()
Definition: hud.cpp:602
int m_GrenadeHitDisabledOffset
Definition: hud.h:152
ESpeedChange m_aLastPlayerSpeedChange[2]
Definition: hud.h:63
Definition: color.h:210
@ NUM_DUMMIES
Definition: enums.h:8
@ MAX_NAME_LENGTH
Definition: protocol.h:97
@ NUM_WEAPONS
Definition: protocol.h:1257
Definition: protocol.h:455
Definition: hud.h:12
char m_aScoreText[16]
Definition: hud.h:34
char m_aPlayerNameText[MAX_NAME_LENGTH]
Definition: hud.h:36
SScoreInfo()
Definition: hud.h:13
bool m_Initialized
Definition: hud.h:40
STextContainerIndex m_OptionalNameTextContainerIndex
Definition: hud.h:38
STextContainerIndex m_TextScoreContainerIndex
Definition: hud.h:32
STextContainerIndex m_TextRankContainerIndex
Definition: hud.h:31
void Reset()
Definition: hud.h:18
char m_aRankText[16]
Definition: hud.h:35
float m_ScoreTextWidth
Definition: hud.h:33
int m_RoundRectQuadContainerIndex
Definition: hud.h:37
Definition: textrender.h:293
void Reset()
Definition: textrender.h:300