R-Type  2
Doom but in better
Loading...
Searching...
No Matches
GUI::ECS::Components::ImageComponent Class Reference

Represents an image component in the GUI ECS system. More...

#include <ImageComponent.hpp>

Inheritance diagram for GUI::ECS::Components::ImageComponent:
Inheritance graph
Collaboration diagram for GUI::ECS::Components::ImageComponent:
Collaboration graph

Public Member Functions

 ImageComponent ()
 Default constructor. Initializes the ImageComponent with default values.
 
 ImageComponent (const std::uint32_t entityId)
 Constructor with an entity ID.
 
 ImageComponent (const std::uint32_t entityId, const GUI::ECS::Components::TextureComponent &imageTexture, const std::string &name="", const std::string &application="")
 Constructor with an entity ID and an image path.
 
 ImageComponent (const std::uint32_t entityId, const GUI::ECS::Components::TextureComponent &imageTexture, std::pair< unsigned int, unsigned int > dimensions, const std::string &name="", const std::string &application="")
 Constructor with an entity ID, font path, text content, and font size.
 
 ImageComponent (const std::uint32_t entityId, const GUI::ECS::Components::TextureComponent &imageTexture, std::pair< unsigned int, unsigned int > dimensions, const GUI::ECS::Systems::Colour &normalColor, const GUI::ECS::Systems::Colour &hoverColor=GUI::ECS::Systems::Colour::White, const GUI::ECS::Systems::Colour &clickedColor=GUI::ECS::Systems::Colour::White, const std::string &name="", const std::string &application="")
 Constructor with detailed parameters.
 
 ImageComponent (const std::uint32_t entityId, const GUI::ECS::Components::TextureComponent &imageTexture, std::pair< unsigned int, unsigned int > dimensions, const std::pair< float, float > &position, const GUI::ECS::Systems::Colour &normalColor=GUI::ECS::Systems::Colour::White, const GUI::ECS::Systems::Colour &hoverColor=GUI::ECS::Systems::Colour::White, const GUI::ECS::Systems::Colour &clickedColor=GUI::ECS::Systems::Colour::White, const std::string &name="", const std::string &application="")
 Constructor with full parameter specification.
 
 ImageComponent (const std::uint32_t entityId, const std::string &imagePath, const std::string &name="", const std::string &application="")
 Constructor with an entity ID and an image path.
 
 ImageComponent (const std::uint32_t entityId, const std::string &imagePath, std::pair< unsigned int, unsigned int > dimensions, const std::string &name="", const std::string &application="")
 Constructor with an entity ID, font path, text content, and font size.
 
 ImageComponent (const std::uint32_t entityId, const std::string &imagePath, std::pair< unsigned int, unsigned int > dimensions, const GUI::ECS::Systems::Colour &normalColor, const GUI::ECS::Systems::Colour &hoverColor=GUI::ECS::Systems::Colour::White, const GUI::ECS::Systems::Colour &clickedColor=GUI::ECS::Systems::Colour::White, const std::string &name="", const std::string &application="")
 Constructor with detailed parameters.
 
 ImageComponent (const std::uint32_t entityId, const std::string &imagePath, std::pair< unsigned int, unsigned int > dimensions, const std::pair< float, float > &position, const GUI::ECS::Systems::Colour &normalColor=GUI::ECS::Systems::Colour::White, const GUI::ECS::Systems::Colour &hoverColor=GUI::ECS::Systems::Colour::White, const GUI::ECS::Systems::Colour &clickedColor=GUI::ECS::Systems::Colour::White, const std::string &name="", const std::string &application="")
 Constructor with full parameter specification.
 
 ~ImageComponent ()
 Destructor for ImageComponent.
 
void setName (const std::string &name)
 Set the Name of the image.
 
void setApplication (const std::string &application)
 Set the Application (the context) of the image.
 
void setNormalColor (const GUI::ECS::Systems::Colour &color)
 Sets the normal color of the image.
 
void setHoverColor (const GUI::ECS::Systems::Colour &color)
 Sets the hover color of the image.
 
void setClickedColor (const GUI::ECS::Systems::Colour &color)
 Sets the clicked color of the image.
 
void setImage (const GUI::ECS::Components::TextureComponent &image, const std::string &name="")
 Assigns a texture to the image component.
 
void setImage (const std::string &path, const std::string &name="")
 Loads and assigns an image from a file path.
 
void setDimension (const std::pair< float, float > &dimension)
 Sets the dimensions of the image.
 
void setPosition (const std::pair< int, int > &position)
 Sets the position of the image.
 
void setVisible (const bool visible)
 Set the visibility of the object using a boolean.
 
void setLevelBackgroundCompatible (const bool levelBackground)
 Set the Level Background Compatible variable.
 
void toggleVisibility ()
 Toggles the visibility of the image.
 
const bool isVisible () const
 Get the visibility state of the Image.
 
const bool isLevelBackgroundCompatible () const
 Know if the background can be used as a level bacground.
 
const std::string getName () const
 Get the Name of the image.
 
const std::string getApplication () const
 Get the Application of the image.
 
const GUI::ECS::Components::TextureComponent getImage () const
 Retrieves the texture associated with the image.
 
const GUI::ECS::Systems::Colour getNormalColor () const
 Retrieves the normal color of the image.
 
const GUI::ECS::Systems::Colour getHoverColor () const
 Retrieves the hover color of the image.
 
const GUI::ECS::Systems::Colour getClickedColor () const
 Retrieves the clicked color of the image.
 
const std::pair< float, float > getDimension () const
 Get the Size of the text.
 
const std::pair< int, int > getPosition () const
 Get the Position of the image.
 
const bool getVisible () const
 Get the Visibility of the text.
 
const GUI::ECS::Systems::Collision getCollision () const
 Get the Collision object.
 
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 bool getLevelBackgroundCompatibility () const
 Get the Level Background Compatibility object.
 
std::any render () const
 Renders the image to the given window.
 
void update (const GUI::ECS::Systems::MouseInfo &mouse)
 Updates the image based on mouse interactions.
 
void update (const GUI::ECS::Components::ImageComponent &copy)
 Updates this ImageComponent with values from another instance.
 
GUI::ECS::Components::ImageComponentoperator= (const GUI::ECS::Components::ImageComponent &copy)
 Assigns values from another ImageComponent.
 
- Public Member Functions inherited from GUI::ECS::EntityNode
 EntityNode (const size_t entityId=0)
 
virtual ~EntityNode ()=default
 
virtual size_t getEntityNodeId () const
 

Additional Inherited Members

- Protected Attributes inherited from GUI::ECS::EntityNode
size_t _entityID
 

Detailed Description

Represents an image component in the GUI ECS system.

This component manages textures, colors, dimensions, and positioning for rendering images within the ECS framework.

Definition at line 43 of file ImageComponent.hpp.

Constructor & Destructor Documentation

◆ ImageComponent() [1/10]

GUI::ECS::Components::ImageComponent::ImageComponent ( )

Default constructor. Initializes the ImageComponent with default values.

Definition at line 16 of file ImageComponent.cpp.

◆ ImageComponent() [2/10]

GUI::ECS::Components::ImageComponent::ImageComponent ( const std::uint32_t entityId)

Constructor with an entity ID.

Parameters
entityIdThe ID of the associated entity.

Definition at line 22 of file ImageComponent.cpp.

◆ ImageComponent() [3/10]

GUI::ECS::Components::ImageComponent::ImageComponent ( const std::uint32_t entityId,
const GUI::ECS::Components::TextureComponent & imageTexture,
const std::string & name = "",
const std::string & application = "" )

Constructor with an entity ID and an image path.

Parameters
entityIdThe ID of the associated entity.
imageTextureThe texture for the image
nameThe name of the image
applicationThe application (context) of the image

Definition at line 28 of file ImageComponent.cpp.

◆ ImageComponent() [4/10]

GUI::ECS::Components::ImageComponent::ImageComponent ( const std::uint32_t entityId,
const GUI::ECS::Components::TextureComponent & imageTexture,
std::pair< unsigned int, unsigned int > dimensions,
const std::string & name = "",
const std::string & application = "" )

Constructor with an entity ID, font path, text content, and font size.

Parameters
entityIdThe ID of the entity this component is associated with.
imageTextureThe texture for the image
dimensionThe dimension of the image.
nameThe name of the image
applicationThe application (context) of the image

Definition at line 39 of file ImageComponent.cpp.

◆ ImageComponent() [5/10]

