Skip to main content

MenuItemConfig Class

Fluent configuration for menu item GameObjects. More...

Declaration

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

Public Constructors Index

MenuItemConfig (helios::engine::ecs::GameObject gameObject, helios::engine::ecs::GameObject &parentMenu)

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

Public Member Functions Index

MenuItemConfig &selected (const bool isSelected)

Sets the selected state. More...

MenuItemConfig &normalColor (const helios::math::vec4f color)

Sets the normal state color. More...

MenuItemConfig &normalScale (const float scale)

Sets the normal state scale. More...

MenuItemConfig &selectedColor (helios::math::vec4f color)

Sets the selected state color. More...

MenuItemConfig &selectedScale (const float scale)

Sets the selected state scale. More...

MenuItemConfig &actionId (const helios::engine::modules::ui::widgets::types::ActionId actionId)

Sets the action ID for this menu item. More...

MenuItemConfig &index (const size_t index)

Sets the index position in the parent menu. More...

Private Member Functions Index

voidattach ()

Attaches this item to the parent menu. More...

Private Member Attributes Index

helios::engine::ecs::GameObjectgameObject_

The GameObject being configured. More...

helios::engine::ecs::GameObject *parentMenu_ = nullptr

Pointer to the parent menu GameObject. More...

std::optional< size_t >index_ = std::nullopt

Optional index position in the menu. More...

boolisSelected_ = false

Whether this item is selected. More...

Description

Fluent configuration for menu item GameObjects.

Provides a builder-style interface for configuring menu items including styling, selection state, and action binding. Automatically attaches the item to the parent menu.

Definition at line 33 of file MenuItemConfig.ixx.

Public Constructors

MenuItemConfig()

helios::engine::builder::gameObject::builders::configs::MenuItemConfig::MenuItemConfig (helios::engine::ecs::GameObject gameObject, helios::engine::ecs::GameObject & parentMenu)
inline explicit

Constructs a MenuItemConfig for the given GameObject.

Automatically adds UiStyleComponent and UiStateComponent, and attaches the item to the parent menu.

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

The GameObject to configure.

parentMenu

The parent menu GameObject (must have MenuComponent).

Definition at line 78 of file MenuItemConfig.ixx.

78 explicit MenuItemConfig(
81 ) : gameObject_(gameObject), parentMenu_(&parentMenu) {
82
83
86
87
89 "parent menu must have MenuComponent");
90
91 attach();
92 }

Referenced by actionId, index, normalColor, normalScale, selected, selectedColor and selectedScale.

Public Member Functions

actionId()

MenuItemConfig & helios::engine::builder::gameObject::builders::configs::MenuItemConfig::actionId (const helios::engine::modules::ui::widgets::types::ActionId actionId)
inline

Sets the action ID for this menu item.

Parameters
actionId

The action to trigger when activated.

Returns

Reference to this config for method chaining.

Definition at line 180 of file MenuItemConfig.ixx.

References actionId and MenuItemConfig.

Referenced by actionId.

index()

MenuItemConfig & helios::engine::builder::gameObject::builders::configs::MenuItemConfig::index (const size_t index)
inline

Sets the index position in the parent menu.

Parameters
index

The index position.

Returns

Reference to this config for method chaining.

Definition at line 194 of file MenuItemConfig.ixx.

194 MenuItemConfig& index(const size_t index) {
195
197 ->insert(gameObject_, index);
198
199 if (isSelected_) {
201 ->setSelectedIndex(index);
202 }
203
204 index_ = index;
205
206 return *this;
207 }

References index and MenuItemConfig.

Referenced by index.

normalColor()

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

Sets the normal state color.

Parameters
color

The RGBA color.

Returns

Reference to this config for method chaining.

Definition at line 124 of file MenuItemConfig.ixx.

126 ->setNormalColor(color);
127
128 return *this;
129 }

Reference MenuItemConfig.

normalScale()

MenuItemConfig & helios::engine::builder::gameObject::builders::configs::MenuItemConfig::normalScale (const float scale)
inline

Sets the normal state scale.

Parameters
scale

The scale factor.

Returns

Reference to this config for method chaining.

Definition at line 138 of file MenuItemConfig.ixx.

138 MenuItemConfig& normalScale(const float scale) {
140 ->setNormalScale(scale);
141
142 return *this;
143 }

Reference MenuItemConfig.

selected()

MenuItemConfig & helios::engine::builder::gameObject::builders::configs::MenuItemConfig::selected (const bool isSelected)
inline

Sets the selected state.

Parameters
isSelected

True if this item should be selected.

Returns

Reference to this config for method chaining.

Definition at line 101 of file MenuItemConfig.ixx.

101 MenuItemConfig& selected(const bool isSelected) {
102
103 if (!isSelected_) {
104 return *this;
105
106 }
107 if (index_) {
109 ->setSelectedIndex(index_.value());
110 } else {
111 isSelected_ = isSelected;
112 }
113
114 return *this;
115 }

Reference MenuItemConfig.

selectedColor()

MenuItemConfig & helios::engine::builder::gameObject::builders::configs::MenuItemConfig::selectedColor (helios::math::vec4f color)
inline

Sets the selected state color.

Parameters
color

The RGBA color.

Returns

Reference to this config for method chaining.

Definition at line 152 of file MenuItemConfig.ixx.

154 ->setSelectedColor(color);
155
156 return *this;
157 }

Reference MenuItemConfig.

selectedScale()

MenuItemConfig & helios::engine::builder::gameObject::builders::configs::MenuItemConfig::selectedScale (const float scale)
inline

Sets the selected state scale.

Parameters
scale

The scale factor.

Returns

Reference to this config for method chaining.

Definition at line 166 of file MenuItemConfig.ixx.

166 MenuItemConfig& selectedScale(const float scale) {
168 ->setSelectedScale(scale);
169
170 return *this;
171 }

Reference MenuItemConfig.

Private Member Functions

attach()

void helios::engine::builder::gameObject::builders::configs::MenuItemConfig::attach ()
inline

Attaches this item to the parent menu.

Definition at line 58 of file MenuItemConfig.ixx.

58 void attach() {
59 assert(parentMenu_ != nullptr);
60
62
63 assert(mc != nullptr && "Unexpected nullptr for MenuComponent");
64
65 mc->addMenuItem(gameObject_);
66 }

Private Member Attributes

gameObject_

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

The GameObject being configured.

Definition at line 38 of file MenuItemConfig.ixx.

index_

std::optional<size_t> helios::engine::builder::gameObject::builders::configs::MenuItemConfig::index_ = std::nullopt

Optional index position in the menu.

Definition at line 48 of file MenuItemConfig.ixx.

48 std::optional<size_t> index_ = std::nullopt;

isSelected_

bool helios::engine::builder::gameObject::builders::configs::MenuItemConfig::isSelected_ = false

Whether this item is selected.

Definition at line 53 of file MenuItemConfig.ixx.

53 bool isSelected_ = false;

parentMenu_

helios::engine::ecs::GameObject* helios::engine::builder::gameObject::builders::configs::MenuItemConfig::parentMenu_ = nullptr

Pointer to the parent menu GameObject.

Definition at line 43 of file MenuItemConfig.ixx.

43 helios::engine::ecs::GameObject* parentMenu_ = nullptr;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.