HUD class
#include <Jazz2/UI/HUD.h>
Player HUD.
In-game heads-up display drawn on top of the level. It renders the player's health, score, collected coins and gems, active weapon and ammo, boss health, transient level text notifications, and the weapon wheel, as well as on-screen touch controls and fade transitions. Individual elements are drawn through overridable OnDraw* methods so subclasses (e.g. multiplayer) can customize them.
Base classes
- class Canvas
- Canvas.
Derived classes
- class MpHUD
- Player HUD for multiplayer.
Constructors, destructors, conversion operators
- HUD(LevelHandler* levelHandler)
- Creates a new instance.
- ~HUD()
Public functions
- void OnUpdate(float timeMult) override
- Called every frame to update the node state.
- auto OnDraw(RenderQueue& renderQueue) -> bool override
- Called when the node needs to be drawn, returning
trueif a command was added. -
void OnTouchEvent(const TouchEvent& event,
std::
uint32_t& overrideActions, Vector2f& overrideMovement) - Called when a touch event occurs, allowing the HUD to override actions and movement.
- void ShowLevelText(StringView text)
- Shows a text notification.
-
void ShowCoins(std::
int32_t count) - Shows a notification about coins.
-
void ShowGems(std::
uint8_t gemType, std:: int32_t count) - Shows a notification about gems.
- void BeginFadeIn(bool skip)
- Begins a fullscreen fade-in transition.
- void BeginFadeOut(float delay = 0.0f)
- Begins a fullscreen face-out transition.
-
auto IsWeaponWheelVisible(std::
int32_t playerIndex) const -> bool - Returns
trueif weapon wheel is visible. - void RefreshTouchButtons()
- Rebuilds internal touch button data from current PreferencesCache::
TouchButtons configuration.
Protected functions
-
void OnDrawOverview(const Rectf& view,
const Rectf& adjustedView,
Actors::
Player* player) virtual - Called when some overview information of the player needs to be drawn.
-
void OnDrawHealth(const Rectf& view,
const Rectf& adjustedView,
Actors::
Player* player) virtual - Called when health of the player needs to be drawn.
-
void OnDrawScore(const Rectf& view,
Actors::
Player* player) virtual - Called when score of the player needs to be drawn.
-
void OnDrawWeaponAmmo(const Rectf& adjustedView,
Actors::
Player* player) virtual - Called when weapon ammo of the player needs to be drawn.
- void OnDrawActiveBoss(const Rectf& adjustedView) virtual
- Called when health of the active boss needs to be drawn.
-
void OnDrawLevelText(std::
int32_t& charOffset) virtual - Called when a text notification needs to be drawn.
-
void OnDrawCoins(const Rectf& view,
std::
int32_t& charOffset) virtual - Called when a notification about coins of the player needs to be drawn.
-
void OnDrawGems(const Rectf& view,
std::
int32_t& charOffset) virtual - Called when a notification about gems of the player needs to be drawn.
-
void OnDrawTouchButtons(Actors::
Player* player) - Called when touch buttons need to be drawn.
-
void DrawHealthCarrots(float x,
float y,
std::
int32_t health) - Draws carrotized health bar (Reforged).
- void DrawViewportSeparators()
- Draws separators of split-screen viewports.
-
void DrawElement(AnimState state,
std::
int32_t frame, float x, float y, std:: uint16_t z, Alignment align, const Colorf& color, float scaleX = 1.0f, float scaleY = 1.0f, bool additiveBlending = false, float angle = 0.0f) - Draws a textured element.
-
auto DrawElementWithPalette(AnimState state,
std::
int32_t frame, float x, float y, std:: uint16_t z, Alignment align, const Colorf& color, float paletteOffset, float scaleX = 1.0f, float scaleY = 1.0f) -> bool - Draws a textured element recolored through a player palette (PaletteRemap shader).
-
void DrawElementClipped(AnimState state,
std::
int32_t frame, float x, float y, std:: uint16_t z, Alignment align, const Colorf& color, float clipX, float clipY) - Draws a textured element with clipping.
Constants
-
static std::
uint16_t MainLayer protected constexpr - Main layer.
-
static std::
uint16_t ShadowLayer protected constexpr - Shadow for main layer.
-
static std::
uint16_t FontLayer protected constexpr - Font layer.
-
static std::
uint16_t FontShadowLayer protected constexpr - Shadow for font layer.
-
static std::
uint16_t TouchButtonsLayer protected constexpr - Touch buttons layer.
Function documentation
bool Jazz2:: UI:: HUD:: DrawElementWithPalette(AnimState state,
std:: int32_t frame,
float x,
float y,
std:: uint16_t z,
Alignment align,
const Colorf& color,
float paletteOffset,
float scaleX = 1.0f,
float scaleY = 1.0f) protected
Draws a textured element recolored through a player palette (PaletteRemap shader).
Returns false if it can't (no indexed metadata or the element isn't an indexed sprite) so the caller can fall back.