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 9431ecfe00
commit 55490a9918
6 changed files with 41 additions and 36 deletions

View File

@ -1,5 +1,5 @@
<prefab name="VNTextbox" type="">
<asset type="truetype" name="font_arial" />
<asset type="truetype" name="font_main" />
<asset type="texture" name="texture_border" />
<UIBorder
@ -22,24 +22,8 @@
alignY="UI_COMPONENT_ALIGN_MIDDLE"
ref="uiLabel"
>
<font font="font_arial" size="32">
<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 font="font_main" size="32">
Hello world!
</font>
</UIRichTextLabel>
</child>

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(

View File

@ -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)

View File

@ -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