From 0ea7f1d7497cccae46701a552e517b095ae306f9 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Sat, 17 Jun 2023 22:15:57 -0700 Subject: [PATCH] Fixed bug with empty string, allowing local fonts to be loaded. --- .../games/vn/components/VNTextboxScroller.cpp | 17 ++++++++++++++--- .../games/vn/components/VNTextboxScroller.hpp | 8 ++++++++ src/dawn/scene/components/ui/text/UILabel.cpp | 2 ++ src/dawnliminal/CMakeLists.txt | 14 ++------------ src/dawntools/truetypetool/CMakeLists.txt | 14 ++++++++++++-- 5 files changed, 38 insertions(+), 17 deletions(-) diff --git a/src/dawn/games/vn/components/VNTextboxScroller.cpp b/src/dawn/games/vn/components/VNTextboxScroller.cpp index 5433a6fb..fd3e5be7 100644 --- a/src/dawn/games/vn/components/VNTextboxScroller.cpp +++ b/src/dawn/games/vn/components/VNTextboxScroller.cpp @@ -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(this->timeCharacter) >= quadsTotal; + return quadsTotal; +} + +bool_t VNTextboxScroller::hasRevealedAllCurrentCharacters() { + return mathFloor(this->timeCharacter) >= this->getTotalQuadsToBeRevealed(); } bool_t VNTextboxScroller::hasRevealedAllCharacters() { diff --git a/src/dawn/games/vn/components/VNTextboxScroller.hpp b/src/dawn/games/vn/components/VNTextboxScroller.hpp index 19562bd3..3bf4b868 100644 --- a/src/dawn/games/vn/components/VNTextboxScroller.hpp +++ b/src/dawn/games/vn/components/VNTextboxScroller.hpp @@ -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. diff --git a/src/dawn/scene/components/ui/text/UILabel.cpp b/src/dawn/scene/components/ui/text/UILabel.cpp index 7f27f5fd..b18d6cb4 100644 --- a/src/dawn/scene/components/ui/text/UILabel.cpp +++ b/src/dawn/scene/components/ui/text/UILabel.cpp @@ -296,6 +296,8 @@ void UILabel::rebufferQuads(const std::vector newTexts) { realNewTexts.push_back(realText); } + lines.push_back(currentLine); + // Create mesh if(!vertices.empty()) { this->mesh.createBuffers( diff --git a/src/dawnliminal/CMakeLists.txt b/src/dawnliminal/CMakeLists.txt index e30099e1..23f69400 100644 --- a/src/dawnliminal/CMakeLists.txt +++ b/src/dawnliminal/CMakeLists.txt @@ -19,20 +19,10 @@ add_subdirectory(save) # Assets set(LIMINAL_ASSETS_DIR ${DAWN_ASSETS_DIR}/games/liminal) -# tool_truetype(font_main FILE=${LIMINAL_ASSETS_DIR}/fonts/Ysabeau-Medium.ttf) tool_texture(texture_eth FILE=${LIMINAL_ASSETS_DIR}/textures/eth.png) tool_texture(texture_border FILE=${LIMINAL_ASSETS_DIR}/textures/texture_test.png) - -tool_truetype(font_arial - REGULAR="/usr/share/fonts/TTF/arial.ttf" - BOLD="/usr/share/fonts/TTF/arialbd.ttf" - ITALICS="/usr/share/fonts/TTF/ariali.ttf" - BOLD_ITALICS="/usr/share/fonts/TTF/arialbi.ttf" - - # REGULAR="C:\\Windows\\Fonts\\arial.ttf" - # BOLD="C:\\Windows\\Fonts\\arialbd.ttf" - # ITALICS="C:\\Windows\\Fonts\\ariali.ttf" - # BOLD_ITALICS="C:\\Windows\\Fonts\\arialbi.ttf" +tool_truetype(font_main + REGULAR=${LIMINAL_ASSETS_DIR}/fonts/Ysabeau-Medium.ttf ) tool_scene(${LIMINAL_ASSETS_DIR}/scenes/SceneBase.xml) diff --git a/src/dawntools/truetypetool/CMakeLists.txt b/src/dawntools/truetypetool/CMakeLists.txt index f29a225c..960d3257 100644 --- a/src/dawntools/truetypetool/CMakeLists.txt +++ b/src/dawntools/truetypetool/CMakeLists.txt @@ -48,13 +48,23 @@ function(tool_truetype target) endif() endforeach() - # Check for missing args - set(DEPS "") if(DAWN_BUILD_TOOLS) set(DEPS truetypetool) endif() + if(DEFINED REGULAR) + set(REGULAR "${DAWN_ASSETS_SOURCE_DIR}/${REGULAR}") + endif() + if(DEFINED BOLD) + set(BOLD "${DAWN_ASSETS_SOURCE_DIR}/${BOLD}") + endif() + if(DEFINED ITALICS) + set(ITALICS "${DAWN_ASSETS_SOURCE_DIR}/${ITALICS}") + endif() + if(DEFINED BOLD_ITALICS) + set(BOLD_ITALICS "${DAWN_ASSETS_SOURCE_DIR}/${BOLD_ITALICS}") + endif() add_custom_target(${target} COMMAND truetypetool