diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 6699ccaaf..7b5c3f7ab 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -21,12 +21,13 @@ using namespace Fallback; CS::Editor::Editor (int argc, char **argv) : mSettingsState (mCfgMgr), mDocumentManager (mCfgMgr), - mViewManager (mDocumentManager), mPid(""), - mLock(), mMerge (mDocumentManager), + mPid(""), mLock(), mMerge (mDocumentManager), mIpcServerName ("org.openmw.OpenCS"), mServer(nullptr), mClientSocket(nullptr) -{ +{ std::pair > config = readConfig(); + mViewManager = new CSVDoc::ViewManager(mDocumentManager); + setupDataFiles (config.first); NifOsg::Loader::setShowMarkers(true); @@ -44,11 +45,11 @@ CS::Editor::Editor (int argc, char **argv) connect (&mDocumentManager, SIGNAL (lastDocumentDeleted()), this, SLOT (lastDocumentDeleted())); - connect (&mViewManager, SIGNAL (newGameRequest ()), this, SLOT (createGame ())); - connect (&mViewManager, SIGNAL (newAddonRequest ()), this, SLOT (createAddon ())); - connect (&mViewManager, SIGNAL (loadDocumentRequest ()), this, SLOT (loadDocument ())); - connect (&mViewManager, SIGNAL (editSettingsRequest()), this, SLOT (showSettings ())); - connect (&mViewManager, SIGNAL (mergeDocument (CSMDoc::Document *)), this, SLOT (mergeDocument (CSMDoc::Document *))); + connect (mViewManager, SIGNAL (newGameRequest ()), this, SLOT (createGame ())); + connect (mViewManager, SIGNAL (newAddonRequest ()), this, SLOT (createAddon ())); + connect (mViewManager, SIGNAL (loadDocumentRequest ()), this, SLOT (loadDocument ())); + connect (mViewManager, SIGNAL (editSettingsRequest()), this, SLOT (showSettings ())); + connect (mViewManager, SIGNAL (mergeDocument (CSMDoc::Document *)), this, SLOT (mergeDocument (CSMDoc::Document *))); connect (&mStartup, SIGNAL (createGame()), this, SLOT (createGame ())); connect (&mStartup, SIGNAL (createAddon()), this, SLOT (createAddon ())); @@ -69,6 +70,8 @@ CS::Editor::Editor (int argc, char **argv) CS::Editor::~Editor () { + delete mViewManager; + mPidFile.close(); if(mServer && boost::filesystem::exists(mPid)) @@ -107,7 +110,9 @@ std::pair > CS::Editor::readConfi boost::program_options::notify(variables); - mCfgMgr.readConfiguration(variables, desc, quiet); + mCfgMgr.readConfiguration(variables, desc, false); + + Fallback::Map::init(variables["fallback"].as().mMap); const std::string encoding = variables["encoding"].as().toStdString(); mDocumentManager.setEncoding (ToUTF8::calculateEncoding (encoding)); @@ -115,8 +120,6 @@ std::pair > CS::Editor::readConfi mDocumentManager.setResourceDir (mResources = variables["resources"].as().toStdString()); - mDocumentManager.setFallbackMap (variables["fallback"].as().mMap); - if (variables["script-blacklist-use"].as()) mDocumentManager.setBlacklistedScripts ( variables["script-blacklist"].as().toStdStringVector()); @@ -367,7 +370,7 @@ int CS::Editor::run() void CS::Editor::documentAdded (CSMDoc::Document *document) { - mViewManager.addView (document); + mViewManager->addView (document); } void CS::Editor::documentAboutToBeRemoved (CSMDoc::Document *document) diff --git a/apps/opencs/editor.hpp b/apps/opencs/editor.hpp index 21199e2ca..2c2e88aef 100644 --- a/apps/opencs/editor.hpp +++ b/apps/opencs/editor.hpp @@ -42,7 +42,6 @@ namespace CS Files::ConfigurationManager mCfgMgr; CSMPrefs::State mSettingsState; CSMDoc::DocumentManager mDocumentManager; - CSVDoc::ViewManager mViewManager; CSVDoc::StartupDialogue mStartup; CSVDoc::NewGameDialogue mNewGame; CSVPrefs::Dialogue mSettings; @@ -54,6 +53,7 @@ namespace CS boost::filesystem::ofstream mPidFile; bool mFsStrict; CSVTools::Merge mMerge; + CSVDoc::ViewManager* mViewManager; void setupDataFiles (const Files::PathContainer& dataDirs); diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp index 76511f535..03693ddfe 100644 --- a/apps/opencs/model/doc/document.cpp +++ b/apps/opencs/model/doc/document.cpp @@ -273,18 +273,16 @@ void CSMDoc::Document::createBase() CSMDoc::Document::Document (const Files::ConfigurationManager& configuration, const std::vector< boost::filesystem::path >& files,bool new_, const boost::filesystem::path& savePath, const boost::filesystem::path& resDir, - const Fallback::Map* fallback, - ToUTF8::FromType encoding, - const std::vector& blacklistedScripts, + ToUTF8::FromType encoding, const std::vector& blacklistedScripts, bool fsStrict, const Files::PathContainer& dataPaths, const std::vector& archives) -: mSavePath (savePath), mContentFiles (files), mNew (new_), mData (encoding, fsStrict, dataPaths, archives, fallback, resDir), +: mSavePath (savePath), mContentFiles (files), mNew (new_), mData (encoding, fsStrict, dataPaths, archives, resDir), mTools (*this, encoding), mProjectPath ((configuration.getUserDataPath() / "projects") / (savePath.filename().string() + ".project")), mSavingOperation (*this, mProjectPath, encoding), mSaving (&mSavingOperation), - mResDir(resDir), mFallbackMap(fallback), - mRunner (mProjectPath), mDirty (false), mIdCompletionManager(mData) + mResDir(resDir), mRunner (mProjectPath), + mDirty (false), mIdCompletionManager(mData) { if (mContentFiles.empty()) throw std::runtime_error ("Empty content file sequence"); diff --git a/apps/opencs/model/doc/document.hpp b/apps/opencs/model/doc/document.hpp index a2579af4c..0332cb43a 100644 --- a/apps/opencs/model/doc/document.hpp +++ b/apps/opencs/model/doc/document.hpp @@ -69,7 +69,6 @@ namespace CSMDoc Saving mSavingOperation; OperationHolder mSaving; boost::filesystem::path mResDir; - const Fallback::Map* mFallbackMap; Blacklist mBlacklist; Runner mRunner; bool mDirty; @@ -105,8 +104,7 @@ namespace CSMDoc Document (const Files::ConfigurationManager& configuration, const std::vector< boost::filesystem::path >& files, bool new_, const boost::filesystem::path& savePath, const boost::filesystem::path& resDir, - const Fallback::Map* fallback, ToUTF8::FromType encoding, - const std::vector& blacklistedScripts, + ToUTF8::FromType encoding, const std::vector& blacklistedScripts, bool fsStrict, const Files::PathContainer& dataPaths, const std::vector& archives); ~Document(); diff --git a/apps/opencs/model/doc/documentmanager.cpp b/apps/opencs/model/doc/documentmanager.cpp index a2859beb5..d70301ac5 100644 --- a/apps/opencs/model/doc/documentmanager.cpp +++ b/apps/opencs/model/doc/documentmanager.cpp @@ -62,7 +62,7 @@ CSMDoc::Document *CSMDoc::DocumentManager::makeDocument ( const std::vector< boost::filesystem::path >& files, const boost::filesystem::path& savePath, bool new_) { - return new Document (mConfiguration, files, new_, savePath, mResDir, &mFallbackMap, mEncoding, mBlacklistedScripts, mFsStrict, mDataPaths, mArchives); + return new Document (mConfiguration, files, new_, savePath, mResDir, mEncoding, mBlacklistedScripts, mFsStrict, mDataPaths, mArchives); } void CSMDoc::DocumentManager::insertDocument (CSMDoc::Document *document) @@ -98,11 +98,6 @@ void CSMDoc::DocumentManager::setResourceDir (const boost::filesystem::path& par mResDir = boost::filesystem::system_complete(parResDir); } -void CSMDoc::DocumentManager::setFallbackMap(const std::map& fallbackMap) -{ - mFallbackMap = Fallback::Map(fallbackMap); -} - void CSMDoc::DocumentManager::setEncoding (ToUTF8::FromType encoding) { mEncoding = encoding; diff --git a/apps/opencs/model/doc/documentmanager.hpp b/apps/opencs/model/doc/documentmanager.hpp index ae6d9481a..ecb2a1103 100644 --- a/apps/opencs/model/doc/documentmanager.hpp +++ b/apps/opencs/model/doc/documentmanager.hpp @@ -41,7 +41,6 @@ namespace CSMDoc std::vector mBlacklistedScripts; boost::filesystem::path mResDir; - Fallback::Map mFallbackMap; bool mFsStrict; Files::PathContainer mDataPaths; @@ -72,8 +71,6 @@ namespace CSMDoc void setResourceDir (const boost::filesystem::path& parResDir); - void setFallbackMap (const std::map& fallbackMap); - void setEncoding (ToUTF8::FromType encoding); void setBlacklistedScripts (const std::vector& scriptIds); diff --git a/apps/opencs/model/filter/textnode.cpp b/apps/opencs/model/filter/textnode.cpp index 246ebae24..808090dc3 100644 --- a/apps/opencs/model/filter/textnode.cpp +++ b/apps/opencs/model/filter/textnode.cpp @@ -38,11 +38,11 @@ bool CSMFilter::TextNode::test (const CSMWorld::IdTableBase& table, int row, { int value = data.toInt(); - std::vector enums = + std::vector> enums = CSMWorld::Columns::getEnums (static_cast (mColumnId)); if (value>=0 && value (enums.size())) - string = QString::fromUtf8 (enums[value].c_str()); + string = QString::fromUtf8 (enums[value].second.c_str()); } else if (data.type()==QVariant::Bool) { diff --git a/apps/opencs/model/tools/search.cpp b/apps/opencs/model/tools/search.cpp index e2cfd177b..7005480d1 100644 --- a/apps/opencs/model/tools/search.cpp +++ b/apps/opencs/model/tools/search.cpp @@ -75,11 +75,11 @@ void CSMTools::Search::searchRecordStateCell (const CSMWorld::IdTableBase *model if (data==mValue) { - std::vector states = + std::vector> states = CSMWorld::Columns::getEnums (CSMWorld::Columns::ColumnId_Modification); const std::string hint = "r: " + std::to_string(model->getColumnId(index.column())); - messages.add (id, states.at(data), hint); + messages.add (id, states.at(data).second, hint); } } diff --git a/apps/opencs/model/world/columns.cpp b/apps/opencs/model/world/columns.cpp index a04281ea6..f357264b8 100644 --- a/apps/opencs/model/world/columns.cpp +++ b/apps/opencs/model/world/columns.cpp @@ -626,19 +626,19 @@ bool CSMWorld::Columns::hasEnums (ColumnId column) return getEnumNames (column)!=0 || column==ColumnId_RecordType; } -std::vector CSMWorld::Columns::getEnums (ColumnId column) +std::vector>CSMWorld::Columns::getEnums (ColumnId column) { - std::vector enums; + std::vector> enums; if (const char **table = getEnumNames (column)) for (int i=0; table[i]; ++i) - enums.push_back (table[i]); + enums.emplace_back(i, table[i]); else if (column==ColumnId_RecordType) { - enums.push_back (""); // none + enums.emplace_back(UniversalId::Type_None, ""); // none for (int i=UniversalId::Type_None+1; i (i)).getTypeName()); + enums.emplace_back (i, UniversalId (static_cast (i)).getTypeName()); } return enums; diff --git a/apps/opencs/model/world/columns.hpp b/apps/opencs/model/world/columns.hpp index 528d210a4..3430a4837 100644 --- a/apps/opencs/model/world/columns.hpp +++ b/apps/opencs/model/world/columns.hpp @@ -390,7 +390,7 @@ namespace CSMWorld bool hasEnums (ColumnId column); - std::vector getEnums (ColumnId column); + std::vector> getEnums (ColumnId column); ///< Returns an empty vector, if \a column isn't an enum type column. } } diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index 8fa449b8f..b9208b44b 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -64,9 +64,9 @@ int CSMWorld::Data::count (RecordBase::State state, const CollectionBase& collec } CSMWorld::Data::Data (ToUTF8::FromType encoding, bool fsStrict, const Files::PathContainer& dataPaths, - const std::vector& archives, const Fallback::Map* fallback, const boost::filesystem::path& resDir) + const std::vector& archives, const boost::filesystem::path& resDir) : mEncoder (encoding), mPathgrids (mCells), mRefs (mCells), - mFallbackMap(fallback), mReader (0), mDialogue (0), mReaderIndex(1), + mReader (0), mDialogue (0), mReaderIndex(1), mFsStrict(fsStrict), mDataPaths(dataPaths), mArchives(archives) { mVFS.reset(new VFS::Manager(mFsStrict)); @@ -1360,8 +1360,3 @@ const VFS::Manager* CSMWorld::Data::getVFS() const { return mVFS.get(); } - -const Fallback::Map* CSMWorld::Data::getFallbackMap() const -{ - return mFallbackMap; -} diff --git a/apps/opencs/model/world/data.hpp b/apps/opencs/model/world/data.hpp index e50780f50..51f921162 100644 --- a/apps/opencs/model/world/data.hpp +++ b/apps/opencs/model/world/data.hpp @@ -112,7 +112,6 @@ namespace CSMWorld IdCollection mFilters; Collection mMetaData; std::unique_ptr mActorAdapter; - const Fallback::Map* mFallbackMap; std::vector mModels; std::map mModelIndex; ESM::ESMReader *mReader; @@ -151,15 +150,12 @@ namespace CSMWorld public: Data (ToUTF8::FromType encoding, bool fsStrict, const Files::PathContainer& dataPaths, - const std::vector& archives, const Fallback::Map* fallback, - const boost::filesystem::path& resDir); + const std::vector& archives, const boost::filesystem::path& resDir); virtual ~Data(); const VFS::Manager* getVFS() const; - const Fallback::Map* getFallbackMap() const; - std::shared_ptr getResourceSystem(); std::shared_ptr getResourceSystem() const; diff --git a/apps/opencs/model/world/idtableproxymodel.cpp b/apps/opencs/model/world/idtableproxymodel.cpp index 534e5dd63..3e24f8d12 100644 --- a/apps/opencs/model/world/idtableproxymodel.cpp +++ b/apps/opencs/model/world/idtableproxymodel.cpp @@ -6,13 +6,13 @@ namespace { - std::string getEnumValue(const std::vector &values, int index) + std::string getEnumValue(const std::vector> &values, int index) { if (index < 0 || index >= static_cast(values.size())) { return ""; } - return values[index]; + return values[index].second; } } diff --git a/apps/opencs/model/world/idtableproxymodel.hpp b/apps/opencs/model/world/idtableproxymodel.hpp index dd7ab41eb..ad5f267db 100644 --- a/apps/opencs/model/world/idtableproxymodel.hpp +++ b/apps/opencs/model/world/idtableproxymodel.hpp @@ -22,7 +22,7 @@ namespace CSMWorld // Cache of enum values for enum columns (e.g. Modified, Record Type). // Used to speed up comparisons during the sort by such columns. - typedef std::map > EnumColumnCache; + typedef std::map> > EnumColumnCache; mutable EnumColumnCache mEnumColumnCache; protected: diff --git a/apps/opencs/view/render/cellwater.cpp b/apps/opencs/view/render/cellwater.cpp index d7e8669ef..435178860 100644 --- a/apps/opencs/view/render/cellwater.cpp +++ b/apps/opencs/view/render/cellwater.cpp @@ -164,7 +164,7 @@ namespace CSVRender mWaterGeometry->setStateSet(SceneUtil::createSimpleWaterStateSet(Alpha, RenderBin)); // Add water texture - std::string textureName = mData.getFallbackMap()->getFallbackString("Water_SurfaceTexture"); + std::string textureName = Fallback::Map::getString("Water_SurfaceTexture"); textureName = "textures/water/" + textureName + "00.dds"; Resource::ImageManager* imageManager = mData.getResourceSystem()->getImageManager(); diff --git a/apps/opencs/view/render/object.cpp b/apps/opencs/view/render/object.cpp index 0a3a950e0..1ed7b3c05 100644 --- a/apps/opencs/view/render/object.cpp +++ b/apps/opencs/view/render/object.cpp @@ -140,14 +140,13 @@ void CSVRender::Object::update() if (light) { - const Fallback::Map* fallback = mData.getFallbackMap(); - static bool outQuadInLin = fallback->getFallbackBool("LightAttenuation_OutQuadInLin"); - static bool useQuadratic = fallback->getFallbackBool("LightAttenuation_UseQuadratic"); - static float quadraticValue = fallback->getFallbackFloat("LightAttenuation_QuadraticValue"); - static float quadraticRadiusMult = fallback->getFallbackFloat("LightAttenuation_QuadraticRadiusMult"); - static bool useLinear = fallback->getFallbackBool("LightAttenuation_UseLinear"); - static float linearRadiusMult = fallback->getFallbackFloat("LightAttenuation_LinearRadiusMult"); - static float linearValue = fallback->getFallbackFloat("LightAttenuation_LinearValue"); + static bool outQuadInLin = Fallback::Map::getBool("LightAttenuation_OutQuadInLin"); + static bool useQuadratic = Fallback::Map::getBool("LightAttenuation_UseQuadratic"); + static float quadraticValue = Fallback::Map::getFloat("LightAttenuation_QuadraticValue"); + static float quadraticRadiusMult = Fallback::Map::getFloat("LightAttenuation_QuadraticRadiusMult"); + static bool useLinear = Fallback::Map::getBool("LightAttenuation_UseLinear"); + static float linearRadiusMult = Fallback::Map::getFloat("LightAttenuation_LinearRadiusMult"); + static float linearValue = Fallback::Map::getFloat("LightAttenuation_LinearValue"); bool isExterior = false; // FIXME SceneUtil::addLight(mBaseNode, light, Mask_ParticleSystem, Mask_Lighting, isExterior, outQuadInLin, useQuadratic, quadraticValue, quadraticRadiusMult, useLinear, linearRadiusMult, linearValue); diff --git a/apps/opencs/view/tools/searchbox.cpp b/apps/opencs/view/tools/searchbox.cpp index 87a8be574..e0f965e3c 100644 --- a/apps/opencs/view/tools/searchbox.cpp +++ b/apps/opencs/view/tools/searchbox.cpp @@ -40,13 +40,13 @@ CSVTools::SearchBox::SearchBox (QWidget *parent) mLayout = new QGridLayout (this); // search panel - std::vector states = + std::vector> states = CSMWorld::Columns::getEnums (CSMWorld::Columns::ColumnId_Modification); states.resize (states.size()-1); // ignore erased state - for (std::vector::const_iterator iter (states.begin()); iter!=states.end(); + for (std::vector>::const_iterator iter (states.begin()); iter!=states.end(); ++iter) - mRecordState.addItem (QString::fromUtf8 (iter->c_str())); + mRecordState.addItem (QString::fromUtf8 (iter->second.c_str())); mMode.addItem (tr("Text")); mMode.addItem (tr("Text (RegEx)")); diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index eeba29d95..e29fcb779 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -76,9 +76,9 @@ void CSVWorld::NotEditableSubDelegate::setEditorData (QWidget* editor, const QMo else if (CSMWorld::Columns::hasEnums (columnId)) { int data = v.toInt(); - std::vector enumNames (CSMWorld::Columns::getEnums (columnId)); + std::vector> enumNames (CSMWorld::Columns::getEnums (columnId)); - label->setText(QString::fromUtf8(enumNames.at(data).c_str())); + label->setText(QString::fromUtf8(enumNames.at(data).second.c_str())); } else { diff --git a/apps/opencs/view/world/enumdelegate.cpp b/apps/opencs/view/world/enumdelegate.cpp index c303b71ac..dd4405a92 100644 --- a/apps/opencs/view/world/enumdelegate.cpp +++ b/apps/opencs/view/world/enumdelegate.cpp @@ -155,7 +155,7 @@ CSVWorld::EnumDelegateFactory::EnumDelegateFactory (const char **names, bool all add (i, names[i]); } -CSVWorld::EnumDelegateFactory::EnumDelegateFactory (const std::vector& names, +CSVWorld::EnumDelegateFactory::EnumDelegateFactory (const std::vector>& names, bool allowNone) { if (allowNone) @@ -164,7 +164,7 @@ CSVWorld::EnumDelegateFactory::EnumDelegateFactory (const std::vector (names.size()); for (int i=0; i& names, bool allowNone = false); + EnumDelegateFactory (const std::vector>& names, bool allowNone = false); /// \param allowNone Use value of -1 for "none selected" (empty string) virtual CommandDelegate *makeDelegate (CSMWorld::CommandDispatcher *dispatcher, CSMDoc::Document& document, QObject *parent) const; diff --git a/apps/opencs/view/world/recordstatusdelegate.cpp b/apps/opencs/view/world/recordstatusdelegate.cpp index 4a229657d..fd98fe6cd 100644 --- a/apps/opencs/view/world/recordstatusdelegate.cpp +++ b/apps/opencs/view/world/recordstatusdelegate.cpp @@ -22,7 +22,7 @@ CSVWorld::CommandDelegate *CSVWorld::RecordStatusDelegateFactory::makeDelegate ( CSVWorld::RecordStatusDelegateFactory::RecordStatusDelegateFactory() { - std::vector enums = + std::vector> enums = CSMWorld::Columns::getEnums (CSMWorld::Columns::ColumnId_Modification); static const char *sIcons[] = @@ -31,5 +31,8 @@ CSVWorld::RecordStatusDelegateFactory::RecordStatusDelegateFactory() }; for (int i=0; sIcons[i]; ++i) - add (i, enums.at (i).c_str(), sIcons[i]); + { + auto& enumPair = enums.at(i); + add (enumPair.first, enumPair.second.c_str(), sIcons[i]); + } } diff --git a/apps/opencs/view/world/vartypedelegate.cpp b/apps/opencs/view/world/vartypedelegate.cpp index 8aa43d15b..48fb4ab87 100644 --- a/apps/opencs/view/world/vartypedelegate.cpp +++ b/apps/opencs/view/world/vartypedelegate.cpp @@ -73,11 +73,11 @@ CSVWorld::CommandDelegate *CSVWorld::VarTypeDelegateFactory::makeDelegate ( void CSVWorld::VarTypeDelegateFactory::add (ESM::VarType type) { - std::vector enums = + std::vector> enums = CSMWorld::Columns::getEnums (CSMWorld::Columns::ColumnId_ValueType); if (static_cast(type) >= enums.size()) throw std::logic_error ("Unsupported variable type"); - mValues.push_back (std::make_pair (type, QString::fromUtf8 (enums[type].c_str()))); + mValues.emplace_back(type, QString::fromUtf8 (enums[type].second.c_str())); } diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 181ebd822..6dcd0977b 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -534,24 +534,24 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) rootNode->addChild(guiRoot); MWGui::WindowManager* window = new MWGui::WindowManager(mViewer, guiRoot, mResourceSystem.get(), mWorkQueue.get(), mCfgMgr.getLogPath().string() + std::string("/"), myguiResources, - mScriptConsoleMode, mTranslationDataStorage, mEncoding, mExportFonts, mFallbackMap, + mScriptConsoleMode, mTranslationDataStorage, mEncoding, mExportFonts, Version::getOpenmwVersionDescription(mResDir.string()), mCfgMgr.getUserConfigPath().string()); mEnvironment.setWindowManager (window); // Create sound system - mEnvironment.setSoundManager (new MWSound::SoundManager(mVFS.get(), mFallbackMap, mUseSound)); + mEnvironment.setSoundManager (new MWSound::SoundManager(mVFS.get(), mUseSound)); if (!mSkipMenu) { - std::string logo = mFallbackMap["Movies_Company_Logo"]; + const std::string& logo = Fallback::Map::getString("Movies_Company_Logo"); if (!logo.empty()) window->playVideo(logo, true); } // Create the world mEnvironment.setWorld( new MWWorld::World (mViewer, rootNode, mResourceSystem.get(), mWorkQueue.get(), - mFileCollections, mContentFiles, mEncoder, mFallbackMap, - mActivationDistanceOverride, mCellName, mResDir.string(), mCfgMgr.getUserDataPath().string())); + mFileCollections, mContentFiles, mEncoder, mActivationDistanceOverride, mCellName, + mStartupScript, mResDir.string(), mCfgMgr.getUserDataPath().string())); mEnvironment.getWorld()->setupPlayer(); input->setPlayer(&mEnvironment.getWorld()->getPlayer()); @@ -712,7 +712,7 @@ void OMW::Engine::go() // start in main menu mEnvironment.getWindowManager()->pushGuiMode (MWGui::GM_MainMenu); mEnvironment.getSoundManager()->playTitleMusic(); - std::string logo = mFallbackMap["Movies_Morrowind_Logo"]; + const std::string& logo = Fallback::Map::getString("Movies_Morrowind_Logo"); if (!logo.empty()) mEnvironment.getWindowManager()->playVideo(logo, true); } @@ -785,11 +785,6 @@ void OMW::Engine::setEncoding(const ToUTF8::FromType& encoding) mEncoding = encoding; } -void OMW::Engine::setFallbackValues(std::map fallbackMap) -{ - mFallbackMap = fallbackMap; -} - void OMW::Engine::setScriptConsoleMode (bool enabled) { mScriptConsoleMode = enabled; diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index bfe9759cd..a00cf474a 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -91,7 +91,6 @@ namespace OMW bool mCompileAllDialogue; int mWarningsMode; std::string mFocusName; - std::map mFallbackMap; bool mScriptConsoleMode; std::string mStartupScript; int mActivationDistanceOverride; @@ -182,8 +181,6 @@ namespace OMW /// Font encoding void setEncoding(const ToUTF8::FromType& encoding); - void setFallbackValues(std::map map); - /// Enable console-only script functionality void setScriptConsoleMode (bool enabled); diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index a56cbfe8a..51a256345 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -233,8 +234,8 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat engine.setSaveGameFile (variables["load-savegame"].as().toStdString()); // other settings + Fallback::Map::init(variables["fallback"].as().mMap); engine.setSoundUsage(!variables["no-sound"].as()); - engine.setFallbackValues(variables["fallback"].as().mMap); engine.setActivationDistanceOverride (variables["activate-dist"].as()); engine.enableFontExport(variables["export-fonts"].as()); engine.setRandomSeed(variables["random-seed"].as()); diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index d3bdb419e..2d5048232 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -72,11 +72,6 @@ namespace MWWorld typedef std::vector > PtrMovementList; } -namespace Fallback -{ - class Map; -} - namespace MWBase { /// \brief Interface for the World (implemented in MWWorld) @@ -130,8 +125,6 @@ namespace MWBase virtual void adjustSky() = 0; - virtual const Fallback::Map *getFallback () const = 0; - virtual MWWorld::Player& getPlayer() = 0; virtual MWWorld::Ptr getPlayerPtr() = 0; virtual MWWorld::ConstPtr getPlayerConstPtr() const = 0; diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index 64b8cb7c6..62ed2f21f 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -33,14 +33,15 @@ namespace }; const ESM::Class::Specialization mSpecializations[3]={ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth}; // The specialization for each answer - Step sGenerateClassSteps(int number) { + Step sGenerateClassSteps(int number) + { number++; - const Fallback::Map* fallback=MWBase::Environment::get().getWorld()->getFallback(); - Step step = {fallback->getFallbackString("Question_"+MyGUI::utility::toString(number)+"_Question"), - {fallback->getFallbackString("Question_"+MyGUI::utility::toString(number)+"_AnswerOne"), - fallback->getFallbackString("Question_"+MyGUI::utility::toString(number)+"_AnswerTwo"), - fallback->getFallbackString("Question_"+MyGUI::utility::toString(number)+"_AnswerThree")}, - "vo\\misc\\chargen qa"+MyGUI::utility::toString(number)+".wav" + Step step = { + Fallback::Map::getString("Question_"+MyGUI::utility::toString(number)+"_Question"), + {Fallback::Map::getString("Question_"+MyGUI::utility::toString(number)+"_AnswerOne"), + Fallback::Map::getString("Question_"+MyGUI::utility::toString(number)+"_AnswerTwo"), + Fallback::Map::getString("Question_"+MyGUI::utility::toString(number)+"_AnswerThree")}, + "vo\\misc\\chargen qa"+MyGUI::utility::toString(number)+".wav" }; return step; } diff --git a/apps/openmw/mwgui/levelupdialog.cpp b/apps/openmw/mwgui/levelupdialog.cpp index 415c8e31c..eb165254a 100644 --- a/apps/openmw/mwgui/levelupdialog.cpp +++ b/apps/openmw/mwgui/levelupdialog.cpp @@ -140,10 +140,10 @@ namespace MWGui mLevelText->setCaptionWithReplacing("#{sLevelUpMenu1} " + MyGUI::utility::toString(level)); std::string levelupdescription; - levelupdescription=world->getFallback()->getFallbackString("Level_Up_Level"+MyGUI::utility::toString(level)); + levelupdescription = Fallback::Map::getString("Level_Up_Level"+MyGUI::utility::toString(level)); if (levelupdescription == "") - levelupdescription=world->getFallback()->getFallbackString("Level_Up_Default"); + levelupdescription = Fallback::Map::getString("Level_Up_Default"); mLevelDescription->setCaption (levelupdescription); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index abd483a72..ebbd8bf97 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -129,7 +129,7 @@ namespace MWGui WindowManager::WindowManager( osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue, const std::string& logpath, const std::string& resourcePath, bool consoleOnlyScripts, Translation::Storage& translationDataStorage, - ToUTF8::FromType encoding, bool exportFonts, const std::map& fallbackMap, const std::string& versionDescription, const std::string& userDataPath) + ToUTF8::FromType encoding, bool exportFonts, const std::string& versionDescription, const std::string& userDataPath) : mStore(nullptr) , mResourceSystem(resourceSystem) , mWorkQueue(workQueue) @@ -189,7 +189,6 @@ namespace MWGui , mForceHidden(GW_None) , mAllowed(GW_ALL) , mRestAllowed(true) - , mFallbackMap(fallbackMap) , mShowOwned(0) , mEncoding(encoding) , mFontHeight(16) @@ -1184,7 +1183,7 @@ namespace MWGui { _result = mTranslationDataStorage.translateCellName(tag.substr(tokenLength)); } - else if (Gui::replaceTag(tag, _result, mFallbackMap)) + else if (Gui::replaceTag(tag, _result)) { return; } diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 050f1667d..e3dcbc699 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -132,7 +132,7 @@ namespace MWGui WindowManager(osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue, const std::string& logpath, const std::string& cacheDir, bool consoleOnlyScripts, Translation::Storage& translationDataStorage, - ToUTF8::FromType encoding, bool exportFonts, const std::map& fallbackMap, const std::string& versionDescription, const std::string& localPath); + ToUTF8::FromType encoding, bool exportFonts, const std::string& versionDescription, const std::string& localPath); virtual ~WindowManager(); /// Set the ESMStore to use for retrieving of GUI-related strings. @@ -514,8 +514,6 @@ namespace MWGui void updateMap(); - std::map mFallbackMap; - int mShowOwned; ToUTF8::FromType mEncoding; diff --git a/apps/openmw/mwrender/actoranimation.cpp b/apps/openmw/mwrender/actoranimation.cpp index 42f108355..b5908e5b4 100644 --- a/apps/openmw/mwrender/actoranimation.cpp +++ b/apps/openmw/mwrender/actoranimation.cpp @@ -428,14 +428,13 @@ void ActorAnimation::addHiddenItemLight(const MWWorld::ConstPtr& item, const ESM if (mItemLights.find(item) != mItemLights.end()) return; - const Fallback::Map* fallback = MWBase::Environment::get().getWorld()->getFallback(); - static bool outQuadInLin = fallback->getFallbackBool("LightAttenuation_OutQuadInLin"); - static bool useQuadratic = fallback->getFallbackBool("LightAttenuation_UseQuadratic"); - static float quadraticValue = fallback->getFallbackFloat("LightAttenuation_QuadraticValue"); - static float quadraticRadiusMult = fallback->getFallbackFloat("LightAttenuation_QuadraticRadiusMult"); - static bool useLinear = fallback->getFallbackBool("LightAttenuation_UseLinear"); - static float linearRadiusMult = fallback->getFallbackFloat("LightAttenuation_LinearRadiusMult"); - static float linearValue = fallback->getFallbackFloat("LightAttenuation_LinearValue"); + static bool outQuadInLin = Fallback::Map::getBool("LightAttenuation_OutQuadInLin"); + static bool useQuadratic = Fallback::Map::getBool("LightAttenuation_UseQuadratic"); + static float quadraticValue = Fallback::Map::getFloat("LightAttenuation_QuadraticValue"); + static float quadraticRadiusMult = Fallback::Map::getFloat("LightAttenuation_QuadraticRadiusMult"); + static bool useLinear = Fallback::Map::getBool("LightAttenuation_UseLinear"); + static float linearRadiusMult = Fallback::Map::getFloat("LightAttenuation_LinearRadiusMult"); + static float linearValue = Fallback::Map::getFloat("LightAttenuation_LinearValue"); bool exterior = mPtr.isInCell() && mPtr.getCell()->getCell()->isExterior(); osg::Vec4f ambient(1,1,1,1); diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 8ec75b1ce..13d3df267 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -1628,14 +1628,13 @@ namespace MWRender void Animation::addExtraLight(osg::ref_ptr parent, const ESM::Light *esmLight) { - const Fallback::Map* fallback = MWBase::Environment::get().getWorld()->getFallback(); - static bool outQuadInLin = fallback->getFallbackBool("LightAttenuation_OutQuadInLin"); - static bool useQuadratic = fallback->getFallbackBool("LightAttenuation_UseQuadratic"); - static float quadraticValue = fallback->getFallbackFloat("LightAttenuation_QuadraticValue"); - static float quadraticRadiusMult = fallback->getFallbackFloat("LightAttenuation_QuadraticRadiusMult"); - static bool useLinear = fallback->getFallbackBool("LightAttenuation_UseLinear"); - static float linearRadiusMult = fallback->getFallbackFloat("LightAttenuation_LinearRadiusMult"); - static float linearValue = fallback->getFallbackFloat("LightAttenuation_LinearValue"); + static bool outQuadInLin = Fallback::Map::getBool("LightAttenuation_OutQuadInLin"); + static bool useQuadratic = Fallback::Map::getBool("LightAttenuation_UseQuadratic"); + static float quadraticValue = Fallback::Map::getFloat("LightAttenuation_QuadraticValue"); + static float quadraticRadiusMult = Fallback::Map::getFloat("LightAttenuation_QuadraticRadiusMult"); + static bool useLinear = Fallback::Map::getBool("LightAttenuation_UseLinear"); + static float linearRadiusMult = Fallback::Map::getFloat("LightAttenuation_LinearRadiusMult"); + static float linearValue = Fallback::Map::getFloat("LightAttenuation_LinearValue"); bool exterior = mPtr.isInCell() && mPtr.getCell()->getCell()->isExterior(); SceneUtil::addLight(parent, esmLight, Mask_ParticleSystem, Mask_Lighting, exterior, outQuadInLin, diff --git a/apps/openmw/mwrender/characterpreview.cpp b/apps/openmw/mwrender/characterpreview.cpp index a3679e844..c4afdde9c 100644 --- a/apps/openmw/mwrender/characterpreview.cpp +++ b/apps/openmw/mwrender/characterpreview.cpp @@ -168,16 +168,15 @@ namespace MWRender stateset->setAttributeAndModes(lightmodel, osg::StateAttribute::ON); osg::ref_ptr light = new osg::Light; - const Fallback::Map* fallback = MWBase::Environment::get().getWorld()->getFallback(); - float diffuseR = fallback->getFallbackFloat("Inventory_DirectionalDiffuseR"); - float diffuseG = fallback->getFallbackFloat("Inventory_DirectionalDiffuseG"); - float diffuseB = fallback->getFallbackFloat("Inventory_DirectionalDiffuseB"); - float ambientR = fallback->getFallbackFloat("Inventory_DirectionalAmbientR"); - float ambientG = fallback->getFallbackFloat("Inventory_DirectionalAmbientG"); - float ambientB = fallback->getFallbackFloat("Inventory_DirectionalAmbientB"); - float azimuth = osg::DegreesToRadians(180.f - fallback->getFallbackFloat("Inventory_DirectionalRotationX")); - float altitude = osg::DegreesToRadians(fallback->getFallbackFloat("Inventory_DirectionalRotationY")); - float positionX = std::cos(azimuth) * std::sin(altitude); + float diffuseR = Fallback::Map::getFloat("Inventory_DirectionalDiffuseR"); + float diffuseG = Fallback::Map::getFloat("Inventory_DirectionalDiffuseG"); + float diffuseB = Fallback::Map::getFloat("Inventory_DirectionalDiffuseB"); + float ambientR = Fallback::Map::getFloat("Inventory_DirectionalAmbientR"); + float ambientG = Fallback::Map::getFloat("Inventory_DirectionalAmbientG"); + float ambientB = Fallback::Map::getFloat("Inventory_DirectionalAmbientB"); + float azimuth = osg::DegreesToRadians(Fallback::Map::getFloat("Inventory_DirectionalRotationX")); + float altitude = osg::DegreesToRadians(Fallback::Map::getFloat("Inventory_DirectionalRotationY")); + float positionX = -std::cos(azimuth) * std::sin(altitude); float positionY = std::sin(azimuth) * std::sin(altitude); float positionZ = std::cos(altitude); light->setPosition(osg::Vec4(positionX,positionY,positionZ, 0.0)); diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index bdefe4c5c..8d0c42940 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -195,8 +195,7 @@ namespace MWRender RenderingManager::RenderingManager(osgViewer::Viewer* viewer, osg::ref_ptr rootNode, Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue, - const Fallback::Map* fallback, const std::string& resourcePath, - DetourNavigator::Navigator& navigator) + const std::string& resourcePath, DetourNavigator::Navigator& navigator) : mViewer(viewer) , mRootNode(rootNode) , mResourceSystem(resourceSystem) @@ -207,9 +206,9 @@ namespace MWRender , mLandFogEnd(std::numeric_limits::max()) , mUnderwaterFogStart(0.f) , mUnderwaterFogEnd(std::numeric_limits::max()) - , mUnderwaterColor(fallback->getFallbackColour("Water_UnderwaterColor")) - , mUnderwaterWeight(fallback->getFallbackFloat("Water_UnderwaterColorWeight")) - , mUnderwaterIndoorFog(fallback->getFallbackFloat("Water_UnderwaterIndoorFog")) + , mUnderwaterColor(Fallback::Map::getColour("Water_UnderwaterColor")) + , mUnderwaterWeight(Fallback::Map::getFloat("Water_UnderwaterColorWeight")) + , mUnderwaterIndoorFog(Fallback::Map::getFloat("Water_UnderwaterIndoorFog")) , mNightEyeFactor(0.f) , mDistantFog(false) , mDistantTerrain(false) @@ -275,7 +274,7 @@ namespace MWRender mEffectManager.reset(new EffectManager(sceneRoot, mResourceSystem)); - mWater.reset(new Water(mRootNode, sceneRoot, mResourceSystem, mViewer->getIncrementalCompileOperation(), fallback, resourcePath)); + mWater.reset(new Water(mRootNode, sceneRoot, mResourceSystem, mViewer->getIncrementalCompileOperation(), resourcePath)); DLLandFogStart = Settings::Manager::getFloat("distant land fog start", "Fog"); DLLandFogEnd = Settings::Manager::getFloat("distant land fog end", "Fog"); diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 8cede92d0..7fb436863 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -86,8 +86,7 @@ namespace MWRender public: RenderingManager(osgViewer::Viewer* viewer, osg::ref_ptr rootNode, Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue, - const Fallback::Map* fallback, const std::string& resourcePath, - DetourNavigator::Navigator& navigator); + const std::string& resourcePath, DetourNavigator::Navigator& navigator); ~RenderingManager(); MWRender::Objects& getObjects(); diff --git a/apps/openmw/mwrender/ripplesimulation.cpp b/apps/openmw/mwrender/ripplesimulation.cpp index a12487060..82d8af241 100644 --- a/apps/openmw/mwrender/ripplesimulation.cpp +++ b/apps/openmw/mwrender/ripplesimulation.cpp @@ -26,13 +26,13 @@ namespace { - void createWaterRippleStateSet(Resource::ResourceSystem* resourceSystem, const Fallback::Map* fallback, osg::Node* node) + void createWaterRippleStateSet(Resource::ResourceSystem* resourceSystem,osg::Node* node) { - int rippleFrameCount = fallback->getFallbackInt("Water_RippleFrameCount"); + int rippleFrameCount = Fallback::Map::getInt("Water_RippleFrameCount"); if (rippleFrameCount <= 0) return; - std::string tex = fallback->getFallbackString("Water_RippleTexture"); + const std::string& tex = Fallback::Map::getString("Water_RippleTexture"); std::vector > textures; for (int i=0; igetFallbackFloat("Water_RippleRotSpeed"))); - particleTemplate.setLifeTime(fallback->getFallbackFloat("Water_RippleLifetime")); + particleTemplate.setAngularVelocity(osg::Vec3f(0,0,Fallback::Map::getFloat("Water_RippleRotSpeed"))); + particleTemplate.setLifeTime(Fallback::Map::getFloat("Water_RippleLifetime")); osg::ref_ptr updater (new osgParticle::ParticleSystemUpdater); updater->addParticleSystem(mParticleSystem); @@ -105,7 +105,7 @@ RippleSimulation::RippleSimulation(osg::Group *parent, Resource::ResourceSystem* mParticleNode->addChild(mParticleSystem); mParticleNode->setNodeMask(Mask_Effect); - createWaterRippleStateSet(resourceSystem, fallback, mParticleNode); + createWaterRippleStateSet(resourceSystem, mParticleNode); mParent->addChild(mParticleNode); } diff --git a/apps/openmw/mwrender/ripplesimulation.hpp b/apps/openmw/mwrender/ripplesimulation.hpp index bca81c59b..186a578ba 100644 --- a/apps/openmw/mwrender/ripplesimulation.hpp +++ b/apps/openmw/mwrender/ripplesimulation.hpp @@ -40,7 +40,7 @@ namespace MWRender class RippleSimulation { public: - RippleSimulation(osg::Group* parent, Resource::ResourceSystem* resourceSystem, const Fallback::Map* fallback); + RippleSimulation(osg::Group* parent, Resource::ResourceSystem* resourceSystem); ~RippleSimulation(); /// @param dt Time since the last frame diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 3b5f0a4fa..a624af0da 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -828,10 +828,9 @@ private: , mTimeOfDayFade(1.f) , mGlareView(1.f) { - const Fallback::Map* fallback = MWBase::Environment::get().getWorld()->getFallback(); - mColor = fallback->getFallbackColour("Weather_Sun_Glare_Fader_Color"); - mSunGlareFaderMax = fallback->getFallbackFloat("Weather_Sun_Glare_Fader_Max"); - mSunGlareFaderAngleMax = fallback->getFallbackFloat("Weather_Sun_Glare_Fader_Angle_Max"); + mColor = Fallback::Map::getColour("Weather_Sun_Glare_Fader_Color"); + mSunGlareFaderMax = Fallback::Map::getFloat("Weather_Sun_Glare_Fader_Max"); + mSunGlareFaderAngleMax = Fallback::Map::getFloat("Weather_Sun_Glare_Fader_Angle_Max"); // Replicating a design flaw in MW. The color was being set on both ambient and emissive properties, which multiplies the result by two, // then finally gets clamped by the fixed function pipeline. With the default INI settings, only the red component gets clamped, @@ -1179,9 +1178,8 @@ void SkyManager::create() mSun.reset(new Sun(mEarlyRenderBinRoot, *mSceneManager->getImageManager())); - const Fallback::Map* fallback=MWBase::Environment::get().getWorld()->getFallback(); - mMasser.reset(new Moon(mEarlyRenderBinRoot, *mSceneManager->getImageManager(), fallback->getFallbackFloat("Moons_Masser_Size")/125, Moon::Type_Masser)); - mSecunda.reset(new Moon(mEarlyRenderBinRoot, *mSceneManager->getImageManager(), fallback->getFallbackFloat("Moons_Secunda_Size")/125, Moon::Type_Secunda)); + mMasser.reset(new Moon(mEarlyRenderBinRoot, *mSceneManager->getImageManager(), Fallback::Map::getFloat("Moons_Masser_Size")/125, Moon::Type_Masser)); + mSecunda.reset(new Moon(mEarlyRenderBinRoot, *mSceneManager->getImageManager(), Fallback::Map::getFloat("Moons_Secunda_Size")/125, Moon::Type_Secunda)); mCloudNode = new osg::PositionAttitudeTransform; mEarlyRenderBinRoot->addChild(mCloudNode); @@ -1205,7 +1203,7 @@ void SkyManager::create() mEarlyRenderBinRoot->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON); mEarlyRenderBinRoot->getOrCreateStateSet()->setMode(GL_FOG, osg::StateAttribute::OFF); - mMoonScriptColor = fallback->getFallbackColour("Moons_Script_Color"); + mMoonScriptColor = Fallback::Map::getColour("Moons_Script_Color"); mCreated = true; } diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index d047130d4..fd7261109 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -400,19 +400,18 @@ public: } }; -Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem *resourceSystem, osgUtil::IncrementalCompileOperation *ico, - const Fallback::Map* fallback, const std::string& resourcePath) +Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem *resourceSystem, + osgUtil::IncrementalCompileOperation *ico, const std::string& resourcePath) : mParent(parent) , mSceneRoot(sceneRoot) , mResourceSystem(resourceSystem) - , mFallback(fallback) , mResourcePath(resourcePath) , mEnabled(true) , mToggled(true) , mTop(0) , mInterior(false) { - mSimulation.reset(new RippleSimulation(parent, resourceSystem, fallback)); + mSimulation.reset(new RippleSimulation(parent, resourceSystem)); mWaterGeom = SceneUtil::createWaterGeometry(Constants::CellSizeInUnits*150, 40, 900); mWaterGeom->setDrawCallback(new DepthClampCallback); @@ -428,7 +427,7 @@ Water::Water(osg::Group *parent, osg::Group* sceneRoot, Resource::ResourceSystem // simple water fallback for the local map osg::ref_ptr geom2 (osg::clone(mWaterGeom.get(), osg::CopyOp::DEEP_COPY_NODES)); - createSimpleWaterStateSet(geom2, mFallback->getFallbackFloat("Water_Map_Alpha")); + createSimpleWaterStateSet(geom2, Fallback::Map::getFloat("Water_Map_Alpha")); geom2->setNodeMask(Mask_SimpleWater); mWaterNode->addChild(geom2); @@ -479,7 +478,7 @@ void Water::updateWaterMaterial() createShaderWaterStateSet(mWaterGeom, mReflection, mRefraction); } else - createSimpleWaterStateSet(mWaterGeom, mFallback->getFallbackFloat("Water_World_Alpha")); + createSimpleWaterStateSet(mWaterGeom, Fallback::Map::getFloat("Water_World_Alpha")); updateVisible(); } @@ -502,8 +501,8 @@ void Water::createSimpleWaterStateSet(osg::Node* node, float alpha) // Add animated textures std::vector > textures; - int frameCount = mFallback->getFallbackInt("Water_SurfaceFrameCount"); - std::string texture = mFallback->getFallbackString("Water_SurfaceTexture"); + int frameCount = Fallback::Map::getInt("Water_SurfaceFrameCount"); + const std::string& texture = Fallback::Map::getString("Water_SurfaceTexture"); for (int i=0; igetFallbackFloat("Water_SurfaceFPS"); + float fps = Fallback::Map::getFloat("Water_SurfaceFPS"); osg::ref_ptr controller (new NifOsg::FlipController(0, 1.f/fps, textures)); controller->setSource(std::shared_ptr(new SceneUtil::FrameTimeSource)); @@ -618,8 +617,8 @@ Water::~Water() void Water::listAssetsToPreload(std::vector &textures) { - int frameCount = mFallback->getFallbackInt("Water_SurfaceFrameCount"); - std::string texture = mFallback->getFallbackString("Water_SurfaceTexture"); + int frameCount = Fallback::Map::getInt("Water_SurfaceFrameCount"); + const std::string& texture = Fallback::Map::getString("Water_SurfaceTexture"); for (int i=0; i mWaterNode; osg::ref_ptr mWaterGeom; Resource::ResourceSystem* mResourceSystem; - const Fallback::Map* mFallback; osg::ref_ptr mIncrementalCompileOperation; std::unique_ptr mSimulation; @@ -85,7 +84,7 @@ namespace MWRender public: Water(osg::Group* parent, osg::Group* sceneRoot, - Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, const Fallback::Map* fallback, + Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, const std::string& resourcePath); ~Water(); diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index ae2c25ead..93a033549 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -33,9 +33,8 @@ namespace MWSound // For combining PlayMode and Type flags inline int operator|(PlayMode a, Type b) { return static_cast(a) | static_cast(b); } - SoundManager::SoundManager(const VFS::Manager* vfs, const std::map& fallbackMap, bool useSound) + SoundManager::SoundManager(const VFS::Manager* vfs, bool useSound) : mVFS(vfs) - , mFallback(fallbackMap) , mOutput(new DEFAULT_OUTPUT(*this)) , mMasterVolume(1.0f) , mSFXVolume(1.0f) @@ -66,12 +65,12 @@ namespace MWSound mFootstepsVolume = Settings::Manager::getFloat("footsteps volume", "Sound"); mFootstepsVolume = std::min(std::max(mFootstepsVolume, 0.0f), 1.0f); - mNearWaterRadius = mFallback.getFallbackInt("Water_NearWaterRadius"); - mNearWaterPoints = mFallback.getFallbackInt("Water_NearWaterPoints"); - mNearWaterIndoorTolerance = mFallback.getFallbackFloat("Water_NearWaterIndoorTolerance"); - mNearWaterOutdoorTolerance = mFallback.getFallbackFloat("Water_NearWaterOutdoorTolerance"); - mNearWaterIndoorID = Misc::StringUtils::lowerCase(mFallback.getFallbackString("Water_NearWaterIndoorID")); - mNearWaterOutdoorID = Misc::StringUtils::lowerCase(mFallback.getFallbackString("Water_NearWaterOutdoorID")); + mNearWaterRadius = Fallback::Map::getInt("Water_NearWaterRadius"); + mNearWaterPoints = Fallback::Map::getInt("Water_NearWaterPoints"); + mNearWaterIndoorTolerance = Fallback::Map::getFloat("Water_NearWaterIndoorTolerance"); + mNearWaterOutdoorTolerance = Fallback::Map::getFloat("Water_NearWaterOutdoorTolerance"); + mNearWaterIndoorID = Misc::StringUtils::lowerCase(Fallback::Map::getString("Water_NearWaterIndoorID")); + mNearWaterOutdoorID = Misc::StringUtils::lowerCase(Fallback::Map::getString("Water_NearWaterOutdoorID")); mBufferCacheMin = std::max(Settings::Manager::getInt("buffer cache min", "Sound"), 1); mBufferCacheMax = std::max(Settings::Manager::getInt("buffer cache max", "Sound"), 1); diff --git a/apps/openmw/mwsound/soundmanagerimp.hpp b/apps/openmw/mwsound/soundmanagerimp.hpp index 9878e924a..d9cf22c32 100644 --- a/apps/openmw/mwsound/soundmanagerimp.hpp +++ b/apps/openmw/mwsound/soundmanagerimp.hpp @@ -46,7 +46,6 @@ namespace MWSound { const VFS::Manager* mVFS; - Fallback::Map mFallback; std::unique_ptr mOutput; // Caches available music tracks by @@ -149,7 +148,7 @@ namespace MWSound ///< Stop the given object from playing given sound buffer. public: - SoundManager(const VFS::Manager* vfs, const std::map& fallbackMap, bool useSound); + SoundManager(const VFS::Manager* vfs, bool useSound); virtual ~SoundManager(); virtual void processChangedSettings(const Settings::CategorySettingVector& settings); diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index c181b95cf..fcb9926be 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -115,67 +115,66 @@ template class MWWorld::TimeOfDayInterpolator; template class MWWorld::TimeOfDayInterpolator; Weather::Weather(const std::string& name, - const Fallback::Map& fallback, float stormWindSpeed, float rainSpeed, float dlFactor, float dlOffset, const std::string& particleEffect) - : mCloudTexture(fallback.getFallbackString("Weather_" + name + "_Cloud_Texture")) - , mSkyColor(fallback.getFallbackColour("Weather_" + name +"_Sky_Sunrise_Color"), - fallback.getFallbackColour("Weather_" + name + "_Sky_Day_Color"), - fallback.getFallbackColour("Weather_" + name + "_Sky_Sunset_Color"), - fallback.getFallbackColour("Weather_" + name + "_Sky_Night_Color")) - , mFogColor(fallback.getFallbackColour("Weather_" + name + "_Fog_Sunrise_Color"), - fallback.getFallbackColour("Weather_" + name + "_Fog_Day_Color"), - fallback.getFallbackColour("Weather_" + name + "_Fog_Sunset_Color"), - fallback.getFallbackColour("Weather_" + name + "_Fog_Night_Color")) - , mAmbientColor(fallback.getFallbackColour("Weather_" + name + "_Ambient_Sunrise_Color"), - fallback.getFallbackColour("Weather_" + name + "_Ambient_Day_Color"), - fallback.getFallbackColour("Weather_" + name + "_Ambient_Sunset_Color"), - fallback.getFallbackColour("Weather_" + name + "_Ambient_Night_Color")) - , mSunColor(fallback.getFallbackColour("Weather_" + name + "_Sun_Sunrise_Color"), - fallback.getFallbackColour("Weather_" + name + "_Sun_Day_Color"), - fallback.getFallbackColour("Weather_" + name + "_Sun_Sunset_Color"), - fallback.getFallbackColour("Weather_" + name + "_Sun_Night_Color")) - , mLandFogDepth(fallback.getFallbackFloat("Weather_" + name + "_Land_Fog_Day_Depth"), - fallback.getFallbackFloat("Weather_" + name + "_Land_Fog_Day_Depth"), - fallback.getFallbackFloat("Weather_" + name + "_Land_Fog_Day_Depth"), - fallback.getFallbackFloat("Weather_" + name + "_Land_Fog_Night_Depth")) - , mSunDiscSunsetColor(fallback.getFallbackColour("Weather_" + name + "_Sun_Disc_Sunset_Color")) - , mWindSpeed(fallback.getFallbackFloat("Weather_" + name + "_Wind_Speed")) - , mCloudSpeed(fallback.getFallbackFloat("Weather_" + name + "_Cloud_Speed")) - , mGlareView(fallback.getFallbackFloat("Weather_" + name + "_Glare_View")) + : mCloudTexture(Fallback::Map::getString("Weather_" + name + "_Cloud_Texture")) + , mSkyColor(Fallback::Map::getColour("Weather_" + name +"_Sky_Sunrise_Color"), + Fallback::Map::getColour("Weather_" + name + "_Sky_Day_Color"), + Fallback::Map::getColour("Weather_" + name + "_Sky_Sunset_Color"), + Fallback::Map::getColour("Weather_" + name + "_Sky_Night_Color")) + , mFogColor(Fallback::Map::getColour("Weather_" + name + "_Fog_Sunrise_Color"), + Fallback::Map::getColour("Weather_" + name + "_Fog_Day_Color"), + Fallback::Map::getColour("Weather_" + name + "_Fog_Sunset_Color"), + Fallback::Map::getColour("Weather_" + name + "_Fog_Night_Color")) + , mAmbientColor(Fallback::Map::getColour("Weather_" + name + "_Ambient_Sunrise_Color"), + Fallback::Map::getColour("Weather_" + name + "_Ambient_Day_Color"), + Fallback::Map::getColour("Weather_" + name + "_Ambient_Sunset_Color"), + Fallback::Map::getColour("Weather_" + name + "_Ambient_Night_Color")) + , mSunColor(Fallback::Map::getColour("Weather_" + name + "_Sun_Sunrise_Color"), + Fallback::Map::getColour("Weather_" + name + "_Sun_Day_Color"), + Fallback::Map::getColour("Weather_" + name + "_Sun_Sunset_Color"), + Fallback::Map::getColour("Weather_" + name + "_Sun_Night_Color")) + , mLandFogDepth(Fallback::Map::getFloat("Weather_" + name + "_Land_Fog_Day_Depth"), + Fallback::Map::getFloat("Weather_" + name + "_Land_Fog_Day_Depth"), + Fallback::Map::getFloat("Weather_" + name + "_Land_Fog_Day_Depth"), + Fallback::Map::getFloat("Weather_" + name + "_Land_Fog_Night_Depth")) + , mSunDiscSunsetColor(Fallback::Map::getColour("Weather_" + name + "_Sun_Disc_Sunset_Color")) + , mWindSpeed(Fallback::Map::getFloat("Weather_" + name + "_Wind_Speed")) + , mCloudSpeed(Fallback::Map::getFloat("Weather_" + name + "_Cloud_Speed")) + , mGlareView(Fallback::Map::getFloat("Weather_" + name + "_Glare_View")) , mIsStorm(mWindSpeed > stormWindSpeed) , mRainSpeed(rainSpeed) - , mRainFrequency(fallback.getFallbackFloat("Weather_" + name + "_Rain_Entrance_Speed")) + , mRainFrequency(Fallback::Map::getFloat("Weather_" + name + "_Rain_Entrance_Speed")) , mParticleEffect(particleEffect) - , mRainEffect(fallback.getFallbackBool("Weather_" + name + "_Using_Precip") ? "meshes\\raindrop.nif" : "") - , mTransitionDelta(fallback.getFallbackFloat("Weather_" + name + "_Transition_Delta")) - , mCloudsMaximumPercent(fallback.getFallbackFloat("Weather_" + name + "_Clouds_Maximum_Percent")) - , mThunderFrequency(fallback.getFallbackFloat("Weather_" + name + "_Thunder_Frequency")) - , mThunderThreshold(fallback.getFallbackFloat("Weather_" + name + "_Thunder_Threshold")) + , mRainEffect(Fallback::Map::getBool("Weather_" + name + "_Using_Precip") ? "meshes\\raindrop.nif" : "") + , mTransitionDelta(Fallback::Map::getFloat("Weather_" + name + "_Transition_Delta")) + , mCloudsMaximumPercent(Fallback::Map::getFloat("Weather_" + name + "_Clouds_Maximum_Percent")) + , mThunderFrequency(Fallback::Map::getFloat("Weather_" + name + "_Thunder_Frequency")) + , mThunderThreshold(Fallback::Map::getFloat("Weather_" + name + "_Thunder_Threshold")) , mThunderSoundID() - , mFlashDecrement(fallback.getFallbackFloat("Weather_" + name + "_Flash_Decrement")) + , mFlashDecrement(Fallback::Map::getFloat("Weather_" + name + "_Flash_Decrement")) , mFlashBrightness(0.0f) { mDL.FogFactor = dlFactor; mDL.FogOffset = dlOffset; - mThunderSoundID[0] = fallback.getFallbackString("Weather_" + name + "_Thunder_Sound_ID_0"); - mThunderSoundID[1] = fallback.getFallbackString("Weather_" + name + "_Thunder_Sound_ID_1"); - mThunderSoundID[2] = fallback.getFallbackString("Weather_" + name + "_Thunder_Sound_ID_2"); - mThunderSoundID[3] = fallback.getFallbackString("Weather_" + name + "_Thunder_Sound_ID_3"); + mThunderSoundID[0] = Fallback::Map::getString("Weather_" + name + "_Thunder_Sound_ID_0"); + mThunderSoundID[1] = Fallback::Map::getString("Weather_" + name + "_Thunder_Sound_ID_1"); + mThunderSoundID[2] = Fallback::Map::getString("Weather_" + name + "_Thunder_Sound_ID_2"); + mThunderSoundID[3] = Fallback::Map::getString("Weather_" + name + "_Thunder_Sound_ID_3"); // TODO: support weathers that have both "Ambient Loop Sound ID" and "Rain Loop Sound ID", need to play both sounds at the same time. if (!mRainEffect.empty()) // NOTE: in vanilla, the weathers with rain seem to be hardcoded; changing Using_Precip has no effect { - mAmbientLoopSoundID = fallback.getFallbackString("Weather_" + name + "_Rain_Loop_Sound_ID"); + mAmbientLoopSoundID = Fallback::Map::getString("Weather_" + name + "_Rain_Loop_Sound_ID"); if (mAmbientLoopSoundID.empty()) // default to "rain" if not set mAmbientLoopSoundID = "rain"; } else - mAmbientLoopSoundID = fallback.getFallbackString("Weather_" + name + "_Ambient_Loop_Sound_ID"); + mAmbientLoopSoundID = Fallback::Map::getString("Weather_" + name + "_Ambient_Loop_Sound_ID"); if (Misc::StringUtils::ciEqual(mAmbientLoopSoundID, "None")) mAmbientLoopSoundID.clear(); @@ -351,17 +350,17 @@ void RegionWeather::chooseNewWeather() mWeather = 0; } -MoonModel::MoonModel(const std::string& name, const Fallback::Map& fallback) - : mFadeInStart(fallback.getFallbackFloat("Moons_" + name + "_Fade_In_Start")) - , mFadeInFinish(fallback.getFallbackFloat("Moons_" + name + "_Fade_In_Finish")) - , mFadeOutStart(fallback.getFallbackFloat("Moons_" + name + "_Fade_Out_Start")) - , mFadeOutFinish(fallback.getFallbackFloat("Moons_" + name + "_Fade_Out_Finish")) - , mAxisOffset(fallback.getFallbackFloat("Moons_" + name + "_Axis_Offset")) - , mSpeed(fallback.getFallbackFloat("Moons_" + name + "_Speed")) - , mDailyIncrement(fallback.getFallbackFloat("Moons_" + name + "_Daily_Increment")) - , mFadeStartAngle(fallback.getFallbackFloat("Moons_" + name + "_Fade_Start_Angle")) - , mFadeEndAngle(fallback.getFallbackFloat("Moons_" + name + "_Fade_End_Angle")) - , mMoonShadowEarlyFadeAngle(fallback.getFallbackFloat("Moons_" + name + "_Moon_Shadow_Early_Fade_Angle")) +MoonModel::MoonModel(const std::string& name) + : mFadeInStart(Fallback::Map::getFloat("Moons_" + name + "_Fade_In_Start")) + , mFadeInFinish(Fallback::Map::getFloat("Moons_" + name + "_Fade_In_Finish")) + , mFadeOutStart(Fallback::Map::getFloat("Moons_" + name + "_Fade_Out_Start")) + , mFadeOutFinish(Fallback::Map::getFloat("Moons_" + name + "_Fade_Out_Finish")) + , mAxisOffset(Fallback::Map::getFloat("Moons_" + name + "_Axis_Offset")) + , mSpeed(Fallback::Map::getFloat("Moons_" + name + "_Speed")) + , mDailyIncrement(Fallback::Map::getFloat("Moons_" + name + "_Daily_Increment")) + , mFadeStartAngle(Fallback::Map::getFloat("Moons_" + name + "_Fade_Start_Angle")) + , mFadeEndAngle(Fallback::Map::getFloat("Moons_" + name + "_Fade_End_Angle")) + , mMoonShadowEarlyFadeAngle(Fallback::Map::getFloat("Moons_" + name + "_Moon_Shadow_Early_Fade_Angle")) { // Morrowind appears to have a minimum speed in order to avoid situations where the moon couldn't conceivably // complete a rotation in a single 24 hour period. The value of 180/23 was deduced from reverse engineering. @@ -520,24 +519,24 @@ inline float MoonModel::earlyMoonShadowAlpha(float angle) const return 0.0f; } -WeatherManager::WeatherManager(MWRender::RenderingManager& rendering, const Fallback::Map& fallback, MWWorld::ESMStore& store) +WeatherManager::WeatherManager(MWRender::RenderingManager& rendering, MWWorld::ESMStore& store) : mStore(store) , mRendering(rendering) - , mSunriseTime(fallback.getFallbackFloat("Weather_Sunrise_Time")) - , mSunsetTime(fallback.getFallbackFloat("Weather_Sunset_Time")) - , mSunriseDuration(fallback.getFallbackFloat("Weather_Sunrise_Duration")) - , mSunsetDuration(fallback.getFallbackFloat("Weather_Sunset_Duration")) - , mSunPreSunsetTime(fallback.getFallbackFloat("Weather_Sun_Pre-Sunset_Time")) + , mSunriseTime(Fallback::Map::getFloat("Weather_Sunrise_Time")) + , mSunsetTime(Fallback::Map::getFloat("Weather_Sunset_Time")) + , mSunriseDuration(Fallback::Map::getFloat("Weather_Sunrise_Duration")) + , mSunsetDuration(Fallback::Map::getFloat("Weather_Sunset_Duration")) + , mSunPreSunsetTime(Fallback::Map::getFloat("Weather_Sun_Pre-Sunset_Time")) , mNightFade(0, 0, 0, 1) - , mHoursBetweenWeatherChanges(fallback.getFallbackFloat("Weather_Hours_Between_Weather_Changes")) - , mRainSpeed(fallback.getFallbackFloat("Weather_Precip_Gravity")) - , mUnderwaterFog(fallback.getFallbackFloat("Water_UnderwaterSunriseFog"), - fallback.getFallbackFloat("Water_UnderwaterDayFog"), - fallback.getFallbackFloat("Water_UnderwaterSunsetFog"), - fallback.getFallbackFloat("Water_UnderwaterNightFog")) + , mHoursBetweenWeatherChanges(Fallback::Map::getFloat("Weather_Hours_Between_Weather_Changes")) + , mRainSpeed(Fallback::Map::getFloat("Weather_Precip_Gravity")) + , mUnderwaterFog(Fallback::Map::getFloat("Water_UnderwaterSunriseFog"), + Fallback::Map::getFloat("Water_UnderwaterDayFog"), + Fallback::Map::getFloat("Water_UnderwaterSunsetFog"), + Fallback::Map::getFloat("Water_UnderwaterNightFog")) , mWeatherSettings() - , mMasser("Masser", fallback) - , mSecunda("Secunda", fallback) + , mMasser("Masser") + , mSecunda("Secunda") , mWindSpeed(0.f) , mIsStorm(false) , mPrecipitation(false) @@ -561,15 +560,15 @@ WeatherManager::WeatherManager(MWRender::RenderingManager& rendering, const Fall mTimeSettings.mDayStart = mSunriseTime + mSunriseDuration; mTimeSettings.mDayEnd = mSunsetTime; - mTimeSettings.addSetting(fallback, "Sky"); - mTimeSettings.addSetting(fallback, "Ambient"); - mTimeSettings.addSetting(fallback, "Fog"); - mTimeSettings.addSetting(fallback, "Sun"); + mTimeSettings.addSetting("Sky"); + mTimeSettings.addSetting("Ambient"); + mTimeSettings.addSetting("Fog"); + mTimeSettings.addSetting("Sun"); // Morrowind handles stars settings differently for other ones - mTimeSettings.mStarsPostSunsetStart = fallback.getFallbackFloat("Weather_Stars_Post-Sunset_Start"); - mTimeSettings.mStarsPreSunriseFinish = fallback.getFallbackFloat("Weather_Stars_Pre-Sunrise_Finish"); - mTimeSettings.mStarsFadingDuration = fallback.getFallbackFloat("Weather_Stars_Fading_Duration"); + mTimeSettings.mStarsPostSunsetStart = Fallback::Map::getFloat("Weather_Stars_Post-Sunset_Start"); + mTimeSettings.mStarsPreSunriseFinish = Fallback::Map::getFloat("Weather_Stars_Pre-Sunrise_Finish"); + mTimeSettings.mStarsFadingDuration = Fallback::Map::getFloat("Weather_Stars_Fading_Duration"); WeatherSetting starSetting = { mTimeSettings.mStarsPreSunriseFinish, @@ -583,16 +582,16 @@ WeatherManager::WeatherManager(MWRender::RenderingManager& rendering, const Fall mWeatherSettings.reserve(10); // These distant land fog factor and offset values are the defaults MGE XE provides. Should be // provided by settings somewhere? - addWeather("Clear", fallback, 1.0f, 0.0f); // 0 - addWeather("Cloudy", fallback, 0.9f, 0.0f); // 1 - addWeather("Foggy", fallback, 0.2f, 30.0f); // 2 - addWeather("Overcast", fallback, 0.7f, 0.0f); // 3 - addWeather("Rain", fallback, 0.5f, 10.0f); // 4 - addWeather("Thunderstorm", fallback, 0.5f, 20.0f); // 5 - addWeather("Ashstorm", fallback, 0.2f, 50.0f, "meshes\\ashcloud.nif"); // 6 - addWeather("Blight", fallback, 0.2f, 60.0f, "meshes\\blightcloud.nif"); // 7 - addWeather("Snow", fallback, 0.5f, 40.0f, "meshes\\snow.nif"); // 8 - addWeather("Blizzard", fallback, 0.16f, 70.0f, "meshes\\blizzard.nif"); // 9 + addWeather("Clear", 1.0f, 0.0f); // 0 + addWeather("Cloudy", 0.9f, 0.0f); // 1 + addWeather("Foggy", 0.2f, 30.0f); // 2 + addWeather("Overcast", 0.7f, 0.0f); // 3 + addWeather("Rain", 0.5f, 10.0f); // 4 + addWeather("Thunderstorm", 0.5f, 20.0f); // 5 + addWeather("Ashstorm", 0.2f, 50.0f, "meshes\\ashcloud.nif"); // 6 + addWeather("Blight", 0.2f, 60.0f, "meshes\\blightcloud.nif"); // 7 + addWeather("Snow", 0.5f, 40.0f, "meshes\\snow.nif"); // 8 + addWeather("Blizzard", 0.16f, 70.0f, "meshes\\blizzard.nif"); // 9 Store::iterator it = store.get().begin(); for(; it != store.get().end(); ++it) @@ -924,13 +923,12 @@ void WeatherManager::clear() } inline void WeatherManager::addWeather(const std::string& name, - const Fallback::Map& fallback, float dlFactor, float dlOffset, const std::string& particleEffect) { static const float fStromWindSpeed = mStore.get().find("fStromWindSpeed")->mValue.getFloat(); - Weather weather(name, fallback, fStromWindSpeed, mRainSpeed, dlFactor, dlOffset, particleEffect); + Weather weather(name, fStromWindSpeed, mRainSpeed, dlFactor, dlOffset, particleEffect); mWeatherSettings.push_back(weather); } diff --git a/apps/openmw/mwworld/weather.hpp b/apps/openmw/mwworld/weather.hpp index f71b34d3e..cd2101ffc 100644 --- a/apps/openmw/mwworld/weather.hpp +++ b/apps/openmw/mwworld/weather.hpp @@ -81,13 +81,13 @@ namespace MWWorld } } - void addSetting(const Fallback::Map& fallback, const std::string& type) + void addSetting(const std::string& type) { WeatherSetting setting = { - fallback.getFallbackFloat("Weather_" + type + "_Pre-Sunrise_Time"), - fallback.getFallbackFloat("Weather_" + type + "_Post-Sunrise_Time"), - fallback.getFallbackFloat("Weather_" + type + "_Pre-Sunset_Time"), - fallback.getFallbackFloat("Weather_" + type + "_Post-Sunset_Time") + Fallback::Map::getFloat("Weather_" + type + "_Pre-Sunrise_Time"), + Fallback::Map::getFloat("Weather_" + type + "_Post-Sunrise_Time"), + Fallback::Map::getFloat("Weather_" + type + "_Pre-Sunset_Time"), + Fallback::Map::getFloat("Weather_" + type + "_Post-Sunset_Time") }; mSunriseTransitions[type] = setting; @@ -116,7 +116,6 @@ namespace MWWorld { public: Weather(const std::string& name, - const Fallback::Map& fallback, float stormWindSpeed, float rainSpeed, float dlFactor, @@ -230,7 +229,7 @@ namespace MWWorld class MoonModel { public: - MoonModel(const std::string& name, const Fallback::Map& fallback); + MoonModel(const std::string& name); MWRender::MoonState calculateState(const TimeStamp& gameTime) const; @@ -260,9 +259,7 @@ namespace MWWorld { public: // Have to pass fallback and Store, can't use singleton since World isn't fully constructed yet at the time - WeatherManager(MWRender::RenderingManager& rendering, - const Fallback::Map& fallback, - MWWorld::ESMStore& store); + WeatherManager(MWRender::RenderingManager& rendering, MWWorld::ESMStore& store); ~WeatherManager(); /** @@ -348,7 +345,6 @@ namespace MWWorld std::string mPlayingSoundID; void addWeather(const std::string& name, - const Fallback::Map& fallback, float dlFactor, float dlOffset, const std::string& particleEffect = ""); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 1d33d039e..771ddcd33 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -156,10 +156,10 @@ namespace MWWorld Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue, const Files::Collections& fileCollections, const std::vector& contentFiles, - ToUTF8::Utf8Encoder* encoder, const std::map& fallbackMap, - int activationDistanceOverride, const std::string& startCell, + ToUTF8::Utf8Encoder* encoder, int activationDistanceOverride, + const std::string& startCell, const std::string& startupScript, const std::string& resourcePath, const std::string& userDataPath) - : mResourceSystem(resourceSystem), mFallback(fallbackMap), mLocalScripts (mStore), + : mResourceSystem(resourceSystem), mLocalScripts (mStore), mSky (true), mCells (mStore, mEsm), mGodMode(false), mScriptsEnabled(true), mContentFiles (contentFiles), mUserDataPath(userDataPath), mActivationDistanceOverride (activationDistanceOverride), @@ -213,11 +213,11 @@ namespace MWWorld mNavigator.reset(new DetourNavigator::NavigatorStub()); } - mRendering.reset(new MWRender::RenderingManager(viewer, rootNode, resourceSystem, workQueue, &mFallback, resourcePath, *mNavigator)); + mRendering.reset(new MWRender::RenderingManager(viewer, rootNode, resourceSystem, workQueue, resourcePath, *mNavigator)); mProjectileManager.reset(new ProjectileManager(mRendering->getLightRoot(), resourceSystem, mRendering.get(), mPhysics.get())); mRendering->preloadCommonAssets(); - mWeatherManager.reset(new MWWorld::WeatherManager(*mRendering, mFallback, mStore)); + mWeatherManager.reset(new MWWorld::WeatherManager(*mRendering, mStore)); mWorldScene.reset(new Scene(*mRendering.get(), mPhysics.get(), *mNavigator)); } @@ -253,7 +253,7 @@ namespace MWWorld // we don't want old weather to persist on a new game // Note that if reset later, the initial ChangeWeather that the chargen script calls will be lost. mWeatherManager.reset(); - mWeatherManager.reset(new MWWorld::WeatherManager(*mRendering.get(), mFallback, mStore)); + mWeatherManager.reset(new MWWorld::WeatherManager(*mRendering.get(), mStore)); if (!bypass) { @@ -298,7 +298,7 @@ namespace MWWorld if (!bypass) { - std::string video = mFallback.getFallbackString("Movies_New_Game"); + const std::string& video = Fallback::Map::getString("Movies_New_Game"); if (!video.empty()) MWBase::Environment::get().getWindowManager()->playVideo(video, true); } @@ -570,11 +570,6 @@ namespace MWWorld return nullptr; } - const Fallback::Map *World::getFallback() const - { - return &mFallback; - } - CellStore *World::getExterior (int x, int y) { return mCells.getExterior (x, y); @@ -1854,7 +1849,7 @@ namespace MWWorld bool isFirstPerson = mRendering->getCamera()->isFirstPerson(); if (isWerewolf && isFirstPerson) { - float werewolfFov = mFallback.getFallbackFloat("General_Werewolf_FOV"); + float werewolfFov = Fallback::Map::getFloat("General_Werewolf_FOV"); if (werewolfFov != 0) mRendering->overrideFieldOfView(werewolfFov); MWBase::Environment::get().getWindowManager()->setWerewolfOverlay(true); @@ -3588,9 +3583,8 @@ namespace MWWorld if (ptr == getPlayerPtr() && Settings::Manager::getBool("hit fader", "GUI")) return; - std::string texture = getFallback()->getFallbackString("Blood_Texture_" + std::to_string(ptr.getClass().getBloodTexture(ptr))); - std::string model = "meshes\\" + getFallback()->getFallbackString("Blood_Model_" + std::to_string(Misc::Rng::rollDice(3))); // [0, 2] - + std::string texture = Fallback::Map::getString("Blood_Texture_" + std::to_string(ptr.getClass().getBloodTexture(ptr))); + std::string model = "meshes\\" + Fallback::Map::getString("Blood_Model_" + std::to_string(Misc::Rng::rollDice(3))); // [0, 2] mRendering->spawnEffect(model, texture, worldPosition, 1.0f, false); } diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index d3e445cff..23d78102f 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -78,8 +78,6 @@ namespace MWWorld { Resource::ResourceSystem* mResourceSystem; - Fallback::Map mFallback; - std::vector mEsm; MWWorld::ESMStore mStore; LocalScripts mLocalScripts; @@ -198,8 +196,9 @@ namespace MWWorld Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue, const Files::Collections& fileCollections, const std::vector& contentFiles, - ToUTF8::Utf8Encoder* encoder, const std::map& fallbackMap, - int activationDistanceOverride, const std::string& startCell, const std::string& resourcePath, const std::string& userDataPath); + ToUTF8::Utf8Encoder* encoder, int activationDistanceOverride, + const std::string& startCell, const std::string& startupScript, + const std::string& resourcePath, const std::string& userDataPath); virtual ~World(); @@ -235,8 +234,6 @@ namespace MWWorld void adjustSky() override; - const Fallback::Map *getFallback() const override; - Player& getPlayer() override; MWWorld::Ptr getPlayerPtr() override; MWWorld::ConstPtr getPlayerConstPtr() const override; diff --git a/components/fallback/fallback.cpp b/components/fallback/fallback.cpp index 9e64d5fea..e2060935e 100644 --- a/components/fallback/fallback.cpp +++ b/components/fallback/fallback.cpp @@ -6,10 +6,14 @@ namespace Fallback { - Map::Map(const std::map& fallback):mFallbackMap(fallback) - {} + std::map Map::mFallbackMap; - std::string Map::getFallbackString(const std::string& fall) const + void Map::init(const std::map& fallback) + { + mFallbackMap = fallback; + } + + std::string Map::getString(const std::string& fall) { std::map::const_iterator it; if ((it = mFallbackMap.find(fall)) == mFallbackMap.end()) @@ -19,9 +23,9 @@ namespace Fallback return it->second; } - float Map::getFallbackFloat(const std::string& fall) const + float Map::getFloat(const std::string& fall) { - std::string fallback = getFallbackString(fall); + const std::string& fallback = getString(fall); if (!fallback.empty()) { try @@ -39,9 +43,9 @@ namespace Fallback return 0; } - int Map::getFallbackInt(const std::string& fall) const + int Map::getInt(const std::string& fall) { - std::string fallback = getFallbackString(fall); + const std::string& fallback = getString(fall); if (!fallback.empty()) { try @@ -61,15 +65,15 @@ namespace Fallback return 0; } - bool Map::getFallbackBool(const std::string& fall) const + bool Map::getBool(const std::string& fall) { - std::string fallback = getFallbackString(fall); + const std::string& fallback = getString(fall); return !fallback.empty() && fallback != "0"; } - osg::Vec4f Map::getFallbackColour(const std::string& fall) const + osg::Vec4f Map::getColour(const std::string& fall) { - std::string sum = getFallbackString(fall); + const std::string& sum = getString(fall); if (!sum.empty()) { try diff --git a/components/fallback/fallback.hpp b/components/fallback/fallback.hpp index e64936531..75a73be5d 100644 --- a/components/fallback/fallback.hpp +++ b/components/fallback/fallback.hpp @@ -11,16 +11,15 @@ namespace Fallback /// @brief contains settings imported from the Morrowind INI file. class Map { - std::map mFallbackMap; + static std::map mFallbackMap; public: - Map(const std::map& fallback); - Map() {} + static void init(const std::map& fallback); - std::string getFallbackString(const std::string& fall) const; - float getFallbackFloat(const std::string& fall) const; - int getFallbackInt(const std::string& fall) const; - bool getFallbackBool(const std::string& fall) const; - osg::Vec4f getFallbackColour(const std::string& fall) const; + static std::string getString(const std::string& fall); + static float getFloat(const std::string& fall); + static int getInt(const std::string& fall); + static bool getBool(const std::string& fall); + static osg::Vec4f getColour(const std::string& fall); }; } #endif diff --git a/components/widgets/tags.cpp b/components/widgets/tags.cpp index 160698c8e..e3575ea8f 100644 --- a/components/widgets/tags.cpp +++ b/components/widgets/tags.cpp @@ -1,11 +1,13 @@ #include "tags.hpp" +#include + #include namespace Gui { -bool replaceTag(const MyGUI::UString& tag, MyGUI::UString& out, const std::map& fallbackSettings) +bool replaceTag(const MyGUI::UString& tag, MyGUI::UString& out) { std::string fontcolour = "fontcolour="; size_t fontcolourLength = fontcolour.length(); @@ -16,14 +18,14 @@ bool replaceTag(const MyGUI::UString& tag, MyGUI::UString& out, const std::map::const_iterator it = fallbackSettings.find(fallbackName); - if (it == fallbackSettings.end()) + std::string str = Fallback::Map::getString(fallbackName); + if (str.empty()) 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::const_iterator it = fallbackSettings.find(fallbackName); - if (it == fallbackSettings.end()) + std::string str = Fallback::Map::getString(fallbackName); + if (str.empty()) 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& fallbackSettings); +bool replaceTag (const MyGUI::UString& tag, MyGUI::UString& out); }