2024-03-01 13:12:02 +00:00
|
|
|
#include "birthsignbindings.hpp"
|
|
|
|
|
2024-02-07 17:08:06 +00:00
|
|
|
#include <components/esm3/loadbsgn.hpp>
|
|
|
|
#include <components/lua/luastate.hpp>
|
|
|
|
#include <components/misc/resourcehelpers.hpp>
|
|
|
|
#include <components/resource/resourcesystem.hpp>
|
|
|
|
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
|
2024-02-28 16:20:46 +00:00
|
|
|
#include "idcollectionbindings.hpp"
|
2024-02-07 17:08:06 +00:00
|
|
|
#include "types/types.hpp"
|
|
|
|
|
|
|
|
namespace sol
|
|
|
|
{
|
|
|
|
template <>
|
|
|
|
struct is_automagical<ESM::BirthSign> : std::false_type
|
|
|
|
{
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace MWLua
|
|
|
|
{
|
2024-02-08 15:53:48 +00:00
|
|
|
sol::table initBirthSignRecordBindings(const Context& context)
|
2024-02-07 17:08:06 +00:00
|
|
|
{
|
|
|
|
sol::state_view& lua = context.mLua->sol();
|
|
|
|
sol::table birthSigns(context.mLua->sol(), sol::create);
|
|
|
|
addRecordFunctionBinding<ESM::BirthSign>(birthSigns, context);
|
|
|
|
|
|
|
|
auto signT = lua.new_usertype<ESM::BirthSign>("ESM3_BirthSign");
|
|
|
|
signT[sol::meta_function::to_string] = [](const ESM::BirthSign& rec) -> std::string {
|
|
|
|
return "ESM3_BirthSign[" + rec.mId.toDebugString() + "]";
|
|
|
|
};
|
|
|
|
signT["id"] = sol::readonly_property([](const ESM::BirthSign& rec) { return rec.mId.serializeText(); });
|
|
|
|
signT["name"] = sol::readonly_property([](const ESM::BirthSign& rec) -> std::string_view { return rec.mName; });
|
|
|
|
signT["description"]
|
|
|
|
= sol::readonly_property([](const ESM::BirthSign& rec) -> std::string_view { return rec.mDescription; });
|
|
|
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
|
|
|
signT["texture"] = sol::readonly_property([vfs](const ESM::BirthSign& rec) -> std::string {
|
|
|
|
return Misc::ResourceHelpers::correctTexturePath(rec.mTexture, vfs);
|
|
|
|
});
|
2024-02-28 16:20:46 +00:00
|
|
|
signT["spells"] = sol::readonly_property([lua](const ESM::BirthSign& rec) -> sol::table {
|
|
|
|
return createReadOnlyRefIdTable(lua, rec.mPowers.mList);
|
|
|
|
});
|
2024-02-07 17:08:06 +00:00
|
|
|
|
|
|
|
return LuaUtil::makeReadOnly(birthSigns);
|
|
|
|
}
|
|
|
|
}
|