MAGE  v0.171.0
Matthias Advanced Game Engine
mage::rendering::SpriteText Class Reference

#include <sprite_text.hpp>

Inheritance diagram for mage::rendering::SpriteText:
mage::Component

Public Types

enum  TextEffect : U8 { TextEffect::None = 0, TextEffect::DropShadow, TextEffect::Outline }
 

Public Member Functions

 SpriteText ()
 
 SpriteText (const SpriteText &sprite)
 
 SpriteText (SpriteText &&sprite) noexcept
 
virtual ~SpriteText ()
 
SpriteTextoperator= (const SpriteText &sprite)
 
SpriteTextoperator= (SpriteText &&sprite) noexcept
 
void Draw (SpriteBatch &sprite_batch) const
 
SpriteTransform2DGetSpriteTransform () noexcept
 
const SpriteTransform2DGetSpriteTransform () const noexcept
 
SpriteEffect GetSpriteEffects () const noexcept
 
void SetSpriteEffects (SpriteEffect sprite_effects) noexcept
 
void ClearText () noexcept
 
const std::vector< ColorString > & GetText () const noexcept
 
void SetText (ColorString text)
 
void AppendText (ColorString text)
 
template<typename ActionT >
void ForEachColorString (ActionT &&action)
 
template<typename ActionT >
void ForEachColorString (ActionT &&action) const
 
RGBAGetTextEffectColor () noexcept
 
const RGBAGetTextEffectColor () const noexcept
 
TextEffect GetTextEffect () const noexcept
 
void SetTextEffect (TextEffect text_effect) noexcept
 
SpriteFontPtr GetFont () const noexcept
 
ID3D11ShaderResourceView * GetFontSRV () const noexcept
 
void SetFont (SpriteFontPtr font) noexcept
 
- Public Member Functions inherited from mage::Component
virtual ~Component ()
 
Componentoperator= (const Component &component) noexcept
 
Componentoperator= (Component &&component) noexcept
 
State GetState () const noexcept
 
void SetState (State state) noexcept
 
U64 GetGuid () const noexcept
 
bool HasOwner () const noexcept
 
ProxyPtr< NodeGetOwner () noexcept
 
ProxyPtr< const NodeGetOwner () const noexcept
 

Private Attributes

SpriteTransform2D m_sprite_transform
 
SpriteEffect m_sprite_effects
 
std::vector< ColorStringm_strings
 
RGBA m_text_effect_color
 
TextEffect m_text_effect
 
SpriteFontPtr m_font
 

Additional Inherited Members

- Protected Member Functions inherited from mage::Component
 Component () noexcept
 
 Component (const Component &component) noexcept
 
 Component (Component &&component) noexcept
 

Detailed Description

A class of sprite texts.

Member Enumeration Documentation

◆ TextEffect

An enumeration of the different text effects. This contains:

None, DropShadow and Outline.

Enumerator
None 
DropShadow 
Outline 

Constructor & Destructor Documentation

◆ SpriteText() [1/3]

mage::rendering::SpriteText::SpriteText ( )

Constructs a sprite text.

◆ SpriteText() [2/3]

mage::rendering::SpriteText::SpriteText ( const SpriteText sprite)
default

Constructs a sprite text from the given sprite text.

Parameters
[in]spriteA reference to the sprite text to copy.

◆ SpriteText() [3/3]

mage::rendering::SpriteText::SpriteText ( SpriteText &&  sprite)
defaultnoexcept

Constructs a sprite text by moving the given sprite text.

Parameters
[in]spriteA reference to the sprite text to move.

◆ ~SpriteText()

mage::rendering::SpriteText::~SpriteText ( )
virtualdefault

Destruct this sprite text.

Member Function Documentation

◆ AppendText()

void mage::rendering::SpriteText::AppendText ( ColorString  text)

Appends the given text to the end of the text of this sprite text.

Parameters
[in]textThe text.

◆ ClearText()

void mage::rendering::SpriteText::ClearText ( )
noexcept

Clears the text of this sprite text.

◆ Draw()

void mage::rendering::SpriteText::Draw ( SpriteBatch sprite_batch) const

Draws this sprite text.

Parameters
[in,out]sprite_batchA reference to the sprite batch used for rendering this sprite text.

◆ ForEachColorString() [1/2]

template<typename ActionT >
void mage::rendering::SpriteText::ForEachColorString ( ActionT &&  action)

Traverses all color strings of this sprite text.

Template Parameters
ActionTAn action to perform on all color strings of this sprite text. The action must accept ColorString& values.
Parameters
[in]actionThe action.

◆ ForEachColorString() [2/2]

template<typename ActionT >
void mage::rendering::SpriteText::ForEachColorString ( ActionT &&  action) const

