TimeFormatterComponent Class
Component that formats elapsed or remaining time into a display string. More...
Declaration
Public Member Functions Index
| void | setFormat (std::string format, const TimeDisplayMode displayMode=TimeDisplayMode::Elapsed) |
|
Sets the format string and display mode. More... | |
| std::string | format (const float elapsed, const float duration=0) const |
|
Formats the given time values into a display string. More... | |
| void | setElapsedLabel (std::string label) |
|
Sets the label shown in place of "00:00" when remaining time reaches zero. More... | |
| std::string | elapsedLabel () |
|
Returns the elapsed label. More... | |
| bool | hasElapsedLabel () const |
|
Returns whether an elapsed label is configured. More... | |
| void | setHideWhenZero (const bool hideWhenZero) noexcept |
|
Sets whether to hide the output when remaining time reaches zero. More... | |
| bool | hideWhenZero () const |
|
Returns whether the output is hidden at zero remaining time. More... | |
Private Member Attributes Index
| std::string | format_ |
|
The format string used by std::vformat (expects minutes, seconds). More... | |
| std::string | elapsedLabel_ |
|
Label displayed instead of "00:00" when remaining time reaches zero. More... | |
| bool | hasElapsedLabel_ = false |
|
True if an elapsed label has been configured. More... | |
| bool | hideWhenZero_ = false |
|
True if the output should be empty when remaining time reaches zero. More... | |
| TimeDisplayMode | displayMode_ = TimeDisplayMode::Elapsed |
|
The active display mode (elapsed or remaining). More... | |
Description
Component that formats elapsed or remaining time into a display string.
Holds a format string compatible with std::vformat and a TimeDisplayMode. The format string receives two integer arguments: minutes and seconds.
- See Also
- See Also
GameTimer2UiTextUpdateSystem
Definition at line 27 of file TimeFormatterComponent.ixx.
Public Member Functions
elapsedLabel()
| inline |
Returns the elapsed label.
- Returns
The configured elapsed label string.
Definition at line 134 of file TimeFormatterComponent.ixx.
format()
| inline |
Formats the given time values into a display string.
If duration is zero, the display mode falls back to Elapsed.
- Parameters
-
elapsed Elapsed time in seconds.
duration Total duration in seconds. Zero disables Remaining mode.
- Returns
The formatted time string.
Definition at line 81 of file TimeFormatterComponent.ixx.
References helios::engine::modules::ui::layout::types::Elapsed and helios::engine::modules::ui::layout::types::Remaining.
Referenced by setFormat.
hasElapsedLabel()
| inline |
Returns whether an elapsed label is configured.
- Returns
True if an elapsed label has been set.
Definition at line 143 of file TimeFormatterComponent.ixx.
hideWhenZero()
| inline |
Returns whether the output is hidden at zero remaining time.
- Returns
True if hidden when zero.
Definition at line 161 of file TimeFormatterComponent.ixx.
Referenced by setHideWhenZero.
setElapsedLabel()
| inline |
Sets the label shown in place of "00:00" when remaining time reaches zero.
In Remaining mode, once the remaining time drops to one second or below, this label is returned by format() instead of the numeric output. Implicitly enables the elapsed label.
- Parameters
-
label The label string to display (e.g. "TIME UP").
Definition at line 124 of file TimeFormatterComponent.ixx.
setFormat()
| inline |
Sets the format string and display mode.
- Parameters
-
format A std::vformat-compatible string (e.g. "{:02d}:{:02d}").
displayMode The display mode to use. Defaults to Elapsed.
Definition at line 66 of file TimeFormatterComponent.ixx.
References helios::engine::modules::ui::layout::types::Elapsed and format.
Referenced by helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::build.
setHideWhenZero()
| inline noexcept |
Sets whether to hide the output when remaining time reaches zero.
- Parameters
-
hideWhenZero True to return an empty string at zero remaining time.
Definition at line 152 of file TimeFormatterComponent.ixx.
Reference hideWhenZero.
Private Member Attributes
displayMode_
| mutable |
The active display mode (elapsed or remaining).
Declared mutable because format() may fall back to Elapsed when duration is zero.
Definition at line 55 of file TimeFormatterComponent.ixx.
elapsedLabel_
|
Label displayed instead of "00:00" when remaining time reaches zero.
Definition at line 37 of file TimeFormatterComponent.ixx.
format_
|
The format string used by std::vformat (expects minutes, seconds).
Definition at line 32 of file TimeFormatterComponent.ixx.
hasElapsedLabel_
|
True if an elapsed label has been configured.
Definition at line 42 of file TimeFormatterComponent.ixx.
hideWhenZero_
|
True if the output should be empty when remaining time reaches zero.
Definition at line 47 of file TimeFormatterComponent.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.