From 206c613b52e599b9366cbfa92278bf961e07bc8c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 26 Dec 2012 17:03:37 +0100 Subject: [PATCH] moved translation storage from GUI manager to engine --- apps/openmw/engine.cpp | 6 +++--- apps/openmw/engine.hpp | 3 ++- apps/openmw/mwgui/windowmanagerimp.cpp | 6 +++--- apps/openmw/mwgui/windowmanagerimp.hpp | 4 ++-- components/translation/translation.cpp | 5 +++++ components/translation/translation.hpp | 3 ++- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 3a7b6f6cf..b995300d5 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -336,15 +336,14 @@ void OMW::Engine::go() mResDir, mCfgMgr.getCachePath(), mNewGame, mEncoding, mFallbackMap)); //Load translation data - std::auto_ptr translationDataStorage(new TranslationData::Storage(mEncoding)); - translationDataStorage->loadTranslationData(mFileCollections, mMaster); + mTranslationDataStorage.loadTranslationData(mFileCollections, mMaster); // Create window manager - this manages all the MW-specific GUI windows MWScript::registerExtensions (mExtensions); mEnvironment.setWindowManager (new MWGui::WindowManager( mExtensions, mFpsLevel, mNewGame, mOgre, mCfgMgr.getLogPath().string() + std::string("/"), - mCfgMgr.getCachePath ().string(), mScriptConsoleMode, translationDataStorage.release())); + mCfgMgr.getCachePath ().string(), mScriptConsoleMode, mTranslationDataStorage)); // Create sound system mEnvironment.setSoundManager (new MWSound::SoundManager(mUseSound)); @@ -495,6 +494,7 @@ void OMW::Engine::showFPS(int level) void OMW::Engine::setEncoding(const ToUTF8::FromType& encoding) { mEncoding = encoding; + mTranslationDataStorage.setEncoding (encoding); } void OMW::Engine::setFallbackValues(std::map fallbackMap) diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 2d2d58234..cbc627b83 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -5,6 +5,7 @@ #include #include +#include #include "mwbase/environment.hpp" @@ -79,9 +80,9 @@ namespace OMW Compiler::Extensions mExtensions; Compiler::Context *mScriptContext; - Files::Collections mFileCollections; bool mFSStrict; + TranslationData::Storage mTranslationDataStorage; // not implemented Engine (const Engine&); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index fbe1250e3..cdcb615dc 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -56,7 +56,7 @@ using namespace MWGui; WindowManager::WindowManager( const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string& logpath, const std::string& cacheDir, bool consoleOnlyScripts, - TranslationData::Storage* pTranslationDataStorage) + TranslationData::Storage& translationDataStorage) : mGuiManager(NULL) , mHud(NULL) , mMap(NULL) @@ -105,7 +105,7 @@ WindowManager::WindowManager( , mCrosshairEnabled(Settings::Manager::getBool ("crosshair", "HUD")) , mSubtitlesEnabled(Settings::Manager::getBool ("subtitles", "GUI")) , mHudEnabled(true) - , mTranslationDataStorage(pTranslationDataStorage) + , mTranslationDataStorage (translationDataStorage) { // Set up the GUI system @@ -731,7 +731,7 @@ void WindowManager::onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _r if (tag.substr(0, tokenLength) == tokenToFind) { - _result = mTranslationDataStorage->translateCellName(tag.substr(tokenLength)); + _result = mTranslationDataStorage.translateCellName(tag.substr(tokenLength)); } else { diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index ad3c9b736..b252254a0 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -78,7 +78,7 @@ namespace MWGui WindowManager(const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string& logpath, const std::string& cacheDir, bool consoleOnlyScripts, - TranslationData::Storage* pTranslationDataStorage); + TranslationData::Storage& translationDataStorage); virtual ~WindowManager(); /** @@ -252,7 +252,7 @@ namespace MWGui SpellCreationDialog* mSpellCreationDialog; EnchantingDialog* mEnchantingDialog; TrainingWindow* mTrainingWindow; - std::auto_ptr mTranslationDataStorage; + TranslationData::Storage& mTranslationDataStorage; CharacterCreation* mCharGen; diff --git a/components/translation/translation.cpp b/components/translation/translation.cpp index a178a053c..e6c6a0233 100644 --- a/components/translation/translation.cpp +++ b/components/translation/translation.cpp @@ -106,4 +106,9 @@ namespace TranslationData return result; } + + void Storage::setEncoding (const ToUTF8::FromType& encoding) + { + mEncoding = encoding; + } } diff --git a/components/translation/translation.hpp b/components/translation/translation.hpp index 7f4162c09..0160bc48a 100644 --- a/components/translation/translation.hpp +++ b/components/translation/translation.hpp @@ -9,7 +9,6 @@ namespace TranslationData class Storage { public: - Storage(const ToUTF8::FromType& encoding) : mEncoding(encoding) {} void loadTranslationData(const Files::Collections& dataFileCollections, const std::string& esmFileName); @@ -17,6 +16,8 @@ namespace TranslationData std::string translateCellName(const std::string& cellName) const; std::string topicID(const std::string& phrase) const; + void setEncoding (const ToUTF8::FromType& encoding); + private: typedef std::map ContainerType;