From c779f67967744826dfe2137a651c4239519043a9 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Thu, 27 Feb 2025 21:42:49 +0300 Subject: [PATCH] Revise birthsign tooltip layout (#6792) Make all description bits distinct widgets to allow proper padding Use spaces instead of line breaks to separate spells Enable word-wrapping for description text Make the tooltip wider and increase padding --- apps/openmw/mwgui/tooltips.cpp | 31 +++++++++++-------------- files/data/mygui/openmw_tooltips.layout | 26 +++++++++++++++++---- 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 28f0b80010..7f8de572ed 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -894,7 +894,8 @@ namespace MWGui widget->setUserString("ToolTipLayout", "BirthSignToolTip"); widget->setUserString( "ImageTexture_BirthSignImage", Misc::ResourceHelpers::correctTexturePath(sign->mTexture, vfs)); - std::string text = sign->mName + "\n#{fontcolourhtml=normal}" + sign->mDescription; + widget->setUserString("Caption_BirthSignName", sign->mName); + widget->setUserString("Caption_BirthSignDescription", sign->mDescription); std::vector abilities, powers, spells; @@ -915,26 +916,22 @@ namespace MWGui spells.push_back(spell); } - using Category = std::pair&, std::string_view>; - for (const auto& [category, label] : std::initializer_list{ - { abilities, "sBirthsignmenu1" }, { powers, "sPowers" }, { spells, "sBirthsignmenu2" } }) + using Category = std::tuple&, std::string_view, std::string_view>; + std::initializer_list categories{ { abilities, "#{sBirthsignmenu1}", "Abilities" }, + { powers, "#{sPowers}", "Powers" }, { spells, "#{sBirthsignmenu2}", "Spells" } }; + + for (const auto& [category, label, widgetName] : categories) { - bool addHeader = true; - for (const ESM::Spell* spell : category) + std::string text; + if (!category.empty()) { - if (addHeader) - { - text += "\n\n#{fontcolourhtml=header}#{"; - text += label; - text += '}'; - addHeader = false; - } - - text += "\n#{fontcolourhtml=normal}" + spell->mName; + text = std::string(label) + "\n#{fontcolourhtml=normal}"; + for (const ESM::Spell* spell : category) + text += spell->mName + ' '; + text.pop_back(); } + widget->setUserString("Caption_BirthSign" + std::string(widgetName), text); } - - widget->setUserString("Caption_BirthSignText", text); } void ToolTips::createRaceToolTip(MyGUI::Widget* widget, const ESM::Race* playerRace) diff --git a/files/data/mygui/openmw_tooltips.layout b/files/data/mygui/openmw_tooltips.layout index ce927038c2..39cfbd06e1 100644 --- a/files/data/mygui/openmw_tooltips.layout +++ b/files/data/mygui/openmw_tooltips.layout @@ -272,16 +272,34 @@ - + - + - + - + + + + + + + + + + + + + + + + + + +