Skip to main content

TextRenderableConfig Class

Fluent configuration for text renderable GameObjects. More...

Declaration

class helios::engine::builder::gameObject::builders::configs::TextRenderableConfig { ... }

Public Constructors Index

TextRenderableConfig (helios::engine::ecs::GameObject gameObject)

Constructs a TextRenderableConfig for the given GameObject. More...

Public Member Functions Index

TextRenderableConfig &shader (const std::shared_ptr< helios::ext::opengl::rendering::shader::LegacyOpenGLShader > &shader)

Sets the shader for text rendering. More...

TextRenderableConfig &color (const helios::math::vec4f color)

Sets the text color. More...

SceneNodeConfigattachTo (helios::engine::ecs::GameObject parent)

Builds the text renderable and attaches to a parent GameObject. More...

SceneNodeConfigattachTo (helios::scene::SceneNode *parent)

Builds the text renderable and attaches to a parent SceneNode. More...

TextRenderableConfig &fontResourceProvider (helios::rendering::text::FontResourceProvider &provider)

Sets the font resource provider. More...

TextRenderableConfig &asUiText ()

Configures this text as a UI text component. More...

TextRenderableConfig &formattedAsNumber (std::string numberFormat="{:.0f}")

Attaches a NumberFormatterComponent with the given format. More...

TextRenderableConfig &formattedAsTimestamp (std::string timestampFormat)

Attaches a TimeFormatterComponent with the given format. More...

TextRenderableConfig &useElapsedLabel (std::string label)

Sets the label shown instead of "00:00" when remaining time reaches zero. More...

TextRenderableConfig &hideWhenZero ()

Hides the time output when remaining time reaches zero. More...

TextRenderableConfig &displayRemaining ()

Switches the time formatter to display remaining time. More...

TextRenderableConfig &text (std::string text)

Sets the text content. More...

TextRenderableConfig &fontId (helios::engine::modules::ui::widgets::types::FontId fontId)

Sets the font identifier. More...

TextRenderableConfig &fontScale (const float fontScale)

Sets the font scale factor. More...

TextRenderableConfig &build ()

Builds the text renderable and adds components to the GameObject. More...

Private Member Attributes Index

helios::engine::ecs::GameObjectgameObject_

The GameObject being configured. More...

helios::rendering::text::FontResourceProvider *fontResourceProvider_

Pointer to the font resource provider. More...

std::shared_ptr< helios::ext::opengl::rendering::shader::LegacyOpenGLShader >shader_

The shader used for text rendering. More...

helios::math::vec4fcolor_

The text color. More...

std::stringtext_

The text content to display. More...

floatfontScale_

The font scale factor. More...

std::stringnumberFormat_ = "{:0.f}"

Format string for number display (std::vformat syntax). More...

boolisUiText_ = false

Whether this text should be configured as UI text. More...

helios::engine::modules::ui::widgets::types::FontIdfontId_ {helios::core::types::no_init}

The font identifier. More...

std::stringtimestampFormat_

Format string for timestamp display (std::vformat syntax). More...

boolusesTimeFormatter_

Whether a TimeFormatterComponent should be attached. More...

boolusesNumberFormatter_

Whether a NumberFormatterComponent should be attached. More...

booldisplayRemaining_

Whether the timer should display remaining instead of elapsed time. More...

std::stringelapsedLabel_

Label displayed instead of "00:00" when remaining time reaches zero. More...

boolshowElapsedLabel_ = false

True if an elapsed label has been configured. More...

boolhideWhenZero_ = false

True if the output should be empty when remaining time reaches zero. More...

Description

Fluent configuration for text renderable GameObjects.

Provides a builder-style interface for configuring text rendering properties including font, color, shader, and optional UI text binding.

Definition at line 36 of file TextRenderableConfig.ixx.

Public Constructors

TextRenderableConfig()

helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::TextRenderableConfig (helios::engine::ecs::GameObject gameObject)
inline explicit

Constructs a TextRenderableConfig for the given GameObject.

Parameters
<a href="/docs/helios/namespaces/helios/engine/builder/gameobject">gameObject</a>

