Merge branch 'no_bonus_points' into 'master'

Show mesh origin

Closes #5771

See merge request OpenMW/openmw!507
pull/3042/head
psi29a 4 years ago
commit 654238fd18

@ -119,6 +119,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

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

@ -4,6 +4,8 @@
#include <chrono>
#include <thread>
#include <components/resource/resourcesystem.hpp>
#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;

@ -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();

@ -13,10 +13,15 @@
#include <components/interpreter/opcodes.hpp>
#include <components/misc/rng.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/esm/loadmgef.hpp>
#include <components/esm/loadcrea.hpp>
#include <components/vfs/manager.hpp>
#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;
}

@ -135,6 +135,11 @@ public:
/// @note Thread safe.
const FileList &getList() const
{ return mFiles; }
const std::string& getFilename() const
{
return mFilename;
}
};
}

@ -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<std::string, File*>& 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;
};
}

@ -39,6 +39,23 @@ void BsaArchive::listResources(std::map<std::string, File *> &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)

@ -24,6 +24,8 @@ namespace VFS
BsaArchive(const std::string& filename);
virtual ~BsaArchive();
void listResources(std::map<std::string, File*>& 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<Bsa::BSAFile> mFile;

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

@ -25,6 +25,9 @@ namespace VFS
void listResources(std::map<std::string, File*>& 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 <std::string, FileSystemArchiveFile> index;

@ -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(auto it = mArchives.rbegin(); it != mArchives.rend(); ++it)
{
if((*it)->contains(normalized, mStrict ? &strict_normalize_char : &nonstrict_normalize_char))
return (*it)->getDescription();
}
return {};
}
}

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

Loading…
Cancel
Save