fix chat line wrapping
This commit is contained in:
parent
ba161f623e
commit
1f61b683a6
1 changed files with 2 additions and 1 deletions
|
|
@ -171,6 +171,7 @@ uint32_t DrawString(const Surface &out, string_view text, const Rectangle &rect,
|
|||
else if (HasAnyOf(flags, UiFlags::AlignRight))
|
||||
characterPosition.x += rect.size.width - lineWidth;
|
||||
|
||||
int rightMargin = rect.position.x + rect.size.width;
|
||||
int bottomMargin = rect.size.height != 0 ? rect.position.y + rect.size.height : out.h();
|
||||
|
||||
if (lineHeight == -1)
|
||||
|
|
@ -195,7 +196,7 @@ uint32_t DrawString(const Surface &out, string_view text, const Rectangle &rect,
|
|||
uint32_t i = 0;
|
||||
for (; i < text.length(); i++) {
|
||||
uint8_t frame = text[i] & 0xFF;
|
||||
if (text[i] == '\n') {
|
||||
if (text[i] == '\n' || characterPosition.x > rightMargin) {
|
||||
if (characterPosition.y + lineHeight >= bottomMargin)
|
||||
break;
|
||||
characterPosition.y += lineHeight;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue