diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 15c3fc0c38..d1923cf2a8 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -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 ) diff --git a/apps/openmw/mwclass/classes.cpp b/apps/openmw/mwclass/classes.cpp index 561b9dd57e..071389c22c 100644 --- a/apps/openmw/mwclass/classes.cpp +++ b/apps/openmw/mwclass/classes.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -81,6 +82,7 @@ namespace MWClass ESM4Named::registerSelf(); ESM4Named::registerSelf(); ESM4Static::registerSelf(); + ESM4Named::registerSelf(); ESM4Tree::registerSelf(); ESM4Named::registerSelf(); ESM4Light::registerSelf(); diff --git a/apps/openmw/mwlua/types/terminal.cpp b/apps/openmw/mwlua/types/terminal.cpp new file mode 100644 index 0000000000..b0f8e3be0b --- /dev/null +++ b/apps/openmw/mwlua/types/terminal.cpp @@ -0,0 +1,45 @@ +#include "types.hpp" + +#include +#include +#include +#include +#include + +#include "apps/openmw/mwworld/esmstore.hpp" + +namespace sol +{ + template <> + struct is_automagical : std::false_type + { + }; +} + +namespace MWLua +{ + + void addESM4TerminalBindings(sol::table term, const Context& context) + { + + auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + + addRecordFunctionBinding(term, context, "ESM4Terminal"); + + sol::usertype record = context.mLua->sol().new_usertype("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); + }); + } +} diff --git a/apps/openmw/mwlua/types/types.cpp b/apps/openmw/mwlua/types/types.cpp index 3f9680e44b..6095053eee 100644 --- a/apps/openmw/mwlua/types/types.cpp +++ b/apps/openmw/mwlua/types/types.cpp @@ -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 }); diff --git a/apps/openmw/mwlua/types/types.hpp b/apps/openmw/mwlua/types/types.hpp index a77f9d3219..8cd126b007 100644 --- a/apps/openmw/mwlua/types/types.hpp +++ b/apps/openmw/mwlua/types/types.hpp @@ -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 void addRecordFunctionBinding( diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index 0385541fd6..d5868f5ee3 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -59,6 +59,7 @@ #include #include #include +#include #include #include #include diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp index 034d136dfe..496e98bf1a 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.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, CellRefList, CellRefList, CellRefList, CellRefList, CellRefList, CellRefList, CellRefList, - CellRefList, CellRefList, CellRefList, CellRefList, - CellRefList, CellRefList, CellRefList, - CellRefList, CellRefList>; + CellRefList, CellRefList, CellRefList, + CellRefList, CellRefList, CellRefList, CellRefList, + CellRefList, CellRefList, CellRefList>; /// \brief Mutable state of a cell class CellStore diff --git a/apps/openmw/mwworld/esmstore.cpp b/apps/openmw/mwworld/esmstore.cpp index ef9c83d82b..209fc39b42 100644 --- a/apps/openmw/mwworld/esmstore.cpp +++ b/apps/openmw/mwworld/esmstore.cpp @@ -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; diff --git a/apps/openmw/mwworld/esmstore.hpp b/apps/openmw/mwworld/esmstore.hpp index ae31cb5560..80cd5719e2 100644 --- a/apps/openmw/mwworld/esmstore.hpp +++ b/apps/openmw/mwworld/esmstore.hpp @@ -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, Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, Store, - Store, Store, Store, Store>; + Store, Store, Store, Store, Store>; private: template diff --git a/apps/openmw/mwworld/manualref.cpp b/apps/openmw/mwworld/manualref.cpp index a07ceac083..e9fd02e6f5 100644 --- a/apps/openmw/mwworld/manualref.cpp +++ b/apps/openmw/mwworld/manualref.cpp @@ -91,6 +91,9 @@ MWWorld::ManualRef::ManualRef(const MWWorld::ESMStore& store, const ESM::RefId& case ESM::REC_STAT4: create(store.get(), name, mRef, mPtr); break; + case ESM::REC_TERM4: + create(store.get(), name, mRef, mPtr); + break; case 0: throw std::logic_error("failed to create manual cell ref for " + name.toDebugString() + " (unknown ID)"); diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index 919f8b9799..cf407f9291 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -1400,6 +1400,7 @@ template class MWWorld::TypedDynamicStore; template class MWWorld::TypedDynamicStore; template class MWWorld::TypedDynamicStore; template class MWWorld::TypedDynamicStore; +template class MWWorld::TypedDynamicStore; template class MWWorld::TypedDynamicStore; template class MWWorld::TypedDynamicStore; template class MWWorld::TypedDynamicStore; diff --git a/components/esm/records.hpp b/components/esm/records.hpp index d5f6e0926a..4af60db8b5 100644 --- a/components/esm/records.hpp +++ b/components/esm/records.hpp @@ -70,6 +70,7 @@ #include #include #include +#include #include #include #include diff --git a/components/esm4/loadterm.cpp b/components/esm4/loadterm.cpp index af7d8dd62f..5f14085d2d 100644 --- a/components/esm4/loadterm.cpp +++ b/components/esm4/loadterm.cpp @@ -29,7 +29,7 @@ #include #include "reader.hpp" -//#include "writer.hpp" +// #include "writer.hpp" void ESM4::Terminal::load(ESM4::Reader& reader) { @@ -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: diff --git a/files/lua_api/openmw/types.lua b/files/lua_api/openmw/types.lua index 7ba2b5d5bb..c9ca478529 100644 --- a/files/lua_api/openmw/types.lua +++ b/files/lua_api/openmw/types.lua @@ -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