|
@@ -5,16 +5,20 @@
|
5
|
5
|
* \author xythobuz
|
6
|
6
|
*/
|
7
|
7
|
|
|
8
|
+#include <vector>
|
|
9
|
+
|
8
|
10
|
#include "global.h"
|
9
|
11
|
#include "Log.h"
|
10
|
12
|
#include "utils/strings.h"
|
11
|
13
|
#include "system/FontImGui.h"
|
12
|
14
|
#include "system/FontTRLE.h"
|
13
|
15
|
#include "system/FontTTF.h"
|
|
16
|
+#include "system/Shader.h"
|
14
|
17
|
#include "system/Font.h"
|
15
|
18
|
|
16
|
19
|
bool Font::isInit = false;
|
17
|
20
|
std::string Font::fontName;
|
|
21
|
+bool Font::showFontBox = false;
|
18
|
22
|
|
19
|
23
|
void Font::shutdown() {
|
20
|
24
|
FontTRLE::shutdown();
|
|
@@ -66,6 +70,12 @@ void Font::drawText(unsigned int x, unsigned int y, float scale,
|
66
|
70
|
} else {
|
67
|
71
|
FontImGui::drawText(x, y, scale, color, s);
|
68
|
72
|
}
|
|
73
|
+
|
|
74
|
+ if (showFontBox) {
|
|
75
|
+ unsigned int w = widthText(scale, s);
|
|
76
|
+ unsigned int h = heightText(scale, w + 100, s); // Should always be one line
|
|
77
|
+ drawFontBox(x, y, w, h);
|
|
78
|
+ }
|
69
|
79
|
}
|
70
|
80
|
|
71
|
81
|
void Font::drawTextWrapped(unsigned int x, unsigned int y, float scale,
|
|
@@ -77,6 +87,14 @@ void Font::drawTextWrapped(unsigned int x, unsigned int y, float scale,
|
77
|
87
|
} else {
|
78
|
88
|
FontImGui::drawTextWrapped(x, y, scale, color, maxWidth, s);
|
79
|
89
|
}
|
|
90
|
+
|
|
91
|
+ if (showFontBox) {
|
|
92
|
+ unsigned int w = widthText(scale, s);
|
|
93
|
+ if (w > maxWidth)
|
|
94
|
+ w = maxWidth;
|
|
95
|
+ unsigned int h = heightText(scale, w, s); // Should always be one line
|
|
96
|
+ drawFontBox(x, y, w, h);
|
|
97
|
+ }
|
80
|
98
|
}
|
81
|
99
|
|
82
|
100
|
void Font::drawTextCentered(unsigned int x, unsigned int y, float scale,
|
|
@@ -84,3 +102,26 @@ void Font::drawTextCentered(unsigned int x, unsigned int y, float scale,
|
84
|
102
|
drawText(x + ((width / 2) - (widthText(scale, s) / 2)), y, scale, color, s);
|
85
|
103
|
}
|
86
|
104
|
|
|
105
|
+void Font::drawFontBox(unsigned int x, unsigned int y, unsigned int w, unsigned int h) {
|
|
106
|
+ static ShaderBuffer vert, uv;
|
|
107
|
+ std::vector<glm::vec2> vertices, uvs;
|
|
108
|
+
|
|
109
|
+ vertices.emplace_back(x, y);
|
|
110
|
+ vertices.emplace_back(x + w, y);
|
|
111
|
+ vertices.emplace_back(x + w, y + h);
|
|
112
|
+ vertices.emplace_back(x, y + h);
|
|
113
|
+ vertices.emplace_back(x, y);
|
|
114
|
+
|
|
115
|
+ uvs.emplace_back(0.0f, 0.0f);
|
|
116
|
+ uvs.emplace_back(1.0f, 0.0f);
|
|
117
|
+ uvs.emplace_back(1.0f, 1.0f);
|
|
118
|
+ uvs.emplace_back(0.0f, 1.0f);
|
|
119
|
+ uvs.emplace_back(0.0f, 0.0f);
|
|
120
|
+
|
|
121
|
+ vert.bufferData(vertices);
|
|
122
|
+ uv.bufferData(uvs);
|
|
123
|
+
|
|
124
|
+ Shader::drawGL(vert, uv, glm::vec4(1.0f, 1.0f, 0.0f, 1.0f), TEXTURE_WHITE,
|
|
125
|
+ TextureStorage::SYSTEM, GL_LINE_STRIP);
|
|
126
|
+}
|
|
127
|
+
|