GUI::ECS::Components::ImageComponent::ImageComponent ( const std::uint32_t entityId,
const GUI::ECS::Components::TextureComponent & imageTexture,
std::pair< unsigned int, unsigned int > dimensions,
const GUI::ECS::Systems::Colour & normalColor,
const GUI::ECS::Systems::Colour & hoverColor = GUI::ECS::Systems::Colour::White,
const GUI::ECS::Systems::Colour & clickedColor = GUI::ECS::Systems::Colour::White,
const std::string & name = "",
const std::string & application = "" )

Constructor with detailed parameters.

Parameters
entityIdThe ID of the entity this component is associated with.
imageTextureThe texture for the image
dimensionThe dimension of the image.
normalColorThe normal color of the text.
hoverColorThe color of the text when hovered.
clickedColorThe color of the text when clicked.
nameThe name of the image
applicationThe application (context) of the image

Definition at line 51 of file ImageComponent.cpp.

◆ ImageComponent() [6/10]

GUI::ECS::Components::ImageComponent::ImageComponent ( const std::uint32_t entityId,
const GUI::ECS::Components::TextureComponent & imageTexture,
std::pair< unsigned int, unsigned int > dimensions,
const std::pair< float, float > & position,
const GUI::ECS::Systems::Colour & normalColor = GUI::ECS::Systems::Colour::White,
const GUI::ECS::Systems::Colour & hoverColor = GUI::ECS::Systems::Colour::White,
const GUI::ECS::Systems::Colour & clickedColor = GUI::ECS::Systems::Colour::White,
const std::string & name = "",
const std::string & application = "" )

Constructor with full parameter specification.

Parameters
entityIdThe ID of the entity this component is associated with.
imageTextureThe texture for the image
dimensionThe dimension of the image.
positionThe position of the text in 2D space.
normalColorThe normal color of the text.
hoverColorThe color of the text when hovered.
clickedColorThe color of the text when clicked.
nameThe name of the image
applicationThe application (context) of the image

Definition at line 66 of file ImageComponent.cpp.

◆ ImageComponent() [7/10]

GUI::ECS::Components::ImageComponent::ImageComponent ( const std::uint32_t entityId,
const std::string & imagePath,
const std::string & name = "",
const std::string & application = "" )

Constructor with an entity ID and an image path.

Parameters
entityIdThe ID of the associated entity.
imagePathThe texture for the image
nameThe name of the image
applicationThe application (context) of the image

Definition at line 82 of file ImageComponent.cpp.

◆ ImageComponent() [8/10]

GUI::ECS::Components::ImageComponent::ImageComponent ( const std::uint32_t entityId,
const std::string & imagePath,
std::pair< unsigned int, unsigned int > dimensions,
const std::string & name = "",
const std::string & application = "" )

Constructor with an entity ID, font path, text content, and font size.

Parameters
entityIdThe ID of the entity this component is associated with.
imagePathThe texture for the image
dimensionThe dimension of the image.
nameThe name of the image
applicationThe application (context) of the image

Definition at line 93 of file ImageComponent.cpp.

◆ ImageComponent() [9/10]

GUI::ECS::Components::ImageComponent::ImageComponent ( const std::uint32_t entityId,
const std::string & imagePath,
std::pair< unsigned int, unsigned int > dimensions,
const GUI::ECS::Systems::Colour & normalColor,
const GUI::ECS::Systems::Colour & hoverColor = GUI::ECS::Systems::Colour::White,
const GUI::ECS::Systems::Colour & clickedColor = GUI::ECS::Systems::Colour::White,
const std::string & name = "",
const std::string & application = "" )

Constructor with detailed parameters.

Parameters
entityIdThe ID of the entity this component is associated with.
imagePathThe texture for the image
dimensionThe dimension of the image.
normalColorThe normal color of the text.
hoverColorThe color of the text when hovered.
clickedColorThe color of the text when clicked.
nameThe name of the image
applicationThe application (context) of the image

Definition at line 105 of file ImageComponent.cpp.

◆ ImageComponent() [10/10]

GUI::ECS::Components::ImageComponent::ImageComponent ( const std::uint32_t entityId,
const std::string & imagePath,
std::pair< unsigned int, unsigned int > dimensions,
const std::pair< float, float > & position,
const GUI::ECS::Systems::Colour & normalColor = GUI::ECS::Systems::Colour::White,
const GUI::ECS::Systems::Colour & hoverColor = GUI::ECS::Systems::Colour::White,
const GUI::ECS::Systems::Colour & clickedColor = GUI::ECS::Systems::Colour::White,
const std::string & name = "",
const std::string & application = "" )

