Skip to content

Commit

Permalink
Change all skins to get font colors from fallback settings (Fixes Ope…
Browse files Browse the repository at this point in the history
  • Loading branch information
scrawl committed Sep 20, 2014
1 parent 25e96b8 commit e42cb80
Show file tree
Hide file tree
Showing 33 changed files with 238 additions and 202 deletions.
42 changes: 25 additions & 17 deletions apps/openmw/mwgui/dialogue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@

#include "journalbooks.hpp" // to_utf8_span

namespace
{

MyGUI::Colour getTextColour (const std::string& type)
{
return MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=" + type + "}"));
}

}

namespace MWGui
{

Expand Down Expand Up @@ -102,7 +112,7 @@ namespace MWGui

void Response::write(BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, std::map<std::string, Link*>& topicLinks) const
{
BookTypesetter::Style* title = typesetter->createStyle("", MyGUI::Colour(223/255.f, 201/255.f, 159/255.f));
BookTypesetter::Style* title = typesetter->createStyle("", getTextColour("header"));
typesetter->sectionBreak(9);
if (mTitle != "")
typesetter->write(title, to_utf8_span(mTitle.c_str()));
Expand Down Expand Up @@ -146,14 +156,14 @@ namespace MWGui

if (hyperLinks.size() && MWBase::Environment::get().getWindowManager()->getTranslationDataStorage().hasTranslation())
{
BookTypesetter::Style* style = typesetter->createStyle("", MyGUI::Colour(202/255.f, 165/255.f, 96/255.f));
BookTypesetter::Style* style = typesetter->createStyle("", getTextColour("normal"));
size_t formatted = 0; // points to the first character that is not laid out yet
for (std::map<Range, intptr_t>::iterator it = hyperLinks.begin(); it != hyperLinks.end(); ++it)
{
intptr_t topicId = it->second;
const MyGUI::Colour linkHot (143/255.f, 155/255.f, 218/255.f);
const MyGUI::Colour linkNormal (112/255.f, 126/255.f, 207/255.f);
const MyGUI::Colour linkActive (175/255.f, 184/255.f, 228/255.f);
const MyGUI::Colour linkHot (getTextColour("link_over"));
const MyGUI::Colour linkNormal (getTextColour("link"));
const MyGUI::Colour linkActive (getTextColour("link_pressed"));
BookTypesetter::Style* hotStyle = typesetter->createHotStyle (style, linkNormal, linkHot, linkActive, topicId);
if (formatted < it->first.first)
typesetter->write(style, formatted, it->first.first);
Expand Down Expand Up @@ -185,11 +195,11 @@ namespace MWGui

void Response::addTopicLink(BookTypesetter::Ptr typesetter, intptr_t topicId, size_t begin, size_t end) const
{
BookTypesetter::Style* style = typesetter->createStyle("", MyGUI::Colour(202/255.f, 165/255.f, 96/255.f));
BookTypesetter::Style* style = typesetter->createStyle("", getTextColour("normal"));

const MyGUI::Colour linkHot (143/255.f, 155/255.f, 218/255.f);
const MyGUI::Colour linkNormal (112/255.f, 126/255.f, 207/255.f);
const MyGUI::Colour linkActive (175/255.f, 184/255.f, 228/255.f);
const MyGUI::Colour linkHot (getTextColour("link_over"));
const MyGUI::Colour linkNormal (getTextColour("link"));
const MyGUI::Colour linkActive (getTextColour("link_pressed"));

if (topicId)
style = typesetter->createHotStyle (style, linkNormal, linkHot, linkActive, topicId);
Expand All @@ -203,7 +213,7 @@ namespace MWGui

void Message::write(BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, std::map<std::string, Link*>& topicLinks) const
{
BookTypesetter::Style* title = typesetter->createStyle("", MyGUI::Colour(223/255.f, 201/255.f, 159/255.f));
BookTypesetter::Style* title = typesetter->createStyle("", getTextColour("notify"));
typesetter->sectionBreak(9);
typesetter->write(title, to_utf8_span(mText.c_str()));
}
Expand Down Expand Up @@ -506,9 +516,9 @@ namespace MWGui

typesetter->sectionBreak(9);
// choices
const MyGUI::Colour linkHot (223/255.f, 201/255.f, 159/255.f);
const MyGUI::Colour linkNormal (150/255.f, 50/255.f, 30/255.f);
const MyGUI::Colour linkActive (243/255.f, 237/255.f, 221/255.f);
const MyGUI::Colour linkHot (getTextColour("answer_over"));
const MyGUI::Colour linkNormal (getTextColour("answer"));
const MyGUI::Colour linkActive (getTextColour("answer_pressed"));
for (std::vector<std::pair<std::string, int> >::iterator it = mChoices.begin(); it != mChoices.end(); ++it)
{
Choice* link = new Choice(it->second);
Expand Down Expand Up @@ -621,8 +631,7 @@ namespace MWGui
dispositionVisible = true;
mDispositionBar->setProgressRange(100);
mDispositionBar->setProgressPosition(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr));
mDispositionText->eraseText(0, mDispositionText->getTextLength());
mDispositionText->addText("#B29154"+boost::lexical_cast<std::string>(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr))+std::string("/100")+"#B29154");
mDispositionText->setCaption(boost::lexical_cast<std::string>(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr))+std::string("/100"));
}

bool dispositionWasVisible = mDispositionBar->getVisible();
Expand Down Expand Up @@ -666,8 +675,7 @@ namespace MWGui
+ MWBase::Environment::get().getDialogueManager()->getTemporaryDispositionChange()));
mDispositionBar->setProgressRange(100);
mDispositionBar->setProgressPosition(disp);
mDispositionText->eraseText(0, mDispositionText->getTextLength());
mDispositionText->addText("#B29154"+boost::lexical_cast<std::string>(disp)+std::string("/100")+"#B29154");
mDispositionText->setCaption(boost::lexical_cast<std::string>(disp)+std::string("/100"));
}
}
}
35 changes: 15 additions & 20 deletions apps/openmw/mwgui/journalbooks.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#include "journalbooks.hpp"

