1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-04-14 04:06:44 +00:00

Merge branch 'correct_path' into 'master'

Use existing functions and objects to call correctMeshPath etc (#6837)

Closes #6837

See merge request OpenMW/openmw!2063
This commit is contained in:
psi29a 2022-06-29 10:22:08 +00:00
commit 451cc6a07c
45 changed files with 222 additions and 226 deletions

View file

@ -337,12 +337,6 @@ namespace MWBase
virtual void playSound(const std::string& soundId, float volume = 1.f, float pitch = 1.f) = 0; 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 addCell(MWWorld::CellStore* cell) = 0;
virtual void removeCell(MWWorld::CellStore* cell) = 0; virtual void removeCell(MWWorld::CellStore* cell) = 0;
virtual void writeFog(MWWorld::CellStore* cell) = 0; virtual void writeFog(MWWorld::CellStore* cell) = 0;

View file

@ -27,6 +27,7 @@
#include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/npcstats.hpp"
#include "classmodel.hpp"
namespace MWClass namespace MWClass
{ {
@ -56,13 +57,7 @@ namespace MWClass
std::string Activator::getModel(const MWWorld::ConstPtr &ptr) const std::string Activator::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>(); return getClassModel<ESM::Activator>(ptr);
const std::string &model = ref->mBase->mModel;
if (!model.empty()) {
return MWBase::Environment::get().getWindowManager()->correctMeshPath(model);
}
return "";
} }
bool Activator::isActivator() const 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 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(); const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
std::string creatureId; std::string creatureId;
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
for (const ESM::Creature &iter : store.get<ESM::Creature>()) for (const ESM::Creature &iter : store.get<ESM::Creature>())
{ {
if (!iter.mModel.empty() && Misc::StringUtils::ciEqual(model, 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; creatureId = !iter.mOriginal.empty() ? iter.mOriginal : iter.mId;
break; break;

View file

@ -18,6 +18,8 @@
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
#include "classmodel.hpp"
namespace MWClass namespace MWClass
{ {
Apparatus::Apparatus() Apparatus::Apparatus()
@ -34,13 +36,7 @@ namespace MWClass
std::string Apparatus::getModel(const MWWorld::ConstPtr &ptr) const std::string Apparatus::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>(); return getClassModel<ESM::Apparatus>(ptr);
const std::string &model = ref->mBase->mModel;
if (!model.empty()) {
return MWBase::Environment::get().getWindowManager()->correctMeshPath(model);
}
return "";
} }
std::string Apparatus::getName (const MWWorld::ConstPtr& ptr) const std::string Apparatus::getName (const MWWorld::ConstPtr& ptr) const

View file

@ -26,6 +26,8 @@
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
#include "classmodel.hpp"
namespace MWClass namespace MWClass
{ {
Armor::Armor() Armor::Armor()
@ -42,13 +44,7 @@ namespace MWClass
std::string Armor::getModel(const MWWorld::ConstPtr &ptr) const std::string Armor::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>(); return getClassModel<ESM::Armor>(ptr);
const std::string &model = ref->mBase->mModel;
if (!model.empty()) {
return MWBase::Environment::get().getWindowManager()->correctMeshPath(model);
}
return "";
} }
std::string Armor::getName (const MWWorld::ConstPtr& ptr) const std::string Armor::getName (const MWWorld::ConstPtr& ptr) const

View file

@ -5,8 +5,7 @@
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwbase/environment.hpp" #include "classmodel.hpp"
#include "../mwbase/windowmanager.hpp"
namespace MWClass namespace MWClass
{ {
@ -41,13 +40,7 @@ namespace MWClass
std::string BodyPart::getModel(const MWWorld::ConstPtr &ptr) const std::string BodyPart::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::BodyPart> *ref = ptr.get<ESM::BodyPart>(); return getClassModel<ESM::BodyPart>(ptr);
const std::string &model = ref->mBase->mModel;
if (!model.empty()) {
return MWBase::Environment::get().getWindowManager()->correctMeshPath(model);
}
return "";
} }
} }

View file

@ -23,6 +23,8 @@
#include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/npcstats.hpp"
#include "classmodel.hpp"
namespace MWClass namespace MWClass
{ {
Book::Book() Book::Book()
@ -39,13 +41,7 @@ namespace MWClass
std::string Book::getModel(const MWWorld::ConstPtr &ptr) const std::string Book::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>(); return getClassModel<ESM::Book>(ptr);
const std::string &model = ref->mBase->mModel;
if (!model.empty()) {
return MWBase::Environment::get().getWindowManager()->correctMeshPath(model);
}
return "";
} }
std::string Book::getName (const MWWorld::ConstPtr& ptr) const std::string Book::getName (const MWWorld::ConstPtr& ptr) const

View file

@ -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 <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <string>
namespace MWClass
{
template <class Class>
std::string getClassModel(const MWWorld::ConstPtr& ptr)
{
const MWWorld::LiveCellRef<Class> *ref = ptr.get<Class>();
if (!ref->mBase->mModel.empty())
return Misc::ResourceHelpers::correctMeshPath(ref->mBase->mModel,
MWBase::Environment::get().getResourceSystem()->getVFS());
return {};
}
}
#endif

View file

@ -21,6 +21,8 @@
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "classmodel.hpp"
namespace MWClass namespace MWClass
{ {
Clothing::Clothing() Clothing::Clothing()
@ -37,13 +39,7 @@ namespace MWClass
std::string Clothing::getModel(const MWWorld::ConstPtr &ptr) const std::string Clothing::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>(); return getClassModel<ESM::Clothing>(ptr);
const std::string &model = ref->mBase->mModel;
if (!model.empty()) {
return MWBase::Environment::get().getWindowManager()->correctMeshPath(model);
}
return "";
} }
std::string Clothing::getName (const MWWorld::ConstPtr& ptr) const std::string Clothing::getName (const MWWorld::ConstPtr& ptr) const

View file

@ -30,6 +30,8 @@
#include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/inventory.hpp" #include "../mwmechanics/inventory.hpp"
#include "classmodel.hpp"
namespace MWClass namespace MWClass
{ {
ContainerCustomData::ContainerCustomData(const ESM::Container& container, MWWorld::CellStore* cell) ContainerCustomData::ContainerCustomData(const ESM::Container& container, MWWorld::CellStore* cell)
@ -119,13 +121,7 @@ namespace MWClass
std::string Container::getModel(const MWWorld::ConstPtr &ptr) const std::string Container::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>(); return getClassModel<ESM::Container>(ptr);
const std::string &model = ref->mBase->mModel;
if (!model.empty()) {
return MWBase::Environment::get().getWindowManager()->correctMeshPath(model);
}
return "";
} }
bool Container::useAnim() const bool Container::useAnim() const

View file

@ -41,6 +41,8 @@
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
#include "classmodel.hpp"
namespace namespace
{ {
bool isFlagBitSet(const MWWorld::ConstPtr &ptr, ESM::Creature::Flags bitMask) 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 std::string Creature::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); return getClassModel<ESM::Creature>(ptr);
const std::string &model = ref->mBase->mModel;
if (!model.empty()) {
return MWBase::Environment::get().getWindowManager()->correctMeshPath(model);
}
return "";
} }
void Creature::getModelsToPreload(const MWWorld::Ptr &ptr, std::vector<std::string> &models) const void Creature::getModelsToPreload(const MWWorld::Ptr &ptr, std::vector<std::string> &models) const
@ -625,11 +621,12 @@ namespace MWClass
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if (!model.empty()) if (!model.empty())
{ {
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
for (const ESM::Creature &creature : store.get<ESM::Creature>()) for (const ESM::Creature &creature : store.get<ESM::Creature>())
{ {
if (creature.mId != ourId && creature.mOriginal != ourId && !creature.mModel.empty() if (creature.mId != ourId && creature.mOriginal != ourId && !creature.mModel.empty()
&& Misc::StringUtils::ciEqual(model, && 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; const std::string& fallbackId = !creature.mOriginal.empty() ? creature.mOriginal : creature.mId;
sound = store.get<ESM::SoundGenerator>().begin(); sound = store.get<ESM::SoundGenerator>().begin();

View file

@ -32,6 +32,8 @@
#include "../mwmechanics/actorutil.hpp" #include "../mwmechanics/actorutil.hpp"
#include "classmodel.hpp"
namespace MWClass namespace MWClass
{ {
class DoorCustomData : public MWWorld::TypedCustomData<DoorCustomData> class DoorCustomData : public MWWorld::TypedCustomData<DoorCustomData>
@ -95,13 +97,7 @@ namespace MWClass
std::string Door::getModel(const MWWorld::ConstPtr &ptr) const std::string Door::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>(); return getClassModel<ESM::Door>(ptr);
const std::string &model = ref->mBase->mModel;
if (!model.empty()) {
return MWBase::Environment::get().getWindowManager()->correctMeshPath(model);
}
return "";
} }
std::string Door::getName (const MWWorld::ConstPtr& ptr) const std::string Door::getName (const MWWorld::ConstPtr& ptr) const

View file

@ -20,6 +20,8 @@
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "classmodel.hpp"
namespace MWClass namespace MWClass
{ {
Ingredient::Ingredient() Ingredient::Ingredient()
@ -36,13 +38,7 @@ namespace MWClass
std::string Ingredient::getModel(const MWWorld::ConstPtr &ptr) const std::string Ingredient::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>(); return getClassModel<ESM::Ingredient>(ptr);
const std::string &model = ref->mBase->mModel;
if (!model.empty()) {
return MWBase::Environment::get().getWindowManager()->correctMeshPath(model);
}
return "";
} }
std::string Ingredient::getName (const MWWorld::ConstPtr& ptr) const std::string Ingredient::getName (const MWWorld::ConstPtr& ptr) const

View file

@ -23,6 +23,8 @@
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "classmodel.hpp"
namespace MWClass namespace MWClass
{ {
Light::Light() Light::Light()
@ -67,13 +69,7 @@ namespace MWClass
std::string Light::getModel(const MWWorld::ConstPtr &ptr) const std::string Light::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>(); return getClassModel<ESM::Light>(ptr);
const std::string &model = ref->mBase->mModel;
if (!model.empty()) {
return MWBase::Environment::get().getWindowManager()->correctMeshPath(model);
}
return "";
} }
std::string Light::getName (const MWWorld::ConstPtr& ptr) const std::string Light::getName (const MWWorld::ConstPtr& ptr) const

View file

@ -20,6 +20,8 @@
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "classmodel.hpp"
namespace MWClass namespace MWClass
{ {
Lockpick::Lockpick() Lockpick::Lockpick()
@ -36,13 +38,7 @@ namespace MWClass
std::string Lockpick::getModel(const MWWorld::ConstPtr &ptr) const std::string Lockpick::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Lockpick> *ref = ptr.get<ESM::Lockpick>(); return getClassModel<ESM::Lockpick>(ptr);
const std::string &model = ref->mBase->mModel;
if (!model.empty()) {
return MWBase::Environment::get().getWindowManager()->correctMeshPath(model);
}
return "";
} }
std::string Lockpick::getName (const MWWorld::ConstPtr& ptr) const std::string Lockpick::getName (const MWWorld::ConstPtr& ptr) const

View file

@ -21,6 +21,8 @@
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "classmodel.hpp"
namespace MWClass namespace MWClass
{ {
Miscellaneous::Miscellaneous() Miscellaneous::Miscellaneous()
@ -46,13 +48,7 @@ namespace MWClass
std::string Miscellaneous::getModel(const MWWorld::ConstPtr &ptr) const std::string Miscellaneous::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>(); return getClassModel<ESM::Miscellaneous>(ptr);
const std::string &model = ref->mBase->mModel;
if (!model.empty()) {
return MWBase::Environment::get().getWindowManager()->correctMeshPath(model);
}
return "";
} }
std::string Miscellaneous::getName (const MWWorld::ConstPtr& ptr) const std::string Miscellaneous::getName (const MWWorld::ConstPtr& ptr) const

View file

@ -6,6 +6,7 @@
#include <components/misc/constants.hpp> #include <components/misc/constants.hpp>
#include <components/misc/rng.hpp> #include <components/misc/rng.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/esm3/loadmgef.hpp> #include <components/esm3/loadmgef.hpp>
@ -449,20 +450,22 @@ namespace MWClass
models.emplace_back(Settings::Manager::getString("xbaseanimfemale", "Models")); models.emplace_back(Settings::Manager::getString("xbaseanimfemale", "Models"));
models.emplace_back(Settings::Manager::getString("xbaseanim", "Models")); models.emplace_back(Settings::Manager::getString("xbaseanim", "Models"));
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
if (!npc->mBase->mModel.empty()) 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()) if (!npc->mBase->mHead.empty())
{ {
const ESM::BodyPart* head = MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>().search(npc->mBase->mHead); const ESM::BodyPart* head = MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>().search(npc->mBase->mHead);
if (head) 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()) if (!npc->mBase->mHair.empty())
{ {
const ESM::BodyPart* hair = MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>().search(npc->mBase->mHair); const ESM::BodyPart* hair = MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>().search(npc->mBase->mHair);
if (hair) 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); bool female = (npc->mBase->mFlags & ESM::NPC::Female);
@ -500,7 +503,7 @@ namespace MWClass
partname = female ? it->mMale : it->mFemale; partname = female ? it->mMale : it->mFemale;
const ESM::BodyPart* part = MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>().search(partname); const ESM::BodyPart* part = MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>().search(partname);
if (part && !part->mModel.empty()) 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; const ESM::BodyPart* part = *it;
if (part && !part->mModel.empty()) if (part && !part->mModel.empty())
models.push_back(MWBase::Environment::get().getWindowManager()->correctMeshPath(part->mModel)); models.push_back(Misc::ResourceHelpers::correctMeshPath(part->mModel, vfs));
} }
} }

View file

@ -22,6 +22,8 @@
#include "../mwmechanics/alchemy.hpp" #include "../mwmechanics/alchemy.hpp"
#include "classmodel.hpp"
namespace MWClass namespace MWClass
{ {
Potion::Potion() Potion::Potion()
@ -38,13 +40,7 @@ namespace MWClass
std::string Potion::getModel(const MWWorld::ConstPtr &ptr) const std::string Potion::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Potion> *ref = ptr.get<ESM::Potion>(); return getClassModel<ESM::Potion>(ptr);
const std::string &model = ref->mBase->mModel;
if (!model.empty()) {
return MWBase::Environment::get().getWindowManager()->correctMeshPath(model);
}
return "";
} }
std::string Potion::getName (const MWWorld::ConstPtr& ptr) const std::string Potion::getName (const MWWorld::ConstPtr& ptr) const

View file

@ -20,6 +20,8 @@
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "classmodel.hpp"
namespace MWClass namespace MWClass
{ {
Probe::Probe() Probe::Probe()
@ -36,13 +38,7 @@ namespace MWClass
std::string Probe::getModel(const MWWorld::ConstPtr &ptr) const std::string Probe::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Probe> *ref = ptr.get<ESM::Probe>(); return getClassModel<ESM::Probe>(ptr);
const std::string &model = ref->mBase->mModel;
if (!model.empty()) {
return MWBase::Environment::get().getWindowManager()->correctMeshPath(model);
}
return "";
} }
std::string Probe::getName (const MWWorld::ConstPtr& ptr) const std::string Probe::getName (const MWWorld::ConstPtr& ptr) const

View file

@ -17,6 +17,8 @@
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "classmodel.hpp"
namespace MWClass namespace MWClass
{ {
Repair::Repair() Repair::Repair()
@ -33,13 +35,7 @@ namespace MWClass
std::string Repair::getModel(const MWWorld::ConstPtr &ptr) const std::string Repair::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Repair> *ref = ptr.get<ESM::Repair>(); return getClassModel<ESM::Repair>(ptr);
const std::string &model = ref->mBase->mModel;
if (!model.empty()) {
return MWBase::Environment::get().getWindowManager()->correctMeshPath(model);
}
return "";
} }
std::string Repair::getName (const MWWorld::ConstPtr& ptr) const std::string Repair::getName (const MWWorld::ConstPtr& ptr) const

View file

@ -11,8 +11,7 @@
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "../mwrender/vismask.hpp" #include "../mwrender/vismask.hpp"
#include "../mwbase/environment.hpp" #include "classmodel.hpp"
#include "../mwbase/windowmanager.hpp"
namespace MWClass namespace MWClass
{ {
@ -42,13 +41,7 @@ namespace MWClass
std::string Static::getModel(const MWWorld::ConstPtr &ptr) const std::string Static::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Static> *ref = ptr.get<ESM::Static>(); return getClassModel<ESM::Static>(ptr);
const std::string &model = ref->mBase->mModel;
if (!model.empty()) {
return MWBase::Environment::get().getWindowManager()->correctMeshPath(model);
}
return "";
} }
std::string Static::getName (const MWWorld::ConstPtr& ptr) const std::string Static::getName (const MWWorld::ConstPtr& ptr) const

View file

@ -26,6 +26,8 @@
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp" #include "../mwrender/renderinginterface.hpp"
#include "classmodel.hpp"
namespace MWClass namespace MWClass
{ {
Weapon::Weapon() Weapon::Weapon()
@ -42,13 +44,7 @@ namespace MWClass
std::string Weapon::getModel(const MWWorld::ConstPtr &ptr) const std::string Weapon::getModel(const MWWorld::ConstPtr &ptr) const
{ {
const MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>(); return getClassModel<ESM::Weapon>(ptr);
const std::string &model = ref->mBase->mModel;
if (!model.empty()) {
return MWBase::Environment::get().getWindowManager()->correctMeshPath(model);
}
return "";
} }
std::string Weapon::getName (const MWWorld::ConstPtr& ptr) const std::string Weapon::getName (const MWWorld::ConstPtr& ptr) const

View file

@ -5,6 +5,9 @@
#include <MyGUI_Gui.h> #include <MyGUI_Gui.h>
#include <MyGUI_ScrollView.h> #include <MyGUI_ScrollView.h>
#include <components/resource/resourcesystem.hpp>
#include <components/misc/resourcehelpers.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
@ -190,7 +193,8 @@ namespace MWGui
const ESM::BirthSign *birth = const ESM::BirthSign *birth =
store.get<ESM::BirthSign>().find(mCurrentBirthId); store.get<ESM::BirthSign>().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<std::string> abilities, powers, spells; std::vector<std::string> abilities, powers, spells;

View file

@ -13,6 +13,9 @@
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/vfs/manager.hpp>
#include "tooltips.hpp" #include "tooltips.hpp"
@ -920,8 +923,9 @@ namespace MWGui
void setClassImage(MyGUI::ImageBox* imageBox, const std::string &classId) void setClassImage(MyGUI::ImageBox* imageBox, const std::string &classId)
{ {
std::string classImage = std::string("textures\\levelup\\") + classId + ".dds"; const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
if (!MWBase::Environment::get().getWindowManager()->textureExists(classImage)) 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"; Log(Debug::Warning) << "No class image for " << classId << ", falling back to default";
classImage = "textures\\levelup\\warrior.dds"; classImage = "textures\\levelup\\warrior.dds";

View file

@ -8,6 +8,8 @@
#include <MyGUI_ScrollView.h> #include <MyGUI_ScrollView.h>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
@ -413,7 +415,7 @@ namespace MWGui
std::string icon = effect->mIcon; std::string icon = effect->mIcon;
int slashPos = icon.rfind('\\'); int slashPos = icon.rfind('\\');
icon.insert(slashPos+1, "b_"); 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); mSpellImage->setSpellIcon(icon);
} }

View file

@ -9,6 +9,7 @@
// correctIconPath // correctIconPath
#include <components/resource/resourcesystem.hpp> #include <components/resource/resourcesystem.hpp>
#include <components/vfs/manager.hpp> #include <components/vfs/manager.hpp>
#include <components/misc/resourcehelpers.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
@ -110,11 +111,12 @@ namespace MWGui
std::string invIcon = ptr.getClass().getInventoryIcon(ptr); std::string invIcon = ptr.getClass().getInventoryIcon(ptr);
if (invIcon.empty()) if (invIcon.empty())
invIcon = "default icon.tga"; invIcon = "default icon.tga";
invIcon = MWBase::Environment::get().getWindowManager()->correctIconPath(invIcon); const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
if (!MWBase::Environment::get().getResourceSystem()->getVFS()->exists(invIcon)) 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'"; 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); setIcon(invIcon);
} }

View file

@ -8,6 +8,8 @@
#include <components/esm3/esmwriter.hpp> #include <components/esm3/esmwriter.hpp>
#include <components/esm3/quickkeys.hpp> #include <components/esm3/quickkeys.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/misc/resourcehelpers.hpp>
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
@ -300,7 +302,7 @@ namespace MWGui
std::string path = effect->mIcon; std::string path = effect->mIcon;
int slashPos = path.rfind('\\'); int slashPos = path.rfind('\\');
path.insert(slashPos+1, "b_"); 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; float scale = 1.f;
MyGUI::ITexture* texture = MyGUI::RenderManager::getInstance().getTexture("textures\\menu_icon_select_magic.dds"); MyGUI::ITexture* texture = MyGUI::RenderManager::getInstance().getTexture("textures\\menu_icon_select_magic.dds");

View file

@ -7,6 +7,8 @@
#include <components/esm/records.hpp> #include <components/esm/records.hpp>
#include <components/widgets/list.hpp> #include <components/widgets/list.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/mechanicsmanager.hpp"
@ -187,7 +189,8 @@ namespace MWGui
void EditEffectDialog::setMagicEffect (const ESM::MagicEffect *effect) 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)+"}"); mEffectName->setCaptionWithReplacing("#{"+ESM::MagicEffect::effectIdToString (effect->mIndex)+"}");

View file

@ -7,6 +7,8 @@
#include <components/esm3/loadmgef.hpp> #include <components/esm3/loadmgef.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
@ -134,7 +136,8 @@ namespace MWGui
("ImageBox", MyGUI::IntCoord(w,2,16,16), MyGUI::Align::Default); ("ImageBox", MyGUI::IntCoord(w,2,16,16), MyGUI::Align::Default);
mWidgetMap[effectId] = image; 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); std::string name = ESM::MagicEffect::effectIdToString (effectId);

View file

@ -9,6 +9,7 @@
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include <components/widgets/box.hpp> #include <components/widgets/box.hpp>
#include <components/misc/resourcehelpers.hpp>
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
@ -436,7 +437,8 @@ namespace MWGui
const int maximumWidth = MyGUI::RenderManager::getInstance().getViewSize().width - imageCaptionHPadding * 2; 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<Gui::EditBox>("NormalText", MyGUI::IntCoord(0, 0, 300, 300), MyGUI::Align::Left | MyGUI::Align::Top, "ToolTipCaption"); Gui::EditBox* captionWidget = mDynamicToolTipBox->createWidget<Gui::EditBox>("NormalText", MyGUI::IntCoord(0, 0, 300, 300), MyGUI::Align::Left | MyGUI::Align::Top, "ToolTipCaption");
captionWidget->setEditStatic(true); captionWidget->setEditStatic(true);
@ -843,10 +845,11 @@ namespace MWGui
MWBase::Environment::get().getWorld()->getStore(); MWBase::Environment::get().getWorld()->getStore();
const ESM::BirthSign *sign = store.get<ESM::BirthSign>().find(birthsignId); const ESM::BirthSign *sign = store.get<ESM::BirthSign>().find(birthsignId);
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
widget->setUserString("ToolTipType", "Layout"); widget->setUserString("ToolTipType", "Layout");
widget->setUserString("ToolTipLayout", "BirthSignToolTip"); 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; std::string text;
text += sign->mName; text += sign->mName;
@ -938,7 +941,7 @@ namespace MWGui
std::string icon = effect->mIcon; std::string icon = effect->mIcon;
int slashPos = icon.rfind('\\'); int slashPos = icon.rfind('\\');
icon.insert(slashPos+1, "b_"); 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("ToolTipType", "Layout");
widget->setUserString("ToolTipLayout", "MagicEffectToolTip"); widget->setUserString("ToolTipLayout", "MagicEffectToolTip");

View file

@ -7,6 +7,9 @@
#include <MyGUI_ImageBox.h> #include <MyGUI_ImageBox.h>
#include <MyGUI_ControllerManager.h> #include <MyGUI_ControllerManager.h>
#include <components/resource/resourcesystem.hpp>
#include <components/misc/resourcehelpers.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
@ -470,7 +473,7 @@ namespace MWGui::Widgets
mTextWidget->setCaptionWithReplacing(spellLine); mTextWidget->setCaptionWithReplacing(spellLine);
mRequestedWidth = mTextWidget->getTextSize().width + sIconOffset; 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() MWSpellEffect::~MWSpellEffect()

View file

@ -2122,27 +2122,6 @@ namespace MWGui
mConsole->setConsoleMode(mode); 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() void WindowManager::createCursors()
{ {
// FIXME: currently we do not scale cursor since it is not a MyGUI widget. // FIXME: currently we do not scale cursor since it is not a MyGUI widget.

View file

@ -377,12 +377,6 @@ namespace MWGui
void playSound(const std::string& soundId, float volume = 1.f, float pitch = 1.f) override; 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 addCell(MWWorld::CellStore* cell) override;
void removeCell(MWWorld::CellStore* cell) override; void removeCell(MWWorld::CellStore* cell) override;
void writeFog(MWWorld::CellStore* cell) override; void writeFog(MWWorld::CellStore* cell) override;

View file

@ -6,6 +6,7 @@
#include <components/misc/rng.hpp> #include <components/misc/rng.hpp>
#include <components/misc/stringops.hpp> #include <components/misc/stringops.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/esm3/loadmgef.hpp> #include <components/esm3/loadmgef.hpp>
@ -17,7 +18,6 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwrender/animation.hpp" #include "../mwrender/animation.hpp"
@ -262,9 +262,12 @@ namespace MWMechanics
const ESM::Static* reflectStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find("VFX_Reflect"); const ESM::Static* reflectStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find("VFX_Reflect");
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr); MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr);
if(animation && !reflectStatic->mModel.empty()) if(animation && !reflectStatic->mModel.empty())
{
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
animation->addEffect( animation->addEffect(
MWBase::Environment::get().getWindowManager()->correctMeshPath(reflectStatic->mModel), Misc::ResourceHelpers::correctMeshPath(reflectStatic->mModel, vfs),
ESM::MagicEffect::Reflect, false, std::string()); ESM::MagicEffect::Reflect, false, std::string());
}
caster.getClass().getCreatureStats(caster).getActiveSpells().addSpell(*reflected); caster.getClass().getCreatureStats(caster).getActiveSpells().addSpell(*reflected);
} }
if(removedSpell) if(removedSpell)

