Working on UI
This commit is contained in:
1 parent
9adcde5c05
commit
c659293bf8
9 files changed
+550
-62
No files matched your search
+20
-6
@@ -210,12 +210,24 @@ namespace ZL {
|
||||
// Draw text on top (uses absolute coords, add anim offset manually)
|
||||
// use left padding, which is required for inventory/quest lists.
|
||||
if (textRenderer && !text.empty()) {
|
||||
const float scale = 1.0f;
|
||||
const std::string displayText = wrap
|
||||
? wrapTextByPixels(text, *textRenderer, rect.w - textPaddingX * 2.0f, scale)
|
||||
: text;
|
||||
|
||||
float tx = rect.x + rect.w / 2.0f + animOffsetX;
|
||||
if (!textCentered) {
|
||||
tx = rect.x + textPaddingX + animOffsetX;
|
||||
}
|
||||
const float ty = rect.y + rect.h * 0.5f + textPaddingY + animOffsetY;
|
||||
textRenderer->drawText(text, tx, ty, 1.0f, textCentered, color);
|
||||
|
||||
float ty;
|
||||
if (topAligned) {
|
||||
ty = rect.y + rect.h - textPaddingY - static_cast<float>(fontSize) + animOffsetY;
|
||||
} else {
|
||||
ty = rect.y + rect.h * 0.5f + textPaddingY + animOffsetY;
|
||||
}
|
||||
|
||||
textRenderer->drawText(displayText, tx, ty, scale, textCentered, color);
|
||||
}
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
@@ -239,7 +251,7 @@ namespace ZL {
|
||||
rect.x + rect.w * 0.5f,
|
||||
rect.y + rect.h * 0.5f,
|
||||
scale,
|
||||
centered,
|
||||
textCentered,
|
||||
color
|
||||
);
|
||||
return;
|
||||
@@ -250,7 +262,7 @@ namespace ZL {
|
||||
? wrapTextByPixels(text, *textRenderer, availableWidth, scale, maxLines)
|
||||
: limitLines(text, maxLines);
|
||||
|
||||
float tx = centered ? rect.x + rect.w * 0.5f : rect.x + paddingX;
|
||||
float tx = textCentered ? rect.x + rect.w * 0.5f : rect.x + paddingX;
|
||||
float ty = rect.y + rect.h * 0.5f;
|
||||
|
||||
if (topAligned) {
|
||||
@@ -259,7 +271,7 @@ namespace ZL {
|
||||
ty = rect.y + rect.h - paddingY - static_cast<float>(fontSize);
|
||||
}
|
||||
|
||||
textRenderer->drawText(finalText, tx, ty, scale, centered, color);
|
||||
textRenderer->drawText(finalText, tx, ty, scale, textCentered, color);
|
||||
}
|
||||
|
||||
void UiSlider::buildTrackMesh() {
|
||||
@@ -623,6 +635,8 @@ namespace ZL {
|
||||
if (j.contains("textCentered")) tb->textCentered = j["textCentered"].get<bool>();
|
||||
if (j.contains("textPaddingX")) tb->textPaddingX = j["textPaddingX"].get<float>();
|
||||
if (j.contains("textPaddingY")) tb->textPaddingY = j["textPaddingY"].get<float>();
|
||||
if (j.contains("wrap")) tb->wrap = j["wrap"].get<bool>();
|
||||
if (j.contains("topAligned")) tb->topAligned = j["topAligned"].get<bool>();
|
||||
if (j.contains("color") && j["color"].is_array() && j["color"].size() == 4) {
|
||||
for (int i = 0; i < 4; ++i) tb->color[i] = j["color"][i].get<float>();
|
||||
}
|
||||
@@ -723,7 +737,7 @@ namespace ZL {
|
||||
tv->color[i] = j["color"][i].get<float>();
|
||||
}
|
||||
}
|
||||
if (j.contains("centered")) tv->centered = j["centered"].get<bool>();
|
||||
if (j.contains("textCentered")) tv->textCentered = j["textCentered"].get<bool>();
|
||||
if (j.contains("wrap")) tv->wrap = j["wrap"].get<bool>();
|
||||
if (j.contains("topAligned")) tv->topAligned = j["topAligned"].get<bool>();
|
||||
if (j.contains("paddingX")) tv->paddingX = j["paddingX"].get<float>();
|
||||
|
||||
Reference in new issue
Block a user