Constructor with full parameter specification.

Parameters
entityIdThe ID of the entity this component is associated with.
imagePathThe texture for the image
dimensionThe dimension of the image.
positionThe position of the text in 2D space.
normalColorThe normal color of the text.
hoverColorThe color of the text when hovered.
clickedColorThe color of the text when clicked.
nameThe name of the image
applicationThe application (context) of the image

Definition at line 120 of file ImageComponent.cpp.

◆ ~ImageComponent()

GUI::ECS::Components::ImageComponent::~ImageComponent ( )

Destructor for ImageComponent.

Definition at line 137 of file ImageComponent.cpp.

Member Function Documentation

◆ getApplication()

const std::string GUI::ECS::Components::ImageComponent::getApplication ( ) const

Get the Application of the image.

Returns
const std::string

Definition at line 241 of file ImageComponent.cpp.

◆ getClickedColor()

const GUI::ECS::Systems::Colour GUI::ECS::Components::ImageComponent::getClickedColor ( ) const

Retrieves the clicked color of the image.

Returns
The clicked color.

Definition at line 261 of file ImageComponent.cpp.

◆ getCollision()

const GUI::ECS::Systems::Collision GUI::ECS::Components::ImageComponent::getCollision ( ) const

Get the Collision object.

Returns
const GUI::ECS::Systems::Collision
Note
This is a sister function used for the update function.

Definition at line 281 of file ImageComponent.cpp.

◆ getDimension()

const std::pair< float, float > GUI::ECS::Components::ImageComponent::getDimension ( ) const

Get the Size of the text.

Returns
const std::pair<float, float>

Definition at line 266 of file ImageComponent.cpp.

◆ getHoverColor()

const GUI::ECS::Systems::Colour GUI::ECS::Components::ImageComponent::getHoverColor ( ) const

Retrieves the hover color of the image.

Returns
The hover color.

Definition at line 256 of file ImageComponent.cpp.

◆ getImage()

const GUI::ECS::Components::TextureComponent GUI::ECS::Components::ImageComponent::getImage ( ) const

Retrieves the texture associated with the image.

Returns
The current texture component.

Definition at line 246 of file ImageComponent.cpp.

◆ getInfo()

const std::string GUI::ECS::Components::ImageComponent::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.

Parameters
indentThe level to which the class should be indented in the dump.
Returns
const std::string The formatted output.

Definition at line 286 of file ImageComponent.cpp.

◆ getLevelBackgroundCompatibility()

const bool GUI::ECS::Components::ImageComponent::getLevelBackgroundCompatibility ( ) const

Get the Level Background Compatibility object.

Returns
true it can be used as a level background
false it cannot be used as a level background
Note
This function is a sub function for the update function, please call the function isLevelBackgroundCompatible for the same effect.

Definition at line 310 of file ImageComponent.cpp.

◆ getName()

const std::string GUI::ECS::Components::ImageComponent::getName ( ) const

Get the Name of the image.

Returns
const std::string

Definition at line 236 of file ImageComponent.cpp.

◆ getNormalColor()

const GUI::ECS::Systems::Colour GUI::ECS::Components::ImageComponent::getNormalColor ( ) const

Retrieves the normal color of the image.

Returns
The normal color.

Definition at line 251 of file ImageComponent.cpp.

◆ getPosition()

const std::pair< int, int > GUI::ECS::Components::ImageComponent::getPosition ( ) const

Get the Position of the image.

Returns
const std::pair<int, int>

Definition at line 271 of file ImageComponent.cpp.

◆ getVisible()

const bool GUI::ECS::Components::ImageComponent::getVisible ( ) const

Get the Visibility of the text.

Returns
true if visible
false if hidden

Definition at line 276 of file ImageComponent.cpp.

◆ isLevelBackgroundCompatible()

const bool GUI::ECS::Components::ImageComponent::isLevelBackgroundCompatible ( ) const

Know if the background can be used as a level bacground.

Returns
true it can be used as a level background
false it cannot be used as a level background

Definition at line 231 of file ImageComponent.cpp.

◆ isVisible()

const bool GUI::ECS::Components::ImageComponent::isVisible ( ) const

Get the visibility state of the Image.

Returns
true The image is visible
false The image is hidden

