ddnet/src/game/client/components/hud.h
c0d3d3v a9c8b344a2
Player position, speed and angle can now be displayed in the HUD.
- Added RenderMovementInformation() to the HUD
- Use m_Width instead of recalculating the display width each time in hud.cpp
- Reworked Debug HUD:
    - Display velspeed.x*ramp and velspeed.y instead of velspeed*ramp
    - Show unit of speed
    - The graph for the velspeed.x*ramp behavior (if dbg_tuning is active) is now nicer and usable. A second graph zooming in on the turning point has been added.
    - The velspeed.x*ramp graph will be redrawn only when new tuning parameters are added
- The target angle used to draw the tees is now calculated using the m_TargetX, m_TargetY in DDNetCharacterDisplayInfo if available.
- Added m_TargetX, m_TargetY and m_RampValue to DDNetCharacterDisplayInfo Snap (m_RampValue has a precision of one thousandth)
- Added CGraph::InsertAt() to create static Graphs
- Added "assets/hud" to initial created Directories
- Added Settings to hide Dummy Action HUD and Player Movement HUD cl_showhud_dummy_actions, cl_showhud_player_position, cl_showhud_player_speed, cl_showhud_player_angle
- Added Pointer to m_PrevExtendedDisplayInfo, for calculation of interpolated Angle in Player Rendering
- Added GetDigitsIndex(int Value, float Max); to hud.cpp
2022-04-14 13:42:19 +02:00

136 lines
3.3 KiB
C++

/* (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_HUD_H
#define GAME_CLIENT_COMPONENTS_HUD_H
#include <game/client/component.h>
struct SScoreInfo
{
SScoreInfo()
{
Reset();
}
void Reset()
{
m_TextRankContainerIndex = m_TextScoreContainerIndex = m_RoundRectQuadContainerIndex = m_OptionalNameTextContainerIndex = -1;
m_aScoreText[0] = 0;
m_aRankText[0] = 0;
m_aPlayerNameText[0] = 0;
m_ScoreTextWidth = 0.f;
m_Initialized = false;
}
int m_TextRankContainerIndex;
int m_TextScoreContainerIndex;
float m_ScoreTextWidth;
char m_aScoreText[16];
char m_aRankText[16];
char m_aPlayerNameText[MAX_NAME_LENGTH];
int m_RoundRectQuadContainerIndex;
int m_OptionalNameTextContainerIndex;
bool m_Initialized;
};
class CHud : public CComponent
{
float m_Width, m_Height;
float m_FrameTimeAvg;
int m_HudQuadContainerIndex;
SScoreInfo m_aScoreInfo[2];
int m_FPSTextContainerIndex;
void RenderCursor();
void RenderTextInfo();
void RenderConnectionWarning();
void RenderTeambalanceWarning();
void RenderVoting();
void PrepareAmmoHealthAndArmorQuads();
void RenderAmmoHealthAndArmor(const CNetObj_Character *pCharacter);
void PreparePlayerStateQuads();
void RenderPlayerState(const int ClientID);
void RenderDummyActions();
void RenderMovementInformation(const int ClientID);
void RenderGameTimer();
void RenderPauseNotification();
void RenderSuddenDeath();
void RenderScoreHud();
void RenderSpectatorHud();
void RenderWarmupTimer();
void RenderLocalTime(float x);
void MapscreenToGroup(float CenterX, float CenterY, struct CMapItemGroup *PGroup);
public:
CHud();
virtual int Sizeof() const override { return sizeof(*this); }
void ResetHudContainers();
virtual void OnWindowResize() override;
virtual void OnReset() override;
virtual void OnRender() override;
virtual void OnInit() override;
// DDRace
virtual void OnMessage(int MsgType, void *pRawMsg) override;
void RenderNinjaBarPos(float x, const float y, const float width, const float height, float Progress, float Alpha = 1.0f);
private:
void RenderRecord();
void RenderDDRaceEffects();
float m_CheckpointDiff;
float m_ServerRecord;
float m_PlayerRecord[NUM_DUMMIES];
int m_DDRaceTime;
int m_LastReceivedTimeTick;
int m_CheckpointTick;
bool m_FinishTime;
bool m_DDRaceTimeReceived;
inline int GetDigitsIndex(int Value, float Max);
// Quad Offsets
int m_AmmoOffset[NUM_WEAPONS];
int m_HealthOffset;
int m_EmptyHealthOffset;
int m_ArmorOffset;
int m_EmptyArmorOffset;
int m_CursorOffset[NUM_WEAPONS];
int m_FlagOffset;
int m_AirjumpOffset;
int m_AirjumpEmptyOffset;
int m_WeaponHammerOffset;
int m_WeaponGunOffset;
int m_WeaponShotgunOffset;
int m_WeaponGrenadeOffset;
int m_WeaponLaserOffset;
int m_WeaponNinjaOffset;
int m_EndlessJumpOffset;
int m_EndlessHookOffset;
int m_JetpackOffset;
int m_TeleportGrenadeOffset;
int m_TeleportGunOffset;
int m_TeleportLaserOffset;
int m_SoloOffset;
int m_NoCollisionOffset;
int m_NoHookHitOffset;
int m_NoHammerHitOffset;
int m_NoShotgunHitOffset;
int m_NoGrenadeHitOffset;
int m_NoLaserHitOffset;
int m_DeepFrozenOffset;
int m_LiveFrozenOffset;
int m_DummyHammerOffset;
int m_DummyCopyOffset;
int m_PracticeModeOffset;
};
#endif