diff --git a/source/Dialog.cpp b/source/Dialog.cpp index 119cd9385658..398db716ce7d 100644 --- a/source/Dialog.cpp +++ b/source/Dialog.cpp @@ -374,7 +374,7 @@ void Dialog::Init(const string &message, Truncate truncate, bool canCancel, bool const Sprite *top = SpriteSet::Get("ui/dialog top"); // If the dialog is too tall, then switch to wide mode. int maxHeight = Screen::Height() * 3 / 4; - if(text->GetTextHeight() > maxHeight) + if(text->GetTextHeight(false) > maxHeight) { textRectSize.Y() = maxHeight; isWide = true; @@ -392,7 +392,7 @@ void Dialog::Init(const string &message, Truncate truncate, bool canCancel, bool } } else - textRectSize.Y() = text->GetTextHeight(); + textRectSize.Y() = text->GetTextHeight(false); top = SpriteSet::Get(isWide ? "ui/dialog top wide" : "ui/dialog top"); const Sprite *middle = SpriteSet::Get(isWide ? "ui/dialog middle wide" : "ui/dialog middle"); diff --git a/source/TextArea.cpp b/source/TextArea.cpp index b16fef65025d..3b32cdc25e0a 100644 --- a/source/TextArea.cpp +++ b/source/TextArea.cpp @@ -108,10 +108,10 @@ void TextArea::SetTruncate(Truncate t) -int TextArea::GetTextHeight() +int TextArea::GetTextHeight(bool trailingBreak) { Validate(); - return wrappedText.Height(); + return wrappedText.Height(trailingBreak); } diff --git a/source/TextArea.h b/source/TextArea.h index a84576cdc06e..b0cfa0ad8b2c 100644 --- a/source/TextArea.h +++ b/source/TextArea.h @@ -47,7 +47,7 @@ class TextArea : public Panel void SetAlignment(Alignment a); void SetTruncate(Truncate t); - int GetTextHeight(); + int GetTextHeight(bool trailingBreak = true); int GetLongestLineWidth(); diff --git a/source/text/WrappedText.cpp b/source/text/WrappedText.cpp index 3622d8f877ae..b32f5089a109 100644 --- a/source/text/WrappedText.cpp +++ b/source/text/WrappedText.cpp @@ -141,10 +141,11 @@ void WrappedText::Wrap(const char *str) -// Get the height of the wrapped text. -int WrappedText::Height() const +/// Get the height of the wrapped text. +/// With trailingBreak, include a paragraph break after the text. +int WrappedText::Height(bool trailingBreak) const { - return height; + return height + trailingBreak * paragraphBreak; } diff --git a/source/text/WrappedText.h b/source/text/WrappedText.h index cdb4bb52ccc5..dd455ad44ddd 100644 --- a/source/text/WrappedText.h +++ b/source/text/WrappedText.h @@ -67,8 +67,9 @@ class WrappedText { void Wrap(const std::string &str); void Wrap(const char *str); - // Get the height of the wrapped text. - int Height() const; + /// Get the height of the wrapped text. + /// With trailingBreak, include a paragraph break after the text. + int Height(bool trailingBreak = true) const; // Return the width of the longest line of the wrapped text. int LongestLineWidth() const;