Load ESM4 Terminal objects, add lua bindings for them

macos_ci_fix
Zackhasacat 1 year ago committed by psi29a
parent 4cf80cdac2
commit 3e8a1cce7c

@ -62,7 +62,7 @@ add_openmw_dir (mwlua
luamanagerimp object worldview userdataserializer luaevents engineevents objectvariant
context globalscripts localscripts playerscripts luabindings objectbindings cellbindings mwscriptbindings
camerabindings uibindings inputbindings nearbybindings postprocessingbindings stats debugbindings
types/types types/door types/item types/actor types/container types/lockable types/weapon types/npc types/creature types/player types/activator types/book types/lockpick types/probe types/apparatus types/potion types/ingredient types/misc types/repair types/armor types/light types/static types/clothing types/levelledlist
types/types types/door types/item types/actor types/container types/lockable types/weapon types/npc types/creature types/player types/activator types/book types/lockpick types/probe types/apparatus types/potion types/ingredient types/misc types/repair types/armor types/light types/static types/clothing types/levelledlist types/terminal
worker magicbindings
)

@ -15,6 +15,7 @@
#include <components/esm4/loadmisc.hpp>
#include <components/esm4/loadnpc.hpp>
#include <components/esm4/loadstat.hpp>
#include <components/esm4/loadterm.hpp>
#include <components/esm4/loadtree.hpp>
#include <components/esm4/loadweap.hpp>
@ -81,6 +82,7 @@ namespace MWClass
ESM4Named<ESM4::Ingredient>::registerSelf();
ESM4Named<ESM4::MiscItem>::registerSelf();
ESM4Static::registerSelf();
ESM4Named<ESM4::Terminal>::registerSelf();
ESM4Tree::registerSelf();
ESM4Named<ESM4::Weapon>::registerSelf();
ESM4Light::registerSelf();

@ -0,0 +1,45 @@
#include "types.hpp"
#include <components/esm4/loadterm.hpp>
#include <components/lua/utilpackage.hpp>
#include <components/misc/convert.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include "apps/openmw/mwworld/esmstore.hpp"
namespace sol
{
template <>
struct is_automagical<ESM4::Terminal> : std::false_type
{
};
}
namespace MWLua
{
void addESM4TerminalBindings(sol::table term, const Context& context)
{
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
addRecordFunctionBinding<ESM4::Terminal>(term, context, "ESM4Terminal");
sol::usertype<ESM4::Terminal> record = context.mLua->sol().new_usertype<ESM4::Terminal>("ESM4_Terminal");
record[sol::meta_function::to_string] = [](const ESM4::Terminal& rec) -> std::string {
return "ESM4_Terminal[" + ESM::RefId(rec.mId).toDebugString() + "]";
};
record["id"] = sol::readonly_property(
[](const ESM4::Terminal& rec) -> std::string { return ESM::RefId(rec.mId).serializeText(); });
record["editorId"]
= sol::readonly_property([](const ESM4::Terminal& rec) -> std::string { return rec.mEditorId; });
record["text"] = sol::readonly_property([](const ESM4::Terminal& rec) -> std::string { return rec.mText; });
record["resultText"]
= sol::readonly_property([](const ESM4::Terminal& rec) -> std::string { return rec.mResultText; });
record["name"] = sol::readonly_property([](const ESM4::Terminal& rec) -> std::string { return rec.mFullName; });
record["model"] = sol::readonly_property([vfs](const ESM4::Terminal& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
}
}

@ -48,6 +48,7 @@ namespace MWLua
constexpr std::string_view ESM4MiscItem = "ESM4Miscellaneous";
constexpr std::string_view ESM4Potion = "ESM4Potion";
constexpr std::string_view ESM4Static = "ESM4Static";
constexpr std::string_view ESM4Terminal = "ESM4Terminal";
constexpr std::string_view ESM4Tree = "ESM4Tree";
constexpr std::string_view ESM4Weapon = "ESM4Weapon";
}
@ -90,6 +91,7 @@ namespace MWLua
{ ESM::REC_MISC4, ObjectTypeName::ESM4MiscItem },
{ ESM::REC_ALCH4, ObjectTypeName::ESM4Potion },
{ ESM::REC_STAT4, ObjectTypeName::ESM4Static },
{ ESM::REC_TERM4, ObjectTypeName::ESM4Terminal },
{ ESM::REC_TREE4, ObjectTypeName::ESM4Tree },
{ ESM::REC_WEAP4, ObjectTypeName::ESM4Weapon },
};
@ -227,6 +229,7 @@ namespace MWLua
addType(ObjectTypeName::ESM4MiscItem, { ESM::REC_MISC4 });
addType(ObjectTypeName::ESM4Potion, { ESM::REC_ALCH4 });
addType(ObjectTypeName::ESM4Static, { ESM::REC_STAT4 });
addESM4TerminalBindings(addType(ObjectTypeName::ESM4Terminal, { ESM::REC_TERM4 }), context);
addType(ObjectTypeName::ESM4Tree, { ESM::REC_TREE4 });
addType(ObjectTypeName::ESM4Weapon, { ESM::REC_WEAP4 });

