diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp index a7809f3e3..d9f86cdde 100644 --- a/apps/opencs/model/doc/document.cpp +++ b/apps/opencs/model/doc/document.cpp @@ -275,7 +275,7 @@ CSMDoc::Document::Document (VFS::Manager* vfs, const Files::ConfigurationManager const Fallback::Map* fallback, ToUTF8::FromType encoding, CSMWorld::ResourcesManager& resourcesManager, const std::vector& blacklistedScripts) -: mVFS(vfs), mSavePath (savePath), mContentFiles (files), mNew (new_), mData (encoding, resourcesManager, fallback, resDir), +: mVFS(vfs), mSavePath (savePath), mContentFiles (files), mNew (new_), mData (encoding, vfs, resourcesManager, fallback, resDir), mTools (*this, encoding), mProjectPath ((configuration.getUserDataPath() / "projects") / (savePath.filename().string() + ".project")), diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index 61db4ff77..d7f42d027 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -62,9 +62,9 @@ int CSMWorld::Data::count (RecordBase::State state, const CollectionBase& collec return number; } -CSMWorld::Data::Data (ToUTF8::FromType encoding, ResourcesManager& resourcesManager, const Fallback::Map* fallback, const boost::filesystem::path& resDir) +CSMWorld::Data::Data (ToUTF8::FromType encoding, VFS::Manager* vfs, ResourcesManager& resourcesManager, const Fallback::Map* fallback, const boost::filesystem::path& resDir) : mEncoder (encoding), mPathgrids (mCells), mRefs (mCells), - mResourcesManager (resourcesManager), mFallbackMap(fallback), + mVFS(vfs), mResourcesManager (resourcesManager), mFallbackMap(fallback), mReader (0), mDialogue (0), mReaderIndex(1), mResourceSystem(new Resource::ResourceSystem(resourcesManager.getVFS())) { mResourceSystem->getSceneManager()->setShaderPath((resDir / "shaders").string()); @@ -1218,8 +1218,7 @@ std::vector CSMWorld::Data::getIds (bool listDeleted) const void CSMWorld::Data::assetsChanged() { - VFS::Manager* vfs = mResourcesManager.getVFS(); - vfs->rebuildIndex(); + mVFS->rebuildIndex(); ResourceTable* meshTable = static_cast(getTableModel(UniversalId::Type_Meshes)); ResourceTable* iconTable = static_cast(getTableModel(UniversalId::Type_Icons)); @@ -1264,7 +1263,7 @@ void CSMWorld::Data::rowsChanged (const QModelIndex& parent, int start, int end) const VFS::Manager* CSMWorld::Data::getVFS() const { - return mResourcesManager.getVFS(); + return mVFS; } const Fallback::Map* CSMWorld::Data::getFallbackMap() const diff --git a/apps/opencs/model/world/data.hpp b/apps/opencs/model/world/data.hpp index 8fe5eeff9..771a706b3 100644 --- a/apps/opencs/model/world/data.hpp +++ b/apps/opencs/model/world/data.hpp @@ -108,6 +108,7 @@ namespace CSMWorld RefCollection mRefs; IdCollection mFilters; Collection mMetaData; + VFS::Manager* mVFS; ResourcesManager& mResourcesManager; const Fallback::Map* mFallbackMap; std::vector mModels; @@ -140,7 +141,7 @@ namespace CSMWorld public: - Data (ToUTF8::FromType encoding, ResourcesManager& resourcesManager, const Fallback::Map* fallback, const boost::filesystem::path& resDir); + Data (ToUTF8::FromType encoding, VFS::Manager* vfs, ResourcesManager& resourcesManager, const Fallback::Map* fallback, const boost::filesystem::path& resDir); virtual ~Data(); diff --git a/apps/opencs/model/world/resourcesmanager.cpp b/apps/opencs/model/world/resourcesmanager.cpp index 6b271c276..c50b86682 100644 --- a/apps/opencs/model/world/resourcesmanager.cpp +++ b/apps/opencs/model/world/resourcesmanager.cpp @@ -14,16 +14,19 @@ void CSMWorld::ResourcesManager::addResources (const Resources& resources) resources)); } -void CSMWorld::ResourcesManager::setVFS(VFS::Manager *vfs) +const char * const * CSMWorld::ResourcesManager::getMeshExtensions() { - mVFS = vfs; - mResources.clear(); - // maybe we could go over the osgDB::Registry to list all supported node formats - static const char * const sMeshTypes[] = { "nif", "osg", "osgt", "osgb", "osgx", "osg2", 0 }; + return sMeshTypes; +} - addResources (Resources (vfs, "meshes", UniversalId::Type_Mesh, sMeshTypes)); +void CSMWorld::ResourcesManager::setVFS(const VFS::Manager *vfs) +{ + mVFS = vfs; + mResources.clear(); + + addResources (Resources (vfs, "meshes", UniversalId::Type_Mesh, getMeshExtensions())); addResources (Resources (vfs, "icons", UniversalId::Type_Icon)); addResources (Resources (vfs, "music", UniversalId::Type_Music)); addResources (Resources (vfs, "sound", UniversalId::Type_SoundRes)); @@ -31,21 +34,18 @@ void CSMWorld::ResourcesManager::setVFS(VFS::Manager *vfs) addResources (Resources (vfs, "videos", UniversalId::Type_Video)); } -VFS::Manager* CSMWorld::ResourcesManager::getVFS() const +const VFS::Manager* CSMWorld::ResourcesManager::getVFS() const { return mVFS; } void CSMWorld::ResourcesManager::recreateResources() { - // TODO make this shared with setVFS function - static const char * const sMeshTypes[] = { "nif", "osg", "osgt", "osgb", "osgx", "osg2", 0 }; - std::map::iterator it = mResources.begin(); for ( ; it != mResources.end(); ++it) { if (it->first == UniversalId::Type_Mesh) - it->second.recreate(mVFS, sMeshTypes); + it->second.recreate(mVFS, getMeshExtensions()); else it->second.recreate(mVFS); } diff --git a/apps/opencs/model/world/resourcesmanager.hpp b/apps/opencs/model/world/resourcesmanager.hpp index 969666856..0e8385300 100644 --- a/apps/opencs/model/world/resourcesmanager.hpp +++ b/apps/opencs/model/world/resourcesmanager.hpp @@ -16,19 +16,21 @@ namespace CSMWorld class ResourcesManager { std::map mResources; - VFS::Manager* mVFS; + const VFS::Manager* mVFS; private: void addResources (const Resources& resources); + const char * const * getMeshExtensions(); + public: ResourcesManager(); - VFS::Manager* getVFS() const; + const VFS::Manager* getVFS() const; - void setVFS(VFS::Manager* vfs); + void setVFS(const VFS::Manager* vfs); void recreateResources(); diff --git a/components/resource/resourcesystem.cpp b/components/resource/resourcesystem.cpp index b1061adcd..d7a6771c4 100644 --- a/components/resource/resourcesystem.cpp +++ b/components/resource/resourcesystem.cpp @@ -2,8 +2,6 @@ #include -#include - #include "scenemanager.hpp" #include "imagemanager.hpp" #include "niffilemanager.hpp"