View file

@ -10,6 +10,7 @@
#include <components/misc/rng.hpp> #include <components/misc/rng.hpp>
#include <components/misc/mathutil.hpp> #include <components/misc/mathutil.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include <components/misc/resourcehelpers.hpp>
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
@ -203,9 +204,12 @@ void soulTrap(const MWWorld::Ptr& creature)
const ESM::Static* fx = world->getStore().get<ESM::Static>() const ESM::Static* fx = world->getStore().get<ESM::Static>()
.search("VFX_Soul_Trap"); .search("VFX_Soul_Trap");
if (fx) if (fx)
{
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
world->spawnEffect( world->spawnEffect(
MWBase::Environment::get().getWindowManager()->correctMeshPath(fx->mModel), Misc::ResourceHelpers::correctMeshPath(fx->mModel, vfs),
"", creature.getRefData().getPosition().asVec3()); "", creature.getRefData().getPosition().asVec3());
}
MWBase::Environment::get().getSoundManager()->playSound3D(creature.getRefData().getPosition().asVec3(), "conjuration hit", 1.f, 1.f); MWBase::Environment::get().getSoundManager()->playSound3D(creature.getRefData().getPosition().asVec3(), "conjuration hit", 1.f, 1.f);
return; //remove to get vanilla behaviour return; //remove to get vanilla behaviour
@ -1747,9 +1751,12 @@ namespace MWMechanics
const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>() const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>()
.search("VFX_Summon_End"); .search("VFX_Summon_End");
if (fx) if (fx)
{
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
MWBase::Environment::get().getWorld()->spawnEffect( MWBase::Environment::get().getWorld()->spawnEffect(
MWBase::Environment::get().getWindowManager()->correctMeshPath(fx->mModel), Misc::ResourceHelpers::correctMeshPath(fx->mModel, vfs),
"", ptr.getRefData().getPosition().asVec3()); "", ptr.getRefData().getPosition().asVec3());
}
// Remove the summoned creature's summoned creatures as well // Remove the summoned creature's summoned creatures as well
MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr); MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr);

