I guess I fixed a bug, not really sure, moving on to restoring game functionality
This commit is contained in:
@ -23,19 +23,23 @@
|
|||||||
ref="uiLabel"
|
ref="uiLabel"
|
||||||
>
|
>
|
||||||
<font font="font_arial" size="32">
|
<font font="font_arial" size="32">
|
||||||
Hello World
|
<font>Hello</font><font style="bold"> World
|
||||||
How <font color="RED">are</font> you today?
|
</font>
|
||||||
I'm doing great, thanks!
|
<font color="red">How are you today?
|
||||||
Thanks, me too!
|
</font>
|
||||||
Glad to hear it!
|
<font>I'm doing great, thanks!</font>
|
||||||
I'm glad to hear it too!
|
<font>
|
||||||
What a great day!
|
Thanks, me too!
|
||||||
It sure is!
|
Glad to hear it!
|
||||||
I'm glad we're friends!
|
I'm glad to hear it too!
|
||||||
Me too!
|
What a great day!
|
||||||
What are you up to?
|
It sure is!
|
||||||
Nothing much, just hanging out.
|
I'm glad we're friends!
|
||||||
Cool, me too!
|
Me too!
|
||||||
|
What are you up to?
|
||||||
|
Nothing much, just hanging out.
|
||||||
|
Cool, me too!
|
||||||
|
</font>
|
||||||
</font>
|
</font>
|
||||||
</UIRichTextLabel>
|
</UIRichTextLabel>
|
||||||
</child>
|
</child>
|
||||||
|
@ -28,7 +28,7 @@ void VNTextboxScroller::onStart() {
|
|||||||
x();
|
x();
|
||||||
|
|
||||||
useEvent(x, this->label->eventTextChanged);
|
useEvent(x, this->label->eventTextChanged);
|
||||||
useEffect(x, visibleLines);
|
// useEffect(x, visibleLines);
|
||||||
|
|
||||||
useEvent([&](float_t delta){
|
useEvent([&](float_t delta){
|
||||||
auto game = this->getGame();
|
auto game = this->getGame();
|
||||||
|
@ -98,6 +98,8 @@ float_t UILabel::getContentHeight() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
|
void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
|
||||||
|
assertTrue(newTexts.size() < FONT_SHADER_PARTS_MAX);
|
||||||
|
|
||||||
int32_t nextTexture = 0;
|
int32_t nextTexture = 0;
|
||||||
glm::vec2 position(0, 0);
|
glm::vec2 position(0, 0);
|
||||||
int32_t partIndex = 0;
|
int32_t partIndex = 0;
|
||||||
@ -180,26 +182,31 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
|
|||||||
// Finalize current line
|
// Finalize current line
|
||||||
lineWidth += wordWidth;
|
lineWidth += wordWidth;
|
||||||
currentLine.width = lineWidth;
|
currentLine.width = lineWidth;
|
||||||
currentLine.quadCount = quadCountTotal - currentLine.quadStart;
|
currentLine.quadCount += quadCountTotal - currentLine.quadStart;
|
||||||
|
|
||||||
// Move to next line
|
// Move to next line
|
||||||
position.x = 0;
|
if(i != len) {
|
||||||
position.y += realText.style.size;
|
position.x = 0;
|
||||||
lines.push_back(currentLine);
|
position.y += realText.style.size;
|
||||||
|
lines.push_back(currentLine);
|
||||||
|
}
|
||||||
|
|
||||||
// Reset line
|
// Reset line
|
||||||
lastSpaceCharacter = i;
|
lastSpaceCharacter = i;
|
||||||
wordWidth = 0.0f;
|
wordWidth = 0.0f;
|
||||||
lineWidth = 0.0f;
|
|
||||||
|
|
||||||
currentLine = UILabelLine();
|
if(i != len) lineWidth = 0.0f;
|
||||||
currentLine.quadStart = quadCountTotal;
|
|
||||||
currentLine.position = position;
|
if(i != len) {
|
||||||
currentLine.height = realText.style.size;
|
currentLine = UILabelLine();
|
||||||
// Here I subtract line height from the line position because we start
|
currentLine.quadStart = quadCountTotal;
|
||||||
// by moving the text down by the initial line height, so we need to
|
currentLine.position = position;
|
||||||
// compensate for that.
|
currentLine.height = realText.style.size;
|
||||||
currentLine.position.y -= realText.style.size;
|
// Here I subtract line height from the line position because we start
|
||||||
|
// by moving the text down by the initial line height, so we need to
|
||||||
|
// compensate for that.
|
||||||
|
currentLine.position.y -= realText.style.size;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Now, iterate each character
|
// Now, iterate each character
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "UIShader.hpp"
|
#include "UIShader.hpp"
|
||||||
#include "util/macro.hpp"
|
#include "util/macro.hpp"
|
||||||
|
|
||||||
#define FONT_SHADER_PARTS_MAX 4
|
#define FONT_SHADER_PARTS_MAX 8
|
||||||
#define FONT_SHADER_QUADS_MAX 1024
|
#define FONT_SHADER_QUADS_MAX 1024
|
||||||
#define FONT_SHADER_TEXTURE_MAX 4
|
#define FONT_SHADER_TEXTURE_MAX 4
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user