1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 15:35:23 +00:00

Don't use WindowManager outside of UI, correct paths for new record types

This commit is contained in:
uramer 2022-06-12 13:07:50 +02:00
parent fd7965d77f
commit bf905fce4c
16 changed files with 129 additions and 46 deletions

View File

@ -339,7 +339,6 @@ namespace MWBase
// In WindowManager for now since there isn't a VFS singleton
virtual std::string correctIconPath(const std::string& path) = 0;
virtual std::string correctBookartPath(const std::string& path, int width, int height, bool* exists = nullptr) = 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;

View File

@ -5,14 +5,15 @@
#include <MyGUI_EditBox.h>
#include <MyGUI_ImageBox.h>
// correctBookartPath
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include <components/debug/debuglog.hpp>
#include <components/interpreter/defines.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/vfs/manager.hpp>
#include <components/misc/stringops.hpp>
#include <components/misc/resourcehelpers.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwscript/interpretercontext.hpp"
namespace MWGui::Formatting
@ -285,8 +286,9 @@ namespace MWGui::Formatting
int width = MyGUI::utility::parseInt(attr.at("width"));
int height = MyGUI::utility::parseInt(attr.at("height"));
bool exists;
std::string correctedSrc = MWBase::Environment::get().getWindowManager()->correctBookartPath(src, width, height, &exists);
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
std::string correctedSrc = Misc::ResourceHelpers::correctBookartPath(src, width, height, vfs);
bool exists = vfs->exists(correctedSrc);
if (!exists)
{
@ -296,8 +298,7 @@ namespace MWGui::Formatting
pag.setIgnoreLeadingEmptyLines(false);
ImageElement elem(paper, pag, mBlockStyle,
correctedSrc, width, height);
ImageElement elem(paper, pag, mBlockStyle, correctedSrc, width, height);
elem.paginate();
break;
}

View File

