diff --git a/CHANGELOG.md b/CHANGELOG.md index ce0cce952..141edcad2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -116,6 +116,7 @@ Feature #5672: Make stretch menu background configuration more accessible Feature #5692: Improve spell/magic item search to factor in magic effect names Feature #5730: Add graphic herbalism option to the launcher and documents + Feature #5771: ori command should report where a mesh is loaded from and whether the x version is used. Task #5480: Drop Qt4 support Task #5520: Improve cell name autocompleter implementation diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 8f23f710d..81a97b0f2 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -749,6 +749,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) // Create dialog system mEnvironment.setJournal (new MWDialogue::Journal); mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions, mTranslationDataStorage)); + mEnvironment.setResourceSystem(mResourceSystem.get()); // scripts if (mCompileAll) diff --git a/apps/openmw/mwbase/environment.cpp b/apps/openmw/mwbase/environment.cpp index aca2685e0..edb10d945 100644 --- a/apps/openmw/mwbase/environment.cpp +++ b/apps/openmw/mwbase/environment.cpp @@ -4,6 +4,8 @@ #include #include +#include + #include "world.hpp" #include "scriptmanager.hpp" #include "dialoguemanager.hpp" @@ -76,6 +78,11 @@ void MWBase::Environment::setStateManager (StateManager *stateManager) mStateManager = stateManager; } +void MWBase::Environment::setResourceSystem (Resource::ResourceSystem *resourceSystem) +{ + mResourceSystem = resourceSystem; +} + void MWBase::Environment::setFrameDuration (float duration) { mFrameDuration = duration; @@ -158,6 +165,11 @@ MWBase::StateManager *MWBase::Environment::getStateManager() const return mStateManager; } +Resource::ResourceSystem *MWBase::Environment::getResourceSystem() const +{ + return mResourceSystem; +} + float MWBase::Environment::getFrameDuration() const { return mFrameDuration; diff --git a/apps/openmw/mwbase/environment.hpp b/apps/openmw/mwbase/environment.hpp index 80e6a6243..7871153cc 100644 --- a/apps/openmw/mwbase/environment.hpp +++ b/apps/openmw/mwbase/environment.hpp @@ -6,6 +6,11 @@ namespace osg class Stats; } +namespace Resource +{ + class ResourceSystem; +} + namespace MWBase { class World; @@ -37,6 +42,7 @@ namespace MWBase Journal *mJournal; InputManager *mInputManager; StateManager *mStateManager; + Resource::ResourceSystem *mResourceSystem; float mFrameDuration; float mFrameRateLimit; @@ -70,6 +76,8 @@ namespace MWBase void setStateManager (StateManager *stateManager); + void setResourceSystem (Resource::ResourceSystem *resourceSystem); + void setFrameDuration (float duration); ///< Set length of current frame in seconds. @@ -95,6 +103,8 @@ namespace MWBase StateManager *getStateManager() const; + Resource::ResourceSystem *getResourceSystem() const; + float getFrameDuration() const; void cleanup(); diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index a288d6673..d78337a62 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -13,10 +13,15 @@ #include #include +#include + +#include #include #include +#include + #include "../mwbase/environment.hpp" #include "../mwbase/windowmanager.hpp" #include "../mwbase/scriptmanager.hpp" @@ -1377,7 +1382,15 @@ namespace MWScript msg << "Grid: " << cell->getCell()->getGridX() << " " << cell->getCell()->getGridY() << std::endl; osg::Vec3f pos (ptr.getRefData().getPosition().asVec3()); msg << "Coordinates: " << pos.x() << " " << pos.y() << " " << pos.z() << std::endl; - msg << "Model: " << ptr.getClass().getModel(ptr) << std::endl; + auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + std::string model = ::Misc::ResourceHelpers::correctActorModelPath(ptr.getClass().getModel(ptr), vfs); + msg << "Model: " << model << std::endl; + if(!model.empty()) + { + const std::string archive = vfs->getArchive(model); + if(!archive.empty()) + msg << "(" << archive << ")" << std::endl; + } if (!ptr.getClass().getScript(ptr).empty()) msg << "Script: " << ptr.getClass().getScript(ptr) << std::endl; } diff --git a/components/bsa/bsa_file.hpp b/components/bsa/bsa_file.hpp index 037802739..3e7538401 100644 --- a/components/bsa/bsa_file.hpp +++ b/components/bsa/bsa_file.hpp @@ -135,6 +135,11 @@ public: /// @note Thread safe. const FileList &getList() const { return mFiles; } + + const std::string& getFilename() const + { + return mFilename; + } }; } diff --git a/components/vfs/archive.hpp b/components/vfs/archive.hpp index b36c7117b..971ac15b3 100644 --- a/components/vfs/archive.hpp +++ b/components/vfs/archive.hpp @@ -23,6 +23,11 @@ namespace VFS /// List all resources contained in this archive, and run the resource names through the given normalize function. virtual void listResources(std::map& out, char (*normalize_function) (char)) = 0; + + /// True if this archive contains the provided normalized file. + virtual bool contains(const std::string& file, char (*normalize_function) (char)) const = 0; + + virtual std::string getDescription() const = 0; }; } diff --git a/components/vfs/bsaarchive.cpp b/components/vfs/bsaarchive.cpp index ac65c58a1..e6d779aab 100644 --- a/components/vfs/bsaarchive.cpp +++ b/components/vfs/bsaarchive.cpp @@ -39,6 +39,23 @@ void BsaArchive::listResources(std::map &out, char (*normal } } +bool BsaArchive::contains(const std::string& file, char (*normalize_function)(char)) const +{ + for (const auto& it : mResources) + { + std::string ent = it.mInfo->name; + std::transform(ent.begin(), ent.end(), ent.begin(), normalize_function); + if(file == ent) + return true; + } + return false; +} + +std::string BsaArchive::getDescription() const +{ + return std::string{"BSA: "} + mFile->getFilename(); +} + // ------------------------------------------------------------------------------ BsaArchiveFile::BsaArchiveFile(const Bsa::BSAFile::FileStruct *info, Bsa::BSAFile* bsa) diff --git a/components/vfs/bsaarchive.hpp b/components/vfs/bsaarchive.hpp index 65a9db16c..c979b5ce7 100644 --- a/components/vfs/bsaarchive.hpp +++ b/components/vfs/bsaarchive.hpp @@ -24,6 +24,8 @@ namespace VFS BsaArchive(const std::string& filename); virtual ~BsaArchive(); void listResources(std::map& out, char (*normalize_function) (char)) override; + bool contains(const std::string& file, char (*normalize_function) (char)) const override; + std::string getDescription() const override; private: std::unique_ptr mFile; diff --git a/components/vfs/filesystemarchive.cpp b/components/vfs/filesystemarchive.cpp index ce4ff020e..17f3891ec 100644 --- a/components/vfs/filesystemarchive.cpp +++ b/components/vfs/filesystemarchive.cpp @@ -53,6 +53,21 @@ namespace VFS } } + bool FileSystemArchive::contains(const std::string& file, char (*normalize_function)(char)) const + { + for (const auto& it : mIndex) + { + if(it.first == file) + return true; + } + return false; + } + + std::string FileSystemArchive::getDescription() const + { + return std::string{"DIR: "} + mPath; + } + // ---------------------------------------------------------------------------------- FileSystemArchiveFile::FileSystemArchiveFile(const std::string &path) diff --git a/components/vfs/filesystemarchive.hpp b/components/vfs/filesystemarchive.hpp index d228ba87c..70463d32f 100644 --- a/components/vfs/filesystemarchive.hpp +++ b/components/vfs/filesystemarchive.hpp @@ -25,6 +25,9 @@ namespace VFS void listResources(std::map& out, char (*normalize_function) (char)) override; + bool contains(const std::string& file, char (*normalize_function) (char)) const override; + + std::string getDescription() const override; private: typedef std::map index; diff --git a/components/vfs/manager.cpp b/components/vfs/manager.cpp index c19882381..c7abc2483 100644 --- a/components/vfs/manager.cpp +++ b/components/vfs/manager.cpp @@ -96,4 +96,15 @@ namespace VFS normalize_path(name, mStrict); } + std::string Manager::getArchive(const std::string& name) const + { + std::string normalized = name; + normalize_path(normalized, mStrict); + for(const auto archive : mArchives) + { + if(archive->contains(normalized, mStrict ? &strict_normalize_char : &nonstrict_normalize_char)) + return archive->getDescription(); + } + return {}; + } } diff --git a/components/vfs/manager.hpp b/components/vfs/manager.hpp index c5f0a8fec..5a09a995e 100644 --- a/components/vfs/manager.hpp +++ b/components/vfs/manager.hpp @@ -58,6 +58,7 @@ namespace VFS /// @note May be called from any thread once the index has been built. Files::IStreamPtr getNormalized(const std::string& normalizedName) const; + std::string getArchive(const std::string& name) const; private: bool mStrict;