forked from mirror/openmw-tes3mp
Add basic framework to retrieve font colors from fallback settings (Feature #704)
This commit is contained in:
parent
144f6ca79a
commit
9c0649c11d
5 changed files with 48 additions and 21 deletions
|
@ -374,7 +374,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
||||||
|
|
||||||
MWGui::WindowManager* window = new MWGui::WindowManager(
|
MWGui::WindowManager* window = new MWGui::WindowManager(
|
||||||
mExtensions, mFpsLevel, mOgre, mCfgMgr.getLogPath().string() + std::string("/"),
|
mExtensions, mFpsLevel, mOgre, mCfgMgr.getLogPath().string() + std::string("/"),
|
||||||
mCfgMgr.getCachePath ().string(), mScriptConsoleMode, mTranslationDataStorage, mEncoding, mExportFonts);
|
mCfgMgr.getCachePath ().string(), mScriptConsoleMode, mTranslationDataStorage, mEncoding, mExportFonts, mFallbackMap);
|
||||||
mEnvironment.setWindowManager (window);
|
mEnvironment.setWindowManager (window);
|
||||||
|
|
||||||
// Create sound system
|
// Create sound system
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace MWGui
|
||||||
WindowManager::WindowManager(
|
WindowManager::WindowManager(
|
||||||
const Compiler::Extensions& extensions, int fpsLevel, OEngine::Render::OgreRenderer *ogre,
|
const Compiler::Extensions& extensions, int fpsLevel, OEngine::Render::OgreRenderer *ogre,
|
||||||
const std::string& logpath, const std::string& cacheDir, bool consoleOnlyScripts,
|
const std::string& logpath, const std::string& cacheDir, bool consoleOnlyScripts,
|
||||||
Translation::Storage& translationDataStorage, ToUTF8::FromType encoding, bool exportFonts)
|
Translation::Storage& translationDataStorage, ToUTF8::FromType encoding, bool exportFonts, const std::map<std::string, std::string>& fallbackMap)
|
||||||
: mConsoleOnlyScripts(consoleOnlyScripts)
|
: mConsoleOnlyScripts(consoleOnlyScripts)
|
||||||
, mGuiManager(NULL)
|
, mGuiManager(NULL)
|
||||||
, mRendering(ogre)
|
, mRendering(ogre)
|
||||||
|
@ -146,10 +146,13 @@ namespace MWGui
|
||||||
, mTriangleCount(0)
|
, mTriangleCount(0)
|
||||||
, mBatchCount(0)
|
, mBatchCount(0)
|
||||||
, mCurrentModals()
|
, mCurrentModals()
|
||||||
|
, mFallbackMap(fallbackMap)
|
||||||
{
|
{
|
||||||
// Set up the GUI system
|
// Set up the GUI system
|
||||||
mGuiManager = new OEngine::GUI::MyGUIManager(mRendering->getWindow(), mRendering->getScene(), false, logpath);
|
mGuiManager = new OEngine::GUI::MyGUIManager(mRendering->getWindow(), mRendering->getScene(), false, logpath);
|
||||||
|
|
||||||
|
MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &WindowManager::onRetrieveTag);
|
||||||
|
|
||||||
// Load fonts
|
// Load fonts
|
||||||
Gui::FontLoader fontLoader (encoding);
|
Gui::FontLoader fontLoader (encoding);
|
||||||
fontLoader.loadAllFonts(exportFonts);
|
fontLoader.loadAllFonts(exportFonts);
|
||||||
|
@ -182,8 +185,6 @@ namespace MWGui
|
||||||
MyGUI::FactoryManager::getInstance().registerFactory<ResourceImageSetPointerFix>("Resource", "ResourceImageSetPointer");
|
MyGUI::FactoryManager::getInstance().registerFactory<ResourceImageSetPointerFix>("Resource", "ResourceImageSetPointer");
|
||||||
MyGUI::ResourceManager::getInstance().load("core.xml");
|
MyGUI::ResourceManager::getInstance().load("core.xml");
|
||||||
|
|
||||||
MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &WindowManager::onRetrieveTag);
|
|
||||||
|
|
||||||
mLoadingScreen = new LoadingScreen(mRendering->getScene (), mRendering->getWindow ());
|
mLoadingScreen = new LoadingScreen(mRendering->getScene (), mRendering->getWindow ());
|
||||||
|
|
||||||
//set up the hardware cursor manager
|
//set up the hardware cursor manager
|
||||||
|
@ -990,10 +991,30 @@ namespace MWGui
|
||||||
std::string tokenToFind = "sCell=";
|
std::string tokenToFind = "sCell=";
|
||||||
size_t tokenLength = tokenToFind.length();
|
size_t tokenLength = tokenToFind.length();
|
||||||
|
|
||||||
|
std::string fontcolour = "fontcolour=";
|
||||||
|
size_t fontcolourLength = fontcolour.length();
|
||||||
|
|
||||||
if (tag.substr(0, tokenLength) == tokenToFind)
|
if (tag.substr(0, tokenLength) == tokenToFind)
|
||||||
{
|
{
|
||||||
_result = mTranslationDataStorage.translateCellName(tag.substr(tokenLength));
|
_result = mTranslationDataStorage.translateCellName(tag.substr(tokenLength));
|
||||||
}
|
}
|
||||||
|
else if (tag.substr(0, fontcolourLength) == fontcolour)
|
||||||
|
{
|
||||||
|
std::string fallbackName = "FontColor_color_" + tag.substr(fontcolourLength);
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
const ESM::GameSetting *setting =
|
const ESM::GameSetting *setting =
|
||||||
|
|
|
@ -99,7 +99,7 @@ namespace MWGui
|
||||||
WindowManager(const Compiler::Extensions& extensions, int fpsLevel,
|
WindowManager(const Compiler::Extensions& extensions, int fpsLevel,
|
||||||
OEngine::Render::OgreRenderer *mOgre, const std::string& logpath,
|
OEngine::Render::OgreRenderer *mOgre, const std::string& logpath,
|
||||||
const std::string& cacheDir, bool consoleOnlyScripts,
|
const std::string& cacheDir, bool consoleOnlyScripts,
|
||||||
Translation::Storage& translationDataStorage, ToUTF8::FromType encoding, bool exportFonts);
|
Translation::Storage& translationDataStorage, ToUTF8::FromType encoding, bool exportFonts, const std::map<std::string,std::string>& fallbackMap);
|
||||||
virtual ~WindowManager();
|
virtual ~WindowManager();
|
||||||
|
|
||||||
void initUI();
|
void initUI();
|
||||||
|
@ -438,9 +438,15 @@ namespace MWGui
|
||||||
unsigned int mTriangleCount;
|
unsigned int mTriangleCount;
|
||||||
unsigned int mBatchCount;
|
unsigned int mBatchCount;
|
||||||
|
|
||||||
|
std::map<std::string, std::string> mFallbackMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when MyGUI tries to retrieve a tag. This usually corresponds to a GMST string,
|
* Called when MyGUI tries to retrieve a tag's value. Tags must be denoted in #{tag} notation and will be replaced upon setting a user visible text/property.
|
||||||
* so this method will retrieve the GMST with the name \a _tag and place the result in \a _result
|
* Supported syntax:
|
||||||
|
* #{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.
|
||||||
*/
|
*/
|
||||||
void onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _result);
|
void onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _result);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<MyGUI type="Skin">
|
<MyGUI type="Skin" version="3.2.1">
|
||||||
<!-- Button graphics -->
|
<!-- Button graphics -->
|
||||||
<Skin name="BTN_Top" size="128 4" texture="textures\menu_button_frame_top.dds">
|
<Skin name="BTN_Top" size="128 4" texture="textures\menu_button_frame_top.dds">
|
||||||
<BasisSkin type="TileRect" offset="0 0 128 4" align="HStretch">
|
<BasisSkin type="TileRect" offset="0 0 128 4" align="HStretch">
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
</Skin>
|
</Skin>
|
||||||
|
|
||||||
<!-- Button widget -->
|
<!-- Button widget -->
|
||||||
<Skin name="MW_Button" size="136 24">
|
<Skin name="MW_Button" size="136 24" version="3.2.1">
|
||||||
<Property key="FontName" value="Default"/>
|
<Property key="FontName" value="Default"/>
|
||||||
<Property key="TextAlign" value="Center"/>
|
<Property key="TextAlign" value="Center"/>
|
||||||
|
|
||||||
|
@ -74,14 +74,14 @@
|
||||||
<Child type="Widget" skin="BTN_BottomRight" offset="132 20 4 4" align="Bottom Right"/>
|
<Child type="Widget" skin="BTN_BottomRight" offset="132 20 4 4" align="Bottom Right"/>
|
||||||
|
|
||||||
<BasisSkin type="SimpleText" offset="4 4 128 16" align="Stretch">
|
<BasisSkin type="SimpleText" offset="4 4 128 16" align="Stretch">
|
||||||
<State name="disabled" colour="0.6 0.56 0.45" shift="0"/>
|
<State name="disabled" colour="#{fontcolour=disabled}" shift="0"/>
|
||||||
<State name="normal" colour="0.75 0.6 0.35" shift="0"/>
|
<State name="normal" colour="#{fontcolour=normal}" shift="0"/>
|
||||||
<State name="highlighted" colour="0.85 0.76 0.60" shift="0"/>
|
<State name="highlighted" colour="#{fontcolour=normal_over}" shift="0"/>
|
||||||
<State name="pushed" colour="1 1 1" shift="0"/>
|
<State name="pushed" colour="#{fontcolour=normal_pressed}" shift="0"/>
|
||||||
<State name="disabled_checked" colour="0.33 0.38 0.67" shift="0"/>
|
<State name="disabled_checked" colour="#{fontcolour=disabled}" shift="0"/>
|
||||||
<State name="normal_checked" colour="0.33 0.38 0.67" shift="0"/>
|
<State name="normal_checked" colour="#{fontcolour=active}" shift="0"/>
|
||||||
<State name="highlighted_checked" colour="0.33 0.38 0.67" shift="0"/>
|
<State name="highlighted_checked" colour="#{fontcolour=active_over}" shift="0"/>
|
||||||
<State name="pushed_checked" colour="0.33 0.38 0.67" shift="0"/>
|
<State name="pushed_checked" colour="#{fontcolour=active_pressed}" shift="0"/>
|
||||||
</BasisSkin>
|
</BasisSkin>
|
||||||
</Skin>
|
</Skin>
|
||||||
</MyGUI>
|
</MyGUI>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<MyGUI type="Skin">
|
<MyGUI type="Skin" version="3.2.1">
|
||||||
|
|
||||||
<!-- HTML colour: #DDC79E -->
|
<!-- HTML colour: #DDC79E -->
|
||||||
<Skin name="NormalText" size="16 16">
|
<Skin name="NormalText" size="16 16">
|
||||||
|
@ -17,12 +17,12 @@
|
||||||
<BasisSkin type="SimpleText" offset="0 0 16 16" align="Stretch"/>
|
<BasisSkin type="SimpleText" offset="0 0 16 16" align="Stretch"/>
|
||||||
</Skin>
|
</Skin>
|
||||||
|
|
||||||
<!-- HTML colour: #BF9959 -->
|
|
||||||
<Skin name="SandText" size="16 16">
|
<Skin name="SandText" size="16 16">
|
||||||
<Property key="FontName" value="Default"/>
|
<Property key="FontName" value="Default"/>
|
||||||
<Property key="TextAlign" value="Left Bottom"/>
|
<Property key="TextAlign" value="Left Bottom"/>
|
||||||
<Property key="TextColour" value="0.75 0.6 0.35"/>
|
<BasisSkin type="SimpleText" offset="0 0 16 16" align="Stretch">
|
||||||
<BasisSkin type="SimpleText" offset="0 0 16 16" align="Stretch"/>
|
<State name="normal" colour="#{fontcolour=normal}" shift="0"/>
|
||||||
|
</BasisSkin>
|
||||||
</Skin>
|
</Skin>
|
||||||
|
|
||||||
<Skin name="SandTextC" size="16 16">
|
<Skin name="SandTextC" size="16 16">
|
||||||
|
|
Loading…
Reference in a new issue