|
Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
|
Factory class for creating UI components in the ECS registry. More...
#include <UiFactory.hpp>
Public Member Functions | |
| UiFactory ()=default | |
| ~UiFactory ()=default | |
Static Public Member Functions | |
| static ecs::Entity | createButton (ecs::Registry ®istry, const position &position, const size &size, const std::string &label, std::function< void()> onClick=nullptr) |
| Create a button UI component. | |
| static ecs::Entity | createText (ecs::Registry ®istry, const position &position, const std::string &content, const std::string &fontPath, unsigned int fontSize, const std::uint8_t zIndex=0, const color &textColor={255, 255, 255}) |
| static ecs::Entity | createSlider (ecs::Registry ®istry, const position &position, const size &size, float minValue, float maxValue, float initialValue, std::function< void(float)> onChange=nullptr) |
| static ecs::Entity | createDropdown (ecs::Registry ®istry, const position &position, const size &size, const std::vector< std::string > &options, const int selectedIndex, std::function< void(int index)> onSelect=nullptr) |
| static ecs::Entity | createTextInput (ecs::Registry ®istry, const position &position, const size &size, const std::string &fontPath, unsigned int fontSize, const int maxLength=64, const std::string &placeholder="", std::function< void(const std::string &)> onSubmit=nullptr, std::function< void(const std::string &)> onChange=nullptr) |
| static ecs::Entity | createSpritePreview (ecs::Registry ®istry, const position &position, const std::string &texturePath, int rectLeft, int rectTop, int rectWidth, int rectHeight, float scale=2.0f, int zIndex=0) |
| Create a sprite preview UI component. | |
Factory class for creating UI components in the ECS registry.
This class provides static methods to create various UI elements
Definition at line 72 of file UiFactory.hpp.
|
default |
|
default |
|
static |
Create a button UI component.
| registry | Reference to the ECS registry. |
| x | X position of the button. |
| y | Y position of the button. |
| width | Width of the button. |
| height | Height of the button. |
| label | Text label of the button. |
| onClick | Callback function to be called when the button is clicked. |
Definition at line 17 of file UiFactory.cpp.
References rtp::ecs::Registry::add(), rtp::log::error(), rtp::client::graphics::size::height, rtp::ecs::components::ui::Button::onClick, rtp::ecs::components::ui::Button::position, rtp::ecs::components::ui::Button::size, rtp::ecs::Registry::spawn(), rtp::ecs::components::ui::Button::text, rtp::client::graphics::size::width, rtp::client::graphics::position::x, and rtp::client::graphics::position::y.
Referenced by rtp::client::scenes::LobbyScene::buildUi(), rtp::client::scenes::GamepadSettingsScene::onEnter(), rtp::client::scenes::SettingsScene::onEnter(), rtp::client::scenes::CreateRoomScene::onEnter(), rtp::client::scenes::GameOverScene::onEnter(), rtp::client::scenes::KeyBindingScene::onEnter(), rtp::client::scenes::LoginScene::onEnter(), rtp::client::scenes::MenuScene::onEnter(), rtp::client::scenes::PauseScene::onEnter(), rtp::client::scenes::PlayingScene::onEnter(), rtp::client::scenes::RoomWaitingScene::onEnter(), rtp::client::scenes::PlayingScene::openChat(), rtp::client::scenes::RoomWaitingScene::openChat(), rtp::client::scenes::ModMenuScene::showCategoryList(), and rtp::client::scenes::ModMenuScene::showEntityCodex().
|
static |
@brief Create a dropdown UI component.
* @param registry Reference to the ECS registry.
| x | X position of the dropdown. |
| y | Y position of the dropdown. |
| width | Width of the dropdown. |
| height | Height of the dropdown. |
| options | List of options for the dropdown. |
| selectedIndex | Index of the initially selected option. |
| onSelect | Callback function to be called when an option is selected. |
Definition at line 106 of file UiFactory.cpp.
References rtp::ecs::Registry::add(), rtp::log::error(), rtp::client::graphics::size::height, rtp::ecs::components::ui::Dropdown::onSelect, rtp::ecs::components::ui::Dropdown::options, rtp::ecs::components::ui::Dropdown::position, rtp::ecs::components::ui::Dropdown::selectedIndex, rtp::ecs::components::ui::Dropdown::size, rtp::ecs::Registry::spawn(), rtp::log::warning(), rtp::client::graphics::size::width, rtp::client::graphics::position::x, and rtp::client::graphics::position::y.
Referenced by rtp::client::scenes::GamepadSettingsScene::onEnter(), rtp::client::scenes::SettingsScene::onEnter(), and rtp::client::scenes::CreateRoomScene::onEnter().
|
static |
@brief Create a slider UI component.
* @param registry Reference to the ECS registry.
| x | X position of the slider. |
| y | Y position of the slider. |
| width | Width of the slider. |
| height | Height of the slider. |
| minValue | Minimum value of the slider. |
| maxValue | Maximum value of the slider. |
| initialValue | Initial value of the slider. |
| onChange | Callback function to be called when the slider value changes. |
Definition at line 75 of file UiFactory.cpp.
References rtp::ecs::Registry::add(), rtp::ecs::components::ui::Slider::currentValue, rtp::log::error(), rtp::client::graphics::size::height, rtp::ecs::components::ui::Slider::maxValue, rtp::ecs::components::ui::Slider::minValue, rtp::ecs::components::ui::Slider::onChange, rtp::ecs::components::ui::Slider::position, rtp::ecs::components::ui::Slider::size, rtp::ecs::Registry::spawn(), rtp::client::graphics::size::width, rtp::client::graphics::position::x, and rtp::client::graphics::position::y.
Referenced by rtp::client::scenes::GamepadSettingsScene::onEnter(), rtp::client::scenes::SettingsScene::onEnter(), rtp::client::scenes::CreateRoomScene::onEnter(), and rtp::client::scenes::PlayingScene::onEnter().
|
static |
Create a sprite preview UI component.
| registry | Reference to the ECS registry. |
| position | Position of the sprite preview. |
| texturePath | Path to the texture file. |
| rectLeft | Left coordinate in the texture. |
| rectTop | Top coordinate in the texture. |
| rectWidth | Width of the sprite in the texture. |
| rectHeight | Height of the sprite in the texture. |
| scale | Scale factor for display. |
| zIndex | Z-index for rendering order. |
Definition at line 177 of file UiFactory.cpp.
References rtp::ecs::Registry::add(), rtp::log::error(), rtp::ecs::components::ui::SpritePreview::rectHeight, rtp::ecs::components::ui::SpritePreview::rectLeft, rtp::ecs::components::ui::SpritePreview::rectTop, rtp::ecs::components::ui::SpritePreview::rectWidth, rtp::ecs::components::ui::SpritePreview::scale, rtp::ecs::Registry::spawn(), rtp::ecs::components::ui::SpritePreview::texturePath, rtp::client::graphics::position::x, rtp::ecs::components::ui::SpritePreview::x, rtp::client::graphics::position::y, rtp::ecs::components::ui::SpritePreview::y, and rtp::ecs::components::ui::SpritePreview::zIndex.
Referenced by rtp::client::scenes::ModMenuScene::showEntityCodex().
|
static |
@brief Create a text UI component.
* @param registry Reference to the ECS registry.
| x | X position of the text. |
| y | Y position of the text. |
| content | Text content. |
| fontPath | Path to the font file. |
| fontSize | Size of the font. |
| zIndex | Z-index for rendering order. |
| textColor | Color of the text. |
Definition at line 43 of file UiFactory.cpp.
References rtp::ecs::Registry::add(), rtp::client::graphics::color::b, rtp::ecs::components::ui::Text::blue, rtp::ecs::components::ui::Text::content, rtp::log::error(), rtp::ecs::components::ui::Text::fontPath, rtp::ecs::components::ui::Text::fontSize, rtp::client::graphics::color::g, rtp::ecs::components::ui::Text::green, rtp::ecs::components::ui::Text::position, rtp::client::graphics::color::r, rtp::ecs::components::ui::Text::red, rtp::ecs::Registry::spawn(), rtp::client::graphics::position::x, rtp::client::graphics::position::y, and rtp::ecs::components::ui::Text::zIndex.
Referenced by rtp::client::scenes::LobbyScene::buildUi(), rtp::client::scenes::GamepadSettingsScene::onEnter(), rtp::client::scenes::SettingsScene::onEnter(), rtp::client::scenes::CreateRoomScene::onEnter(), rtp::client::scenes::GameOverScene::onEnter(), rtp::client::scenes::KeyBindingScene::onEnter(), rtp::client::scenes::LoginScene::onEnter(), rtp::client::scenes::MenuScene::onEnter(), rtp::client::scenes::PauseScene::onEnter(), rtp::client::scenes::PlayingScene::onEnter(), rtp::client::scenes::RoomWaitingScene::onEnter(), rtp::client::scenes::PlayingScene::openChat(), rtp::client::scenes::RoomWaitingScene::openChat(), rtp::client::scenes::ModMenuScene::showCategoryList(), and rtp::client::scenes::ModMenuScene::showEntityCodex().
|
static |
@brief Create a text input UI component.
* @param registry Reference to the ECS registry.
| x | X position of the text input. |
| y | Y position of the text input. |
| width | Width of the text input. |
| height | Height of the text input. |
| fontPath | Path to the font file. |
| fontSize | Size of the font. |
| maxLength | Maximum length of the input text. |
| placeholder | Placeholder text when input is empty. |
| onChange | Callback function to be called when the text changes. |
Definition at line 142 of file UiFactory.cpp.
References rtp::ecs::Registry::add(), rtp::log::error(), rtp::ecs::components::ui::TextInput::fontPath, rtp::ecs::components::ui::TextInput::fontSize, rtp::client::graphics::size::height, rtp::ecs::components::ui::TextInput::maxLength, rtp::ecs::components::ui::TextInput::onChange, rtp::ecs::components::ui::TextInput::onSubmit, rtp::ecs::components::ui::TextInput::placeholder, rtp::ecs::components::ui::TextInput::position, rtp::ecs::components::ui::TextInput::size, rtp::ecs::Registry::spawn(), rtp::client::graphics::size::width, rtp::client::graphics::position::x, and rtp::client::graphics::position::y.
Referenced by rtp::client::scenes::CreateRoomScene::onEnter(), rtp::client::scenes::LoginScene::onEnter(), rtp::client::scenes::PlayingScene::openChat(), and rtp::client::scenes::RoomWaitingScene::openChat().