WOWCube Docs logo
WOWCube Docs
Mission Control
Section Shortcuts
APIExamplesSourceWOWConnectChangelog
Filters
SDK and language defaults persist in cookies.
SDK version
Navigation Tree
Collapsed by default, focused on the active path.
Made byMcKay Seamons
GitHub
  1. Home
  2. Docs
  3. Source
  4. Text.cpp
Mission NodeSDK 6.3C++gfx

Text.cpp

SDK Source File: Text.cpp

Source / SDK 6.3 / C++ / gfx

Text.cpp

Text.cpp
CPP
1/* Copyright Statement:
2 *
3 * (C) 2021-2025 Cubios Inc. All rights reserved.
4 */
5#include <cstdarg>
6#include "Text.h"
7
8namespace Cubios
9{
10namespace Gfx
11{
12Text::Text(std::string text, const Cubios::Math::Transform& t, uint32_t fontSize, const Cubios::Math::Color& color, Cubios::text_align_t al)
13{
14 this->Transform = t;
15 this->Color = color;
16
17 this->Alignment = al;
18 this->FontSize = fontSize;
19
20 this->Content = text;
21}
22
23Text::Text(std::string text, const Cubios::Math::Transform& t, uint32_t fontSize, Cubios::text_align_t al)
24{
25 this->Transform = t;
26 this->Alignment = al;
27 this->FontSize = fontSize;
28
29 this->Content = text;
30}
31
32Text::Text(std::string text, float x, float y,uint32_t fontSize)
33{
34 this->Transform.Position.X = x;
35 this->Transform.Position.Y = y;
36
37 this->Alignment = Cubios::text_align_t::TEXT_ALIGN_CENTER;
38 this->FontSize = fontSize;
39
40 this->Content = text;
41}
42
43Text::Text(std::string text, float x, float y, uint32_t fontSize, const Cubios::Math::Color& color)
44{
45 this->Transform.Position.X = x;
46 this->Transform.Position.Y = y;
47 this->Color = color;
48
49 this->Alignment = Cubios::text_align_t::TEXT_ALIGN_CENTER;
50 this->FontSize = fontSize;
51
52 this->Content = text;
53}
54
55Text::~Text() { }
56
57
58Cubios::SceneObject* Text::SetContent(std::string text)
59{
60 this->Content = text;
61 return this;
62}
63
64Cubios::SceneObject* Text::FormatContent(char const* format,...)
65{
66 va_list args;
67 va_start(args, format);
68
69 va_list copy;
70 va_copy(copy, args);
71 int len = std::vsnprintf(nullptr, 0, format, copy);
72 va_end(copy);
73
74 if (len >= 0)
75 {
76 std::string s(std::size_t(len) + 1, '\0');
77 std::vsnprintf(&s[0], s.size(), format, args);
78 s.resize(len);
79
80 this->Content = s;
81 }
82
83 va_end(args);
84 return this;
85}
86
87Cubios::SceneObject* Text::SetFontSize(uint32_t fontSize)
88{
89 this->FontSize = fontSize;
90 return this;
91}
92
93void Text::Render()
94{
95 Math::Vec2 pos = this->ScreenPosition();
96 Cubios::GFX_drawText(pos.X, pos.Y, this->FontSize, Transform.SafeRotation()+ScreenAngle, this->Alignment, Color.Value(), this->Content.c_str());
97}
98}
99}
100
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.
Context Rail

Related nodes

AnimatedSprite.cpp
Source / SDK 6.3 / C++ / gfx
AnimatedSprite.h
Source / SDK 6.3 / C++ / gfx
Background.cpp
Source / SDK 6.3 / C++ / gfx
Background.h
Source / SDK 6.3 / C++ / gfx
Previous Node
SpriteAtlas.h
Source / SDK 6.3 / C++ / gfx
Next Node
Text.h
Source / SDK 6.3 / C++ / gfx