Definition at line 226 of file ImageComponent.cpp.

◆ operator=()

GUI::ECS::Components::ImageComponent & GUI::ECS::Components::ImageComponent::operator= ( const GUI::ECS::Components::ImageComponent & copy)

Assigns values from another ImageComponent.

Parameters
copyThe source ImageComponent.
Returns
A reference to the updated instance.

Definition at line 354 of file ImageComponent.cpp.

◆ render()

std::any GUI::ECS::Components::ImageComponent::render ( ) const

Renders the image to the given window.

Returns
std::optional<std::any> the internal component to render

Definition at line 315 of file ImageComponent.cpp.

◆ setApplication()

void GUI::ECS::Components::ImageComponent::setApplication ( const std::string & application)

Set the Application (the context) of the image.

Parameters
application

Definition at line 144 of file ImageComponent.cpp.

◆ setClickedColor()

void GUI::ECS::Components::ImageComponent::setClickedColor ( const GUI::ECS::Systems::Colour & color)

Sets the clicked color of the image.

Parameters
colorThe clicked color.

Definition at line 159 of file ImageComponent.cpp.

◆ setDimension()

void GUI::ECS::Components::ImageComponent::setDimension ( const std::pair< float, float > & dimension)

Sets the dimensions of the image.

Parameters
dimensionThe new dimensions as a pair (width, height).

Definition at line 187 of file ImageComponent.cpp.

◆ setHoverColor()

void GUI::ECS::Components::ImageComponent::setHoverColor ( const GUI::ECS::Systems::Colour & color)

Sets the hover color of the image.

Parameters
colorThe hover color.

Definition at line 154 of file ImageComponent.cpp.

◆ setImage() [1/2]

void GUI::ECS::Components::ImageComponent::setImage ( const GUI::ECS::Components::TextureComponent & image,
const std::string & name = "" )

Assigns a texture to the image component.

Parameters
imageThe texture component.
nameAn optional name for the image.

Definition at line 164 of file ImageComponent.cpp.

◆ setImage() [2/2]

void GUI::ECS::Components::ImageComponent::setImage ( const std::string & path,
const std::string & name = "" )

Loads and assigns an image from a file path.

Parameters
pathPath to the image file.
nameAn optional name for the image.

Definition at line 176 of file ImageComponent.cpp.

◆ setLevelBackgroundCompatible()

void GUI::ECS::Components::ImageComponent::setLevelBackgroundCompatible ( const bool levelBackground)

Set the Level Background Compatible variable.

Parameters
levelBackground

Definition at line 212 of file ImageComponent.cpp.

◆ setName()

void GUI::ECS::Components::ImageComponent::setName ( const std::string & name)

Set the Name of the image.

Parameters
name

Definition at line 139 of file ImageComponent.cpp.

◆ setNormalColor()

void GUI::ECS::Components::ImageComponent::setNormalColor ( const GUI::ECS::Systems::Colour & color)

Sets the normal color of the image.

Parameters
colorThe normal color.

Definition at line 149 of file ImageComponent.cpp.

◆ setPosition()

void GUI::ECS::Components::ImageComponent::setPosition ( const std::pair< int, int > & position)

Sets the position of the image.

Parameters
positionThe new position as a pair (x, y).

Definition at line 197 of file ImageComponent.cpp.

◆ setVisible()

void GUI::ECS::Components::ImageComponent::setVisible ( const bool visible)

Set the visibility of the object using a boolean.

  • true : visible
  • false : hidden
Parameters
visibleThe boolean value

Definition at line 207 of file ImageComponent.cpp.

◆ toggleVisibility()

void GUI::ECS::Components::ImageComponent::toggleVisibility ( )

Toggles the visibility of the image.

Definition at line 217 of file ImageComponent.cpp.

◆ update() [1/2]

void GUI::ECS::Components::ImageComponent::update ( const GUI::ECS::Components::ImageComponent & copy)

Updates this ImageComponent with values from another instance.

Parameters
copyThe source ImageComponent.

Definition at line 330 of file ImageComponent.cpp.

◆ update() [2/2]

void GUI::ECS::Components::ImageComponent::update ( const GUI::ECS::Systems::MouseInfo & mouse)

Updates the image based on mouse interactions.

Parameters
mouseThe mouse information.

Definition at line 324 of file ImageComponent.cpp.


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