1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-31 20:36:39 +00:00

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
This commit is contained in:
Kagernac 2024-06-04 23:14:44 -07:00
parent f9577d904c
commit 3e6ccfce1f
7 changed files with 46 additions and 41 deletions

View file

@ -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");
}
}

View file

@ -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();
};

View file

@ -109,8 +109,7 @@ static const std::set<std::string_view> 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",

View file

@ -32,12 +32,12 @@ namespace Settings
SettingValue<MyGUI::Colour> mColorCrosshairOwned{ mIndex, "GUI", "color crosshair owned" };
SettingValue<bool> mKeyboardNavigation{ mIndex, "GUI", "keyboard navigation" };
SettingValue<bool> mColorTopicEnable{ mIndex, "GUI", "color topic enable" };
SettingValue<MyGUI::Colour> mColorTopicSpecific{ mIndex, "GUI", "FontColor_color_specific" };
SettingValue<MyGUI::Colour> mColorTopicSpecificOver{ mIndex, "GUI", "FontColor_color_specific_over" };
SettingValue<MyGUI::Colour> mColorTopicSpecificPressed{ mIndex, "GUI", "FontColor_color_specific_pressed" };
SettingValue<MyGUI::Colour> mColorTopicExhausted{ mIndex, "GUI", "FontColor_color_exhausted" };
SettingValue<MyGUI::Colour> mColorTopicExhaustedOver{ mIndex, "GUI", "FontColor_color_exhausted_over" };
SettingValue<MyGUI::Colour> mColorTopicExhaustedPressed{ mIndex, "GUI", "FontColor_color_exhausted_pressed" };
SettingValue<MyGUI::Colour> mColorTopicSpecific{ mIndex, "GUI", "color topic specific" };
SettingValue<MyGUI::Colour> mColorTopicSpecificOver{ mIndex, "GUI", "color topic specific over" };
SettingValue<MyGUI::Colour> mColorTopicSpecificPressed{ mIndex, "GUI", "color topic specific pressed" };
SettingValue<MyGUI::Colour> mColorTopicExhausted{ mIndex, "GUI", "color topic exhausted" };
SettingValue<MyGUI::Colour> mColorTopicExhaustedOver{ mIndex, "GUI", "color topic exhausted over" };
SettingValue<MyGUI::Colour> mColorTopicExhaustedPressed{ mIndex, "GUI", "color topic exhausted pressed" };
};
}

View file

@ -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;
}

View file

@ -129,9 +129,9 @@
<Property key="TextAlign" value="Left VCenter"/>
<BasisSkin type="SimpleText" offset="2 0 1 5" align="Stretch">
<State name="normal" colour="#{fontcolour=specific}"/>
<State name="highlighted" colour="#{fontcolour=specific_over}"/>
<State name="pushed" colour="#{fontcolour=specific_pressed}"/>
<State name="normal" colour="#{fontcolouroptional=specific}"/>
<State name="highlighted" colour="#{fontcolouroptional=specific_over}"/>
<State name="pushed" colour="#{fontcolouroptional=specific_pressed}"/>
</BasisSkin>
</Resource>
@ -140,9 +140,9 @@
<Property key="TextAlign" value="Left VCenter"/>
<BasisSkin type="SimpleText" offset="2 0 1 5" align="Stretch">
<State name="normal" colour="#{fontcolour=exhausted}"/>
<State name="highlighted" colour="#{fontcolour=exhausted_over}"/>
<State name="pushed" colour="#{fontcolour=exhausted_pressed}"/>
<State name="normal" colour="#{fontcolouroptional=exhausted}"/>
<State name="highlighted" colour="#{fontcolouroptional=exhausted_over}"/>
<State name="pushed" colour="#{fontcolouroptional=exhausted_pressed}"/>
</BasisSkin>
</Resource>

View file

@ -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]