TnxHud class

One player's HUD.

Constructors, destructors, conversion operators

operator bool() const explicit
Whether it names a HUD that was set.

Public functions

auto Add(const char* region, const char* asset, std::initializer_list<GGUI::GGWidgetInput> inputs = {}) const -> TnxWidgetRef
Add asset to the region (or layer: Menu, Modal, Toast) region.
void Remove(TnxWidgetRef widget) const
Remove a widget Add added. Its "hidden" clips play first. Nothing if it is gone.
void SetArea(float x, float y, float width, float height) const
The part of the screen it is shown in, as fractions of it (0..1), for a game whose views are split its own way.
void SetLifetime(ConstructLifetime lifetime) const
How long it lasts, as Constructs do (ConstructLifetime).
void OnNewWorld(std::function<void(const TnxHud&hud, WorldBase&world)> rebind) const
A HUD that outlived its world was given to world: give its class new contexts there.
auto Widget() const -> TnxWidgetBase*
Its class's instance (TnxUI::SetHud<T>), whose contexts and inputs it is given as they are; null for a HUD with none.
template<typename T>
auto Widget() const -> T*
The same as T: hud.Widget<PlayerHud>()->Gold = 10. T must be its class.

Public variables

uint64_t ID
0: none

Function documentation

TnxWidgetRef TnxHud::Add(const char* region, const char* asset, std::initializer_list<GGUI::GGWidgetInput> inputs = {}) const

Add asset to the region (or layer: Menu, Modal, Toast) region.

A region the HUD hasn't got, or an asset it doesn't accept, is reported and adds nothing. A region at its most loses its oldest.

void TnxHud::SetArea(float x, float y, float width, float height) const

The part of the screen it is shown in, as fractions of it (0..1), for a game whose views are split its own way.

Without it, the local players of one world share the screen: two one above the other, three or four in quarters.

void TnxHud::SetLifetime(ConstructLifetime lifetime) const

How long it lasts, as Constructs do (ConstructLifetime).

World, the default: it goes with its world. Level: also when the level unloads. Session: it outlives its world, waits unshown for the next one, and goes when its player leaves. Persistent: only when removed.