From e7ae84ee2a020d06c1e447f788e7be32e6e296e9 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Wed, 4 Jan 2023 20:50:21 -0500 Subject: [PATCH] Fix large string dialogs not wrapping text and expanding to crazy widths --- src/dialogxml/dialogs/3choice.cpp | 1 + src/dialogxml/widgets/message.cpp | 5 +++++ src/dialogxml/widgets/message.hpp | 1 + 3 files changed, 7 insertions(+) diff --git a/src/dialogxml/dialogs/3choice.cpp b/src/dialogxml/dialogs/3choice.cpp index c6a568fc..c257533e 100644 --- a/src/dialogxml/dialogs/3choice.cpp +++ b/src/dialogxml/dialogs/3choice.cpp @@ -86,6 +86,7 @@ void cThreeChoice::init_strings(std::vector& strings, unsigned shor cur_text_rect.bottom = cur_text_rect.top + str_height; cTextMsg* str = new cTextMsg(*me); str->setText(strings[j]); + str->setFixed(true, false); me->add(str, cur_text_rect, sout.str()); cur_text_rect.top = cur_text_rect.bottom + 8; } diff --git a/src/dialogxml/widgets/message.cpp b/src/dialogxml/widgets/message.cpp index a427ba7e..39bee37d 100644 --- a/src/dialogxml/widgets/message.cpp +++ b/src/dialogxml/widgets/message.cpp @@ -90,6 +90,11 @@ void cTextMsg::validatePostParse(ticpp::Element& who, std::string fname, const s if(attrs.count("height")) fixedHeight = true; } +void cTextMsg::setFixed(bool w, bool h) { + fixedWidth = w; + fixedHeight = h; +} + void cTextMsg::recalcRect() { if(fixedWidth && fixedHeight) return; TextStyle style; diff --git a/src/dialogxml/widgets/message.hpp b/src/dialogxml/widgets/message.hpp index 297e4843..44a59751 100644 --- a/src/dialogxml/widgets/message.hpp +++ b/src/dialogxml/widgets/message.hpp @@ -36,6 +36,7 @@ public: bool isClickable() override; bool isFocusable() override; bool isScrollable() override; + void setFixed(bool w, bool h); virtual ~cTextMsg(); void draw() override; void recalcRect() override;