@ -2127,14 +2127,6 @@ namespace MWGui
return Misc::ResourceHelpers::correctIconPath(path, mResourceSystem->getVFS());
}
std::string WindowManager::correctBookartPath(const std::string& path, int width, int height, bool* exists)
{
std::string corrected = Misc::ResourceHelpers::correctBookartPath(path, width, height, mResourceSystem->getVFS());
if (exists)
*exists = mResourceSystem->getVFS()->exists(corrected);
return corrected;
}
std::string WindowManager::correctTexturePath(const std::string& path)
{
return Misc::ResourceHelpers::correctTexturePath(path, mResourceSystem->getVFS());

View File

@ -379,7 +379,6 @@ namespace MWGui
// In WindowManager for now since there isn't a VFS singleton
std::string correctIconPath(const std::string& path) override;
std::string correctBookartPath(const std::string& path, int width, int height, bool* exists = nullptr) override;
std::string correctTexturePath(const std::string& path) override;
std::string correctMeshPath(const std::string& path) override;
bool textureExists(const std::string& path) override;

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loadacti.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
@ -16,6 +18,8 @@ namespace MWLua
{
void addActivatorBindings(sol::table activator, const Context& context)
{
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Activator>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Activator>();
activator["record"] = sol::overload(
[](const Object& obj) -> const ESM::Activator* { return obj.ptr().get<ESM::Activator>()->mBase; },
@ -24,7 +28,10 @@ namespace MWLua
record[sol::meta_function::to_string] = [](const ESM::Activator& rec) { return "ESM3_Activator[" + rec.mId + "]"; };
record["id"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mId; });
record["name"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mModel; });
record["model"] = sol::readonly_property([vfs](const ESM::Activator& rec) -> std::string
{
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mScript; });
}
}

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loadappa.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
@ -23,6 +25,8 @@ namespace MWLua
{"Retort", ESM::Apparatus::Retort},
}));
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Apparatus>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Apparatus>();
apparatus["record"] = sol::overload(
[](const Object& obj) -> const ESM::Apparatus* { return obj.ptr().get<ESM::Apparatus>()->mBase; },
@ -31,9 +35,15 @@ namespace MWLua
record[sol::meta_function::to_string] = [](const ESM::Apparatus& rec) { return "ESM3_Apparatus[" + rec.mId + "]"; };
record["id"] = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mId; });
record["name"] = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mModel; });
record["model"] = sol::readonly_property([vfs](const ESM::Apparatus& rec) -> std::string
{
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"] = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mScript; });
record["icon"] = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mIcon; });
record["icon"] = sol::readonly_property([vfs](const ESM::Apparatus& rec) -> std::string
{
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});
record["type"] = sol::readonly_property([](const ESM::Apparatus& rec) -> int { return rec.mData.mType; });
record["value"] = sol::readonly_property([](const ESM::Apparatus& rec) -> int { return rec.mData.mValue; });
record["weight"] = sol::readonly_property([](const ESM::Apparatus& rec) -> float { return rec.mData.mWeight; });

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loadbook.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
@ -24,6 +26,8 @@ namespace MWLua
skill[skillName] = skillName;
}
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Book>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Book>();
book["record"] = sol::overload(
[](const Object& obj) -> const ESM::Book* { return obj.ptr().get<ESM::Book>()->mBase; },
@ -32,9 +36,15 @@ namespace MWLua
record[sol::meta_function::to_string] = [](const ESM::Book& rec) { return "ESM3_Book[" + rec.mId + "]"; };
record["id"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mId; });
record["name"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mModel; });
record["model"] = sol::readonly_property([vfs](const ESM::Book& rec) -> std::string
{
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mScript; });
record["icon"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mIcon; });
record["icon"] = sol::readonly_property([vfs](const ESM::Book& rec) -> std::string
{
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});
record["text"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mText; });
record["enchant"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mEnchant; });
record["isScroll"] = sol::readonly_property([](const ESM::Book& rec) -> bool { return rec.mData.mIsScroll; });

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loadcont.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
#include <apps/openmw/mwworld/class.hpp>
@ -33,6 +35,8 @@ namespace MWLua
return ptr.getClass().getCapacity(ptr);
};
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Container>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Container>();
container["record"] = sol::overload(
[](const Object& obj) -> const ESM::Container* { return obj.ptr().get<ESM::Container>()->mBase; },
@ -41,7 +45,10 @@ namespace MWLua
record[sol::meta_function::to_string] = [](const ESM::Container& rec) -> std::string { return "ESM3_Container[" + rec.mId + "]"; };
record["id"] = sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mId; });
record["name"] = sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mModel; });
record["model"] = sol::readonly_property([vfs](const ESM::Container& rec) -> std::string
{
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"] = sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mScript; });
record["weight"] = sol::readonly_property([](const ESM::Container& rec) -> float { return rec.mWeight; });
}

View File

@ -3,7 +3,8 @@
#include <components/esm3/loadcrea.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
#include <apps/openmw/mwbase/windowmanager.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include "../stats.hpp"
#include "../luabindings.hpp"
@ -18,6 +19,8 @@ namespace MWLua
{
void addCreatureBindings(sol::table creature, const Context& context)
{
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Creature>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>();
creature["record"] = sol::overload(
[](const Object& obj) -> const ESM::Creature* { return obj.ptr().get<ESM::Creature>()->mBase; },
@ -25,9 +28,9 @@ namespace MWLua
sol::usertype<ESM::Creature> record = context.mLua->sol().new_usertype<ESM::Creature>("ESM3_Creature");
record[sol::meta_function::to_string] = [](const ESM::Creature& rec) { return "ESM3_Creature[" + rec.mId + "]"; };
record["name"] = sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([](const ESM::Creature& rec) -> std::string
record["model"] = sol::readonly_property([vfs](const ESM::Creature& rec) -> std::string
{
return MWBase::Environment::get().getWindowManager()->correctMeshPath(rec.mModel);
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"] = sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mScript; });
record["baseCreature"] = sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mOriginal; });

View File

@ -1,9 +1,10 @@
#include "types.hpp"
#include <components/esm3/loaddoor.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
#include <apps/openmw/mwbase/windowmanager.hpp>
#include "../luabindings.hpp"
@ -41,6 +42,8 @@ namespace MWLua
return sol::nil;
};
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Door>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Door>();
door["record"] = sol::overload(
[](const Object& obj) -> const ESM::Door* { return obj.ptr().get<ESM::Door>()->mBase; },
@ -49,9 +52,9 @@ namespace MWLua
record[sol::meta_function::to_string] = [](const ESM::Door& rec) -> std::string { return "ESM3_Door[" + rec.mId + "]"; };
record["id"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mId; });
record["name"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([](const ESM::Door& rec) -> std::string
record["model"] = sol::readonly_property([vfs](const ESM::Door& rec) -> std::string
{
return MWBase::Environment::get().getWindowManager()->correctMeshPath(rec.mModel);
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mScript; });
record["openSound"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mOpenSound; });

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loadlock.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
@ -16,6 +18,8 @@ namespace MWLua
{
void addLockpickBindings(sol::table lockpick, const Context& context)
{
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Lockpick>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Lockpick>();
lockpick["record"] = sol::overload(
[](const Object& obj) -> const ESM::Lockpick* { return obj.ptr().get<ESM::Lockpick>()->mBase;},
@ -24,9 +28,15 @@ namespace MWLua
record[sol::meta_function::to_string] = [](const ESM::Lockpick& rec) { return "ESM3_Lockpick[" + rec.mId + "]";};
record["id"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mId;});
record["name"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mName;});
record["model"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mModel;});
record["model"] = sol::readonly_property([vfs](const ESM::Lockpick& rec) -> std::string
{
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mScript;});
record["icon"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mIcon;});
record["icon"] = sol::readonly_property([vfs](const ESM::Lockpick& rec) -> std::string
{
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});
record["maxCondition"] = sol::readonly_property([](const ESM::Lockpick& rec) -> int { return rec.mData.mUses;});
record["value"] = sol::readonly_property([](const ESM::Lockpick& rec) -> int { return rec.mData.mValue;});
record["weight"] = sol::readonly_property([](const ESM::Lockpick& rec) -> float { return rec.mData.mWeight;});

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loadmisc.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
@ -16,6 +18,8 @@ namespace MWLua
{
void addMiscellaneousBindings(sol::table miscellaneous, const Context& context)
{
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Miscellaneous>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Miscellaneous>();
miscellaneous["record"] = sol::overload(
[](const Object& obj) -> const ESM::Miscellaneous* { return obj.ptr().get<ESM::Miscellaneous>()->mBase; },
@ -24,9 +28,15 @@ namespace MWLua
record[sol::meta_function::to_string] = [](const ESM::Miscellaneous& rec) { return "ESM3_Miscellaneous[" + rec.mId + "]"; };
record["id"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mId; });
record["name"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mModel; });
record["model"] = sol::readonly_property([vfs](const ESM::Miscellaneous& rec) -> std::string
{
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mScript; });
record["icon"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mIcon; });
record["icon"] = sol::readonly_property([vfs](const ESM::Miscellaneous& rec) -> std::string
{
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});
record["isKey"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> bool { return rec.mData.mIsKey; });
record["value"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> int { return rec.mData.mValue; });
record["weight"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> float { return rec.mData.mWeight; });

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loadalch.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
@ -21,12 +23,19 @@ namespace MWLua
[](const Object& obj) -> const ESM::Potion* { return obj.ptr().get<ESM::Potion>()->mBase; },
[store](const std::string& recordId) -> const ESM::Potion* { return store->find(recordId); });
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
sol::usertype<ESM::Potion> record = context.mLua->sol().new_usertype<ESM::Potion>("ESM3_Potion");
record[sol::meta_function::to_string] = [](const ESM::Potion& rec) { return "ESM3_Potion[" + rec.mId + "]"; };
record["id"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mId; });
record["name"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mModel; });
record["icon"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mIcon; });
record["model"] = sol::readonly_property([vfs](const ESM::Potion& rec) -> std::string
{
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["icon"] = sol::readonly_property([vfs](const ESM::Potion& rec) -> std::string
{
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});
record["mwscript"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mScript; });
record["weight"] = sol::readonly_property([](const ESM::Potion& rec) -> float { return rec.mData.mWeight; });
record["value"] = sol::readonly_property([](const ESM::Potion& rec) -> int { return rec.mData.mValue; });

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loadprob.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
@ -16,6 +18,8 @@ namespace MWLua
{
void addProbeBindings(sol::table probe, const Context& context)
{
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Probe>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Probe>();
probe["record"] = sol::overload(
[](const Object& obj) -> const ESM::Probe* { return obj.ptr().get<ESM::Probe>()->mBase;},
@ -24,9 +28,15 @@ namespace MWLua
record[sol::meta_function::to_string] = [](const ESM::Probe& rec) { return "ESM3_Probe[" + rec.mId + "]";};
record["id"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mId;});
record["name"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mName;});
record["model"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mModel;});
record["model"] = sol::readonly_property([vfs](const ESM::Probe& rec) -> std::string
{
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mScript;});
record["icon"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mIcon;});
record["icon"] = sol::readonly_property([vfs](const ESM::Probe& rec) -> std::string
{
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});
record["maxCondition"] = sol::readonly_property([](const ESM::Probe& rec) -> int { return rec.mData.mUses;});
record["value"] = sol::readonly_property([](const ESM::Probe& rec) -> int { return rec.mData.mValue;});
record["weight"] = sol::readonly_property([](const ESM::Probe& rec) -> float { return rec.mData.mWeight;});

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loadrepa.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
@ -16,6 +18,8 @@ namespace MWLua
{
void addRepairBindings(sol::table repair, const Context& context)
{
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Repair>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Repair>();
repair["record"] = sol::overload(
[](const Object& obj) -> const ESM::Repair* { return obj.ptr().get<ESM::Repair>()->mBase; },
@ -24,9 +28,15 @@ namespace MWLua
record[sol::meta_function::to_string] = [](const ESM::Repair& rec) { return "ESM3_Repair[" + rec.mId + "]"; };
record["id"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mId; });
record["name"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mModel; });
record["model"] = sol::readonly_property([vfs](const ESM::Repair& rec) -> std::string
{
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["mwscript"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mScript; });
record["icon"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mIcon; });
record["icon"] = sol::readonly_property([vfs](const ESM::Repair& rec) -> std::string
{
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});
record["maxCondition"] = sol::readonly_property([](const ESM::Repair& rec) -> int { return rec.mData.mUses; });
record["value"] = sol::readonly_property([](const ESM::Repair& rec) -> int { return rec.mData.mValue; });
record["weight"] = sol::readonly_property([](const ESM::Repair& rec) -> float { return rec.mData.mWeight; });

View File

@ -1,9 +1,10 @@
#include "types.hpp"
#include <components/esm3/loadweap.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
#include <apps/openmw/mwbase/windowmanager.hpp>
#include "../luabindings.hpp"
@ -12,7 +13,7 @@ namespace sol
template <>
struct is_automagical<ESM::Weapon> : std::false_type {};
}
#include <components/resource/resourcesystem.hpp>
namespace MWLua
{
void addWeaponBindings(sol::table weapon, const Context& context)
@ -34,6 +35,8 @@ namespace MWLua
{"Bolt", ESM::Weapon::Bolt},
}));
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Weapon>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Weapon>();
weapon["record"] = sol::overload(
[](const Object& obj) -> const ESM::Weapon* { return obj.ptr().get<ESM::Weapon>()->mBase; },
@ -42,13 +45,13 @@ namespace MWLua
record[sol::meta_function::to_string] = [](const ESM::Weapon& rec) -> std::string { return "ESM3_Weapon[" + rec.mId + "]"; };
record["id"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mId; });
record["name"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string
record["model"] = sol::readonly_property([vfs](const ESM::Weapon& rec) -> std::string
{
return MWBase::Environment::get().getWindowManager()->correctMeshPath(rec.mModel);
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["icon"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string
record["icon"] = sol::readonly_property([vfs](const ESM::Weapon& rec) -> std::string
{
return MWBase::Environment::get().getWindowManager()->correctIconPath(rec.mIcon);
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
});
record["enchant"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mEnchant; });
record["mwscript"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mScript; });