View file

@ -24,6 +24,7 @@
#include <components/misc/mathutil.hpp> #include <components/misc/mathutil.hpp>
#include <components/misc/rng.hpp> #include <components/misc/rng.hpp>
#include <components/misc/stringops.hpp> #include <components/misc/stringops.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
@ -1402,16 +1403,18 @@ bool CharacterController::updateState(CharacterState idle)
const ESM::Static* castStatic = world->getStore().get<ESM::Static>().find ("VFX_Hands"); const ESM::Static* castStatic = world->getStore().get<ESM::Static>().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 for (size_t iter = 0; iter < effects.size(); ++iter) // play hands vfx for each effect
{ {
if (mAnimation->getNode("Bip01 L Hand")) if (mAnimation->getNode("Bip01 L Hand"))
mAnimation->addEffect( mAnimation->addEffect(
MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel), Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs),
-1, false, "Bip01 L Hand", effect->mParticle); -1, false, "Bip01 L Hand", effect->mParticle);
if (mAnimation->getNode("Bip01 R Hand")) if (mAnimation->getNode("Bip01 R Hand"))
mAnimation->addEffect( mAnimation->addEffect(
MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel), Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs),
-1, false, "Bip01 R Hand", effect->mParticle); -1, false, "Bip01 R Hand", effect->mParticle);
} }

