diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 3a7b6f6cfa..b995300d50 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 2d2d58234a..cbc627b832 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 fbe1250e36..cdcb615dcb 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 ad3c9b7360..b252254a0b 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 a178a053cf..e6c6a02334 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 7f4162c099..0160bc48ae 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;