Minor bug fixing
This commit is contained in:
1 parent
1fc8120ee0
commit
0e27521bea
2 files changed
+14
-6
No files matched your search
+9
-2
@@ -844,9 +844,16 @@ namespace ZL {
|
||||
mesh.RefreshVBO();
|
||||
}
|
||||
|
||||
float UiChatBubble::computeWidth() const {
|
||||
if (!textRenderer) return MAX_WIDTH;
|
||||
const float measuredTextW = textRenderer->measureTextWidth(text, 1.0f);
|
||||
const float required = measuredTextW + CORNER_SIZE * 2.0f + PAD_X * 2.0f;
|
||||
return min(required, MAX_WIDTH);
|
||||
}
|
||||
|
||||
float UiChatBubble::computeHeight() const {
|
||||
if (!textRenderer) return CORNER_SIZE * 2 + PAD_Y * 2 + static_cast<float>(fontSize);
|
||||
const float textW = MAX_WIDTH - CORNER_SIZE * 2.0f - PAD_X * 2.0f;
|
||||
const float textW = computeWidth() - CORNER_SIZE * 2.0f - PAD_X * 2.0f;
|
||||
const std::string wrapped = wrapTextByPixels(text, *textRenderer, textW, 1.0f);
|
||||
int lines = 1;
|
||||
for (char c : wrapped) if (c == '\n') ++lines;
|
||||
@@ -2152,7 +2159,7 @@ namespace ZL {
|
||||
// Build the UiNode
|
||||
auto node = std::make_shared<UiNode>();
|
||||
node->name = nodeName;
|
||||
node->width = UiChatBubble::MAX_WIDTH;
|
||||
node->width = bubble->computeWidth();
|
||||
node->height = bubble->computeHeight();
|
||||
node->localX = 430.0f;
|
||||
node->localY = 0.0f;
|
||||
|
||||
Reference in new issue
Block a user