The GameObject to configure.

Definition at line 127 of file TextRenderableConfig.ixx.

Referenced by asUiText, build, color, displayRemaining, fontId, fontResourceProvider, fontScale, formattedAsNumber, formattedAsTimestamp, hideWhenZero, shader, text and useElapsedLabel.

Public Member Functions

asUiText()

TextRenderableConfig & helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::asUiText ()
inline

Configures this text as a UI text component.

Returns

Reference to this config for method chaining.

Definition at line 210 of file TextRenderableConfig.ixx.

211 isUiText_ = true;
212 return *this;
213 }

Reference TextRenderableConfig.

attachTo()

SceneNodeConfig helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::attachTo (helios::engine::ecs::GameObject parent)
inline

Builds the text renderable and attaches to a parent GameObject.

Parameters
parent

The parent GameObject to attach to.

Returns

A SceneNodeConfig for further configuration.

Definition at line 164 of file TextRenderableConfig.ixx.

165
166 build();
167
168 SceneNodeConfig scn{gameObject_};
169
170 scn.parent(parent);
171
172 return scn;
173 }

References build and helios::engine::builder::gameObject::builders::configs::SceneNodeConfig::parent.

attachTo()

SceneNodeConfig helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::attachTo (helios::scene::SceneNode * parent)
inline

Builds the text renderable and attaches to a parent SceneNode.

Parameters
parent

The parent SceneNode to attach to.

Returns

A SceneNodeConfig for further configuration.

Definition at line 182 of file TextRenderableConfig.ixx.

183
184 build();
185
186 SceneNodeConfig scn{gameObject_};
187
188 scn.parent(parent);
189
190 return scn;
191 }

References build and helios::engine::builder::gameObject::builders::configs::SceneNodeConfig::parent.

build()

TextRenderableConfig & helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::build ()
inline

Builds the text renderable and adds components to the GameObject.

Creates a TextRenderable with the configured properties and adds RenderableComponent and ModelAabbComponent. If configured as UI text, also adds UiTextComponent.

Returns

Reference to this config for method chaining.

Definition at line 333 of file TextRenderableConfig.ixx.

334
335 assert(shader_ && "Unexpected missing shape and/or shader");
336
337 auto shaderProperties = std::make_shared<helios::rendering::text::TextShaderProperties>(color_);
338
339 const auto textPrototype = std::make_shared<helios::rendering::text::TextRenderPrototype>(
340 shader_, shaderProperties, fontResourceProvider_
341 );
342
343 auto renderable = std::make_shared<helios::rendering::text::TextRenderable>(
344 std::make_unique<helios::rendering::text::TextMesh>(std::move(text_), fontScale_, fontId_),
345 textPrototype
346 );
347
349
351 msc.setAabb(renderable->localAABB());
352
353 if (isUiText_ || usesNumberFormatter_ || usesTimeFormatter_) {
355 isUiText_ = false;
356 }
357
358 if (usesTimeFormatter_) {
360 tfc.setFormat(
361 timestampFormat_,
364 );
365 if (showElapsedLabel_) {
366 tfc.setElapsedLabel(elapsedLabel_);
367 }
368 tfc.setHideWhenZero(hideWhenZero_);
369 usesTimeFormatter_ = false;
370 }
371
372 if (usesNumberFormatter_) {
374 .setFormat(numberFormat_);
375 usesNumberFormatter_ = false;
376 }
377
378
379 return *this;
380 }

References helios::engine::modules::ui::layout::types::Elapsed, helios::engine::modules::ui::layout::types::Remaining, helios::engine::modules::ui::layout::components::TimeFormatterComponent::setFormat and TextRenderableConfig.

Referenced by attachTo and attachTo.

color()

TextRenderableConfig & helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::color (const helios::math::vec4f color)
inline

Sets the text color.

Parameters
color

The RGBA color.

Returns

Reference to this config for method chaining.

Definition at line 151 of file TextRenderableConfig.ixx.

152 color_ = color;
153
154 return *this;
155 }

References color and TextRenderableConfig.

Referenced by color.

displayRemaining()

