diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index bce7c5d7d..00ad90a02 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -374,7 +374,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) MWGui::WindowManager* window = new MWGui::WindowManager( 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); // Create sound system diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 55462792c..083939c8e 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -78,7 +78,7 @@ namespace MWGui WindowManager::WindowManager( const Compiler::Extensions& extensions, int fpsLevel, OEngine::Render::OgreRenderer *ogre, 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& fallbackMap) : mConsoleOnlyScripts(consoleOnlyScripts) , mGuiManager(NULL) , mRendering(ogre) @@ -146,10 +146,13 @@ namespace MWGui , mTriangleCount(0) , mBatchCount(0) , mCurrentModals() + , mFallbackMap(fallbackMap) { // Set up the GUI system mGuiManager = new OEngine::GUI::MyGUIManager(mRendering->getWindow(), mRendering->getScene(), false, logpath); + MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &WindowManager::onRetrieveTag); + // Load fonts Gui::FontLoader fontLoader (encoding); fontLoader.loadAllFonts(exportFonts); @@ -182,8 +185,6 @@ namespace MWGui MyGUI::FactoryManager::getInstance().registerFactory("Resource", "ResourceImageSetPointer"); MyGUI::ResourceManager::getInstance().load("core.xml"); - MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &WindowManager::onRetrieveTag); - mLoadingScreen = new LoadingScreen(mRendering->getScene (), mRendering->getWindow ()); //set up the hardware cursor manager @@ -990,10 +991,30 @@ namespace MWGui std::string tokenToFind = "sCell="; size_t tokenLength = tokenToFind.length(); + std::string fontcolour = "fontcolour="; + size_t fontcolourLength = fontcolour.length(); + if (tag.substr(0, tokenLength) == tokenToFind) { _result = mTranslationDataStorage.translateCellName(tag.substr(tokenLength)); } + else if (tag.substr(0, fontcolourLength) == fontcolour) + { + std::string fallbackName = "FontColor_color_" + tag.substr(fontcolourLength); + std::map::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& fallbackMap); virtual ~WindowManager(); void initUI(); @@ -438,9 +438,15 @@ namespace MWGui unsigned int mTriangleCount; unsigned int mBatchCount; + std::map mFallbackMap; + /** - * Called when MyGUI tries to retrieve a tag. This usually corresponds to a GMST string, - * so this method will retrieve the GMST with the name \a _tag and place the result in \a _result + * 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. + * 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_" 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); diff --git a/files/mygui/openmw_button.skin.xml b/files/mygui/openmw_button.skin.xml index e152a9112..9b0783160 100644 --- a/files/mygui/openmw_button.skin.xml +++ b/files/mygui/openmw_button.skin.xml @@ -1,6 +1,6 @@ - + @@ -60,7 +60,7 @@ - + @@ -74,14 +74,14 @@ - - - - - - - - + + + + + + + + diff --git a/files/mygui/openmw_text.skin.xml b/files/mygui/openmw_text.skin.xml index 4c1117cf5..843a7817c 100644 --- a/files/mygui/openmw_text.skin.xml +++ b/files/mygui/openmw_text.skin.xml @@ -1,6 +1,6 @@ - + @@ -17,12 +17,12 @@ - - - + + +