TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
TurtleBrains::Express::Counters::Counter Class Reference

#include <tbx_health_bar.hpp>

Inheritance diagram for TurtleBrains::Express::Counters::Counter:
TurtleBrains::Graphics::Text TurtleBrains::Graphics::Graphic TurtleBrains::Core::Noncopyable

Public Member Functions

 Counter (tbCore::uint16 total)
 
virtual ~Counter (void)
 
const tbCore::uint16GetTotal (void) const
 
void SetTotal (const tbCore::uint16 total)
 
const tbCore::uint16GetCount (void) const
 
void SetCount (const tbCore::uint16 count)
 
void JumpDisplay (void)
 
- Public Member Functions inherited from TurtleBrains::Graphics::Text
 Text (const String &text=tb_string(""), const FontSize pointSize=DefaultFontSize(), const String &fontFilepath=DefaultFontFile())
 
virtual ~Text (void)
 
String GetText (void) const
 
String GetFont (void) const
 
FontSize GetPointSize (void) const
 
float Unstable_GetBaseline (const BaselineFrom from=BaselineFrom::Top) const
 
float Unstable_GetScaledBaseline (const BaselineFrom from=BaselineFrom::Top) const
 
void SetText (const String &text, const tbGraphics::AnchorLocation &alignment, const FontSize pointSize, const String &fontFilepath)
 
void SetText (const String &text, const FontSize pointSize, const String &fontFilepath)
 
void SetText (const String &text, const FontSize pointSize)
 
void SetText (const String &text)
 
void SetAlignment (const AnchorLocation &alignment)
 
virtual void SetColor (const Color &newColor) override
 
void SetColor (const Color &topColor, const Color &bottomColor)
 
const ColorGetOutlineColor (void) const
 
void SetOutlineColor (const Color &outlineColor)
 
float GetOutlineThickness (void) const
 
void SetOutlineThickness (const float thickness)
 
const ColorGetShadowColor (void) const
 
void SetShadowColor (const Color &shadowColor)
 
Math::Vector2 GetShadowOffset (void) const
 
void SetShadowOffset (const Math::Vector2 &shadowOffset)
 
void SetShadowOffset (const float offsetX, const float offsetY)
 
virtual PixelSpace GetPixelWidth (void) const override
 
virtual PixelSpace GetPixelHeight (void) const override
 
- Public Member Functions inherited from TurtleBrains::Graphics::Graphic
 Graphic (void)
 
 Graphic (const Graphic &other)=default
 
virtual ~Graphic (void)=default
 
Graphicoperator= (const Graphic &other)=default
 
bool IsActive (void) const
 
void SetActive (const bool isActive)
 
void Update (const float deltaTime)
 
bool IsVisible (void) const
 
void SetVisible (const bool isVisible)
 
void Render (void) const
 
const tbMath::Vector2GetPosition (void) const
 
void SetPosition (const float x, const float y)
 
void SetPosition (const tbMath::Vector2 &position)
 
const tbMath::Vector2GetOrigin (void) const
 
void SetOrigin (const AnchorLocation &anchor, const float offsetX, const float offsetY)
 
void SetOrigin (const AnchorLocation &anchor, const tbMath::Vector2 &offset=tbMath::Vector2::Zero())
 
void SetOrigin (const float originX, const float originY)
 
void SetOrigin (const tbMath::Vector2 &origin)
 
float GetDepth (void) const
 
void SetDepth (const float newDepth)
 
const tbMath::Vector2GetScale (void) const
 
void SetScale (const float scale)
 
void SetScale (const tbMath::Vector2 &scale)
 
void SetScale (const float scaleX, const float scaleY)
 
tbMath::Angle GetRotation (void) const
 
void SetRotation (const tbMath::Angle &angle)
 
void SetScroll (const float scroll)
 
void SetScroll (const float scrollX, const float scrollY)
 
bool IsRelative (void) const
 
const ColorGetColor (void) const
 
float GetWidth (void) const
 
float GetHeight (void) const
 
float GetScaledWidth (void) const
 
float GetScaledHeight (void) const
 
tbMath::Vector2 GetAnchorPosition (const tbGraphics::AnchorLocation &anchor, const float offsetX, const float offsetY) const
 
tbMath::Vector2 GetAnchorPosition (const tbGraphics::AnchorLocation &anchor, const tbMath::Vector2 &offset=tbMath::Vector2::Zero()) const
 
bool UnstableIsPointContained (const tbMath::Vector2 &point) const
 

Protected Member Functions

virtual void OnUpdate (const float deltaTime) override
 
- Protected Member Functions inherited from TurtleBrains::Graphics::Text
virtual void OnRender (void) const override
 
- Protected Member Functions inherited from TurtleBrains::Graphics::Graphic
virtual void ApplyTransform (void) const
 
virtual void PopTransform (void) const
 

Additional Inherited Members

- Public Types inherited from TurtleBrains::Graphics::Text
enum class  BaselineFrom { Top , Center , Bottom }
 
- Static Public Member Functions inherited from TurtleBrains::Graphics::Text
static FontSize DefaultFontSize (void)
 
static const String & DefaultFontFile (void)
 
static void SetLineHeightForFont (const String &fontFilepath, const float multiplier)
 
static void CreateGraphicsContext (void)
 
static void DestroyGraphicsContext (void)
 

Detailed Description

Counter object to display a text counter that ticks up/down.

Constructor & Destructor Documentation

◆ Counter()

TurtleBrains::Express::Counters::Counter::Counter ( tbCore::uint16  total)
explicit

Constructs a counter with the count, total and display matching.

Parameters
totalSets the display, count and total to the total specified here.

◆ ~Counter()

virtual TurtleBrains::Express::Counters::Counter::~Counter ( void  )
virtual

Destructs and cleans up after the Counter object.

Member Function Documentation

◆ GetCount()

const tbCore::uint16& TurtleBrains::Express::Counters::Counter::GetCount ( void  ) const

Returns the current count, how many active icons are displayed.

◆ GetTotal()

const tbCore::uint16& TurtleBrains::Express::Counters::Counter::GetTotal ( void  ) const

Returns the total value of the counter which can be set via SetTotal() the percentage of GetCount() / GetTotal() determines the display of the slider.

◆ JumpDisplay()

void TurtleBrains::Express::Counters::Counter::JumpDisplay ( void  )

Jumps the display immediately to the current value instead of ticking up/down overtime.

◆ OnUpdate()

virtual void TurtleBrains::Express::Counters::Counter::OnUpdate ( const float  deltaTime)
overrideprotectedvirtual

Ticks the displayed counter toward the count.

Reimplemented from TurtleBrains::Graphics::Graphic.

◆ SetCount()

void TurtleBrains::Express::Counters::Counter::SetCount ( const tbCore::uint16  count)

Sets the current value of the counter which will change how the slider is displayed. The count must be less-than-or-equal-to the total. There will not be an error condition triggered though a warning may be displayed.

Parameters
countThe value of the slider, to be full it would be the same as Total, and to be empty it would be 0.

◆ SetTotal()

void TurtleBrains::Express::Counters::Counter::SetTotal ( const tbCore::uint16  total)

Sets the total value of the counter to determine the display of the slider. The value is a 16bit unsigned value. If the new total is less than the current count, the count will be lowered to match the new total.

Parameters
totalThe value it takes for the slider to display as completely full. Must not be 0 or an error condition will be triggered.