-
Notifications
You must be signed in to change notification settings - Fork 4
/
TextElement.hpp
51 lines (40 loc) · 1.23 KB
/
TextElement.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
#pragma once
#include "Texture.hpp"
#include <string>
#define NORMAL 0
#define MONOSPACED 1
#define ICON 2 // old icon font, no longer used
#define OLD_MONOSPACED 2
#define SERIF 3
#define SIMPLIFIED_CHINESE 4
std::string i18n(std::string key);
class TextElement : public Texture
{
public:
// constructors
TextElement();
TextElement(std::string text, int size, CST_Color* color = 0, int font_type = NORMAL, int wrapped_width = 0);
// change TextElement
void setText(const std::string& text);
void setSize(int size);
void setColor(const CST_Color& color);
void setFont(int font_type);
void setWrappedWidth(int wrapped_width);
/// update TextElement with changes
void update(bool forceUpdate = false);
std::string text = "";
// if specified, will override any font_type setting
std::string customFontPath = "";
static std::unordered_map<std::string, std::string> i18nCache;
static void loadI18nCache(std::string locale);
// if true, replaces all NORMAL fonts with SIMPLIFIED_CHINESE
static bool useSimplifiedChineseFont;
private:
// default values
int textSize = 16;
CST_Color textColor = (CST_Color){ 0xff, 0xff, 0xff };
int textFont = NORMAL;
int textWrappedWidth = 0;
// font ttf files path
static const char *fontPaths[];
};