View file

@ -2,6 +2,7 @@
#include <components/misc/constants.hpp> #include <components/misc/constants.hpp>
#include <components/misc/rng.hpp> #include <components/misc/rng.hpp>
#include <components/misc/resourcehelpers.hpp>
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
@ -464,6 +465,8 @@ namespace MWMechanics
{ {
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
std::vector<std::string> addedEffects; std::vector<std::string> addedEffects;
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
for (const ESM::ENAMstruct& effectData : effects) for (const ESM::ENAMstruct& effectData : effects)
{ {
const auto effect = store.get<ESM::MagicEffect>().find(effectData.mEffectID); const auto effect = store.get<ESM::MagicEffect>().find(effectData.mEffectID);
@ -477,7 +480,7 @@ namespace MWMechanics
// check if the effect was already added // check if the effect was already added
if (std::find(addedEffects.begin(), addedEffects.end(), if (std::find(addedEffects.begin(), addedEffects.end(),
MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel)) Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs))
!= addedEffects.end()) != addedEffects.end())
continue; continue;
@ -485,7 +488,7 @@ namespace MWMechanics
if (animation) if (animation)
{ {
animation->addEffect( animation->addEffect(
MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel), Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs),
effect->mIndex, false, "", effect->mParticle); effect->mIndex, false, "", effect->mParticle);
} }
else else
@ -516,7 +519,7 @@ namespace MWMechanics
} }
scale = std::max(scale, 1.f); scale = std::max(scale, 1.f);
MWBase::Environment::get().getWorld()->spawnEffect( MWBase::Environment::get().getWorld()->spawnEffect(
MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel), Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs),
effect->mParticle, pos, scale); effect->mParticle, pos, scale);
} }
@ -527,7 +530,7 @@ namespace MWMechanics
"alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration" "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(); MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
if(!effect->mCastSound.empty()) 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. // Don't play particle VFX unless the effect is new or it should be looping.
if (playNonLooping || loop) if (playNonLooping || loop)
{
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
anim->addEffect( anim->addEffect(
MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel), Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs),
magicEffect.mIndex, loop, "", magicEffect.mParticle); magicEffect.mIndex, loop, "", magicEffect.mParticle);
} }
} }
} }
}

