-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLabel.hpp
90 lines (74 loc) · 1.77 KB
/
Label.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* Rhythm Run for Nintendo 3DS
* Lauren Kelly, 2020
*/
#pragma once
#include "debug.hpp"
#include <3ds.h>
#include <citro2d.h>
#include <stdint.h>
#include "Drawable.hpp"
/**
* Label class
*/
class Label : public Drawable {
public:
Label(const char* a_text, float a_x, float a_y, u32 a_flags, float a_scaleX, float a_scaleY, u32 a_color, size_t a_bufSize);
Label() {}; // default empty constructor
// Destructor -- clean up text buf
~Label() { C2D_TextBufDelete(textBuf); }
// Label(const Label&) = delete;
// Label(Label&&) = delete;
// Label& operator=(const Label&) = delete;
// Label& operator=(Label&&) = delete;
// Getters
float getX() { return posX; }
float getY() { return posY; }
float getWidth()
{
float width;
C2D_TextGetDimensions(&text, scaleX, scaleY, &width, nullptr);
return width;
}
float getHeight()
{
float height;
C2D_TextGetDimensions(&text, scaleX, scaleY, nullptr, &height);
return height;
}
float getCenterX()
{
return getWidth() / 2.0f;
};
float getCenterY()
{
return getHeight() / 2.0f;
};
void setPosition(float a_x, float a_y)
{
posX = a_x;
posY = a_y;
};
void move(float a_dX, float a_dY)
{
posX += a_dX;
posY += a_dY;
};
void scale(float a_scaleX, float a_scaleY)
{
scaleX *= a_scaleX;
scaleY *= a_scaleY;
};
/// Set label text
void setText(const char* a_text, size_t a_bufSize);
/// Set label color
void setColor(u32 a_color) { color = a_color; };
bool draw();
private:
C2D_Text text;
C2D_TextBuf textBuf;
u32 textFlags;
float posX, posY;
float scaleX, scaleY;
u32 color;
};