I guess I fixed a bug, not really sure, moving on to restoring game functionality

This commit is contained in:
2023-06-17 20:23:30 -07:00
parent 77f5383cb9
commit 4e1e1cacfb
4 changed files with 39 additions and 28 deletions

View File

@ -23,19 +23,23 @@
ref="uiLabel"
>
<font font="font_arial" size="32">
Hello World
How <font color="RED">are</font> you today?
I'm doing great, thanks!
Thanks, me too!
Glad to hear it!
I'm glad to hear it too!
What a great day!
It sure is!
I'm glad we're friends!
Me too!
What are you up to?
Nothing much, just hanging out.
Cool, me too!
<font>Hello</font><font style="bold"> World
</font>
<font color="red">How are you today?
</font>
<font>I'm doing great, thanks!</font>
<font>
Thanks, me too!
Glad to hear it!
I'm glad to hear it too!
What a great day!
It sure is!
I'm glad we're friends!
Me too!
What are you up to?
Nothing much, just hanging out.
Cool, me too!
</font>
</font>
</UIRichTextLabel>
</child>

View File

@ -28,7 +28,7 @@ void VNTextboxScroller::onStart() {
x();
useEvent(x, this->label->eventTextChanged);
useEffect(x, visibleLines);
// useEffect(x, visibleLines);
useEvent([&](float_t delta){
auto game = this->getGame();

View File

@ -98,6 +98,8 @@ float_t UILabel::getContentHeight() {
}
void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
assertTrue(newTexts.size() < FONT_SHADER_PARTS_MAX);
int32_t nextTexture = 0;
glm::vec2 position(0, 0);
int32_t partIndex = 0;
@ -180,26 +182,31 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
// Finalize current line
lineWidth += wordWidth;
currentLine.width = lineWidth;
currentLine.quadCount = quadCountTotal - currentLine.quadStart;
currentLine.quadCount += quadCountTotal - currentLine.quadStart;
// Move to next line
position.x = 0;
position.y += realText.style.size;
lines.push_back(currentLine);
if(i != len) {
position.x = 0;
position.y += realText.style.size;
lines.push_back(currentLine);
}
// Reset line
lastSpaceCharacter = i;
wordWidth = 0.0f;
lineWidth = 0.0f;
currentLine = UILabelLine();
currentLine.quadStart = quadCountTotal;
currentLine.position = position;
currentLine.height = 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;
if(i != len) lineWidth = 0.0f;
if(i != len) {
currentLine = UILabelLine();
currentLine.quadStart = quadCountTotal;
currentLine.position = position;
currentLine.height = 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

View File

@ -7,7 +7,7 @@
#include "UIShader.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_TEXTURE_MAX 4