moved translation storage from GUI manager to engine

actorid
Marc Zinnschlag 12 years ago
parent 2d468fec02
commit 206c613b52

@ -336,15 +336,14 @@ void OMW::Engine::go()
mResDir, mCfgMgr.getCachePath(), mNewGame, mEncoding, mFallbackMap)); mResDir, mCfgMgr.getCachePath(), mNewGame, mEncoding, mFallbackMap));
//Load translation data //Load translation data
std::auto_ptr<TranslationData::Storage> translationDataStorage(new TranslationData::Storage(mEncoding)); mTranslationDataStorage.loadTranslationData(mFileCollections, mMaster);
translationDataStorage->loadTranslationData(mFileCollections, mMaster);
// Create window manager - this manages all the MW-specific GUI windows // Create window manager - this manages all the MW-specific GUI windows
MWScript::registerExtensions (mExtensions); MWScript::registerExtensions (mExtensions);
mEnvironment.setWindowManager (new MWGui::WindowManager( mEnvironment.setWindowManager (new MWGui::WindowManager(
mExtensions, mFpsLevel, mNewGame, mOgre, mCfgMgr.getLogPath().string() + std::string("/"), mExtensions, mFpsLevel, mNewGame, mOgre, mCfgMgr.getLogPath().string() + std::string("/"),
mCfgMgr.getCachePath ().string(), mScriptConsoleMode, translationDataStorage.release())); mCfgMgr.getCachePath ().string(), mScriptConsoleMode, mTranslationDataStorage));
// Create sound system // Create sound system
mEnvironment.setSoundManager (new MWSound::SoundManager(mUseSound)); mEnvironment.setSoundManager (new MWSound::SoundManager(mUseSound));
@ -495,6 +494,7 @@ void OMW::Engine::showFPS(int level)
void OMW::Engine::setEncoding(const ToUTF8::FromType& encoding) void OMW::Engine::setEncoding(const ToUTF8::FromType& encoding)
{ {
mEncoding = encoding; mEncoding = encoding;
mTranslationDataStorage.setEncoding (encoding);
} }
void OMW::Engine::setFallbackValues(std::map<std::string,std::string> fallbackMap) void OMW::Engine::setFallbackValues(std::map<std::string,std::string> fallbackMap)

@ -5,6 +5,7 @@
#include <components/compiler/extensions.hpp> #include <components/compiler/extensions.hpp>
#include <components/files/collections.hpp> #include <components/files/collections.hpp>
#include <components/translation/translation.hpp>
#include "mwbase/environment.hpp" #include "mwbase/environment.hpp"
@ -79,9 +80,9 @@ namespace OMW
Compiler::Extensions mExtensions; Compiler::Extensions mExtensions;
Compiler::Context *mScriptContext; Compiler::Context *mScriptContext;
Files::Collections mFileCollections; Files::Collections mFileCollections;
bool mFSStrict; bool mFSStrict;
TranslationData::Storage mTranslationDataStorage;
// not implemented // not implemented
Engine (const Engine&); Engine (const Engine&);

@ -56,7 +56,7 @@ using namespace MWGui;
WindowManager::WindowManager( WindowManager::WindowManager(
const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre,
const std::string& logpath, const std::string& cacheDir, bool consoleOnlyScripts, const std::string& logpath, const std::string& cacheDir, bool consoleOnlyScripts,
TranslationData::Storage* pTranslationDataStorage) TranslationData::Storage& translationDataStorage)
: mGuiManager(NULL) : mGuiManager(NULL)
, mHud(NULL) , mHud(NULL)
, mMap(NULL) , mMap(NULL)
@ -105,7 +105,7 @@ WindowManager::WindowManager(
, mCrosshairEnabled(Settings::Manager::getBool ("crosshair", "HUD")) , mCrosshairEnabled(Settings::Manager::getBool ("crosshair", "HUD"))
, mSubtitlesEnabled(Settings::Manager::getBool ("subtitles", "GUI")) , mSubtitlesEnabled(Settings::Manager::getBool ("subtitles", "GUI"))
, mHudEnabled(true) , mHudEnabled(true)
, mTranslationDataStorage(pTranslationDataStorage) , mTranslationDataStorage (translationDataStorage)
{ {
// Set up the GUI system // 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) if (tag.substr(0, tokenLength) == tokenToFind)
{ {
_result = mTranslationDataStorage->translateCellName(tag.substr(tokenLength)); _result = mTranslationDataStorage.translateCellName(tag.substr(tokenLength));
} }
else else
{ {

@ -78,7 +78,7 @@ namespace MWGui
WindowManager(const Compiler::Extensions& extensions, int fpsLevel, bool newGame, WindowManager(const Compiler::Extensions& extensions, int fpsLevel, bool newGame,
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,
TranslationData::Storage* pTranslationDataStorage); TranslationData::Storage& translationDataStorage);
virtual ~WindowManager(); virtual ~WindowManager();
/** /**
@ -252,7 +252,7 @@ namespace MWGui
SpellCreationDialog* mSpellCreationDialog; SpellCreationDialog* mSpellCreationDialog;
EnchantingDialog* mEnchantingDialog; EnchantingDialog* mEnchantingDialog;
TrainingWindow* mTrainingWindow; TrainingWindow* mTrainingWindow;
std::auto_ptr<TranslationData::Storage> mTranslationDataStorage; TranslationData::Storage& mTranslationDataStorage;
CharacterCreation* mCharGen; CharacterCreation* mCharGen;

@ -106,4 +106,9 @@ namespace TranslationData
return result; return result;
} }
void Storage::setEncoding (const ToUTF8::FromType& encoding)
{
mEncoding = encoding;
}
} }

@ -9,7 +9,6 @@ namespace TranslationData
class Storage class Storage
{ {
public: public:
Storage(const ToUTF8::FromType& encoding) : mEncoding(encoding) {}
void loadTranslationData(const Files::Collections& dataFileCollections, void loadTranslationData(const Files::Collections& dataFileCollections,
const std::string& esmFileName); const std::string& esmFileName);
@ -17,6 +16,8 @@ namespace TranslationData
std::string translateCellName(const std::string& cellName) const; std::string translateCellName(const std::string& cellName) const;
std::string topicID(const std::string& phrase) const; std::string topicID(const std::string& phrase) const;
void setEncoding (const ToUTF8::FromType& encoding);
private: private:
typedef std::map<std::string, std::string> ContainerType; typedef std::map<std::string, std::string> ContainerType;

Loading…
Cancel
Save