Skip to main content

GameTimer2UiTextUpdateSystem.ixx File

System for binding game timer values to UI text components. More...

Included Headers

Namespaces Index

namespacehelios
namespaceengine

Main engine module aggregating core infrastructure and game systems. More...

namespacemodules

Domain-specific components and systems. More...

namespaceui

User interface components and systems for game entities. More...

namespacebinding

Data binding systems for UI components. More...

namespacesystems

UI data binding systems. More...

Classes Index

classGameTimer2UiTextUpdateSystem

System for binding game timer values to UI text components. More...

Description

System for binding game timer values to UI text components.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file GameTimer2UiTextUpdateSystem.ixx
3 * @brief System for binding game timer values to UI text components.
4 */
5module;
6
7
8#include <format>
9
10
11
12export module helios.engine.modules.ui.binding.systems.GameTimer2UiTextUpdateSystem;
13
14import helios.engine.mechanics.timing.TimerManager;
15import helios.engine.mechanics.timing.components;
16
17import helios.engine.runtime.world.GameWorld;
18import helios.engine.runtime.world.UpdateContext;
19
20
21import helios.engine.modules.ui.widgets;
22import helios.engine.modules.ui.layout;
23
24import helios.engine.mechanics.lifecycle.components.Active;
25
27
28import helios.engine.common.tags.SystemRole;
29
31
32 /**
33 * @brief System for binding game timer values to UI text components.
34 *
35 * Queries entities with GameTimerBindingComponent, TimeFormatterComponent,
36 * and UiTextComponent. When the observed timer's revision changes, the
37 * formatted time string is propagated to the text component for display.
38 *
39 * @see TimerManager
40 * @see GameTimerBindingComponent
41 * @see TimeFormatterComponent
42 */
44
45 /**
46 * @brief Reference to the TimerManager that owns the game timers.
47 */
48 TimerManager& timerManager_;
49
50 public:
51
53 /**
54 * @brief Constructs the system with a reference to the TimerManager.
55 *
56 * @param timerManager The TimerManager providing game timer state.
57 */
59 : timerManager_(timerManager) {}
60
61
62
63 /**
64 * @brief Updates text components with current game timer values.
65 *
66 * For each matching entity, compares the timer revision against the
67 * observer's cached revision. On mismatch, formats the elapsed/remaining
68 * time via the TimeFormatterComponent and updates the UiTextComponent.
69 *
70 * @param updateContext The current frame's update context.
71 */
73
74 for (auto [entity, gtc, dfc, txt, active] : updateContext.view<
79 >().whereEnabled()) {
80
81 if (const auto* timer = timerManager_.gameTimer(gtc->gameTimerId());
82 timer->timerRevision() != gtc->timerRevision()) {
83 txt->setText(dfc->format(timer->elapsed(), timer->duration()));
84 gtc->setTimerRevision(timer->timerRevision());
85 }
86
87 }
88 }
89
90 };
91
92}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.