From 02730af391922f37663f1c39e8a4df42cb8ddc42 Mon Sep 17 00:00:00 2001 From: Kagernac Date: Sun, 19 May 2024 14:43:41 -0700 Subject: [PATCH 1/9] Changing the skin of the widget seems to be the easiest way to have the choices in the list react to specific conditions and interactions. Seems that changing the skin modifies some size properties so they had to be reset. Needed to create a specific skin in order to prevent modifying unintended text. The exhausted color is not referenced by the settings.cfg, the user will need to modify the color in the skin file. Edit: Fixed the coding convention issues and converted the tabs into spaces in the .xml. Closed the previous merge request out of confusion, sorry new to Git. --- apps/openmw/mwgui/dialogue.cpp | 19 +++++++++++++++---- files/data/mygui/openmw_list.skin.xml | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 56f69eb906..ba40fa92e1 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -794,18 +794,29 @@ namespace MWGui if (!Settings::gui().mColorTopicEnable) return; - const MyGUI::Colour& specialColour = Settings::gui().mColorTopicSpecific; - const MyGUI::Colour& oldColour = Settings::gui().mColorTopicExhausted; + std::string specificSkin = "MW_ListLine_Specific"; + std::string 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(); if (flag & MWBase::DialogueManager::TopicType::Specific) - button->getSubWidgetText()->setTextColour(specialColour); + { + button->changeWidgetSkin(specificSkin); + button->setCaption(holdCaption); + int height = button->getTextSize().height; + button->setSize(MyGUI::IntSize(button->getSize().width, height)); + } else if (flag & MWBase::DialogueManager::TopicType::Exhausted) - button->getSubWidgetText()->setTextColour(oldColour); + { + button->changeWidgetSkin(exhaustedSkin); + button->setCaption(holdCaption); + int height = button->getTextSize().height; + button->setSize(MyGUI::IntSize(button->getSize().width, height)); + } } } diff --git a/files/data/mygui/openmw_list.skin.xml b/files/data/mygui/openmw_list.skin.xml index 75f4b9e850..877c827833 100644 --- a/files/data/mygui/openmw_list.skin.xml +++ b/files/data/mygui/openmw_list.skin.xml @@ -124,6 +124,28 @@ + + + + + + + + + + + + + + + + + + + + + + From f9577d904cf0b2c351919b3e70a47020470cb056 Mon Sep 17 00:00:00 2001 From: Kagernac Date: Wed, 22 May 2024 20:25:58 -0700 Subject: [PATCH 2/9] This commit introduces six new color settings for dialogue topic keywords referencing settings.cfg and settings-default.cfg. These settings work similarly to the color references found in openmw.cfg and Morrowind.ini. Changes include: Removal of deprecated settings: color topic specific color topic exhausted Addition of six new color settings to settings.cfg and settings-default.cfg Updated description in settings-default.cfg to reflect the new color format --- apps/openmw/mwgui/textcolours.cpp | 8 ++++++++ apps/openmw/mwgui/textcolours.hpp | 8 ++++++++ components/fallback/validate.cpp | 4 +++- components/settings/categories/gui.hpp | 8 ++++++-- components/widgets/tags.cpp | 9 +++++++-- files/data/mygui/openmw_list.skin.xml | 16 ++++++++-------- files/settings-default.cfg | 13 +++++++++---- 7 files changed, 49 insertions(+), 17 deletions(-) diff --git a/apps/openmw/mwgui/textcolours.cpp b/apps/openmw/mwgui/textcolours.cpp index 77afa5e265..c3c293297c 100644 --- a/apps/openmw/mwgui/textcolours.cpp +++ b/apps/openmw/mwgui/textcolours.cpp @@ -32,5 +32,13 @@ namespace MWGui journalTopic = getTextColour("journal_topic"); journalTopicOver = getTextColour("journal_topic_over"); journalTopicPressed = getTextColour("journal_topic_pressed"); + + specific = getTextColour("specific"); + specificOver = getTextColour("specific_over"); + specificPressed = getTextColour("specific_pressed"); + + exhausted = getTextColour("exhausted"); + exhaustedOver = getTextColour("exhausted_over"); + exhaustedPressed = getTextColour("exhausted_pressed"); } } diff --git a/apps/openmw/mwgui/textcolours.hpp b/apps/openmw/mwgui/textcolours.hpp index 83bc1d3f5a..add251a1c9 100644 --- a/apps/openmw/mwgui/textcolours.hpp +++ b/apps/openmw/mwgui/textcolours.hpp @@ -27,6 +27,14 @@ namespace MWGui MyGUI::Colour journalTopicOver; MyGUI::Colour journalTopicPressed; + MyGUI::Colour specific; + MyGUI::Colour specificOver; + MyGUI::Colour specificPressed; + + MyGUI::Colour exhausted; + MyGUI::Colour exhaustedOver; + MyGUI::Colour exhaustedPressed; + public: void loadColours(); }; diff --git a/components/fallback/validate.cpp b/components/fallback/validate.cpp index 571f0f9b19..5728880354 100644 --- a/components/fallback/validate.cpp +++ b/components/fallback/validate.cpp @@ -109,7 +109,9 @@ static const std::set allowedKeysNonNumeric = { "Blood_Model_0 "FontColor_color_link", "FontColor_color_link_over", "FontColor_color_link_pressed", "FontColor_color_magic", "FontColor_color_magic_fill", "FontColor_color_misc", "FontColor_color_negative", "FontColor_color_normal", "FontColor_color_normal_over", "FontColor_color_normal_pressed", "FontColor_color_notify", - "FontColor_color_positive", "FontColor_color_weapon_fill", "Fonts_Font_0", "Fonts_Font_1", "Fonts_Font_2", + "FontColor_color_positive", "FontColor_color_weapon_fill", "FontColor_color_specific", "FontColor_color_specific_over", + "FontColor_color_specific_pressed", "FontColor_color_exhausted", "FontColor_color_exhausted_over", "FontColor_color_exhausted_pressed", + "Fonts_Font_0", "Fonts_Font_1", "Fonts_Font_2", "Level_Up_Default", "Moons_Script_Color", "Movies_Company_Logo", "Movies_Morrowind_Logo", "Movies_New_Game", "Question_10_AnswerOne", "Question_10_AnswerThree", "Question_10_AnswerTwo", "Question_10_Question", "Question_10_Sound", "Question_1_AnswerOne", "Question_1_AnswerThree", "Question_1_AnswerTwo", diff --git a/components/settings/categories/gui.hpp b/components/settings/categories/gui.hpp index 4a5e50fd8a..88f6924638 100644 --- a/components/settings/categories/gui.hpp +++ b/components/settings/categories/gui.hpp @@ -32,8 +32,12 @@ namespace Settings SettingValue mColorCrosshairOwned{ mIndex, "GUI", "color crosshair owned" }; SettingValue mKeyboardNavigation{ mIndex, "GUI", "keyboard navigation" }; SettingValue mColorTopicEnable{ mIndex, "GUI", "color topic enable" }; - SettingValue mColorTopicSpecific{ mIndex, "GUI", "color topic specific" }; - SettingValue mColorTopicExhausted{ mIndex, "GUI", "color topic exhausted" }; + SettingValue mColorTopicSpecific{ mIndex, "GUI", "FontColor_color_specific" }; + SettingValue mColorTopicSpecificOver{ mIndex, "GUI", "FontColor_color_specific_over" }; + SettingValue mColorTopicSpecificPressed{ mIndex, "GUI", "FontColor_color_specific_pressed" }; + SettingValue mColorTopicExhausted{ mIndex, "GUI", "FontColor_color_exhausted" }; + SettingValue mColorTopicExhaustedOver{ mIndex, "GUI", "FontColor_color_exhausted_over" }; + SettingValue mColorTopicExhaustedPressed{ mIndex, "GUI", "FontColor_color_exhausted_pressed" }; }; } diff --git a/components/widgets/tags.cpp b/components/widgets/tags.cpp index 3fe72480b7..e10cbeda88 100644 --- a/components/widgets/tags.cpp +++ b/components/widgets/tags.cpp @@ -1,5 +1,6 @@ #include "tags.hpp" +#include #include #include @@ -10,7 +11,6 @@ namespace Gui bool replaceTag(std::string_view tag, MyGUI::UString& out) { std::string_view fontcolour = "fontcolour="; - std::string_view fontcolourhtml = "fontcolourhtml="; if (tag.starts_with(fontcolour)) @@ -19,7 +19,12 @@ namespace Gui fallbackName += tag.substr(fontcolour.length()); std::string_view str = Fallback::Map::getString(fallbackName); if (str.empty()) - throw std::runtime_error("Unknown fallback name: " + fallbackName); + { + std::string_view category = "GUI"; + str = Settings::Manager::getString(fallbackName, category); + if (str.empty()) + throw std::runtime_error("Unable to map setting to value: " + fallbackName); + } std::string ret[3]; unsigned int j = 0; diff --git a/files/data/mygui/openmw_list.skin.xml b/files/data/mygui/openmw_list.skin.xml index 877c827833..10524c6d1f 100644 --- a/files/data/mygui/openmw_list.skin.xml +++ b/files/data/mygui/openmw_list.skin.xml @@ -127,22 +127,22 @@ - + - - - + + + - + - - - + + + diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 9d15f44401..3f2963dc17 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -218,14 +218,19 @@ keyboard navigation = true color topic enable = false # The color of dialogue topic keywords that gives unique actor responses -# Format R G B A or empty for no special formatting +# Format (R,G,B) (255,255,255) or empty for no special formatting # Default to blue -color topic specific = 0.45 0.5 0.8 1 +FontColor_color_specific = 112,126,207 +FontColor_color_specific_over = 143,155,218 +FontColor_color_specific_pressed = 175,184,228 + # The color of dialogue topic keywords that gives already read responses -# Format R G B A or empty for no special formatting +# Format (R,G,B) (255,255,255) or empty for no special formatting # Default to grey -color topic exhausted = 0.3 0.3 0.3 1 +FontColor_color_exhausted = 103,103,111 +FontColor_color_exhausted_over = 170,170,188 +FontColor_color_exhausted_pressed = 69,69,85 [HUD] From 3e6ccfce1ff7b384d9f7b5b33fd42f139767fee7 Mon Sep 17 00:00:00 2001 From: Kagernac Date: Tue, 4 Jun 2024 23:14:44 -0700 Subject: [PATCH 3/9] Took @Capostrophic's suggestion about leveraging a new tag format Removed the color settings from Textcolours, they are unneccessary Removed the Fallback workaround as a dedicated else condition was created with the new tag "fontcolouroptional". This code section has no involvement in Fallback openmw_list.skin.xml was updated to reflect this new tag settings.cfg was updated with the updated variable names --- apps/openmw/mwgui/textcolours.cpp | 8 +------ apps/openmw/mwgui/textcolours.hpp | 8 ------- components/fallback/validate.cpp | 3 +-- components/settings/categories/gui.hpp | 12 +++++----- components/widgets/tags.cpp | 32 +++++++++++++++++++++----- files/data/mygui/openmw_list.skin.xml | 12 +++++----- files/settings-default.cfg | 12 +++++----- 7 files changed, 46 insertions(+), 41 deletions(-) diff --git a/apps/openmw/mwgui/textcolours.cpp b/apps/openmw/mwgui/textcolours.cpp index c3c293297c..981817a4a9 100644 --- a/apps/openmw/mwgui/textcolours.cpp +++ b/apps/openmw/mwgui/textcolours.cpp @@ -11,6 +11,7 @@ namespace MWGui return MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=" + type + "}")); } + void TextColours::loadColours() { header = getTextColour("header"); @@ -33,12 +34,5 @@ namespace MWGui journalTopicOver = getTextColour("journal_topic_over"); journalTopicPressed = getTextColour("journal_topic_pressed"); - specific = getTextColour("specific"); - specificOver = getTextColour("specific_over"); - specificPressed = getTextColour("specific_pressed"); - - exhausted = getTextColour("exhausted"); - exhaustedOver = getTextColour("exhausted_over"); - exhaustedPressed = getTextColour("exhausted_pressed"); } } diff --git a/apps/openmw/mwgui/textcolours.hpp b/apps/openmw/mwgui/textcolours.hpp index add251a1c9..83bc1d3f5a 100644 --- a/apps/openmw/mwgui/textcolours.hpp +++ b/apps/openmw/mwgui/textcolours.hpp @@ -27,14 +27,6 @@ namespace MWGui MyGUI::Colour journalTopicOver; MyGUI::Colour journalTopicPressed; - MyGUI::Colour specific; - MyGUI::Colour specificOver; - MyGUI::Colour specificPressed; - - MyGUI::Colour exhausted; - MyGUI::Colour exhaustedOver; - MyGUI::Colour exhaustedPressed; - public: void loadColours(); }; diff --git a/components/fallback/validate.cpp b/components/fallback/validate.cpp index 5728880354..f6868e56f4 100644 --- a/components/fallback/validate.cpp +++ b/components/fallback/validate.cpp @@ -109,8 +109,7 @@ static const std::set allowedKeysNonNumeric = { "Blood_Model_0 "FontColor_color_link", "FontColor_color_link_over", "FontColor_color_link_pressed", "FontColor_color_magic", "FontColor_color_magic_fill", "FontColor_color_misc", "FontColor_color_negative", "FontColor_color_normal", "FontColor_color_normal_over", "FontColor_color_normal_pressed", "FontColor_color_notify", - "FontColor_color_positive", "FontColor_color_weapon_fill", "FontColor_color_specific", "FontColor_color_specific_over", - "FontColor_color_specific_pressed", "FontColor_color_exhausted", "FontColor_color_exhausted_over", "FontColor_color_exhausted_pressed", + "FontColor_color_positive", "FontColor_color_weapon_fill", "Fonts_Font_0", "Fonts_Font_1", "Fonts_Font_2", "Level_Up_Default", "Moons_Script_Color", "Movies_Company_Logo", "Movies_Morrowind_Logo", "Movies_New_Game", "Question_10_AnswerOne", "Question_10_AnswerThree", "Question_10_AnswerTwo", "Question_10_Question", diff --git a/components/settings/categories/gui.hpp b/components/settings/categories/gui.hpp index 88f6924638..a26364c5dd 100644 --- a/components/settings/categories/gui.hpp +++ b/components/settings/categories/gui.hpp @@ -32,12 +32,12 @@ namespace Settings SettingValue mColorCrosshairOwned{ mIndex, "GUI", "color crosshair owned" }; SettingValue mKeyboardNavigation{ mIndex, "GUI", "keyboard navigation" }; SettingValue mColorTopicEnable{ mIndex, "GUI", "color topic enable" }; - SettingValue mColorTopicSpecific{ mIndex, "GUI", "FontColor_color_specific" }; - SettingValue mColorTopicSpecificOver{ mIndex, "GUI", "FontColor_color_specific_over" }; - SettingValue mColorTopicSpecificPressed{ mIndex, "GUI", "FontColor_color_specific_pressed" }; - SettingValue mColorTopicExhausted{ mIndex, "GUI", "FontColor_color_exhausted" }; - SettingValue mColorTopicExhaustedOver{ mIndex, "GUI", "FontColor_color_exhausted_over" }; - SettingValue mColorTopicExhaustedPressed{ mIndex, "GUI", "FontColor_color_exhausted_pressed" }; + SettingValue mColorTopicSpecific{ mIndex, "GUI", "color topic specific" }; + SettingValue mColorTopicSpecificOver{ mIndex, "GUI", "color topic specific over" }; + SettingValue mColorTopicSpecificPressed{ mIndex, "GUI", "color topic specific pressed" }; + SettingValue mColorTopicExhausted{ mIndex, "GUI", "color topic exhausted" }; + SettingValue mColorTopicExhaustedOver{ mIndex, "GUI", "color topic exhausted over" }; + SettingValue mColorTopicExhaustedPressed{ mIndex, "GUI", "color topic exhausted pressed" }; }; } diff --git a/components/widgets/tags.cpp b/components/widgets/tags.cpp index e10cbeda88..ae55e4b76d 100644 --- a/components/widgets/tags.cpp +++ b/components/widgets/tags.cpp @@ -12,6 +12,7 @@ namespace Gui { std::string_view fontcolour = "fontcolour="; std::string_view fontcolourhtml = "fontcolourhtml="; + std::string_view fontcolouroptional = "fontcolouroptional="; if (tag.starts_with(fontcolour)) { @@ -19,12 +20,7 @@ namespace Gui fallbackName += tag.substr(fontcolour.length()); std::string_view str = Fallback::Map::getString(fallbackName); if (str.empty()) - { - std::string_view category = "GUI"; - str = Settings::Manager::getString(fallbackName, category); - if (str.empty()) - throw std::runtime_error("Unable to map setting to value: " + fallbackName); - } + throw std::runtime_error("Unable to map setting to value: " + fallbackName); std::string ret[3]; unsigned int j = 0; @@ -63,6 +59,30 @@ namespace Gui out = html.str(); return true; } + else if (tag.starts_with(fontcolouroptional)) + { + std::string settingprefix = "color topic "; + std::string_view category = "GUI"; + settingprefix += tag.substr(fontcolouroptional.length()); + std::replace(settingprefix.begin(), settingprefix.end(), '_', ' '); + std::string str = Settings::Manager::getString(settingprefix, category); + if (str.empty()) + throw std::runtime_error("Unable to map setting to value: " + settingprefix); + + std::string ret[3]; + unsigned int j = 0; + for (unsigned int i = 0; i < str.length(); ++i) + { + if (str[i] == ',') + j++; + else if (str[i] != ' ') + ret[j] += str[i]; + } + MyGUI::Colour col(MyGUI::utility::parseInt(ret[0]) / 255.f, MyGUI::utility::parseInt(ret[1]) / 255.f, + MyGUI::utility::parseInt(ret[2]) / 255.f); + out = col.print(); + return true; + } return false; } diff --git a/files/data/mygui/openmw_list.skin.xml b/files/data/mygui/openmw_list.skin.xml index 10524c6d1f..0e57f44992 100644 --- a/files/data/mygui/openmw_list.skin.xml +++ b/files/data/mygui/openmw_list.skin.xml @@ -129,9 +129,9 @@ - - - + + + @@ -140,9 +140,9 @@ - - - + + + diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 3f2963dc17..9a262260e7 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -220,17 +220,17 @@ color topic enable = false # The color of dialogue topic keywords that gives unique actor responses # Format (R,G,B) (255,255,255) or empty for no special formatting # Default to blue -FontColor_color_specific = 112,126,207 -FontColor_color_specific_over = 143,155,218 -FontColor_color_specific_pressed = 175,184,228 +color topic specific = 112,126,207 +color topic specific over = 143,155,218 +color topic specific pressed = 175,184,228 # The color of dialogue topic keywords that gives already read responses # Format (R,G,B) (255,255,255) or empty for no special formatting # Default to grey -FontColor_color_exhausted = 103,103,111 -FontColor_color_exhausted_over = 170,170,188 -FontColor_color_exhausted_pressed = 69,69,85 +color topic exhausted = 103,103,111 +color topic exhausted over = 170,170,188 +color topic exhausted pressed= 69,69,85 [HUD] From aca39c919fce6d788407603344bdc8c099b1e7fe Mon Sep 17 00:00:00 2001 From: Kagernac Date: Wed, 5 Jun 2024 20:26:45 -0700 Subject: [PATCH 4/9] Changed the tagname to match the values in settings.cfg Changed the values from int to float in settings.cfg. This is consistent with the older format. The prefix is no longer referenced and hardcoded. There were four original values in the old color format, the parsing had to be modified to account for floats and four values. --- components/widgets/tags.cpp | 17 ++++++++--------- files/data/mygui/openmw_list.skin.xml | 12 ++++++------ files/settings-default.cfg | 12 ++++++------ 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/components/widgets/tags.cpp b/components/widgets/tags.cpp index ae55e4b76d..1477470024 100644 --- a/components/widgets/tags.cpp +++ b/components/widgets/tags.cpp @@ -61,25 +61,24 @@ namespace Gui } else if (tag.starts_with(fontcolouroptional)) { - std::string settingprefix = "color topic "; std::string_view category = "GUI"; - settingprefix += tag.substr(fontcolouroptional.length()); - std::replace(settingprefix.begin(), settingprefix.end(), '_', ' '); - std::string str = Settings::Manager::getString(settingprefix, category); + std::string colortag = ""; + colortag += tag.substr(fontcolouroptional.length()); + std::string str = Settings::Manager::getString(colortag, category); if (str.empty()) - throw std::runtime_error("Unable to map setting to value: " + settingprefix); + throw std::runtime_error("Unable to map setting to value: " + colortag); - std::string ret[3]; + std::string ret[4]; unsigned int j = 0; for (unsigned int i = 0; i < str.length(); ++i) { - if (str[i] == ',') + if (str[i] == ' ') j++; else if (str[i] != ' ') ret[j] += str[i]; } - MyGUI::Colour col(MyGUI::utility::parseInt(ret[0]) / 255.f, MyGUI::utility::parseInt(ret[1]) / 255.f, - MyGUI::utility::parseInt(ret[2]) / 255.f); + MyGUI::Colour col(MyGUI::utility::parseFloat(ret[0]), MyGUI::utility::parseFloat(ret[1]), + MyGUI::utility::parseFloat(ret[2]), MyGUI::utility::parseFloat(ret[3])); out = col.print(); return true; } diff --git a/files/data/mygui/openmw_list.skin.xml b/files/data/mygui/openmw_list.skin.xml index 0e57f44992..45551429ed 100644 --- a/files/data/mygui/openmw_list.skin.xml +++ b/files/data/mygui/openmw_list.skin.xml @@ -129,9 +129,9 @@ - - - + + + @@ -140,9 +140,9 @@ - - - + + + diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 9a262260e7..1efcec8db4 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -220,17 +220,17 @@ color topic enable = false # The color of dialogue topic keywords that gives unique actor responses # Format (R,G,B) (255,255,255) or empty for no special formatting # Default to blue -color topic specific = 112,126,207 -color topic specific over = 143,155,218 -color topic specific pressed = 175,184,228 +color topic specific = 0.45 0.5 0.8 1 +color topic specific over = 0.58 0.62 0.85 1 +color topic specific pressed = 0.29 0.36 0.75 1 # The color of dialogue topic keywords that gives already read responses # Format (R,G,B) (255,255,255) or empty for no special formatting # Default to grey -color topic exhausted = 103,103,111 -color topic exhausted over = 170,170,188 -color topic exhausted pressed= 69,69,85 +color topic exhausted = 0.3 0.3 0.3 1 +color topic exhausted over = 0.56 0.56 0.56 1 +color topic exhausted pressed= 0.44 0.44 0.44 1 [HUD] From 7d403089ec01ffc6d1429f6ebf401949152ada3c Mon Sep 17 00:00:00 2001 From: Kagernac Date: Fri, 7 Jun 2024 18:38:32 -0700 Subject: [PATCH 5/9] Cleaner implementation Retrieved the Colours straight from Settings Made tagname clearer in openmw_list.skin.xml Fixed minor formatting issue in validate.cpp, textcolours.cpp Updated skin variables to be const and string_view --- apps/openmw/mwgui/dialogue.cpp | 4 ++-- apps/openmw/mwgui/textcolours.cpp | 2 -- components/fallback/validate.cpp | 3 +-- components/widgets/tags.cpp | 24 ++++-------------------- files/data/mygui/openmw_list.skin.xml | 12 ++++++------ 5 files changed, 13 insertions(+), 32 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index ba40fa92e1..56d2699175 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -794,8 +794,8 @@ namespace MWGui if (!Settings::gui().mColorTopicEnable) return; - std::string specificSkin = "MW_ListLine_Specific"; - std::string exhaustedSkin = "MW_ListLine_Exhausted"; + const std::string_view specificSkin = "MW_ListLine_Specific"; + const std::string_view exhaustedSkin = "MW_ListLine_Exhausted"; for (const std::string& keyword : mKeywords) { diff --git a/apps/openmw/mwgui/textcolours.cpp b/apps/openmw/mwgui/textcolours.cpp index 981817a4a9..77afa5e265 100644 --- a/apps/openmw/mwgui/textcolours.cpp +++ b/apps/openmw/mwgui/textcolours.cpp @@ -11,7 +11,6 @@ namespace MWGui return MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=" + type + "}")); } - void TextColours::loadColours() { header = getTextColour("header"); @@ -33,6 +32,5 @@ namespace MWGui journalTopic = getTextColour("journal_topic"); journalTopicOver = getTextColour("journal_topic_over"); journalTopicPressed = getTextColour("journal_topic_pressed"); - } } diff --git a/components/fallback/validate.cpp b/components/fallback/validate.cpp index f6868e56f4..571f0f9b19 100644 --- a/components/fallback/validate.cpp +++ b/components/fallback/validate.cpp @@ -109,8 +109,7 @@ static const std::set allowedKeysNonNumeric = { "Blood_Model_0 "FontColor_color_link", "FontColor_color_link_over", "FontColor_color_link_pressed", "FontColor_color_magic", "FontColor_color_magic_fill", "FontColor_color_misc", "FontColor_color_negative", "FontColor_color_normal", "FontColor_color_normal_over", "FontColor_color_normal_pressed", "FontColor_color_notify", - "FontColor_color_positive", "FontColor_color_weapon_fill", - "Fonts_Font_0", "Fonts_Font_1", "Fonts_Font_2", + "FontColor_color_positive", "FontColor_color_weapon_fill", "Fonts_Font_0", "Fonts_Font_1", "Fonts_Font_2", "Level_Up_Default", "Moons_Script_Color", "Movies_Company_Logo", "Movies_Morrowind_Logo", "Movies_New_Game", "Question_10_AnswerOne", "Question_10_AnswerThree", "Question_10_AnswerTwo", "Question_10_Question", "Question_10_Sound", "Question_1_AnswerOne", "Question_1_AnswerThree", "Question_1_AnswerTwo", diff --git a/components/widgets/tags.cpp b/components/widgets/tags.cpp index 1477470024..d5796c35b5 100644 --- a/components/widgets/tags.cpp +++ b/components/widgets/tags.cpp @@ -12,7 +12,7 @@ namespace Gui { std::string_view fontcolour = "fontcolour="; std::string_view fontcolourhtml = "fontcolourhtml="; - std::string_view fontcolouroptional = "fontcolouroptional="; + std::string_view fontcolouroptional = "fontcoloursetting="; if (tag.starts_with(fontcolour)) { @@ -61,25 +61,9 @@ namespace Gui } else if (tag.starts_with(fontcolouroptional)) { - std::string_view category = "GUI"; - std::string colortag = ""; - colortag += tag.substr(fontcolouroptional.length()); - std::string str = Settings::Manager::getString(colortag, category); - if (str.empty()) - throw std::runtime_error("Unable to map setting to value: " + colortag); - - std::string ret[4]; - unsigned int j = 0; - for (unsigned int i = 0; i < str.length(); ++i) - { - if (str[i] == ' ') - j++; - else if (str[i] != ' ') - ret[j] += str[i]; - } - MyGUI::Colour col(MyGUI::utility::parseFloat(ret[0]), MyGUI::utility::parseFloat(ret[1]), - MyGUI::utility::parseFloat(ret[2]), MyGUI::utility::parseFloat(ret[3])); - out = col.print(); + std::string_view colortag = tag.substr(fontcolouroptional.length()); + const MyGUI::Colour& customColour = Settings::get("GUI", colortag).get(); + out = customColour.print(); return true; } return false; diff --git a/files/data/mygui/openmw_list.skin.xml b/files/data/mygui/openmw_list.skin.xml index 45551429ed..30ebdca35d 100644 --- a/files/data/mygui/openmw_list.skin.xml +++ b/files/data/mygui/openmw_list.skin.xml @@ -129,9 +129,9 @@ - - - + + + @@ -140,9 +140,9 @@ - - - + + + From f7628ff0a82f1fb73f2fc9fc70c2dd50281ef4ac Mon Sep 17 00:00:00 2001 From: Kagernac Date: Wed, 19 Jun 2024 11:08:05 -0700 Subject: [PATCH 6/9] Code cleanup and documentation Added documentation in GUI.rst for the new settings Cleaned up the MR with some remnant changes. --- components/widgets/tags.cpp | 2 +- .../source/reference/modding/settings/GUI.rst | 52 +++++++++++++++++++ files/settings-default.cfg | 4 +- 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/components/widgets/tags.cpp b/components/widgets/tags.cpp index d5796c35b5..ddca0171c8 100644 --- a/components/widgets/tags.cpp +++ b/components/widgets/tags.cpp @@ -20,7 +20,7 @@ namespace Gui fallbackName += tag.substr(fontcolour.length()); std::string_view str = Fallback::Map::getString(fallbackName); if (str.empty()) - throw std::runtime_error("Unable to map setting to value: " + fallbackName); + throw std::runtime_error("Unknown fallback name: " + fallbackName); std::string ret[3]; unsigned int j = 0; diff --git a/docs/source/reference/modding/settings/GUI.rst b/docs/source/reference/modding/settings/GUI.rst index edacdc730a..0369e23651 100644 --- a/docs/source/reference/modding/settings/GUI.rst +++ b/docs/source/reference/modding/settings/GUI.rst @@ -157,6 +157,32 @@ The alpha value is currently ignored. A topic response is considered unique if its Actor filter field contains the speaking actor's object ID and hasn't yet been read. +color topic specific over +-------------------- + +:Type: RGBA floating point +:Range: 0.0 to 1.0 +:Default: empty + +This setting provides an "over" colour to dialogue topics that meet the color topic specific criteria. +The value is composed of four floating point values representing the red, green, blue and alpha channels. +The alpha value is currently ignored. + +A dialogue topic is considered "over" if it is the active GUI element through keyboard or mouse events. + +color topic specific pressed +-------------------- + +:Type: RGBA floating point +:Range: 0.0 to 1.0 +:Default: empty + +This setting provides an "pressed" colour to dialogue topics that meet the color topic specific criteria. +The value is composed of four floating point values representing the red, green, blue and alpha channels. +The alpha value is currently ignored. + +A dialogue topic is considered "pressed" if it is the active GUI element and it receives a sustained keyboard or mouse event. + color topic exhausted --------------------- @@ -169,3 +195,29 @@ The value is composed of four floating point values representing the red, green, The alpha value is currently ignored. A topic is considered "exhausted" if the response the player is about to see has already been seen. + +color topic exhausted over +-------------------- + +:Type: RGBA floating point +:Range: 0.0 to 1.0 +:Default: empty + +This setting provides an "over" colour to dialogue topics that meet the color topic exhausted criteria. +The value is composed of four floating point values representing the red, green, blue and alpha channels. +The alpha value is currently ignored. + +A dialogue topic is considered "over" if it is the active GUI element through keyboard or mouse events. + +color topic exhausted pressed +-------------------- + +:Type: RGBA floating point +:Range: 0.0 to 1.0 +:Default: empty + +This setting provides an "pressed" colour to dialogue topics that meet the color topic exhausted criteria. +The value is composed of four floating point values representing the red, green, blue and alpha channels. +The alpha value is currently ignored. + +A dialogue topic is considered "pressed" if it is the active GUI element and it receives a sustained keyboard or mouse event. \ No newline at end of file diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 1efcec8db4..d5c6e01398 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -218,7 +218,7 @@ keyboard navigation = true color topic enable = false # The color of dialogue topic keywords that gives unique actor responses -# Format (R,G,B) (255,255,255) or empty for no special formatting +# Format R G B A or empty for no special formatting # Default to blue color topic specific = 0.45 0.5 0.8 1 color topic specific over = 0.58 0.62 0.85 1 @@ -226,7 +226,7 @@ color topic specific pressed = 0.29 0.36 0.75 1 # The color of dialogue topic keywords that gives already read responses -# Format (R,G,B) (255,255,255) or empty for no special formatting +# Format R G B A or empty for no special formatting # Default to grey color topic exhausted = 0.3 0.3 0.3 1 color topic exhausted over = 0.56 0.56 0.56 1 From 2ab6dd022986d7e4ed08e576b595efa5aa2fde22 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Thu, 19 Sep 2024 03:25:51 +0300 Subject: [PATCH 7/9] Address my own review concerns Correct the number of hyphens in documentation Use the correct settings tag Simplify color values --- components/widgets/tags.cpp | 10 +--------- docs/source/reference/modding/settings/GUI.rst | 10 +++++----- files/data/mygui/openmw_list.skin.xml | 12 ++++++------ files/settings-default.cfg | 9 ++++----- 4 files changed, 16 insertions(+), 25 deletions(-) diff --git a/components/widgets/tags.cpp b/components/widgets/tags.cpp index ddca0171c8..3fe72480b7 100644 --- a/components/widgets/tags.cpp +++ b/components/widgets/tags.cpp @@ -1,6 +1,5 @@ #include "tags.hpp" -#include #include #include @@ -11,8 +10,8 @@ namespace Gui bool replaceTag(std::string_view tag, MyGUI::UString& out) { std::string_view fontcolour = "fontcolour="; + std::string_view fontcolourhtml = "fontcolourhtml="; - std::string_view fontcolouroptional = "fontcoloursetting="; if (tag.starts_with(fontcolour)) { @@ -59,13 +58,6 @@ namespace Gui out = html.str(); return true; } - else if (tag.starts_with(fontcolouroptional)) - { - std::string_view colortag = tag.substr(fontcolouroptional.length()); - const MyGUI::Colour& customColour = Settings::get("GUI", colortag).get(); - out = customColour.print(); - return true; - } return false; } diff --git a/docs/source/reference/modding/settings/GUI.rst b/docs/source/reference/modding/settings/GUI.rst index 0369e23651..08ca23c7d1 100644 --- a/docs/source/reference/modding/settings/GUI.rst +++ b/docs/source/reference/modding/settings/GUI.rst @@ -158,7 +158,7 @@ The alpha value is currently ignored. A topic response is considered unique if its Actor filter field contains the speaking actor's object ID and hasn't yet been read. color topic specific over --------------------- +------------------------- :Type: RGBA floating point :Range: 0.0 to 1.0 @@ -171,7 +171,7 @@ The alpha value is currently ignored. A dialogue topic is considered "over" if it is the active GUI element through keyboard or mouse events. color topic specific pressed --------------------- +---------------------------- :Type: RGBA floating point :Range: 0.0 to 1.0 @@ -197,7 +197,7 @@ The alpha value is currently ignored. A topic is considered "exhausted" if the response the player is about to see has already been seen. color topic exhausted over --------------------- +-------------------------- :Type: RGBA floating point :Range: 0.0 to 1.0 @@ -210,7 +210,7 @@ The alpha value is currently ignored. A dialogue topic is considered "over" if it is the active GUI element through keyboard or mouse events. color topic exhausted pressed --------------------- +----------------------------- :Type: RGBA floating point :Range: 0.0 to 1.0 @@ -220,4 +220,4 @@ This setting provides an "pressed" colour to dialogue topics that meet the color The value is composed of four floating point values representing the red, green, blue and alpha channels. The alpha value is currently ignored. -A dialogue topic is considered "pressed" if it is the active GUI element and it receives a sustained keyboard or mouse event. \ No newline at end of file +A dialogue topic is considered "pressed" if it is the active GUI element and it receives a sustained keyboard or mouse event. diff --git a/files/data/mygui/openmw_list.skin.xml b/files/data/mygui/openmw_list.skin.xml index 30ebdca35d..d17b258b80 100644 --- a/files/data/mygui/openmw_list.skin.xml +++ b/files/data/mygui/openmw_list.skin.xml @@ -129,9 +129,9 @@ - - - + + + @@ -140,9 +140,9 @@ - - - + + + diff --git a/files/settings-default.cfg b/files/settings-default.cfg index d5c6e01398..df14ef0634 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -221,16 +221,15 @@ color topic enable = false # Format R G B A or empty for no special formatting # Default to blue color topic specific = 0.45 0.5 0.8 1 -color topic specific over = 0.58 0.62 0.85 1 -color topic specific pressed = 0.29 0.36 0.75 1 - +color topic specific over = 0.6 0.6 0.85 1 +color topic specific pressed = 0.3 0.35 0.75 1 # The color of dialogue topic keywords that gives already read responses # Format R G B A or empty for no special formatting # Default to grey color topic exhausted = 0.3 0.3 0.3 1 -color topic exhausted over = 0.56 0.56 0.56 1 -color topic exhausted pressed= 0.44 0.44 0.44 1 +color topic exhausted over = 0.55 0.55 0.55 1 +color topic exhausted pressed= 0.45 0.45 0.45 1 [HUD] From e369ab941e95a3884894bbd5c1eb88de9816bfac Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Thu, 19 Sep 2024 04:25:36 +0300 Subject: [PATCH 8/9] 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); } } } From b412b60a07224512df9377466c7cdb9020a122fb Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Sun, 22 Sep 2024 21:10:59 +0300 Subject: [PATCH 9/9] Update topic highlighting documentation --- .../source/reference/modding/settings/GUI.rst | 26 +++++++++---------- files/settings-default.cfg | 6 +---- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/docs/source/reference/modding/settings/GUI.rst b/docs/source/reference/modding/settings/GUI.rst index 08ca23c7d1..118fd19212 100644 --- a/docs/source/reference/modding/settings/GUI.rst +++ b/docs/source/reference/modding/settings/GUI.rst @@ -148,8 +148,8 @@ color topic specific -------------------- :Type: RGBA floating point -:Range: 0.0 to 1.0 -:Default: empty +:Range: 0.0 to 1.0 for each channel +:Default: 0.45 0.5 0.8 1 (blue) This setting overrides the colour of dialogue topics that have a response unique to the actors speaking. The value is composed of four floating point values representing the red, green, blue and alpha channels. @@ -161,8 +161,8 @@ color topic specific over ------------------------- :Type: RGBA floating point -:Range: 0.0 to 1.0 -:Default: empty +:Range: 0.0 to 1.0 for each channel +:Default: 0.6 0.6 0.85 1 (blue) This setting provides an "over" colour to dialogue topics that meet the color topic specific criteria. The value is composed of four floating point values representing the red, green, blue and alpha channels. @@ -174,8 +174,8 @@ color topic specific pressed ---------------------------- :Type: RGBA floating point -:Range: 0.0 to 1.0 -:Default: empty +:Range: 0.0 to 1.0 for each channel +:Default: 0.3 0.35 0.75 1 (blue) This setting provides an "pressed" colour to dialogue topics that meet the color topic specific criteria. The value is composed of four floating point values representing the red, green, blue and alpha channels. @@ -187,8 +187,8 @@ color topic exhausted --------------------- :Type: RGBA floating point -:Range: 0.0 to 1.0 -:Default: empty +:Range: 0.0 to 1.0 for each channel +:Default: 0.3 0.3 0.3 1 (grey) This setting overrides the colour of dialogue topics which have been "exhausted" by the player. The value is composed of four floating point values representing the red, green, blue and alpha channels. @@ -200,8 +200,8 @@ color topic exhausted over -------------------------- :Type: RGBA floating point -:Range: 0.0 to 1.0 -:Default: empty +:Range: 0.0 to 1.0 for each channel +:Default: 0.55 0.55 0.55 1 (grey) This setting provides an "over" colour to dialogue topics that meet the color topic exhausted criteria. The value is composed of four floating point values representing the red, green, blue and alpha channels. @@ -213,10 +213,10 @@ color topic exhausted pressed ----------------------------- :Type: RGBA floating point -:Range: 0.0 to 1.0 -:Default: empty +:Range: 0.0 to 1.0 for each channel +:Default: 0.45 0.45 0.45 1 (grey) -This setting provides an "pressed" colour to dialogue topics that meet the color topic exhausted criteria. +This setting provides a "pressed" colour to dialogue topics that meet the color topic exhausted criteria. The value is composed of four floating point values representing the red, green, blue and alpha channels. The alpha value is currently ignored. diff --git a/files/settings-default.cfg b/files/settings-default.cfg index df14ef0634..1fa9db2640 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -218,18 +218,14 @@ keyboard navigation = true color topic enable = false # The color of dialogue topic keywords that gives unique actor responses -# Format R G B A or empty for no special formatting -# Default to blue color topic specific = 0.45 0.5 0.8 1 color topic specific over = 0.6 0.6 0.85 1 color topic specific pressed = 0.3 0.35 0.75 1 # The color of dialogue topic keywords that gives already read responses -# Format R G B A or empty for no special formatting -# Default to grey color topic exhausted = 0.3 0.3 0.3 1 color topic exhausted over = 0.55 0.55 0.55 1 -color topic exhausted pressed= 0.45 0.45 0.45 1 +color topic exhausted pressed = 0.45 0.45 0.45 1 [HUD]