diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 2d7c2299a6..a65ccd6932 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -337,12 +337,6 @@ namespace MWBase virtual void playSound(const std::string& soundId, float volume = 1.f, float pitch = 1.f) = 0; - // In WindowManager for now since there isn't a VFS singleton - virtual std::string correctIconPath(const std::string& path) = 0; - virtual std::string correctTexturePath(const std::string& path) = 0; - virtual std::string correctMeshPath(const std::string& path) = 0; - virtual bool textureExists(const std::string& path) = 0; - virtual void addCell(MWWorld::CellStore* cell) = 0; virtual void removeCell(MWWorld::CellStore* cell) = 0; virtual void writeFog(MWWorld::CellStore* cell) = 0; diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index e50b3cca85..4937ca3b03 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -27,6 +27,7 @@ #include "../mwmechanics/npcstats.hpp" +#include "classmodel.hpp" namespace MWClass { @@ -56,13 +57,7 @@ namespace MWClass std::string Activator::getModel(const MWWorld::ConstPtr &ptr) const { - const MWWorld::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->mBase->mModel; - if (!model.empty()) { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); - } - return ""; + return getClassModel(ptr); } bool Activator::isActivator() const @@ -142,11 +137,12 @@ namespace MWClass const std::string model = getModel(ptr); // Assume it's not empty, since we wouldn't have gotten the soundgen otherwise const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); std::string creatureId; + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); for (const ESM::Creature &iter : store.get()) { if (!iter.mModel.empty() && Misc::StringUtils::ciEqual(model, - MWBase::Environment::get().getWindowManager()->correctMeshPath(iter.mModel))) + Misc::ResourceHelpers::correctMeshPath(iter.mModel, vfs))) { creatureId = !iter.mOriginal.empty() ? iter.mOriginal : iter.mId; break; diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index 07dac3e2d7..39dd864f99 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -18,6 +18,8 @@ #include "../mwgui/tooltips.hpp" +#include "classmodel.hpp" + namespace MWClass { Apparatus::Apparatus() @@ -34,13 +36,7 @@ namespace MWClass std::string Apparatus::getModel(const MWWorld::ConstPtr &ptr) const { - const MWWorld::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->mBase->mModel; - if (!model.empty()) { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); - } - return ""; + return getClassModel(ptr); } std::string Apparatus::getName (const MWWorld::ConstPtr& ptr) const diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index d2b5c096cb..2fb6ecba34 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -26,6 +26,8 @@ #include "../mwgui/tooltips.hpp" +#include "classmodel.hpp" + namespace MWClass { Armor::Armor() @@ -42,13 +44,7 @@ namespace MWClass std::string Armor::getModel(const MWWorld::ConstPtr &ptr) const { - const MWWorld::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->mBase->mModel; - if (!model.empty()) { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); - } - return ""; + return getClassModel(ptr); } std::string Armor::getName (const MWWorld::ConstPtr& ptr) const diff --git a/apps/openmw/mwclass/bodypart.cpp b/apps/openmw/mwclass/bodypart.cpp index bd32784a7d..d9438f80c1 100644 --- a/apps/openmw/mwclass/bodypart.cpp +++ b/apps/openmw/mwclass/bodypart.cpp @@ -5,8 +5,7 @@ #include "../mwworld/cellstore.hpp" -#include "../mwbase/environment.hpp" -#include "../mwbase/windowmanager.hpp" +#include "classmodel.hpp" namespace MWClass { @@ -41,13 +40,7 @@ namespace MWClass std::string BodyPart::getModel(const MWWorld::ConstPtr &ptr) const { - const MWWorld::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->mBase->mModel; - if (!model.empty()) { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); - } - return ""; + return getClassModel(ptr); } } diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index c057182187..75648a1180 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -23,6 +23,8 @@ #include "../mwmechanics/npcstats.hpp" +#include "classmodel.hpp" + namespace MWClass { Book::Book() @@ -39,13 +41,7 @@ namespace MWClass std::string Book::getModel(const MWWorld::ConstPtr &ptr) const { - const MWWorld::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->mBase->mModel; - if (!model.empty()) { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); - } - return ""; + return getClassModel(ptr); } std::string Book::getName (const MWWorld::ConstPtr& ptr) const diff --git a/apps/openmw/mwclass/classmodel.hpp b/apps/openmw/mwclass/classmodel.hpp new file mode 100644 index 0000000000..3f5997cf4d --- /dev/null +++ b/apps/openmw/mwclass/classmodel.hpp @@ -0,0 +1,29 @@ +#ifndef OPENMW_MWCLASS_CLASSMODEL_H +#define OPENMW_MWCLASS_CLASSMODEL_H + +#include "../mwbase/environment.hpp" + +#include "../mwworld/ptr.hpp" +#include "../mwworld/livecellref.hpp" + +#include +#include + +#include + +namespace MWClass +{ + template + std::string getClassModel(const MWWorld::ConstPtr& ptr) + { + const MWWorld::LiveCellRef *ref = ptr.get(); + + if (!ref->mBase->mModel.empty()) + return Misc::ResourceHelpers::correctMeshPath(ref->mBase->mModel, + MWBase::Environment::get().getResourceSystem()->getVFS()); + + return {}; + } +} + +#endif diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index 0a922b30af..c20a7dae22 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -21,6 +21,8 @@ #include "../mwrender/objects.hpp" #include "../mwrender/renderinginterface.hpp" +#include "classmodel.hpp" + namespace MWClass { Clothing::Clothing() @@ -37,13 +39,7 @@ namespace MWClass std::string Clothing::getModel(const MWWorld::ConstPtr &ptr) const { - const MWWorld::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->mBase->mModel; - if (!model.empty()) { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); - } - return ""; + return getClassModel(ptr); } std::string Clothing::getName (const MWWorld::ConstPtr& ptr) const diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 38c55cdd52..63b511cadd 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -30,6 +30,8 @@ #include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/inventory.hpp" +#include "classmodel.hpp" + namespace MWClass { ContainerCustomData::ContainerCustomData(const ESM::Container& container, MWWorld::CellStore* cell) @@ -119,13 +121,7 @@ namespace MWClass std::string Container::getModel(const MWWorld::ConstPtr &ptr) const { - const MWWorld::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->mBase->mModel; - if (!model.empty()) { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); - } - return ""; + return getClassModel(ptr); } bool Container::useAnim() const diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index b587fdf146..620315d0a3 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -41,6 +41,8 @@ #include "../mwgui/tooltips.hpp" +#include "classmodel.hpp" + namespace { bool isFlagBitSet(const MWWorld::ConstPtr &ptr, ESM::Creature::Flags bitMask) @@ -182,13 +184,7 @@ namespace MWClass std::string Creature::getModel(const MWWorld::ConstPtr &ptr) const { - const MWWorld::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->mBase->mModel; - if (!model.empty()) { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); - } - return ""; + return getClassModel(ptr); } void Creature::getModelsToPreload(const MWWorld::Ptr &ptr, std::vector &models) const @@ -625,11 +621,12 @@ namespace MWClass const std::string model = getModel(ptr); if (!model.empty()) { + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); for (const ESM::Creature &creature : store.get()) { if (creature.mId != ourId && creature.mOriginal != ourId && !creature.mModel.empty() && Misc::StringUtils::ciEqual(model, - MWBase::Environment::get().getWindowManager()->correctMeshPath(creature.mModel))) + Misc::ResourceHelpers::correctMeshPath(creature.mModel, vfs))) { const std::string& fallbackId = !creature.mOriginal.empty() ? creature.mOriginal : creature.mId; sound = store.get().begin(); diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 23e492bec4..1a8c01571d 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -32,6 +32,8 @@ #include "../mwmechanics/actorutil.hpp" +#include "classmodel.hpp" + namespace MWClass { class DoorCustomData : public MWWorld::TypedCustomData @@ -95,13 +97,7 @@ namespace MWClass std::string Door::getModel(const MWWorld::ConstPtr &ptr) const { - const MWWorld::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->mBase->mModel; - if (!model.empty()) { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); - } - return ""; + return getClassModel(ptr); } std::string Door::getName (const MWWorld::ConstPtr& ptr) const diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 1996e1742e..bd830dc6b7 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -20,6 +20,8 @@ #include "../mwrender/objects.hpp" #include "../mwrender/renderinginterface.hpp" +#include "classmodel.hpp" + namespace MWClass { Ingredient::Ingredient() @@ -36,13 +38,7 @@ namespace MWClass std::string Ingredient::getModel(const MWWorld::ConstPtr &ptr) const { - const MWWorld::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->mBase->mModel; - if (!model.empty()) { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); - } - return ""; + return getClassModel(ptr); } std::string Ingredient::getName (const MWWorld::ConstPtr& ptr) const diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 3b1cb19068..564775b5d2 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -23,6 +23,8 @@ #include "../mwrender/objects.hpp" #include "../mwrender/renderinginterface.hpp" +#include "classmodel.hpp" + namespace MWClass { Light::Light() @@ -67,13 +69,7 @@ namespace MWClass std::string Light::getModel(const MWWorld::ConstPtr &ptr) const { - const MWWorld::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->mBase->mModel; - if (!model.empty()) { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); - } - return ""; + return getClassModel(ptr); } std::string Light::getName (const MWWorld::ConstPtr& ptr) const diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index ff23535145..ee32e2945c 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -20,6 +20,8 @@ #include "../mwrender/objects.hpp" #include "../mwrender/renderinginterface.hpp" +#include "classmodel.hpp" + namespace MWClass { Lockpick::Lockpick() @@ -36,13 +38,7 @@ namespace MWClass std::string Lockpick::getModel(const MWWorld::ConstPtr &ptr) const { - const MWWorld::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->mBase->mModel; - if (!model.empty()) { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); - } - return ""; + return getClassModel(ptr); } std::string Lockpick::getName (const MWWorld::ConstPtr& ptr) const diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 10fada6dbb..be5cf9c143 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -21,6 +21,8 @@ #include "../mwrender/objects.hpp" #include "../mwrender/renderinginterface.hpp" +#include "classmodel.hpp" + namespace MWClass { Miscellaneous::Miscellaneous() @@ -46,13 +48,7 @@ namespace MWClass std::string Miscellaneous::getModel(const MWWorld::ConstPtr &ptr) const { - const MWWorld::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->mBase->mModel; - if (!model.empty()) { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); - } - return ""; + return getClassModel(ptr); } std::string Miscellaneous::getName (const MWWorld::ConstPtr& ptr) const diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 5f2ce00690..1baff60455 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -449,20 +450,22 @@ namespace MWClass models.emplace_back(Settings::Manager::getString("xbaseanimfemale", "Models")); models.emplace_back(Settings::Manager::getString("xbaseanim", "Models")); + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + if (!npc->mBase->mModel.empty()) - models.push_back(MWBase::Environment::get().getWindowManager()->correctMeshPath(npc->mBase->mModel)); + models.push_back(Misc::ResourceHelpers::correctMeshPath(npc->mBase->mModel, vfs)); if (!npc->mBase->mHead.empty()) { const ESM::BodyPart* head = MWBase::Environment::get().getWorld()->getStore().get().search(npc->mBase->mHead); if (head) - models.push_back(MWBase::Environment::get().getWindowManager()->correctMeshPath(head->mModel)); + models.push_back(Misc::ResourceHelpers::correctMeshPath(head->mModel, vfs)); } if (!npc->mBase->mHair.empty()) { const ESM::BodyPart* hair = MWBase::Environment::get().getWorld()->getStore().get().search(npc->mBase->mHair); if (hair) - models.push_back(MWBase::Environment::get().getWindowManager()->correctMeshPath(hair->mModel)); + models.push_back(Misc::ResourceHelpers::correctMeshPath(hair->mModel, vfs)); } bool female = (npc->mBase->mFlags & ESM::NPC::Female); @@ -500,7 +503,7 @@ namespace MWClass partname = female ? it->mMale : it->mFemale; const ESM::BodyPart* part = MWBase::Environment::get().getWorld()->getStore().get().search(partname); if (part && !part->mModel.empty()) - models.push_back(MWBase::Environment::get().getWindowManager()->correctMeshPath(part->mModel)); + models.push_back(Misc::ResourceHelpers::correctMeshPath(part->mModel, vfs)); } } } @@ -513,7 +516,7 @@ namespace MWClass { const ESM::BodyPart* part = *it; if (part && !part->mModel.empty()) - models.push_back(MWBase::Environment::get().getWindowManager()->correctMeshPath(part->mModel)); + models.push_back(Misc::ResourceHelpers::correctMeshPath(part->mModel, vfs)); } } diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index 20f4c3bcce..6e3bf24a5b 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -22,6 +22,8 @@ #include "../mwmechanics/alchemy.hpp" +#include "classmodel.hpp" + namespace MWClass { Potion::Potion() @@ -38,13 +40,7 @@ namespace MWClass std::string Potion::getModel(const MWWorld::ConstPtr &ptr) const { - const MWWorld::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->mBase->mModel; - if (!model.empty()) { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); - } - return ""; + return getClassModel(ptr); } std::string Potion::getName (const MWWorld::ConstPtr& ptr) const diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index ea90c1e78c..e3b22514d5 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -20,6 +20,8 @@ #include "../mwrender/objects.hpp" #include "../mwrender/renderinginterface.hpp" +#include "classmodel.hpp" + namespace MWClass { Probe::Probe() @@ -36,13 +38,7 @@ namespace MWClass std::string Probe::getModel(const MWWorld::ConstPtr &ptr) const { - const MWWorld::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->mBase->mModel; - if (!model.empty()) { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); - } - return ""; + return getClassModel(ptr); } std::string Probe::getName (const MWWorld::ConstPtr& ptr) const diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index 6a23c43303..9da2f7775f 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -17,6 +17,8 @@ #include "../mwrender/objects.hpp" #include "../mwrender/renderinginterface.hpp" +#include "classmodel.hpp" + namespace MWClass { Repair::Repair() @@ -33,13 +35,7 @@ namespace MWClass std::string Repair::getModel(const MWWorld::ConstPtr &ptr) const { - const MWWorld::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->mBase->mModel; - if (!model.empty()) { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); - } - return ""; + return getClassModel(ptr); } std::string Repair::getName (const MWWorld::ConstPtr& ptr) const diff --git a/apps/openmw/mwclass/static.cpp b/apps/openmw/mwclass/static.cpp index 27b04481ad..f587199237 100644 --- a/apps/openmw/mwclass/static.cpp +++ b/apps/openmw/mwclass/static.cpp @@ -11,8 +11,7 @@ #include "../mwrender/renderinginterface.hpp" #include "../mwrender/vismask.hpp" -#include "../mwbase/environment.hpp" -#include "../mwbase/windowmanager.hpp" +#include "classmodel.hpp" namespace MWClass { @@ -42,13 +41,7 @@ namespace MWClass std::string Static::getModel(const MWWorld::ConstPtr &ptr) const { - const MWWorld::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->mBase->mModel; - if (!model.empty()) { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); - } - return ""; + return getClassModel(ptr); } std::string Static::getName (const MWWorld::ConstPtr& ptr) const diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 478e67036c..43bb2b110d 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -26,6 +26,8 @@ #include "../mwrender/objects.hpp" #include "../mwrender/renderinginterface.hpp" +#include "classmodel.hpp" + namespace MWClass { Weapon::Weapon() @@ -42,13 +44,7 @@ namespace MWClass std::string Weapon::getModel(const MWWorld::ConstPtr &ptr) const { - const MWWorld::LiveCellRef *ref = ptr.get(); - - const std::string &model = ref->mBase->mModel; - if (!model.empty()) { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); - } - return ""; + return getClassModel(ptr); } std::string Weapon::getName (const MWWorld::ConstPtr& ptr) const diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 41711f5e4e..f5fc164ee2 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -5,6 +5,9 @@ #include #include +#include +#include + #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" @@ -190,7 +193,8 @@ namespace MWGui const ESM::BirthSign *birth = store.get().find(mCurrentBirthId); - mBirthImage->setImageTexture(MWBase::Environment::get().getWindowManager()->correctTexturePath(birth->mTexture)); + mBirthImage->setImageTexture(Misc::ResourceHelpers::correctTexturePath(birth->mTexture, + MWBase::Environment::get().getResourceSystem()->getVFS())); std::vector abilities, powers, spells; diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 1732bc24ea..9568ba578a 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -13,6 +13,9 @@ #include "../mwworld/esmstore.hpp" #include +#include +#include +#include #include "tooltips.hpp" @@ -920,8 +923,9 @@ namespace MWGui void setClassImage(MyGUI::ImageBox* imageBox, const std::string &classId) { - std::string classImage = std::string("textures\\levelup\\") + classId + ".dds"; - if (!MWBase::Environment::get().getWindowManager()->textureExists(classImage)) + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + std::string classImage = Misc::ResourceHelpers::correctTexturePath("textures\\levelup\\" + classId + ".dds", vfs); + if (!vfs->exists(classImage)) { Log(Debug::Warning) << "No class image for " << classId << ", falling back to default"; classImage = "textures\\levelup\\warrior.dds"; diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 1aa0496ae9..989cd8e258 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -8,6 +8,8 @@ #include #include +#include +#include #include "../mwbase/environment.hpp" #include "../mwbase/windowmanager.hpp" @@ -413,7 +415,7 @@ namespace MWGui std::string icon = effect->mIcon; int slashPos = icon.rfind('\\'); icon.insert(slashPos+1, "b_"); - icon = MWBase::Environment::get().getWindowManager()->correctIconPath(icon); + icon = Misc::ResourceHelpers::correctIconPath(icon, MWBase::Environment::get().getResourceSystem()->getVFS()); mSpellImage->setSpellIcon(icon); } diff --git a/apps/openmw/mwgui/itemwidget.cpp b/apps/openmw/mwgui/itemwidget.cpp index f914ee8556..1ae683f3b4 100644 --- a/apps/openmw/mwgui/itemwidget.cpp +++ b/apps/openmw/mwgui/itemwidget.cpp @@ -9,6 +9,7 @@ // correctIconPath #include #include +#include #include "../mwbase/environment.hpp" #include "../mwbase/windowmanager.hpp" @@ -110,11 +111,12 @@ namespace MWGui std::string invIcon = ptr.getClass().getInventoryIcon(ptr); if (invIcon.empty()) invIcon = "default icon.tga"; - invIcon = MWBase::Environment::get().getWindowManager()->correctIconPath(invIcon); - if (!MWBase::Environment::get().getResourceSystem()->getVFS()->exists(invIcon)) + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + invIcon = Misc::ResourceHelpers::correctIconPath(invIcon, vfs); + if (!vfs->exists(invIcon)) { Log(Debug::Error) << "Failed to open image: '" << invIcon << "' not found, falling back to 'default-icon.tga'"; - invIcon = MWBase::Environment::get().getWindowManager()->correctIconPath("default icon.tga"); + invIcon = Misc::ResourceHelpers::correctIconPath("default icon.tga", vfs); } setIcon(invIcon); } diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index 7f53916d65..793c232e2e 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -8,6 +8,8 @@ #include #include +#include +#include #include "../mwworld/inventorystore.hpp" #include "../mwworld/class.hpp" @@ -300,7 +302,7 @@ namespace MWGui std::string path = effect->mIcon; int slashPos = path.rfind('\\'); path.insert(slashPos+1, "b_"); - path = MWBase::Environment::get().getWindowManager()->correctIconPath(path); + path = Misc::ResourceHelpers::correctIconPath(path, MWBase::Environment::get().getResourceSystem()->getVFS()); float scale = 1.f; MyGUI::ITexture* texture = MyGUI::RenderManager::getInstance().getTexture("textures\\menu_icon_select_magic.dds"); diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 4fa6076ec9..c6ee5b5e66 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -7,6 +7,8 @@ #include #include +#include +#include #include "../mwbase/windowmanager.hpp" #include "../mwbase/mechanicsmanager.hpp" @@ -187,7 +189,8 @@ namespace MWGui void EditEffectDialog::setMagicEffect (const ESM::MagicEffect *effect) { - mEffectImage->setImageTexture(MWBase::Environment::get().getWindowManager()->correctIconPath(effect->mIcon)); + mEffectImage->setImageTexture(Misc::ResourceHelpers::correctIconPath(effect->mIcon, + MWBase::Environment::get().getResourceSystem()->getVFS())); mEffectName->setCaptionWithReplacing("#{"+ESM::MagicEffect::effectIdToString (effect->mIndex)+"}"); diff --git a/apps/openmw/mwgui/spellicons.cpp b/apps/openmw/mwgui/spellicons.cpp index acc5131a22..0934feec1e 100644 --- a/apps/openmw/mwgui/spellicons.cpp +++ b/apps/openmw/mwgui/spellicons.cpp @@ -7,6 +7,8 @@ #include #include +#include +#include #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" @@ -134,7 +136,8 @@ namespace MWGui ("ImageBox", MyGUI::IntCoord(w,2,16,16), MyGUI::Align::Default); mWidgetMap[effectId] = image; - image->setImageTexture(MWBase::Environment::get().getWindowManager()->correctIconPath(effect->mIcon)); + image->setImageTexture(Misc::ResourceHelpers::correctIconPath(effect->mIcon, + MWBase::Environment::get().getResourceSystem()->getVFS())); std::string name = ESM::MagicEffect::effectIdToString (effectId); diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 10ed206e3f..0b37e97245 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -9,6 +9,7 @@ #include #include +#include #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" @@ -436,7 +437,8 @@ namespace MWGui const int maximumWidth = MyGUI::RenderManager::getInstance().getViewSize().width - imageCaptionHPadding * 2; - std::string realImage = MWBase::Environment::get().getWindowManager()->correctIconPath(image); + const std::string realImage = Misc::ResourceHelpers::correctIconPath(image, + MWBase::Environment::get().getResourceSystem()->getVFS()); Gui::EditBox* captionWidget = mDynamicToolTipBox->createWidget("NormalText", MyGUI::IntCoord(0, 0, 300, 300), MyGUI::Align::Left | MyGUI::Align::Top, "ToolTipCaption"); captionWidget->setEditStatic(true); @@ -843,10 +845,11 @@ namespace MWGui MWBase::Environment::get().getWorld()->getStore(); const ESM::BirthSign *sign = store.get().find(birthsignId); + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); widget->setUserString("ToolTipType", "Layout"); widget->setUserString("ToolTipLayout", "BirthSignToolTip"); - widget->setUserString("ImageTexture_BirthSignImage", MWBase::Environment::get().getWindowManager()->correctTexturePath(sign->mTexture)); + widget->setUserString("ImageTexture_BirthSignImage", Misc::ResourceHelpers::correctTexturePath(sign->mTexture, vfs)); std::string text; text += sign->mName; @@ -938,7 +941,7 @@ namespace MWGui std::string icon = effect->mIcon; int slashPos = icon.rfind('\\'); icon.insert(slashPos+1, "b_"); - icon = MWBase::Environment::get().getWindowManager()->correctIconPath(icon); + icon = Misc::ResourceHelpers::correctIconPath(icon, MWBase::Environment::get().getResourceSystem()->getVFS()); widget->setUserString("ToolTipType", "Layout"); widget->setUserString("ToolTipLayout", "MagicEffectToolTip"); diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 3d5fa949c3..97d70240c0 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -7,6 +7,9 @@ #include #include +#include +#include + #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" @@ -470,7 +473,7 @@ namespace MWGui::Widgets mTextWidget->setCaptionWithReplacing(spellLine); mRequestedWidth = mTextWidget->getTextSize().width + sIconOffset; - mImageWidget->setImageTexture(MWBase::Environment::get().getWindowManager()->correctIconPath(magicEffect->mIcon)); + mImageWidget->setImageTexture(Misc::ResourceHelpers::correctIconPath(magicEffect->mIcon, MWBase::Environment::get().getResourceSystem()->getVFS())); } MWSpellEffect::~MWSpellEffect() diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index f768b784eb..a3f039e351 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -2122,27 +2122,6 @@ namespace MWGui mConsole->setConsoleMode(mode); } - std::string WindowManager::correctIconPath(const std::string& path) - { - return Misc::ResourceHelpers::correctIconPath(path, mResourceSystem->getVFS()); - } - - std::string WindowManager::correctTexturePath(const std::string& path) - { - return Misc::ResourceHelpers::correctTexturePath(path, mResourceSystem->getVFS()); - } - - std::string WindowManager::correctMeshPath(const std::string& path) - { - return Misc::ResourceHelpers::correctMeshPath(path, mResourceSystem->getVFS()); - } - - bool WindowManager::textureExists(const std::string &path) - { - std::string corrected = Misc::ResourceHelpers::correctTexturePath(path, mResourceSystem->getVFS()); - return mResourceSystem->getVFS()->exists(corrected); - } - void WindowManager::createCursors() { // FIXME: currently we do not scale cursor since it is not a MyGUI widget. diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index dc17e31a77..2367470223 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -377,12 +377,6 @@ namespace MWGui void playSound(const std::string& soundId, float volume = 1.f, float pitch = 1.f) override; - // In WindowManager for now since there isn't a VFS singleton - std::string correctIconPath(const std::string& path) override; - std::string correctTexturePath(const std::string& path) override; - std::string correctMeshPath(const std::string& path) override; - bool textureExists(const std::string& path) override; - void addCell(MWWorld::CellStore* cell) override; void removeCell(MWWorld::CellStore* cell) override; void writeFog(MWWorld::CellStore* cell) override; diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index 663809d109..e03947d7fc 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -6,6 +6,7 @@ #include #include +#include #include @@ -17,7 +18,6 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" -#include "../mwbase/windowmanager.hpp" #include "../mwrender/animation.hpp" @@ -262,9 +262,12 @@ namespace MWMechanics const ESM::Static* reflectStatic = MWBase::Environment::get().getWorld()->getStore().get().find("VFX_Reflect"); MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr); if(animation && !reflectStatic->mModel.empty()) + { + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); animation->addEffect( - MWBase::Environment::get().getWindowManager()->correctMeshPath(reflectStatic->mModel), + Misc::ResourceHelpers::correctMeshPath(reflectStatic->mModel, vfs), ESM::MagicEffect::Reflect, false, std::string()); + } caster.getClass().getCreatureStats(caster).getActiveSpells().addSpell(*reflected); } if(removedSpell) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index b24149827c..129dda8c19 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "../mwworld/esmstore.hpp" #include "../mwworld/class.hpp" @@ -203,9 +204,12 @@ void soulTrap(const MWWorld::Ptr& creature) const ESM::Static* fx = world->getStore().get() .search("VFX_Soul_Trap"); if (fx) + { + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); world->spawnEffect( - MWBase::Environment::get().getWindowManager()->correctMeshPath(fx->mModel), + Misc::ResourceHelpers::correctMeshPath(fx->mModel, vfs), "", creature.getRefData().getPosition().asVec3()); + } MWBase::Environment::get().getSoundManager()->playSound3D(creature.getRefData().getPosition().asVec3(), "conjuration hit", 1.f, 1.f); return; //remove to get vanilla behaviour @@ -1747,9 +1751,12 @@ namespace MWMechanics const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get() .search("VFX_Summon_End"); if (fx) + { + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); MWBase::Environment::get().getWorld()->spawnEffect( - MWBase::Environment::get().getWindowManager()->correctMeshPath(fx->mModel), + Misc::ResourceHelpers::correctMeshPath(fx->mModel, vfs), "", ptr.getRefData().getPosition().asVec3()); + } // Remove the summoned creature's summoned creatures as well MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr); diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index c60f64884f..7ea3b9a205 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -1402,16 +1403,18 @@ bool CharacterController::updateState(CharacterState idle) const ESM::Static* castStatic = world->getStore().get().find ("VFX_Hands"); + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + for (size_t iter = 0; iter < effects.size(); ++iter) // play hands vfx for each effect { if (mAnimation->getNode("Bip01 L Hand")) mAnimation->addEffect( - MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel), + Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs), -1, false, "Bip01 L Hand", effect->mParticle); if (mAnimation->getNode("Bip01 R Hand")) mAnimation->addEffect( - MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel), + Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs), -1, false, "Bip01 R Hand", effect->mParticle); } diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index dcfd125519..3852d3f61a 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "../mwbase/windowmanager.hpp" #include "../mwbase/soundmanager.hpp" @@ -464,6 +465,8 @@ namespace MWMechanics { const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); std::vector addedEffects; + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + for (const ESM::ENAMstruct& effectData : effects) { const auto effect = store.get().find(effectData.mEffectID); @@ -477,7 +480,7 @@ namespace MWMechanics // check if the effect was already added if (std::find(addedEffects.begin(), addedEffects.end(), - MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel)) + Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs)) != addedEffects.end()) continue; @@ -485,7 +488,7 @@ namespace MWMechanics if (animation) { animation->addEffect( - MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel), + Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs), effect->mIndex, false, "", effect->mParticle); } else @@ -516,7 +519,7 @@ namespace MWMechanics } scale = std::max(scale, 1.f); MWBase::Environment::get().getWorld()->spawnEffect( - MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel), + Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs), effect->mParticle, pos, scale); } @@ -527,7 +530,7 @@ namespace MWMechanics "alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration" }; - addedEffects.push_back(MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel)); + addedEffects.push_back(Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs)); MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); if(!effect->mCastSound.empty()) @@ -565,9 +568,12 @@ namespace MWMechanics { // Don't play particle VFX unless the effect is new or it should be looping. if (playNonLooping || loop) + { + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); anim->addEffect( - MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel), + Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs), magicEffect.mIndex, loop, "", magicEffect.mParticle); + } } } } diff --git a/apps/openmw/mwmechanics/spelleffects.cpp b/apps/openmw/mwmechanics/spelleffects.cpp index e10eaa3ff9..8a92dd5b68 100644 --- a/apps/openmw/mwmechanics/spelleffects.cpp +++ b/apps/openmw/mwmechanics/spelleffects.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "../mwbase/environment.hpp" #include "../mwbase/mechanicsmanager.hpp" @@ -272,9 +273,12 @@ namespace const ESM::Static* absorbStatic = esmStore.get().find("VFX_Absorb"); MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(target); if (animation && !absorbStatic->mModel.empty()) + { + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); animation->addEffect( - MWBase::Environment::get().getWindowManager()->correctMeshPath(absorbStatic->mModel), + Misc::ResourceHelpers::correctMeshPath(absorbStatic->mModel, vfs), ESM::MagicEffect::SpellAbsorption, false, std::string()); + } const ESM::Spell* spell = esmStore.get().search(spellId); int spellCost = 0; if (spell) @@ -432,7 +436,10 @@ void applyMagicEffect(const MWWorld::Ptr& target, const MWWorld::Ptr& caster, co anim->removeEffect(effect.mEffectId); const ESM::Static* fx = world->getStore().get().search("VFX_Summon_end"); if (fx) - anim->addEffect(MWBase::Environment::get().getWindowManager()->correctMeshPath(fx->mModel), -1); + { + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + anim->addEffect(Misc::ResourceHelpers::correctMeshPath(fx->mModel, vfs), -1); + } } } else if (caster == getPlayer()) diff --git a/apps/openmw/mwmechanics/spellutil.cpp b/apps/openmw/mwmechanics/spellutil.cpp index 3c4f094be4..7fa9687189 100644 --- a/apps/openmw/mwmechanics/spellutil.cpp +++ b/apps/openmw/mwmechanics/spellutil.cpp @@ -3,7 +3,6 @@ #include #include "../mwbase/environment.hpp" -#include "../mwbase/windowmanager.hpp" #include "../mwbase/world.hpp" #include "../mwworld/class.hpp" diff --git a/apps/openmw/mwmechanics/summoning.cpp b/apps/openmw/mwmechanics/summoning.cpp index 5fc39f416b..0cf2e26f47 100644 --- a/apps/openmw/mwmechanics/summoning.cpp +++ b/apps/openmw/mwmechanics/summoning.cpp @@ -1,11 +1,11 @@ #include "summoning.hpp" #include +#include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/mechanicsmanager.hpp" -#include "../mwbase/windowmanager.hpp" #include "../mwworld/esmstore.hpp" #include "../mwworld/class.hpp" @@ -86,7 +86,10 @@ namespace MWMechanics { const ESM::Static* fx = world->getStore().get().search("VFX_Summon_Start"); if (fx) - anim->addEffect(MWBase::Environment::get().getWindowManager()->correctMeshPath(fx->mModel), -1, false); + { + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + anim->addEffect(Misc::ResourceHelpers::correctMeshPath(fx->mModel, vfs), -1, false); + } } } catch (std::exception& e) diff --git a/apps/openmw/mwrender/actoranimation.cpp b/apps/openmw/mwrender/actoranimation.cpp index 777a095c9e..373a29bc1a 100644 --- a/apps/openmw/mwrender/actoranimation.cpp +++ b/apps/openmw/mwrender/actoranimation.cpp @@ -17,6 +17,7 @@ #include #include +#include #include @@ -24,7 +25,6 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" -#include "../mwbase/windowmanager.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/class.hpp" #include "../mwworld/cellstore.hpp" @@ -128,7 +128,8 @@ std::string ActorAnimation::getShieldMesh(const MWWorld::ConstPtr& shield, bool if (bodypart == nullptr || bodypart->mData.mType != ESM::BodyPart::MT_Armor) return std::string(); if (!bodypart->mModel.empty()) - return MWBase::Environment::get().getWindowManager()->correctMeshPath(bodypart->mModel); + return Misc::ResourceHelpers::correctMeshPath(bodypart->mModel, + MWBase::Environment::get().getResourceSystem()->getVFS()); } } } diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 00798604ce..bd9fe543c4 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -39,7 +39,6 @@ #include "../mwbase/world.hpp" #include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/soundmanager.hpp" -#include "../mwbase/windowmanager.hpp" #include "camera.hpp" #include "rotatecontroller.hpp" @@ -51,7 +50,7 @@ namespace { -std::string getVampireHead(const std::string& race, bool female) +std::string getVampireHead(const std::string& race, bool female, const VFS::Manager& vfs) { static std::map , const ESM::BodyPart* > sVampireMapping; @@ -81,7 +80,7 @@ std::string getVampireHead(const std::string& race, bool female) const ESM::BodyPart* bodyPart = sVampireMapping[thisCombination]; if (!bodyPart) return std::string(); - return MWBase::Environment::get().getWindowManager()->correctMeshPath(bodyPart->mModel); + return Misc::ResourceHelpers::correctMeshPath(bodyPart->mModel, &vfs); } } @@ -470,7 +469,7 @@ void NpcAnimation::updateNpcBase() { const ESM::BodyPart* bp = store.get().search(headName); if (bp) - mHeadModel = MWBase::Environment::get().getWindowManager()->correctMeshPath(bp->mModel); + mHeadModel = Misc::ResourceHelpers::correctMeshPath(bp->mModel, mResourceSystem->getVFS()); else Log(Debug::Warning) << "Warning: Failed to load body part '" << headName << "'"; } @@ -479,12 +478,12 @@ void NpcAnimation::updateNpcBase() { const ESM::BodyPart* bp = store.get().search(hairName); if (bp) - mHairModel = MWBase::Environment::get().getWindowManager()->correctMeshPath(bp->mModel); + mHairModel = Misc::ResourceHelpers::correctMeshPath(bp->mModel, mResourceSystem->getVFS()); else Log(Debug::Warning) << "Warning: Failed to load body part '" << hairName << "'"; } - const std::string& vampireHead = getVampireHead(mNpc->mRace, isFemale); + const std::string vampireHead = getVampireHead(mNpc->mRace, isFemale, *mResourceSystem->getVFS()); if (!isWerewolf && isVampire && !vampireHead.empty()) mHeadModel = vampireHead; @@ -497,7 +496,7 @@ void NpcAnimation::updateNpcBase() std::string smodel = defaultSkeleton; if (!is1stPerson && !isWerewolf && !mNpc->mModel.empty()) smodel = Misc::ResourceHelpers::correctActorModelPath( - MWBase::Environment::get().getWindowManager()->correctMeshPath(mNpc->mModel), mResourceSystem->getVFS()); + Misc::ResourceHelpers::correctMeshPath(mNpc->mModel, mResourceSystem->getVFS()), mResourceSystem->getVFS()); setObjectRoot(smodel, true, true, false); @@ -657,8 +656,9 @@ void NpcAnimation::updateParts() if(store != inv.end() && (part=*store).getType() == ESM::Light::sRecordId) { const ESM::Light *light = part.get()->mBase; + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1, - MWBase::Environment::get().getWindowManager()->correctMeshPath(light->mModel), false, nullptr, true); + Misc::ResourceHelpers::correctMeshPath(light->mModel, vfs), false, nullptr, true); if (mObjectParts[ESM::PRT_Shield]) addExtraLight(mObjectParts[ESM::PRT_Shield]->getNode()->asGroup(), light); } @@ -677,8 +677,11 @@ void NpcAnimation::updateParts() { const ESM::BodyPart* bodypart = parts[part]; if(bodypart) - addOrReplaceIndividualPart((ESM::PartReferenceType)part, -1, 1, - MWBase::Environment::get().getWindowManager()->correctMeshPath(bodypart->mModel)); + { + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + addOrReplaceIndividualPart(static_cast(part), -1, 1, + Misc::ResourceHelpers::correctMeshPath(bodypart->mModel, vfs)); + } } } @@ -908,8 +911,11 @@ void NpcAnimation::addPartGroup(int group, int priority, const std::vectorcorrectMeshPath(bodypart->mModel), enchantedGlow, glowColor); + { + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + addOrReplaceIndividualPart(static_cast(part.mPart), group, priority, + Misc::ResourceHelpers::correctMeshPath(bodypart->mModel, vfs), enchantedGlow, glowColor); + } else reserveIndividualPart((ESM::PartReferenceType)part.mPart, group, priority); } diff --git a/apps/openmw/mwrender/objectpaging.cpp b/apps/openmw/mwrender/objectpaging.cpp index 848c27db47..20d69bcf11 100644 --- a/apps/openmw/mwrender/objectpaging.cpp +++ b/apps/openmw/mwrender/objectpaging.cpp @@ -32,10 +32,11 @@ #include "apps/openmw/mwworld/esmstore.hpp" #include "apps/openmw/mwbase/environment.hpp" #include "apps/openmw/mwbase/world.hpp" -#include "apps/openmw/mwbase/windowmanager.hpp" #include "vismask.hpp" +#include + namespace MWRender { @@ -532,7 +533,7 @@ namespace MWRender int type = store.findStatic(ref.mRefID); std::string model = getModel(type, ref.mRefID, store); if (model.empty()) continue; - model = MWBase::Environment::get().getWindowManager()->correctMeshPath(model); + model = Misc::ResourceHelpers::correctMeshPath(model, mSceneManager->getVFS()); if (activeGrid && type != ESM::REC_STAT) { diff --git a/apps/openmw/mwworld/groundcoverstore.cpp b/apps/openmw/mwworld/groundcoverstore.cpp index 567735e02a..0c3b016482 100644 --- a/apps/openmw/mwworld/groundcoverstore.cpp +++ b/apps/openmw/mwworld/groundcoverstore.cpp @@ -4,9 +4,10 @@ #include #include #include +#include +#include #include -#include #include "store.hpp" @@ -23,6 +24,8 @@ namespace MWWorld const ::EsmLoader::EsmData content = ::EsmLoader::loadEsmData(query, groundcoverFiles, fileCollections, readers, encoder, listener); + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + static constexpr std::string_view prefix = "grass\\"; for (const ESM::Static& stat : statics) { @@ -31,7 +34,7 @@ namespace MWWorld std::replace(model.begin(), model.end(), '/', '\\'); if (model.compare(0, prefix.size(), prefix) != 0) continue; - mMeshCache[id] = MWBase::Environment::get().getWindowManager()->correctMeshPath(model); + mMeshCache[id] = Misc::ResourceHelpers::correctMeshPath(model, vfs); } for (const ESM::Static& stat : content.mStatics) @@ -41,7 +44,7 @@ namespace MWWorld std::replace(model.begin(), model.end(), '/', '\\'); if (model.compare(0, prefix.size(), prefix) != 0) continue; - mMeshCache[id] = MWBase::Environment::get().getWindowManager()->correctMeshPath(model); + mMeshCache[id] = Misc::ResourceHelpers::correctMeshPath(model, vfs); } for (const ESM::Cell& cell : content.mCells) diff --git a/apps/openmw/mwworld/projectilemanager.cpp b/apps/openmw/mwworld/projectilemanager.cpp index 3acef2db3f..6ede604eea 100644 --- a/apps/openmw/mwworld/projectilemanager.cpp +++ b/apps/openmw/mwworld/projectilemanager.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -211,6 +212,9 @@ namespace MWWorld osg::ref_ptr projectile = mResourceSystem->getSceneManager()->getInstance(model, attachTo); if (state.mIdMagic.size() > 1) + { + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + for (size_t iter = 1; iter != state.mIdMagic.size(); ++iter) { std::ostringstream nodeName; @@ -220,8 +224,9 @@ namespace MWWorld attachTo->accept(findVisitor); if (findVisitor.mFoundNode) mResourceSystem->getSceneManager()->getInstance( - MWBase::Environment::get().getWindowManager()->correctMeshPath(weapon->mModel), findVisitor.mFoundNode); + Misc::ResourceHelpers::correctMeshPath(weapon->mModel, vfs), findVisitor.mFoundNode); } + } if (createLight) { @@ -320,8 +325,11 @@ namespace MWWorld // in case there are multiple effects, the model is a dummy without geometry. Use the second effect for physics shape if (state.mIdMagic.size() > 1) - model = MWBase::Environment::get().getWindowManager()->correctMeshPath( - MWBase::Environment::get().getWorld()->getStore().get().find(state.mIdMagic[1])->mModel); + { + model = Misc::ResourceHelpers::correctMeshPath( + MWBase::Environment::get().getWorld()->getStore().get().find(state.mIdMagic[1])->mModel, + MWBase::Environment::get().getResourceSystem()->getVFS()); + } state.mProjectileId = mPhysics->addProjectile(caster, pos, model, true); state.mToDelete = false; mMagicBolts.push_back(state); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index bd89bca0df..c626ef9d46 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -3690,8 +3690,9 @@ namespace MWWorld if (texture.empty()) texture = Fallback::Map::getString("Blood_Texture_0"); - std::string model = MWBase::Environment::get().getWindowManager()->correctMeshPath( - Fallback::Map::getString("Blood_Model_" + std::to_string(Misc::Rng::rollDice(3)))); // [0, 2] + std::string model = Misc::ResourceHelpers::correctMeshPath( + Fallback::Map::getString("Blood_Model_" + std::to_string(Misc::Rng::rollDice(3))), // [0, 2] + mResourceSystem->getVFS()); mRendering->spawnEffect(model, texture, worldPosition, 1.0f, false); } @@ -3731,13 +3732,13 @@ namespace MWWorld { if (effectInfo.mRange == ESM::RT_Target) mRendering->spawnEffect( - MWBase::Environment::get().getWindowManager()->correctMeshPath(areaStatic->mModel), + Misc::ResourceHelpers::correctMeshPath(areaStatic->mModel, mResourceSystem->getVFS()), texture, origin, 1.0f); continue; } else mRendering->spawnEffect( - MWBase::Environment::get().getWindowManager()->correctMeshPath(areaStatic->mModel), + Misc::ResourceHelpers::correctMeshPath(areaStatic->mModel, mResourceSystem->getVFS()), texture, origin, static_cast(effectInfo.mArea * 2)); // Play explosion sound (make sure to use NoTrack, since we will delete the projectile now)