View file

@ -5,6 +5,7 @@
#include <components/esm3/loadmgef.hpp> #include <components/esm3/loadmgef.hpp>
#include <components/misc/rng.hpp> #include <components/misc/rng.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include <components/misc/resourcehelpers.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/mechanicsmanager.hpp"
@ -272,9 +273,12 @@ namespace
const ESM::Static* absorbStatic = esmStore.get<ESM::Static>().find("VFX_Absorb"); const ESM::Static* absorbStatic = esmStore.get<ESM::Static>().find("VFX_Absorb");
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(target); MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(target);
if (animation && !absorbStatic->mModel.empty()) if (animation && !absorbStatic->mModel.empty())
{
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
animation->addEffect( animation->addEffect(
MWBase::Environment::get().getWindowManager()->correctMeshPath(absorbStatic->mModel), Misc::ResourceHelpers::correctMeshPath(absorbStatic->mModel, vfs),
ESM::MagicEffect::SpellAbsorption, false, std::string()); ESM::MagicEffect::SpellAbsorption, false, std::string());
}
const ESM::Spell* spell = esmStore.get<ESM::Spell>().search(spellId); const ESM::Spell* spell = esmStore.get<ESM::Spell>().search(spellId);
int spellCost = 0; int spellCost = 0;
if (spell) if (spell)
@ -432,7 +436,10 @@ void applyMagicEffect(const MWWorld::Ptr& target, const MWWorld::Ptr& caster, co
anim->removeEffect(effect.mEffectId); anim->removeEffect(effect.mEffectId);
const ESM::Static* fx = world->getStore().get<ESM::Static>().search("VFX_Summon_end"); const ESM::Static* fx = world->getStore().get<ESM::Static>().search("VFX_Summon_end");
if (fx) 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()) else if (caster == getPlayer())

