Fixed bug with empty string, allowing local fonts to be loaded.

This commit is contained in:
2023-06-17 22:15:57 -07:00
parent 6a202edf23
commit 0ea7f1d749
5 changed files with 38 additions and 17 deletions

View File

@ -36,6 +36,11 @@ void VNTextboxScroller::onStart() {
this->timeCharacter += delta;
if(this->hasRevealedAllCurrentCharacters()) {
if(this->hasRevealedAllCharacters()) {
if(!this->label->lines.empty()) {
this->label->quadStart = this->label->lines[this->lineCurrent].quadStart;
}
this->label->quadCount = this->getTotalQuadsToBeRevealed();
if(!this->readyToClose) {
this->readyToClose = true;
this->eventReadyToClose.invoke();
@ -43,7 +48,9 @@ void VNTextboxScroller::onStart() {
} else {
if(game->inputManager.isPressed(INPUT_BIND_ACCEPT)) {
this->lineCurrent += this->visibleLines;
this->label->quadStart = this->label->lines[this->lineCurrent].quadStart;
if(!this->label->lines.empty()) {
this->label->quadStart = this->label->lines[this->lineCurrent].quadStart;
}
this->label->quadCount = 0;
this->timeCharacter = 0.0f;
@ -69,7 +76,7 @@ void VNTextboxScroller::onStart() {
}, getScene()->eventSceneUpdate);
}
bool_t VNTextboxScroller::hasRevealedAllCurrentCharacters() {
int32_t VNTextboxScroller::getTotalQuadsToBeRevealed() {
int32_t quadsTotal = 0;
for(
size_t i = this->lineCurrent;
@ -81,7 +88,11 @@ bool_t VNTextboxScroller::hasRevealedAllCurrentCharacters() {
) {
quadsTotal += this->label->lines[i].quadCount;
}
return mathFloor<int32_t>(this->timeCharacter) >= quadsTotal;
return quadsTotal;
}
bool_t VNTextboxScroller::hasRevealedAllCurrentCharacters() {
return mathFloor<int32_t>(this->timeCharacter) >= this->getTotalQuadsToBeRevealed();
}
bool_t VNTextboxScroller::hasRevealedAllCharacters() {

View File

@ -31,6 +31,14 @@ namespace Dawn {
VNTextboxScroller(SceneItem *item);
virtual void onStart() override;
/**
* Returns the count of quads, relative to the current visible line to be
* revealed based on the current time.
*
* @return The count of quads to be revealed.
*/
int32_t getTotalQuadsToBeRevealed();
/**
* Returns true if all of the characters that can be made visible for the
* current textbox size have finished revealing, or false if not.

View File

@ -296,6 +296,8 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
realNewTexts.push_back(realText);
}
lines.push_back(currentLine);
// Create mesh
if(!vertices.empty()) {
this->mesh.createBuffers(