From e369ab941e95a3884894bbd5c1eb88de9816bfac Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Thu, 19 Sep 2024 04:25:36 +0300 Subject: [PATCH] Fix word-wrapping for dialogue topics with changed skin --- apps/openmw/mwgui/dialogue.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 56d2699175..2e052de768 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -794,28 +794,31 @@ namespace MWGui if (!Settings::gui().mColorTopicEnable) return; - const std::string_view specificSkin = "MW_ListLine_Specific"; - const std::string_view exhaustedSkin = "MW_ListLine_Exhausted"; - for (const std::string& keyword : mKeywords) { int flag = MWBase::Environment::get().getDialogueManager()->getTopicFlag(ESM::RefId::stringRefId(keyword)); MyGUI::Button* button = mTopicsList->getItemWidget(keyword); - const auto holdCaption = button->getCaption(); + const auto oldCaption = button->getCaption(); + const MyGUI::IntSize oldSize = button->getSize(); + bool changed = false; if (flag & MWBase::DialogueManager::TopicType::Specific) { - button->changeWidgetSkin(specificSkin); - button->setCaption(holdCaption); - int height = button->getTextSize().height; - button->setSize(MyGUI::IntSize(button->getSize().width, height)); + button->changeWidgetSkin("MW_ListLine_Specific"); + changed = true; } else if (flag & MWBase::DialogueManager::TopicType::Exhausted) { - button->changeWidgetSkin(exhaustedSkin); - button->setCaption(holdCaption); - int height = button->getTextSize().height; - button->setSize(MyGUI::IntSize(button->getSize().width, height)); + button->changeWidgetSkin("MW_ListLine_Exhausted"); + changed = true; + } + + if (changed) + { + button->setCaption(oldCaption); + button->getSubWidgetText()->setWordWrap(true); + button->getSubWidgetText()->setTextAlign(MyGUI::Align::Left); + button->setSize(oldSize); } } }