View file

@ -3,7 +3,6 @@
#include <limits> #include <limits>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"

View file

@ -1,11 +1,11 @@
#include "summoning.hpp" #include "summoning.hpp"
#include <components/debug/debuglog.hpp> #include <components/debug/debuglog.hpp>
#include <components/misc/resourcehelpers.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
@ -86,7 +86,10 @@ namespace MWMechanics
{ {
const ESM::Static* fx = world->getStore().get<ESM::Static>().search("VFX_Summon_Start"); const ESM::Static* fx = world->getStore().get<ESM::Static>().search("VFX_Summon_Start");
if (fx) 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) catch (std::exception& e)

View file

@ -17,6 +17,7 @@
#include <components/sceneutil/visitor.hpp> #include <components/sceneutil/visitor.hpp>
#include <components/misc/stringops.hpp> #include <components/misc/stringops.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
@ -24,7 +25,6 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/cellstore.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) if (bodypart == nullptr || bodypart->mData.mType != ESM::BodyPart::MT_Armor)
return std::string(); return std::string();
if (!bodypart->mModel.empty()) if (!bodypart->mModel.empty())
return MWBase::Environment::get().getWindowManager()->correctMeshPath(bodypart->mModel); return Misc::ResourceHelpers::correctMeshPath(bodypart->mModel,
MWBase::Environment::get().getResourceSystem()->getVFS());
} }
} }
} }

View file