@ -68,6 +68,7 @@ namespace MWLua
void addLevelledCreatureBindings(sol::table list, const Context& context);
void addESM4DoorBindings(sol::table door, const Context& context);
void addESM4TerminalBindings(sol::table term, const Context& context);
template <class T>
void addRecordFunctionBinding(

@ -59,6 +59,7 @@
#include <components/esm4/loadnpc.hpp>
#include <components/esm4/loadrefr.hpp>
#include <components/esm4/loadstat.hpp>
#include <components/esm4/loadterm.hpp>
#include <components/esm4/loadtree.hpp>
#include <components/esm4/loadweap.hpp>
#include <components/esm4/readerutils.hpp>

@ -72,6 +72,7 @@ namespace ESM4
struct Furniture;
struct Ingredient;
struct MiscItem;
struct Terminal;
struct Tree;
struct Weapon;
struct Creature;
@ -92,9 +93,9 @@ namespace MWWorld
CellRefList<ESM4::Static>, CellRefList<ESM4::Light>, CellRefList<ESM4::Activator>, CellRefList<ESM4::Potion>,
CellRefList<ESM4::Ammunition>, CellRefList<ESM4::Armor>, CellRefList<ESM4::Book>, CellRefList<ESM4::Clothing>,
CellRefList<ESM4::Container>, CellRefList<ESM4::Door>, CellRefList<ESM4::Ingredient>, CellRefList<ESM4::Tree>,
CellRefList<ESM4::MiscItem>, CellRefList<ESM4::Weapon>, CellRefList<ESM4::Furniture>,
CellRefList<ESM4::Creature>, CellRefList<ESM4::Npc>>;
CellRefList<ESM4::Container>, CellRefList<ESM4::Door>, CellRefList<ESM4::Ingredient>,
CellRefList<ESM4::Terminal>, CellRefList<ESM4::Tree>, CellRefList<ESM4::MiscItem>, CellRefList<ESM4::Weapon>,
CellRefList<ESM4::Furniture>, CellRefList<ESM4::Creature>, CellRefList<ESM4::Npc>>;
/// \brief Mutable state of a cell
class CellStore

@ -293,6 +293,7 @@ namespace MWWorld
case ESM::REC_MISC4:
case ESM::REC_NPC_4:
case ESM::REC_STAT4:
case ESM::REC_TERM4:
case ESM::REC_TREE4:
case ESM::REC_WEAP4:
return true;

@ -102,6 +102,7 @@ namespace ESM4
struct Race;
struct Reference;
struct Static;
struct Terminal;
struct Tree;
struct Weapon;
struct World;
@ -139,7 +140,7 @@ namespace MWWorld
Store<ESM4::HeadPart>, Store<ESM4::Ingredient>, Store<ESM4::Land>, Store<ESM4::LevelledCreature>,
Store<ESM4::LevelledItem>, Store<ESM4::LevelledNpc>, Store<ESM4::Light>, Store<ESM4::MiscItem>,
Store<ESM4::Npc>, Store<ESM4::Outfit>, Store<ESM4::Potion>, Store<ESM4::Race>, Store<ESM4::Reference>,
Store<ESM4::Static>, Store<ESM4::Tree>, Store<ESM4::Weapon>, Store<ESM4::World>>;
Store<ESM4::Static>, Store<ESM4::Terminal>, Store<ESM4::Tree>, Store<ESM4::Weapon>, Store<ESM4::World>>;
private:
template <typename T>

@ -91,6 +91,9 @@ MWWorld::ManualRef::ManualRef(const MWWorld::ESMStore& store, const ESM::RefId&
case ESM::REC_STAT4:
create(store.get<ESM4::Static>(), name, mRef, mPtr);
break;
case ESM::REC_TERM4:
create(store.get<ESM4::Terminal>(), name, mRef, mPtr);
break;
case 0:
throw std::logic_error("failed to create manual cell ref for " + name.toDebugString() + " (unknown ID)");

@ -1400,6 +1400,7 @@ template class MWWorld::TypedDynamicStore<ESM4::Outfit>;
template class MWWorld::TypedDynamicStore<ESM4::Potion>;
template class MWWorld::TypedDynamicStore<ESM4::Race>;
template class MWWorld::TypedDynamicStore<ESM4::Static>;
template class MWWorld::TypedDynamicStore<ESM4::Terminal>;
template class MWWorld::TypedDynamicStore<ESM4::Tree>;
template class MWWorld::TypedDynamicStore<ESM4::Weapon>;
template class MWWorld::TypedDynamicStore<ESM4::World>;

@ -70,6 +70,7 @@
#include <components/esm4/loadrace.hpp>
#include <components/esm4/loadrefr.hpp>
#include <components/esm4/loadstat.hpp>
#include <components/esm4/loadterm.hpp>
#include <components/esm4/loadtree.hpp>
#include <components/esm4/loadweap.hpp>
#include <components/esm4/loadwrld.hpp>

@ -69,7 +69,7 @@ void ESM4::Terminal::load(ESM4::Reader& reader)
case ESM4::SUB_ANAM: // flags
case ESM4::SUB_CTDA:
case ESM4::SUB_INAM:
case ESM4::SUB_ITXT:
case ESM4::SUB_ITXT: // Menu Item
case ESM4::SUB_MODT: // texture hash?
case ESM4::SUB_SCDA:
case ESM4::SUB_SCHR:

@ -1625,6 +1625,9 @@
--- Functions for @{#ESM4Door} objects
-- @field [parent=#types] #ESM4Door ESM4Door
--- Functions for @{#ESM4Terminal} objects
-- @field [parent=#types] #ESM4Terminal ESM4Terminal
--- Functions for @{#ESM4Ingredient} objects
-- @field [parent=#types] #ESM4Ingredient ESM4Ingredient
@ -1643,6 +1646,31 @@
--- Functions for @{#ESM4Weapon} objects
-- @field [parent=#types] #ESM4Weapon ESM4Weapon
---
-- @type ESM4Terminal
-- @field #list<#ESM4TerminalRecord> records A read-only list of all @{#ESM4TerminalRecord}s in the world database.
---
-- Whether the object is a ESM4Terminal.
-- @function [parent=#ESM4Terminal] objectIsInstance
-- @param openmw.core#GameObject object
-- @return #boolean
---
-- Returns the read-only @{#ESM4TerminalRecord} of a terminal
-- @function [parent=#ESM4Terminal] record
-- @param #any objectOrRecordId
-- @return #ESM4TerminalRecord
---
-- @type ESM4TerminalRecord
-- @field #string id Record id (Form ID)
-- @field #string editorId Human-readable ID
-- @field #string name Human-readable name
-- @field #string model VFS path to the model
-- @field #string text Text body of the terminal record
-- @field #string resultText Result text of the terminal record
---
-- @type ESM4Door
-- @extends #Lockable

Loading…
Cancel
Save