1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2024-12-29 03:19:44 +00:00

moved translation storage from GUI manager to engine

This commit is contained in:
Marc Zinnschlag 2012-12-26 17:03:37 +01:00
parent 2d468fec02
commit 206c613b52
6 changed files with 17 additions and 10 deletions

View File

@ -336,15 +336,14 @@ void OMW::Engine::go()
mResDir, mCfgMgr.getCachePath(), mNewGame, mEncoding, mFallbackMap));
//Load translation data
std::auto_ptr<TranslationData::Storage> 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<std::string,std::string> fallbackMap)

View File

@ -5,6 +5,7 @@
#include <components/compiler/extensions.hpp>
#include <components/files/collections.hpp>
#include <components/translation/translation.hpp>
#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&);

View File

@ -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
{

View File

@ -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<TranslationData::Storage> mTranslationDataStorage;
TranslationData::Storage& mTranslationDataStorage;
CharacterCreation* mCharGen;

View File

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

View File

@ -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<std::string, std::string> ContainerType;