![]() |
R-Type
2
Doom but in better
|
A class that represents a text component in the GUI system. It manages font, size, color, and position of text entities in a graphical application. More...
#include <TextComponent.hpp>
Public Member Functions | |
TextComponent () | |
Default constructor. Initializes the text component with default values. | |
TextComponent (const std::uint32_t entityId) | |
Constructor with an entity ID. | |
TextComponent (const std::uint32_t entityId, const std::string &fontPath) | |
Constructor with an entity ID and a font path. | |
TextComponent (const std::uint32_t entityId, const std::string &fontPath, const std::string &text) | |
Constructor with an entity ID, a font path, and text content. | |
TextComponent (const std::uint32_t entityId, const std::string &fontPath, const std::string &text, const unsigned int &size) | |
Constructor with an entity ID, font path, text content, and font size. | |
TextComponent (const std::uint32_t entityId, const std::string &fontPath, const std::string &text, const unsigned int &size, const GUI::ECS::Systems::Colour &normalColor, const GUI::ECS::Systems::Colour &hoverColor, const GUI::ECS::Systems::Colour &clickedColor) | |
Constructor with detailed parameters. | |
TextComponent (const std::uint32_t entityId, const std::string &fontPath, const std::string &text, const unsigned int &size, const GUI::ECS::Systems::Colour &normalColor, const GUI::ECS::Systems::Colour &hoverColor, const GUI::ECS::Systems::Colour &clickedColor, const std::pair< float, float > &position) | |
Constructor with full parameter specification. | |
TextComponent (const std::uint32_t entityId, const GUI::ECS::Systems::Font &fontInstance) | |
Constructor with a font instance. | |
TextComponent (const std::uint32_t entityId, const GUI::ECS::Systems::Font &fontInstance, const std::string &text) | |
Constructor with a font instance and text content. | |
TextComponent (const std::uint32_t entityId, const GUI::ECS::Systems::Font &fontInstance, const std::string &text, const unsigned int &size) | |
Constructor with a font instance, text content, and font size. | |
TextComponent (const std::uint32_t entityId, const GUI::ECS::Systems::Font &fontInstance, const std::string &text, const unsigned int &size, const GUI::ECS::Systems::Colour &normalColor, const GUI::ECS::Systems::Colour &hoverColor, const GUI::ECS::Systems::Colour &clickedColor) | |
Constructor with detailed parameters and a font instance. | |
TextComponent (const std::uint32_t entityId, const GUI::ECS::Systems::Font &fontInstance, const std::string &text, const unsigned int &size, const GUI::ECS::Systems::Colour &normalColor, const GUI::ECS::Systems::Colour &hoverColor, const GUI::ECS::Systems::Colour &clickedColor, const std::pair< float, float > &position) | |
Constructor with detailed parameters and a font instance, including position. | |
~TextComponent () | |
Destructor for TextComponent. | |
void | setFont (const GUI::ECS::Systems::Font &font) |
Set the Font of the text using a loaded Font instance from GUI::ECS::Systems::Font. | |
void | setNormalColor (const GUI::ECS::Systems::Colour &color) |
Set the default colour of the text object. | |
void | setHoverColor (const GUI::ECS::Systems::Colour &color) |
Set the Hover Color of the text object. | |
void | setClickedColor (const GUI::ECS::Systems::Colour &color) |
Set the Clicked Color of the text object. | |
void | setText (const std::string &text) |
Set the Text. | |
void | setSize (const std::uint32_t &size) |
Set the Size of the text. | |
void | setFontPath (const std::string &fontPath, const std::string &name="") |
Set the font from a path (this will attempt to load the font internally) | |
void | setPosition (const std::pair< float, float > &position) |
Set the Position of the text. | |
void | setVisible (const bool visible) |
Set the visibility of the object using a boolean. | |
void | setName (const std::string &name) |
Set the Name of the component. | |
void | setApplication (const std::string &application) |
Set the application context of the component. | |
void | toggleVisibility () |
Toggle the visibility of the object. hidden. | |
const bool | isVisible () const |
Check if the text is set to be rendered or not. | |
const GUI::ECS::Systems::Font | getFont () const |
Get the Font object contained in the class. | |
const std::string | getFontPath () const |
Get the Font Path object. | |
const GUI::ECS::Systems::Colour | getNormalColor () const |
Get the Normal Color of the text. | |
const GUI::ECS::Systems::Colour | getHoverColor () const |
Get the Hover Color of the text. | |
const GUI::ECS::Systems::Colour | getClickedColor () const |
Get the Clicked Color of the text. | |
const std::string | getText () const |
Get the Text that was set in the class. | |
const std::uint32_t | getSize () const |
Get the Size of the text. | |
const std::pair< float, float > | getPosition () const |
Get the Position of the text. | |
const bool | getVisible () const |
Get the Visibility of the text. | |
const std::string | getInfo (const unsigned int indent=0) const |
This is a function meant for debugging purposes It will dump the current state of the variables upon call. It will dump them for itself and any of it's underlying classes. | |
const GUI::ECS::Systems::Collision | getCollision () const |
Function in charge of returning the collision instance of the text component. | |
const std::string | getName () const |
Get the Name text component. | |
const std::string | getApplication () const |
Get the Application context of the component. | |
std::any | render () const |
Function in charge of rendering the text if it is set to visible, otherwise, does nothing. | |
void | update (const GUI::ECS::Systems::MouseInfo &mouse) |
The function in charge of updating the stored mouse information. | |
void | update (const GUI::ECS::Components::TextComponent ©) |
The function in charge of updating the current text component using another text component instance. | |
GUI::ECS::Components::TextComponent & | operator= (const GUI::ECS::Components::TextComponent ©) |
The overload in charge of allowing a TextComponent update using the '=' sign. | |
![]() | |
EntityNode (const size_t entityId=0) | |
virtual | ~EntityNode ()=default |
virtual size_t | getEntityNodeId () const |
Additional Inherited Members | |
![]() | |
size_t | _entityID |
A class that represents a text component in the GUI system. It manages font, size, color, and position of text entities in a graphical application.
This class is derived from the EntityNode class and is a part of the ECS system. It includes various constructors for initializing a text component with different configurations.
GUI::ECS::Components::TextComponent::TextComponent | ( | ) |
Default constructor. Initializes the text component with default values.
Definition at line 16 of file TextComponent.cpp.
GUI::ECS::Components::TextComponent::TextComponent | ( | const std::uint32_t | entityId | ) |
Constructor with an entity ID.
entityId | The ID of the entity this component is associated with. |
Definition at line 26 of file TextComponent.cpp.
GUI::ECS::Components::TextComponent::TextComponent | ( | const std::uint32_t | entityId, |
const std::string & | fontPath ) |
Constructor with an entity ID and a font path.
entityId | The ID of the entity this component is associated with. |
fontPath | Path to the font file. |
Definition at line 36 of file TextComponent.cpp.
GUI::ECS::Components::TextComponent::TextComponent | ( | const std::uint32_t | entityId, |
const std::string & | fontPath, | ||
const std::string & | text ) |
Constructor with an entity ID, a font path, and text content.
entityId | The ID of the entity this component is associated with. |
fontPath | Path to the font file. |
text | The text to be displayed. |
Definition at line 50 of file TextComponent.cpp.
GUI::ECS::Components::TextComponent::TextComponent | ( | const std::uint32_t | entityId, |
const std::string & | fontPath, | ||
const std::string & | text, | ||
const unsigned int & | size ) |
Constructor with an entity ID, font path, text content, and font size.
entityId | The ID of the entity this component is associated with. |
fontPath | Path to the font file. |
text | The text to be displayed. |
size | The size of the font. |
Definition at line 65 of file TextComponent.cpp.
GUI::ECS::Components::TextComponent::TextComponent | ( | const std::uint32_t | entityId, |
const std::string & | fontPath, | ||
const std::string & | text, | ||
const unsigned int & | size, | ||
const GUI::ECS::Systems::Colour & | normalColor, | ||
const GUI::ECS::Systems::Colour & | hoverColor, | ||
const GUI::ECS::Systems::Colour & | clickedColor ) |
Constructor with detailed parameters.
entityId | The ID of the entity this component is associated with. |
fontPath | Path to the font file. |
text | The text to be displayed. |
size | The size of the font. |
normalColor | The normal color of the text. |
hoverColor | The color of the text when hovered. |
clickedColor | The color of the text when clicked. |
Definition at line 81 of file TextComponent.cpp.
GUI::ECS::Components::TextComponent::TextComponent | ( | const std::uint32_t | entityId, |
const std::string & | fontPath, | ||
const std::string & | text, | ||
const unsigned int & | size, | ||
const GUI::ECS::Systems::Colour & | normalColor, | ||
const GUI::ECS::Systems::Colour & | hoverColor, | ||
const GUI::ECS::Systems::Colour & | clickedColor, | ||
const std::pair< float, float > & | position ) |
Constructor with full parameter specification.
entityId | The ID of the entity this component is associated with. |
fontPath | Path to the font file. |
text | The text to be displayed. |
size | The size of the font. |
normalColor | The normal color of the text. |
hoverColor | The color of the text when hovered. |
clickedColor | The color of the text when clicked. |
position | The position of the text in 2D space. |
Definition at line 100 of file TextComponent.cpp.
GUI::ECS::Components::TextComponent::TextComponent | ( | const std::uint32_t | entityId, |
const GUI::ECS::Systems::Font & | fontInstance ) |
Constructor with a font instance.
entityId | The ID of the entity this component is associated with. |
fontInstance | An instance of the font. |
Definition at line 120 of file TextComponent.cpp.
GUI::ECS::Components::TextComponent::TextComponent | ( | const std::uint32_t | entityId, |
const GUI::ECS::Systems::Font & | fontInstance, | ||
const std::string & | text ) |
Constructor with a font instance and text content.
entityId | The ID of the entity this component is associated with. |
fontInstance | An instance of the font. |
text | The text to be displayed. |
Definition at line 134 of file TextComponent.cpp.
GUI::ECS::Components::TextComponent::TextComponent | ( | const std::uint32_t | entityId, |
const GUI::ECS::Systems::Font & | fontInstance, | ||
const std::string & | text, | ||
const unsigned int & | size ) |
Constructor with a font instance, text content, and font size.
entityId | The ID of the entity this component is associated with. |
fontInstance | An instance of the font. |
text | The text to be displayed. |
size | The size of the font. |
Definition at line 149 of file TextComponent.cpp.
GUI::ECS::Components::TextComponent::TextComponent | ( | const std::uint32_t | entityId, |
const GUI::ECS::Systems::Font & | fontInstance, | ||
const std::string & | text, | ||
const unsigned int & | size, | ||
const GUI::ECS::Systems::Colour & | normalColor, | ||
const GUI::ECS::Systems::Colour & | hoverColor, | ||
const GUI::ECS::Systems::Colour & | clickedColor ) |
Constructor with detailed parameters and a font instance.
entityId | The ID of the entity this component is associated with. |
fontInstance | An instance of the font. |
text | The text to be displayed. |
size | The size of the font. |
normalColor | The normal color of the text. |
hoverColor | The color of the text when hovered. |
clickedColor | The color of the text when clicked. |
Definition at line 165 of file TextComponent.cpp.
GUI::ECS::Components::TextComponent::TextComponent | ( | const std::uint32_t | entityId, |
const GUI::ECS::Systems::Font & | fontInstance, | ||
const std::string & | text, | ||
const unsigned int & | size, | ||
const GUI::ECS::Systems::Colour & | normalColor, | ||
const GUI::ECS::Systems::Colour & | hoverColor, | ||
const GUI::ECS::Systems::Colour & | clickedColor, | ||
const std::pair< float, float > & | position ) |
Constructor with detailed parameters and a font instance, including position.
entityId | The ID of the entity this component is associated with. |
fontInstance | An instance of the font. |
text | The text to be displayed. |
size | The size of the font. |
normalColor | The normal color of the text. |
hoverColor | The color of the text when hovered. |
clickedColor | The color of the text when clicked. |
position | The position of the text in 2D space. |
Definition at line 184 of file TextComponent.cpp.
GUI::ECS::Components::TextComponent::~TextComponent | ( | ) |
Destructor for TextComponent.
Definition at line 205 of file TextComponent.cpp.
const std::string GUI::ECS::Components::TextComponent::getApplication | ( | ) | const |
Get the Application context of the component.
Definition at line 419 of file TextComponent.cpp.
const GUI::ECS::Systems::Colour GUI::ECS::Components::TextComponent::getClickedColor | ( | ) | const |
Get the Clicked Color of the text.
Definition at line 347 of file TextComponent.cpp.
const GUI::ECS::Systems::Collision GUI::ECS::Components::TextComponent::getCollision | ( | ) | const |
Function in charge of returning the collision instance of the text component.
Definition at line 409 of file TextComponent.cpp.
const GUI::ECS::Systems::Font GUI::ECS::Components::TextComponent::getFont | ( | ) | const |
Get the Font object contained in the class.
Definition at line 327 of file TextComponent.cpp.
const std::string GUI::ECS::Components::TextComponent::getFontPath | ( | ) | const |
Get the Font Path object.
Definition at line 332 of file TextComponent.cpp.
const GUI::ECS::Systems::Colour GUI::ECS::Components::TextComponent::getHoverColor | ( | ) | const |
Get the Hover Color of the text.
Definition at line 342 of file TextComponent.cpp.
const std::string GUI::ECS::Components::TextComponent::getInfo | ( | const unsigned int | indent = 0 | ) | const |
This is a function meant for debugging purposes It will dump the current state of the variables upon call. It will dump them for itself and any of it's underlying classes.
indent | The level to which the class should be indented in the dump. |
Definition at line 373 of file TextComponent.cpp.
const std::string GUI::ECS::Components::TextComponent::getName | ( | ) | const |
Get the Name text component.
Definition at line 414 of file TextComponent.cpp.
const GUI::ECS::Systems::Colour GUI::ECS::Components::TextComponent::getNormalColor | ( | ) | const |
Get the Normal Color of the text.
Definition at line 337 of file TextComponent.cpp.
const std::pair< float, float > GUI::ECS::Components::TextComponent::getPosition | ( | ) | const |
Get the Position of the text.
Definition at line 362 of file TextComponent.cpp.
const std::uint32_t GUI::ECS::Components::TextComponent::getSize | ( | ) | const |
Get the Size of the text.
Definition at line 357 of file TextComponent.cpp.
const std::string GUI::ECS::Components::TextComponent::getText | ( | ) | const |
Get the Text that was set in the class.
Definition at line 352 of file TextComponent.cpp.
const bool GUI::ECS::Components::TextComponent::getVisible | ( | ) | const |
Get the Visibility of the text.
Definition at line 367 of file TextComponent.cpp.
const bool GUI::ECS::Components::TextComponent::isVisible | ( | ) | const |
Check if the text is set to be rendered or not.
Definition at line 322 of file TextComponent.cpp.
GUI::ECS::Components::TextComponent & GUI::ECS::Components::TextComponent::operator= | ( | const GUI::ECS::Components::TextComponent & | copy | ) |
The overload in charge of allowing a TextComponent update using the '=' sign.
copy | The TextComponent to copy the data from. |
Definition at line 638 of file TextComponent.cpp.
std::any GUI::ECS::Components::TextComponent::render | ( | ) | const |
Function in charge of rendering the text if it is set to visible, otherwise, does nothing.
Definition at line 400 of file TextComponent.cpp.
void GUI::ECS::Components::TextComponent::setApplication | ( | const std::string & | application | ) |
Set the application context of the component.
application |
Definition at line 308 of file TextComponent.cpp.
void GUI::ECS::Components::TextComponent::setClickedColor | ( | const GUI::ECS::Systems::Colour & | color | ) |
Set the Clicked Color of the text object.
color | The clicked colour of the text |
Definition at line 258 of file TextComponent.cpp.
void GUI::ECS::Components::TextComponent::setFont | ( | const GUI::ECS::Systems::Font & | font | ) |
Set the Font of the text using a loaded Font instance from GUI::ECS::Systems::Font.
font |
Definition at line 207 of file TextComponent.cpp.
void GUI::ECS::Components::TextComponent::setFontPath | ( | const std::string & | fontPath, |
const std::string & | name = "" ) |
Set the font from a path (this will attempt to load the font internally)
fontPath | The font path to be loaded. |
name | The name of the font |
CustomExceptions::InvalidFontPath | if the font path provided is incorrect |
Definition at line 268 of file TextComponent.cpp.
void GUI::ECS::Components::TextComponent::setHoverColor | ( | const GUI::ECS::Systems::Colour & | color | ) |
Set the Hover Color of the text object.
color | The hover colour of the text |
Definition at line 248 of file TextComponent.cpp.
void GUI::ECS::Components::TextComponent::setName | ( | const std::string & | name | ) |
void GUI::ECS::Components::TextComponent::setNormalColor | ( | const GUI::ECS::Systems::Colour & | color | ) |
Set the default colour of the text object.
color | The default colour for the text |
Definition at line 238 of file TextComponent.cpp.
void GUI::ECS::Components::TextComponent::setPosition | ( | const std::pair< float, float > & | position | ) |
Set the Position of the text.
position | The position to be set. |
Definition at line 287 of file TextComponent.cpp.
void GUI::ECS::Components::TextComponent::setSize | ( | const std::uint32_t & | size | ) |
Set the Size of the text.
size | The size of the text (in pixels) |
Definition at line 227 of file TextComponent.cpp.
void GUI::ECS::Components::TextComponent::setText | ( | const std::string & | text | ) |
Set the Text.
text | The text to be displayed |
Definition at line 216 of file TextComponent.cpp.
void GUI::ECS::Components::TextComponent::setVisible | ( | const bool | visible | ) |
Set the visibility of the object using a boolean.
visible | The boolean value |
Definition at line 298 of file TextComponent.cpp.
void GUI::ECS::Components::TextComponent::toggleVisibility | ( | ) |
Toggle the visibility of the object. hidden.
Definition at line 313 of file TextComponent.cpp.
void GUI::ECS::Components::TextComponent::update | ( | const GUI::ECS::Components::TextComponent & | copy | ) |
The function in charge of updating the current text component using another text component instance.
copy | A TextComponent instance |
Definition at line 432 of file TextComponent.cpp.
void GUI::ECS::Components::TextComponent::update | ( | const GUI::ECS::Systems::MouseInfo & | mouse | ) |
The function in charge of updating the stored mouse information.
mouse | A mouse instance |
Definition at line 424 of file TextComponent.cpp.