#include <MyGUI_LanguageManager.h>

namespace
{
const MyGUI::Colour linkHot (0.40f, 0.40f, 0.80f);
const MyGUI::Colour linkNormal (0.20f, 0.20f, 0.60f);
const MyGUI::Colour linkActive (0.50f, 0.50f, 1.00f);
MyGUI::Colour getTextColour (const std::string& type)
{
return MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=" + type + "}"));
}

struct AddContent
{
Expand All @@ -28,6 +31,10 @@ namespace
{
MWGui::BookTypesetter::Style* style = mBodyStyle;

static const MyGUI::Colour linkHot (getTextColour("journal_link_over"));
static const MyGUI::Colour linkNormal (getTextColour("journal_link"));
static const MyGUI::Colour linkActive (getTextColour("journal_link_pressed"));

if (topicId)
style = mTypesetter->createHotStyle (mBodyStyle, linkNormal, linkHot, linkActive, topicId);

Expand Down Expand Up @@ -132,22 +139,6 @@ namespace
mTypesetter->sectionBreak (10);
}
};

struct AddTopicLink : AddContent
{
AddTopicLink (MWGui::BookTypesetter::Ptr typesetter, MWGui::BookTypesetter::Style* style) :
AddContent (typesetter, style)
{
}

void operator () (MWGui::JournalViewModel::TopicId topicId, MWGui::JournalViewModel::Utf8Span name)
{
MWGui::BookTypesetter::Style* link = mTypesetter->createHotStyle (mBodyStyle, MyGUI::Colour::Black, linkHot, linkActive, topicId);

mTypesetter->write (link, name);
mTypesetter->lineBreak ();
}
};
}

namespace MWGui
Expand Down Expand Up @@ -242,7 +233,11 @@ book JournalBooks::createTopicIndexBook ()