Traverses all color strings of this sprite text.

Template Parameters
ActionTAn action to perform on all color strings of this sprite text. The action must accept const ColorString& values.
Parameters
[in]actionThe action.

◆ GetFont()

SpriteFontPtr mage::rendering::SpriteText::GetFont ( ) const
noexcept

Returns the font of this sprite text.

Returns
A pointer to the font of this sprite text.

◆ GetFontSRV()

ID3D11ShaderResourceView* mage::rendering::SpriteText::GetFontSRV ( ) const
noexcept

Returns the shader resource view of the font of this sprite text.

Returns
A pointer to the shader resource view of the font of this sprite text.

◆ GetSpriteEffects()

SpriteEffect mage::rendering::SpriteText::GetSpriteEffects ( ) const
noexcept

Returns the sprite effects of this sprite text.

Returns
The sprite effects of this sprite text.

◆ GetSpriteTransform() [1/2]

SpriteTransform2D& mage::rendering::SpriteText::GetSpriteTransform ( )
noexcept

Returns the sprite transform of this sprite text.

Returns
A reference to the sprite transform of this sprite text.

◆ GetSpriteTransform() [2/2]

const SpriteTransform2D& mage::rendering::SpriteText::GetSpriteTransform ( ) const
noexcept

Returns the sprite transform of this sprite text.

Returns
A reference to the sprite transform of this sprite text.

◆ GetText()

const std::vector< ColorString >& mage::rendering::SpriteText::GetText ( ) const
noexcept

Returns the text of this sprite text.

Returns
A reference to a vector containing the color strings of this sprite text.

◆ GetTextEffect()

TextEffect mage::rendering::SpriteText::GetTextEffect ( ) const
noexcept

Returns the text effect of this sprite text.

Returns
The text effect of this sprite text.

◆ GetTextEffectColor() [1/2]

RGBA& mage::rendering::SpriteText::GetTextEffectColor ( )
noexcept

Returns the (linear) text effect color of this sprite text.

Returns
A reference to the (linear) text effect color of this sprite text.

◆ GetTextEffectColor() [2/2]

const RGBA& mage::rendering::SpriteText::GetTextEffectColor ( ) const
noexcept

Returns the (linear) text effect color of this sprite text.

Returns
A reference to the (linear) text effect color of this sprite text.

◆ operator=() [1/2]

SpriteText & mage::rendering::SpriteText::operator= ( const SpriteText sprite)
default

Copies the given sprite text to this sprite text.

Parameters
[in]spriteA reference to the sprite text to copy.
Returns
A reference to the copy of the given sprite text (i.e. this sprite text).

◆ operator=() [2/2]

SpriteText & mage::rendering::SpriteText::operator= ( SpriteText &&  sprite)
defaultnoexcept

Moves the given sprite text to this sprite text.

Parameters
[in]spriteA reference to the sprite text to move.
Returns
A reference to the moved sprite text (i.e. this sprite text).

◆ SetFont()

void mage::rendering::SpriteText::SetFont ( SpriteFontPtr  font)
noexcept

Sets the font of this sprite text to the given font.

Parameters
[in]fontA pointer to the font of this sprite text.

◆ SetSpriteEffects()

void mage::rendering::SpriteText::SetSpriteEffects ( SpriteEffect  sprite_effects)
noexcept

Sets the sprite effects of this sprite text to the given sprite effects.

Parameters
[in]sprite_effectsThe sprite effects.

◆ SetText()

void mage::rendering::SpriteText::SetText ( ColorString  text)

Sets the text of this sprite text to the given text.

Parameters
[in]textThe text.

◆ SetTextEffect()

void mage::rendering::SpriteText::SetTextEffect ( TextEffect  text_effect)
noexcept

Sets the text effect of this sprite text to the given text effect.

Parameters
[in]text_effectThe text effect.

Member Data Documentation

◆ m_font

SpriteFontPtr mage::rendering::SpriteText::m_font
private

A pointer to the sprite font of this sprite text.

◆ m_sprite_effects

SpriteEffect mage::rendering::SpriteText::m_sprite_effects
private

The sprite effects of this sprite text.

◆ m_sprite_transform

SpriteTransform2D mage::rendering::SpriteText::m_sprite_transform
private

The sprite transform of this sprite text.

◆ m_strings

std::vector< ColorString > mage::rendering::SpriteText::m_strings
private

A vector with the color strings of this sprite text.

◆ m_text_effect

TextEffect mage::rendering::SpriteText::m_text_effect
private

The text effect of this sprite text.

◆ m_text_effect_color

RGBA mage::rendering::SpriteText::m_text_effect_color
private

The (linear) text effect color of this sprite text.