@ -39,7 +39,6 @@
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "camera.hpp" #include "camera.hpp"
#include "rotatecontroller.hpp" #include "rotatecontroller.hpp"
@ -51,7 +50,7 @@
namespace 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 <std::pair<std::string,int>, const ESM::BodyPart* > sVampireMapping; static std::map <std::pair<std::string,int>, const ESM::BodyPart* > sVampireMapping;
@ -81,7 +80,7 @@ std::string getVampireHead(const std::string& race, bool female)
const ESM::BodyPart* bodyPart = sVampireMapping[thisCombination]; const ESM::BodyPart* bodyPart = sVampireMapping[thisCombination];
if (!bodyPart) if (!bodyPart)
return std::string(); 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<ESM::BodyPart>().search(headName); const ESM::BodyPart* bp = store.get<ESM::BodyPart>().search(headName);
if (bp) if (bp)
mHeadModel = MWBase::Environment::get().getWindowManager()->correctMeshPath(bp->mModel); mHeadModel = Misc::ResourceHelpers::correctMeshPath(bp->mModel, mResourceSystem->getVFS());
else else
Log(Debug::Warning) << "Warning: Failed to load body part '" << headName << "'"; Log(Debug::Warning) << "Warning: Failed to load body part '" << headName << "'";
} }
@ -479,12 +478,12 @@ void NpcAnimation::updateNpcBase()
{ {
const ESM::BodyPart* bp = store.get<ESM::BodyPart>().search(hairName); const ESM::BodyPart* bp = store.get<ESM::BodyPart>().search(hairName);
if (bp) if (bp)
mHairModel = MWBase::Environment::get().getWindowManager()->correctMeshPath(bp->mModel); mHairModel = Misc::ResourceHelpers::correctMeshPath(bp->mModel, mResourceSystem->getVFS());
else else
Log(Debug::Warning) << "Warning: Failed to load body part '" << hairName << "'"; 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()) if (!isWerewolf && isVampire && !vampireHead.empty())
mHeadModel = vampireHead; mHeadModel = vampireHead;
@ -497,7 +496,7 @@ void NpcAnimation::updateNpcBase()
std::string smodel = defaultSkeleton; std::string smodel = defaultSkeleton;
if (!is1stPerson && !isWerewolf && !mNpc->mModel.empty()) if (!is1stPerson && !isWerewolf && !mNpc->mModel.empty())
smodel = Misc::ResourceHelpers::correctActorModelPath( 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); setObjectRoot(smodel, true, true, false);
@ -657,8 +656,9 @@ void NpcAnimation::updateParts()
if(store != inv.end() && (part=*store).getType() == ESM::Light::sRecordId) if(store != inv.end() && (part=*store).getType() == ESM::Light::sRecordId)
{ {
const ESM::Light *light = part.get<ESM::Light>()->mBase; const ESM::Light *light = part.get<ESM::Light>()->mBase;
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1, 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]) if (mObjectParts[ESM::PRT_Shield])
addExtraLight(mObjectParts[ESM::PRT_Shield]->getNode()->asGroup(), light); addExtraLight(mObjectParts[ESM::PRT_Shield]->getNode()->asGroup(), light);
} }
@ -677,8 +677,11 @@ void NpcAnimation::updateParts()
{ {
const ESM::BodyPart* bodypart = parts[part]; const ESM::BodyPart* bodypart = parts[part];
if(bodypart) 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<ESM::PartReferenceType>(part), -1, 1,
Misc::ResourceHelpers::correctMeshPath(bodypart->mModel, vfs));
}
} }
} }
@ -908,8 +911,11 @@ void NpcAnimation::addPartGroup(int group, int priority, const std::vector<ESM::
} }
if(bodypart) if(bodypart)
addOrReplaceIndividualPart((ESM::PartReferenceType)part.mPart, group, priority, {
MWBase::Environment::get().getWindowManager()->correctMeshPath(bodypart->mModel), enchantedGlow, glowColor); const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
addOrReplaceIndividualPart(static_cast<ESM::PartReferenceType>(part.mPart), group, priority,
Misc::ResourceHelpers::correctMeshPath(bodypart->mModel, vfs), enchantedGlow, glowColor);
}
else else
reserveIndividualPart((ESM::PartReferenceType)part.mPart, group, priority); reserveIndividualPart((ESM::PartReferenceType)part.mPart, group, priority);
} }

View file