sprintf (buffer, "( %c )", ch);

BookTypesetter::Style* style = typesetter->createHotStyle (body, MyGUI::Colour::Black, linkHot, linkActive, ch);
MyGUI::Colour linkHot (getTextColour("journal_topic_over"));
MyGUI::Colour linkActive (getTextColour("journal_topic_pressed"));
MyGUI::Colour linkNormal (getTextColour("journal_topic"));

BookTypesetter::Style* style = typesetter->createHotStyle (body, linkNormal, linkHot, linkActive, ch);

if (i == 13)
typesetter->sectionBreak ();
Expand Down
6 changes: 3 additions & 3 deletions apps/openmw/mwgui/quickkeysmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ namespace MWGui
for (std::vector<std::string>::const_iterator it = powers.begin(); it != powers.end(); ++it)
{
const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(*it);
MyGUI::Button* t = mMagicList->createWidget<MyGUI::Button>("SpellText",
MyGUI::Button* t = mMagicList->createWidget<MyGUI::Button>("SandTextButton",
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
t->setCaption(spell->mName);
t->setTextAlign(MyGUI::Align::Left);
Expand All @@ -617,7 +617,7 @@ namespace MWGui
for (std::vector<std::string>::const_iterator it = spellList.begin(); it != spellList.end(); ++it)
{
const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(*it);
MyGUI::Button* t = mMagicList->createWidget<MyGUI::Button>("SpellText",
MyGUI::Button* t = mMagicList->createWidget<MyGUI::Button>("SandTextButton",
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
t->setCaption(spell->mName);
t->setTextAlign(MyGUI::Align::Left);
Expand Down Expand Up @@ -648,7 +648,7 @@ namespace MWGui
}
}

MyGUI::Button* t = mMagicList->createWidget<MyGUI::Button>(equipped ? "SpellText" : "SpellTextUnequipped",
MyGUI::Button* t = mMagicList->createWidget<MyGUI::Button>(equipped ? "SandTextButton" : "SpellTextUnequipped",
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
t->setCaption(item.getClass().getName(item));
t->setTextAlign(MyGUI::Align::Left);
Expand Down
10 changes: 5 additions & 5 deletions apps/openmw/mwgui/spellwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ namespace MWGui
for (std::vector<std::string>::const_iterator it = powers.begin(); it != powers.end(); ++it)
{
const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(*it);
MyGUI::Button* t = mSpellView->createWidget<MyGUI::Button>("SpellText",
MyGUI::Button* t = mSpellView->createWidget<MyGUI::Button>("SandTextButton",
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
t->setCaption(spell->mName);
t->setTextAlign(MyGUI::Align::Left);
Expand All @@ -177,7 +177,7 @@ namespace MWGui
for (std::vector<std::string>::const_iterator it = spellList.begin(); it != spellList.end(); ++it)
{
const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(*it);
MyGUI::Button* t = mSpellView->createWidget<MyGUI::Button>("SpellText",
MyGUI::Button* t = mSpellView->createWidget<MyGUI::Button>("SandTextButton",
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
t->setCaption(spell->mName);
t->setTextAlign(MyGUI::Align::Left);
Expand All @@ -188,7 +188,7 @@ namespace MWGui
t->setStateSelected(*it == MWBase::Environment::get().getWindowManager()->getSelectedSpell());

// cost / success chance
MyGUI::Button* costChance = mSpellView->createWidget<MyGUI::Button>("SpellText",
MyGUI::Button* costChance = mSpellView->createWidget<MyGUI::Button>("SandTextButton",
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
std::string cost = boost::lexical_cast<std::string>(spell->mData.mCost);
std::string chance = boost::lexical_cast<std::string>(int(MWMechanics::getSpellSuccessChance(*it, player)));
Expand Down Expand Up @@ -224,7 +224,7 @@ namespace MWGui
}
}

MyGUI::Button* t = mSpellView->createWidget<MyGUI::Button>(equipped ? "SpellText" : "SpellTextUnequipped",
MyGUI::Button* t = mSpellView->createWidget<MyGUI::Button>(equipped ? "SandTextButton" : "SpellTextUnequipped",
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
t->setCaption(item.getClass().getName(item));
t->setTextAlign(MyGUI::Align::Left);
Expand All @@ -238,7 +238,7 @@ namespace MWGui


// cost / charge
MyGUI::Button* costCharge = mSpellView->createWidget<MyGUI::Button>(equipped ? "SpellText" : "SpellTextUnequipped",
MyGUI::Button* costCharge = mSpellView->createWidget<MyGUI::Button>(equipped ? "SandTextButton" : "SpellTextUnequipped",
MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);

float enchantCost = enchant->mData.mCost;
Expand Down
14 changes: 7 additions & 7 deletions apps/openmw/mwgui/statswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,30 +505,30 @@ namespace MWGui

std::string text;

text += std::string("#DDC79E") + faction->mName;
text += std::string("#{fontcolourhtml=header}") + faction->mName;

if (expelled.find(it->first) != expelled.end())
text += "\n#BF9959#{sExpelled}";
text += "\n#{fontcolourhtml=normal}#{sExpelled}";
else
{
int rank = it->second;
rank = std::max(0, std::min(9, rank));
text += std::string("\n#BF9959") + faction->mRanks[rank];
text += std::string("\n#{fontcolourhtml=normal}") + faction->mRanks[rank];

if (rank < 9)
{
// player doesn't have max rank yet
text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->mRanks[rank+1];
text += std::string("\n\n#{fontcolourhtml=header}#{sNextRank} ") + faction->mRanks[rank+1];

ESM::RankData rankData = faction->mData.mRankData[rank+1];
const ESM::Attribute* attr1 = store.get<ESM::Attribute>().find(faction->mData.mAttribute[0]);
const ESM::Attribute* attr2 = store.get<ESM::Attribute>().find(faction->mData.mAttribute[1]);

text += "\n#BF9959#{" + attr1->mName + "}: " + boost::lexical_cast<std::string>(rankData.mAttribute1)
text += "\n#{fontcolourhtml=normal}#{" + attr1->mName + "}: " + boost::lexical_cast<std::string>(rankData.mAttribute1)
+ ", #{" + attr2->mName + "}: " + boost::lexical_cast<std::string>(rankData.mAttribute2);

text += "\n\n#DDC79E#{sFavoriteSkills}";
text += "\n#BF9959";
text += "\n\n#{fontcolourhtml=header}#{sFavoriteSkills}";
text += "\n#{fontcolourhtml=normal}";
bool firstSkill = true;
for (int i=0; i<7; ++i)
{
Expand Down
6 changes: 3 additions & 3 deletions apps/openmw/mwgui/tooltips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ namespace MWGui
std::string text;

text += sign->mName;
text += "\n#BF9959" + sign->mDescription;
text += "\n#{fontcolourhtml=normal}" + sign->mDescription;

std::vector<std::string> abilities, powers, spells;

Expand Down Expand Up @@ -694,13 +694,13 @@ namespace MWGui
{
if (it == categories[category].spells.begin())
{
text += std::string("\n#DDC79E") + std::string("#{") + categories[category].label + "}";
text += std::string("\n#{fontcolourhtml=header}") + std::string("#{") + categories[category].label + "}";
}

const std::string &spellId = *it;

const ESM::Spell *spell = store.get<ESM::Spell>().find(spellId);
text += "\n#BF9959" + spell->mName;
text += "\n#{fontcolourhtml=normal}" + spell->mName;
}
}

Expand Down
25 changes: 23 additions & 2 deletions apps/openmw/mwgui/windowmanagerimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -994,11 +994,14 @@ namespace MWGui
std::string fontcolour = "fontcolour=";
size_t fontcolourLength = fontcolour.length();

if (tag.substr(0, tokenLength) == tokenToFind)
std::string fontcolourhtml = "fontcolourhtml=";
size_t fontcolourhtmlLength = fontcolourhtml.length();

if (tag.compare(0, tokenLength, tokenToFind) == 0)
{
_result = mTranslationDataStorage.translateCellName(tag.substr(tokenLength));
}
else if (tag.substr(0, fontcolourLength) == fontcolour)
else if (tag.compare(0, fontcolourLength, fontcolour) == 0)
{
std::string fallbackName = "FontColor_color_" + tag.substr(fontcolourLength);
std::map<std::string, std::string>::const_iterator it = mFallbackMap.find(fallbackName);
Expand All @@ -1015,6 +1018,24 @@ namespace MWGui
MyGUI::Colour col (MyGUI::utility::parseInt(ret[0])/255.f,MyGUI::utility::parseInt(ret[1])/255.f,MyGUI::utility::parseInt(ret[2])/255.f);
_result = col.print();
}
else if (tag.compare(0, fontcolourhtmlLength, fontcolourhtml) == 0)
{
std::string fallbackName = "FontColor_color_" + tag.substr(fontcolourhtmlLength);
std::map<std::string, std::string>::const_iterator it = mFallbackMap.find(fallbackName);
if (it == mFallbackMap.end())
throw std::runtime_error("Unknown fallback name: " + fallbackName);
std::string str = it->second;

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];
}
std::stringstream html;
html << "#" << std::hex << MyGUI::utility::parseInt(ret[0]) << MyGUI::utility::parseInt(ret[1]) << MyGUI::utility::parseInt(ret[2]);
_result = html.str();
}
else
{
const ESM::GameSetting *setting =
Expand Down
4 changes: 3 additions & 1 deletion apps/openmw/mwgui/windowmanagerimp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,9 @@ namespace MWGui
* #{GMSTName}: retrieves String value of the GMST called GMSTName
* #{sCell=CellID}: retrieves translated name of the given CellID (used only by some Morrowind localisations, in others cell ID is == cell name)
* #{fontcolour=FontColourName}: retrieves the value of the fallback setting "FontColor_color_<FontColourName>" from openmw.cfg,
* in the format "r g b a", float values in range 0-1.
* in the format "r g b a", float values in range 0-1. Useful for "Colour" and "TextColour" properties in skins.
* #{fontcolourhtml=FontColourName}: retrieves the value of the fallback setting "FontColor_color_<FontColourName>" from openmw.cfg,
* in the format "#xxxxxx" where x are hexadecimal numbers. Useful in an EditBox's caption to change the color of following text.
*/
void onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _result);

Expand Down
5 changes: 2 additions & 3 deletions apps/openmw/mwrender/renderingmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,10 +870,9 @@ void RenderingManager::processChangedSettings(const Settings::CategorySettingVec

void RenderingManager::setMenuTransparency(float val)
{
Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().getByName("transparent.png");
std::vector<Ogre::uint32> buffer;
Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().getByName("transparent.png"); std::vector<Ogre::uint32> buffer;
buffer.resize(1);
buffer[0] = (int(255*val) << 24);
buffer[0] = (int(255*val) << 24) | (255 << 16) | (255 << 8) | 255;
memcpy(tex->getBuffer()->lock(Ogre::HardwareBuffer::HBL_DISCARD), &buffer[0], 1*4);
tex->getBuffer()->unlock();
}
Expand Down
1 change: 1 addition & 0 deletions files/mygui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(DDIR ${OpenMW_BINARY_DIR}/resources/mygui)

set(MYGUI_FILES
black.png
white.png
core.skin
core.xml
openmw_alchemy_window.layout
Expand Down
2 changes: 1 addition & 1 deletion files/mygui/core.skin
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<MyGUI type="Skin">
<MyGUI type="Skin" version="3.2.1">
<Skin name = "TextBox" size = "16 16">
<Property key="FontHeight" value = "16" />
<Property key="TextAlign" value = "ALIGN_DEFAULT" />
Expand Down
Loading

0 comments on commit e42cb80

Please sign in to comment.