diff --git a/assets/games/liminal/prefabs/VNTextboxMonologue.xml b/assets/games/liminal/prefabs/VNTextboxMonologue.xml
index 6fa6db8e..a7560480 100644
--- a/assets/games/liminal/prefabs/VNTextboxMonologue.xml
+++ b/assets/games/liminal/prefabs/VNTextboxMonologue.xml
@@ -16,8 +16,9 @@
diff --git a/assets/games/liminal/scenes/prologue/ScenePrologue0.xml b/assets/games/liminal/scenes/prologue/ScenePrologue0.xml
index 6d2a1737..effedd4d 100644
--- a/assets/games/liminal/scenes/prologue/ScenePrologue0.xml
+++ b/assets/games/liminal/scenes/prologue/ScenePrologue0.xml
@@ -166,11 +166,11 @@
- "I wouldn't expect any less from our daughter,” Mother says. She smiles at me: it creases her mouth in an unnatural way. "Doesn't Ethereality look like Angelwood's Queen already?”
+ "I wouldn't expect any less from our daughter," Mother says. She smiles at me: it creases her mouth in an unnatural way. "Doesn't Ethereality look like Angelwood's Queen already?"
- My father nods his agreement. "Yes,” he tells me, "An Estridge in her finest.”
+ My father nods his agreement. "Yes," he tells me, "An Estridge in her finest."
@@ -198,7 +198,7 @@
- "Thank you,” I say. "I'm really happy you think that.”
+ "Thank you," I say. "I'm really happy you think that."
diff --git a/src/dawn/scene/components/ui/text/UILabel.cpp b/src/dawn/scene/components/ui/text/UILabel.cpp
index 4f896f01..214b4533 100644
--- a/src/dawn/scene/components/ui/text/UILabel.cpp
+++ b/src/dawn/scene/components/ui/text/UILabel.cpp
@@ -9,7 +9,8 @@
using namespace Dawn;
UILabel::UILabel(SceneItem *item) :
- UIComponentRenderable(item)
+ UIComponentRenderable(item),
+ lineHeight(1.0f)
{
}
@@ -22,6 +23,10 @@ void UILabel::onStart() {
useEvent([&]{
this->rebufferQuads(this->texts);
}, eventAlignmentUpdated);
+
+ useEffect([&]{
+ this->rebufferQuads(this->texts);
+ }, lineHeight);
}
std::vector UILabel::getUIRenderPasses() {
@@ -94,10 +99,15 @@ float_t UILabel::getContentHeight() {
h += it->height;
++it;
}
- return 1;
+ return h;
}
void UILabel::rebufferQuads(const std::vector newTexts) {
+ if(this->ignoreAlignmentUpdate) {
+ this->ignoreAlignmentUpdate = false;
+ return;
+ }
+
assertTrue(newTexts.size() <= FONT_SHADER_PARTS_MAX);
int32_t nextTexture = 0;
@@ -116,7 +126,7 @@ void UILabel::rebufferQuads(const std::vector newTexts) {
// Determine font dimensions.
auto itText = newTexts.begin();
while(itText != newTexts.end()) {
- position.y = mathMax(position.y, itText->style.size);
+ position.y = mathMax(position.y, itText->style.size * this->lineHeight);
++itText;
}
@@ -189,7 +199,7 @@ void UILabel::rebufferQuads(const std::vector newTexts) {
// Move to next line
if(i != len) {
position.x = 0;
- position.y += realText.style.size;
+ position.y += realText.style.size * this->lineHeight;
lines.push_back(currentLine);
}
@@ -203,11 +213,11 @@ void UILabel::rebufferQuads(const std::vector newTexts) {
currentLine = UILabelLine();
currentLine.quadStart = quadCountTotal;
currentLine.position = position;
- currentLine.height = realText.style.size;
+ currentLine.height = realText.style.size * this->lineHeight;
// 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;
+ currentLine.position.y -= realText.style.size * this->lineHeight;
}
};
@@ -342,6 +352,9 @@ void UILabel::rebufferQuads(const std::vector newTexts) {
textsBuffered = realNewTexts;
texts = newTexts;
+ this->ignoreAlignmentUpdate = true;
+ this->alignmentNeedsUpdating = true;
+
// Event
this->eventTextChanged.invoke();
}
\ No newline at end of file
diff --git a/src/dawn/scene/components/ui/text/UILabel.hpp b/src/dawn/scene/components/ui/text/UILabel.hpp
index c720e0eb..1d937099 100644
--- a/src/dawn/scene/components/ui/text/UILabel.hpp
+++ b/src/dawn/scene/components/ui/text/UILabel.hpp
@@ -36,11 +36,18 @@ namespace Dawn {
int32_t quadCount = 0;
};
+ enum UILabelVerticalAlign {
+ UI_LABEL_VERTICAL_ALIGN_TOP,
+ UI_LABEL_VERTICAL_ALIGN_MIDDLE,
+ UI_LABEL_VERTICAL_ALIGN_BOTTOM
+ };
+
class UILabel : public UIComponentRenderable {
private:
Mesh mesh;
FontShaderBuffer shaderBuffer;
std::map textureMap;
+ bool_t ignoreAlignmentUpdate = false;
public:
int32_t quadStart = 0;
@@ -55,6 +62,9 @@ namespace Dawn {
StateEvent<> eventTextChanged;
+ // @optional
+ StateProperty lineHeight;
+
UILabel(SceneItem *item);
void onStart() override;