Chesto
0.9
A declarative and element-based library for creating GUIs on homebrew'd consoles
src
TextElement.hpp
1
#pragma once
2
3
#include "Texture.hpp"
4
#include <string>
5
6
#define NORMAL 0
7
#define MONOSPACED 1
8
#define ICON 2
// old icon font, no longer used
9
#define OLD_MONOSPACED 2
10
#define SERIF 3
11
#define SIMPLIFIED_CHINESE 4
12
13
std::string i18n(std::string key);
14
15
class
TextElement
:
public
Texture
16
{
17
public
:
18
// constructors
19
TextElement
();
20
TextElement
(std::string text,
int
size, CST_Color* color = 0,
int
font_type = NORMAL,
int
wrapped_width = 0);
21
22
// change TextElement
23
void
setText(
const
std::string& text);
24
void
setSize(
int
size);
25
void
setColor(
const
CST_Color& color);
26
void
setFont(
int
font_type);
27
void
setWrappedWidth(
int
wrapped_width);
28
30
void
update
(
bool
forceUpdate =
false
);
31
std::string text =
""
;
32
33
// if specified, will override any font_type setting
34
std::string customFontPath =
""
;
35
36
static
std::unordered_map<std::string, std::string> i18nCache;
37
static
void
loadI18nCache(std::string locale);
38
39
// if true, replaces all NORMAL fonts with SIMPLIFIED_CHINESE
40
static
bool
useSimplifiedChineseFont;
41
42
private
:
43
// default values
44
int
textSize = 16;
45
CST_Color textColor = (CST_Color){ 0xff, 0xff, 0xff };
46
int
textFont = NORMAL;
47
int
textWrappedWidth = 0;
48
49
// font ttf files path
50
static
const
char
*fontPaths[];
51
};
TextElement
Definition:
TextElement.hpp:16
TextElement::update
void update(bool forceUpdate=false)
update TextElement with changes
Definition:
TextElement.cpp:89
Texture
Definition:
Texture.hpp:24
Generated by
1.9.4