@ -32,10 +32,11 @@
#include "apps/openmw/mwworld/esmstore.hpp" #include "apps/openmw/mwworld/esmstore.hpp"
#include "apps/openmw/mwbase/environment.hpp" #include "apps/openmw/mwbase/environment.hpp"
#include "apps/openmw/mwbase/world.hpp" #include "apps/openmw/mwbase/world.hpp"
#include "apps/openmw/mwbase/windowmanager.hpp"
#include "vismask.hpp" #include "vismask.hpp"
#include <condition_variable>
namespace MWRender namespace MWRender
{ {
@ -532,7 +533,7 @@ namespace MWRender
int type = store.findStatic(ref.mRefID); int type = store.findStatic(ref.mRefID);
std::string model = getModel(type, ref.mRefID, store); std::string model = getModel(type, ref.mRefID, store);
if (model.empty()) continue; if (model.empty()) continue;
model = MWBase::Environment::get().getWindowManager()->correctMeshPath(model); model = Misc::ResourceHelpers::correctMeshPath(model, mSceneManager->getVFS());
if (activeGrid && type != ESM::REC_STAT) if (activeGrid && type != ESM::REC_STAT)
{ {

View file

@ -4,9 +4,10 @@
#include <components/esmloader/esmdata.hpp> #include <components/esmloader/esmdata.hpp>
#include <components/misc/stringops.hpp> #include <components/misc/stringops.hpp>
#include <components/esm3/readerscache.hpp> #include <components/esm3/readerscache.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwbase/environment.hpp> #include <apps/openmw/mwbase/environment.hpp>
#include <apps/openmw/mwbase/windowmanager.hpp>
#include "store.hpp" #include "store.hpp"
@ -23,6 +24,8 @@ namespace MWWorld
const ::EsmLoader::EsmData content = ::EsmLoader::loadEsmData(query, groundcoverFiles, fileCollections, const ::EsmLoader::EsmData content = ::EsmLoader::loadEsmData(query, groundcoverFiles, fileCollections,
readers, encoder, listener); readers, encoder, listener);
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
static constexpr std::string_view prefix = "grass\\"; static constexpr std::string_view prefix = "grass\\";
for (const ESM::Static& stat : statics) for (const ESM::Static& stat : statics)
{ {
@ -31,7 +34,7 @@ namespace MWWorld
std::replace(model.begin(), model.end(), '/', '\\'); std::replace(model.begin(), model.end(), '/', '\\');
if (model.compare(0, prefix.size(), prefix) != 0) if (model.compare(0, prefix.size(), prefix) != 0)
continue; continue;
mMeshCache[id] = MWBase::Environment::get().getWindowManager()->correctMeshPath(model); mMeshCache[id] = Misc::ResourceHelpers::correctMeshPath(model, vfs);
} }
for (const ESM::Static& stat : content.mStatics) for (const ESM::Static& stat : content.mStatics)
@ -41,7 +44,7 @@ namespace MWWorld
std::replace(model.begin(), model.end(), '/', '\\'); std::replace(model.begin(), model.end(), '/', '\\');
if (model.compare(0, prefix.size(), prefix) != 0) if (model.compare(0, prefix.size(), prefix) != 0)
continue; continue;
mMeshCache[id] = MWBase::Environment::get().getWindowManager()->correctMeshPath(model); mMeshCache[id] = Misc::ResourceHelpers::correctMeshPath(model, vfs);
} }
for (const ESM::Cell& cell : content.mCells) for (const ESM::Cell& cell : content.mCells)

View file

@ -13,6 +13,7 @@
#include <components/misc/constants.hpp> #include <components/misc/constants.hpp>
#include <components/misc/convert.hpp> #include <components/misc/convert.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp> #include <components/resource/resourcesystem.hpp>
#include <components/resource/scenemanager.hpp> #include <components/resource/scenemanager.hpp>
@ -211,6 +212,9 @@ namespace MWWorld
osg::ref_ptr<osg::Node> projectile = mResourceSystem->getSceneManager()->getInstance(model, attachTo); osg::ref_ptr<osg::Node> projectile = mResourceSystem->getSceneManager()->getInstance(model, attachTo);
if (state.mIdMagic.size() > 1) 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) for (size_t iter = 1; iter != state.mIdMagic.size(); ++iter)
{ {
std::ostringstream nodeName; std::ostringstream nodeName;
@ -220,7 +224,8 @@ namespace MWWorld
attachTo->accept(findVisitor); attachTo->accept(findVisitor);
if (findVisitor.mFoundNode) if (findVisitor.mFoundNode)
mResourceSystem->getSceneManager()->getInstance( mResourceSystem->getSceneManager()->getInstance(
MWBase::Environment::get().getWindowManager()->correctMeshPath(weapon->mModel), findVisitor.mFoundNode); Misc::ResourceHelpers::correctMeshPath(weapon->mModel, vfs), findVisitor.mFoundNode);
}
} }
if (createLight) 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 // 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) if (state.mIdMagic.size() > 1)
model = MWBase::Environment::get().getWindowManager()->correctMeshPath( {
MWBase::Environment::get().getWorld()->getStore().get<ESM::Weapon>().find(state.mIdMagic[1])->mModel); model = Misc::ResourceHelpers::correctMeshPath(
MWBase::Environment::get().getWorld()->getStore().get<ESM::Weapon>().find(state.mIdMagic[1])->mModel,
MWBase::Environment::get().getResourceSystem()->getVFS());
}
state.mProjectileId = mPhysics->addProjectile(caster, pos, model, true); state.mProjectileId = mPhysics->addProjectile(caster, pos, model, true);
state.mToDelete = false; state.mToDelete = false;
mMagicBolts.push_back(state); mMagicBolts.push_back(state);

View file

@ -3690,8 +3690,9 @@ namespace MWWorld
if (texture.empty()) if (texture.empty())
texture = Fallback::Map::getString("Blood_Texture_0"); texture = Fallback::Map::getString("Blood_Texture_0");
std::string model = MWBase::Environment::get().getWindowManager()->correctMeshPath( std::string model = Misc::ResourceHelpers::correctMeshPath(
Fallback::Map::getString("Blood_Model_" + std::to_string(Misc::Rng::rollDice(3)))); // [0, 2] Fallback::Map::getString("Blood_Model_" + std::to_string(Misc::Rng::rollDice(3))), // [0, 2]
mResourceSystem->getVFS());
mRendering->spawnEffect(model, texture, worldPosition, 1.0f, false); mRendering->spawnEffect(model, texture, worldPosition, 1.0f, false);
} }
@ -3731,13 +3732,13 @@ namespace MWWorld
{ {
if (effectInfo.mRange == ESM::RT_Target) if (effectInfo.mRange == ESM::RT_Target)
mRendering->spawnEffect( mRendering->spawnEffect(
MWBase::Environment::get().getWindowManager()->correctMeshPath(areaStatic->mModel), Misc::ResourceHelpers::correctMeshPath(areaStatic->mModel, mResourceSystem->getVFS()),
texture, origin, 1.0f); texture, origin, 1.0f);
continue; continue;
} }
else else
mRendering->spawnEffect( mRendering->spawnEffect(
MWBase::Environment::get().getWindowManager()->correctMeshPath(areaStatic->mModel), Misc::ResourceHelpers::correctMeshPath(areaStatic->mModel, mResourceSystem->getVFS()),
texture, origin, static_cast<float>(effectInfo.mArea * 2)); texture, origin, static_cast<float>(effectInfo.mArea * 2));
// Play explosion sound (make sure to use NoTrack, since we will delete the projectile now) // Play explosion sound (make sure to use NoTrack, since we will delete the projectile now)