TextRenderableConfig & helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::displayRemaining ()
inline

Switches the time formatter to display remaining time.

Only effective when formattedAsTimestamp() has been called.

Returns

Reference to this config for method chaining.

Definition at line 282 of file TextRenderableConfig.ixx.

283 displayRemaining_ = true;
284 return *this;
285 }

Reference TextRenderableConfig.

fontId()

TextRenderableConfig & helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::fontId (helios::engine::modules::ui::widgets::types::FontId fontId)
inline

Sets the font identifier.

Parameters
fontId

The font ID to use.

Returns

Reference to this config for method chaining.

Definition at line 307 of file TextRenderableConfig.ixx.

References fontId and TextRenderableConfig.

Referenced by fontId.

fontResourceProvider()

TextRenderableConfig & helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::fontResourceProvider (helios::rendering::text::FontResourceProvider & provider)
inline

Sets the font resource provider.

Parameters
provider

The font resource provider.

Returns

Reference to this config for method chaining.

Definition at line 200 of file TextRenderableConfig.ixx.

201 fontResourceProvider_ = &provider;
202 return *this;
203 }

Reference TextRenderableConfig.

fontScale()

TextRenderableConfig & helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::fontScale (const float fontScale)
inline

Sets the font scale factor.

Parameters
fontScale

The scale factor.

Returns

Reference to this config for method chaining.

Definition at line 319 of file TextRenderableConfig.ixx.

320 fontScale_ = fontScale;
321 return *this;
322 }

References fontScale and TextRenderableConfig.

Referenced by fontScale.

formattedAsNumber()

TextRenderableConfig & helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::formattedAsNumber (std::string numberFormat="{:.0f}")
inline

Attaches a NumberFormatterComponent with the given format.

Implicitly enables UI text mode.

Parameters
numberFormat

A std::vformat-compatible string. Defaults to "{:.0f}".

Returns

Reference to this config for method chaining.

Definition at line 224 of file TextRenderableConfig.ixx.

224 TextRenderableConfig& formattedAsNumber(std::string numberFormat = "{:.0f}") {
225 numberFormat_ = std::move(numberFormat);
226 usesNumberFormatter_ = true;
227 return *this;
228 }

Reference TextRenderableConfig.

formattedAsTimestamp()

TextRenderableConfig & helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::formattedAsTimestamp (std::string timestampFormat)
inline

Attaches a TimeFormatterComponent with the given format.

Implicitly enables UI text mode.

Parameters
timestampFormat

A std::vformat-compatible string expecting minutes and seconds.

Returns

Reference to this config for method chaining.

Definition at line 239 of file TextRenderableConfig.ixx.

239 TextRenderableConfig& formattedAsTimestamp(std::string timestampFormat) {
240 timestampFormat_ = std::move(timestampFormat);
241 usesTimeFormatter_ = true;
242 return *this;
243 }

Reference TextRenderableConfig.

hideWhenZero()

TextRenderableConfig & helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::hideWhenZero ()
inline

Hides the time output when remaining time reaches zero.

Only effective in Remaining mode. When enabled, format() returns an empty string once the remaining time is exhausted.

Returns

Reference to this config for method chaining.

Definition at line 270 of file TextRenderableConfig.ixx.

271 hideWhenZero_ = true;
272 return *this;
273 }

Reference TextRenderableConfig.

shader()

TextRenderableConfig & helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::shader (const std::shared_ptr< helios::ext::opengl::rendering::shader::LegacyOpenGLShader > & shader)
inline

Sets the shader for text rendering.

Parameters
shader

The shader to use.

Returns

Reference to this config for method chaining.

Definition at line 138 of file TextRenderableConfig.ixx.

138 TextRenderableConfig& shader(const std::shared_ptr<helios::ext::opengl::rendering::shader::LegacyOpenGLShader>& shader) {
139 shader_ = std::move(shader);
140
141 return *this;
142 }

References shader and TextRenderableConfig.

Referenced by shader.

text()

TextRenderableConfig & helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::text (std::string text)
inline

Sets the text content.

Parameters
text

The text to display.

Returns

