Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
Text Class Reference

UI Text Component. More...

#include <text.h>

Inheritance diagram for Text:
[legend]

Public Member Functions

 Text (std::string text, std::string font, std::string font_path, int font_size, Color color)
 
void update (float dt) override
 
const std::string & text () const
 
Texttext (const std::string &text)
 
const std::string & font () const
 
Textfont (const std::string &font)
 
const std::string & font_path () const
 
Textfont_path (const std::string &font_path)
 
int font_size () const
 
Textfont_size (int font_size)
 
Color color () const
 
Textcolor (Color color)
 
bool dirty () const
 
void mark_dirty (bool dirty=true)
 
std::string type_name () const override
 Provides a consistent type name for the component.
 
TextAlignment alignment () const
 
Textalignment (TextAlignment alignment)
 
Point offset () const
 
Textoffset (Point offset)
 
- Public Member Functions inherited from Renderable
 Renderable ()
 
 Renderable (int layer)
 
 ~Renderable () override=default
 
Renderableorder_in_layer (int layer)
 
int order_in_layer () const
 
void set_render_strategy (Component &component)
 
virtual IRenderingStrategyrender_strategy () const
 
Renderabledisable_draw () noexcept
 
Renderableenable_draw () noexcept
 
bool should_draw () const noexcept
 
- Public Member Functions inherited from Component
 Component ()
 
virtual ~Component ()=default
 
bool active () const noexcept
 Checks if the component is active.
 
Componentactive (bool value) noexcept
 
bool marked_for_deletion () const noexcept
 Activates the component.
 
Componentmark_for_deletion () noexcept
 
virtual void on_attach ()
 Called when the component is attached to a GameObject.
 
virtual void on_detach ()
 Called when the component is detached from a GameObject.
 
virtual void on_serialize (std::vector< uint8_t > &) const
 Serializes the component's state into a byte array.
 
virtual void on_deserialize (const std::vector< uint8_t > &, size_t &)
 Deserializes the component's state from a byte array.
 
const std::optional< std::reference_wrapper< GameObject > > & parent () const noexcept
 Gets the parent GameObject of this component.
 
std::optional< std::reference_wrapper< GameObject > > & parent () noexcept
 Gets the parent GameObject of this component.
 
Componentparent (GameObject &parent)
 
Componentparent (std::nullopt_t nullopt)
 
size_t add_on_attach (const std::function< void(Component &)> &action)
 Retrieves the type information of the component.
 
void remove_on_attach (size_t index)
 
size_t add_on_detach (const std::function< void(Component &)> &action)
 Adds an action to be performed when the component is attached.
 
void remove_on_detach (size_t index)
 

Additional Inherited Members

- Protected Attributes inherited from Renderable
std::unique_ptr< IRenderingStrategyrender_strategy_
 
int ordering_layer_ = 0
 
bool draw {true}
 

Detailed Description

UI Text Component.

Represents a text element in the UI with customizable font, size, color, and content. Inherits from Renderable to allow rendering strategies.

Usage:

  • Create a Text component with desired properties.
  • Attach the Text component to a GameObject to display text in the UI.
  • Modify properties such as text content, font, size, color, alignment, and offset as needed.
    Note
    Ensure the specified font is available in the assets.

Constructor & Destructor Documentation

◆ Text()

Text::Text ( std::string  text,
std::string  font,
std::string  font_path,
int  font_size,
Color  color 
)

Member Function Documentation

◆ alignment() [1/2]

TextAlignment Text::alignment ( ) const

◆ alignment() [2/2]

Text & Text::alignment ( TextAlignment  alignment)

◆ color() [1/2]

Color Text::color ( ) const

◆ color() [2/2]

Text & Text::color ( Color  color)

◆ dirty()

bool Text::dirty ( ) const

◆ font() [1/2]

const std::string & Text::font ( ) const

◆ font() [2/2]

Text & Text::font ( const std::string &  font)

◆ font_path() [1/2]

const std::string & Text::font_path ( ) const

◆ font_path() [2/2]

Text & Text::font_path ( const std::string &  font_path)

◆ font_size() [1/2]

int Text::font_size ( ) const

◆ font_size() [2/2]

Text & Text::font_size ( int  font_size)

◆ mark_dirty()

void Text::mark_dirty ( bool  dirty = true)

◆ offset() [1/2]

Point Text::offset ( ) const

◆ offset() [2/2]

Text & Text::offset ( Point  offset)

◆ text() [1/2]

const std::string & Text::text ( ) const

◆ text() [2/2]

Text & Text::text ( const std::string &  text)

◆ type_name()

std::string Text::type_name ( ) const
overridevirtual

Provides a consistent type name for the component.

Returns
A string representing the type name of the component. @CAUTION: All derived components must implement this method to ensure consistent serialization across different compilers and platforms.

Reimplemented from Renderable.

◆ update()

void Text::update ( float  dt)
inlineoverridevirtual

Implements Component.


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