Reference to this config for method chaining.

Definition at line 295 of file TextRenderableConfig.ixx.

296 text_ = std::move(text);
297 return *this;
298 }

References text and TextRenderableConfig.

Referenced by text.

useElapsedLabel()

TextRenderableConfig & helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::useElapsedLabel (std::string label)
inline

Sets the label shown instead of "00:00" when remaining time reaches zero.

Only effective in Remaining mode. Once the remaining time drops to one second or below, format() returns this label instead of the numeric output.

Parameters
label

The label string to display (e.g. "TIME UP").

Returns

Reference to this config for method chaining.

Definition at line 256 of file TextRenderableConfig.ixx.

257 elapsedLabel_ = std::move(label);
258 showElapsedLabel_ = true;
259 return *this;
260 }

Reference TextRenderableConfig.

Private Member Attributes

color_

helios::math::vec4f helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::color_

The text color.

Definition at line 56 of file TextRenderableConfig.ixx.

displayRemaining_

bool helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::displayRemaining_

Whether the timer should display remaining instead of elapsed time.

Definition at line 101 of file TextRenderableConfig.ixx.

101 bool displayRemaining_;

elapsedLabel_

std::string helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::elapsedLabel_

Label displayed instead of "00:00" when remaining time reaches zero.

Definition at line 106 of file TextRenderableConfig.ixx.

106 std::string elapsedLabel_;

fontId_

helios::engine::modules::ui::widgets::types::FontId helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::fontId_ {helios::core::types::no_init}

fontResourceProvider_

helios::rendering::text::FontResourceProvider* helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::fontResourceProvider_

Pointer to the font resource provider.

Definition at line 46 of file TextRenderableConfig.ixx.

fontScale_

float helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::fontScale_

The font scale factor.

Definition at line 66 of file TextRenderableConfig.ixx.

66 float fontScale_;

gameObject_

helios::engine::ecs::GameObject helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::gameObject_

The GameObject being configured.

Definition at line 41 of file TextRenderableConfig.ixx.

hideWhenZero_

bool helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::hideWhenZero_ = false

True if the output should be empty when remaining time reaches zero.

Definition at line 116 of file TextRenderableConfig.ixx.

116 bool hideWhenZero_ = false;

isUiText_

bool helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::isUiText_ = false

Whether this text should be configured as UI text.

Definition at line 76 of file TextRenderableConfig.ixx.

76 bool isUiText_ = false;

numberFormat_

std::string helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::numberFormat_ = "{:0.f}"

Format string for number display (std::vformat syntax).

Definition at line 71 of file TextRenderableConfig.ixx.

71 std::string numberFormat_ = "{:0.f}";

shader_

std::shared_ptr<helios::ext::opengl::rendering::shader::LegacyOpenGLShader> helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::shader_

The shader used for text rendering.

Definition at line 51 of file TextRenderableConfig.ixx.

51 std::shared_ptr<helios::ext::opengl::rendering::shader::LegacyOpenGLShader> shader_;

showElapsedLabel_

bool helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::showElapsedLabel_ = false

True if an elapsed label has been configured.

Definition at line 111 of file TextRenderableConfig.ixx.

111 bool showElapsedLabel_ = false;

text_

std::string helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::text_

The text content to display.

Definition at line 61 of file TextRenderableConfig.ixx.

61 std::string text_;

timestampFormat_

std::string helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::timestampFormat_

Format string for timestamp display (std::vformat syntax).

Definition at line 86 of file TextRenderableConfig.ixx.

86 std::string timestampFormat_;

usesNumberFormatter_

bool helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::usesNumberFormatter_

Whether a NumberFormatterComponent should be attached.

Definition at line 96 of file TextRenderableConfig.ixx.

96 bool usesNumberFormatter_;

usesTimeFormatter_

bool helios::engine::builder::gameObject::builders::configs::TextRenderableConfig::usesTimeFormatter_

Whether a TimeFormatterComponent should be attached.

Definition at line 91 of file TextRenderableConfig.ixx.

91 bool usesTimeFormatter_;

The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.