From f3a2bc6e12b85c30ba5e78886da95f11d046ae76 Mon Sep 17 00:00:00 2001 From: hispidence Date: Sun, 6 Feb 2022 20:59:48 +0000 Subject: [PATCH] Update Animations script class. --- Scripting/Scripting.vcxproj | 4 ++-- Scripting/Scripting.vcxproj.filters | 12 +++++----- Scripting/src/Flow/Animations/Animations.cpp | 22 +++++++++---------- Scripting/src/Flow/Animations/Animations.h | 4 ++-- Scripting/src/Flow/FlowHandler.cpp | 23 ++++++++++---------- Scripting/src/Flow/FlowHandler.h | 20 ++++++++--------- 6 files changed, 43 insertions(+), 42 deletions(-) diff --git a/Scripting/Scripting.vcxproj b/Scripting/Scripting.vcxproj index 8160724e2..b708ad9a8 100644 --- a/Scripting/Scripting.vcxproj +++ b/Scripting/Scripting.vcxproj @@ -76,8 +76,8 @@ + - @@ -114,6 +114,7 @@ frameworkandsol.h Create + @@ -125,7 +126,6 @@ - diff --git a/Scripting/Scripting.vcxproj.filters b/Scripting/Scripting.vcxproj.filters index 0c58ab523..095a9e303 100644 --- a/Scripting/Scripting.vcxproj.filters +++ b/Scripting/Scripting.vcxproj.filters @@ -177,9 +177,6 @@ Header Files - - Header Files - Header Files @@ -279,6 +276,9 @@ Header Files + + Header Files + @@ -308,9 +308,6 @@ Source Files - - Source Files - Source Files @@ -359,6 +356,9 @@ Source Files + + Source Files + diff --git a/Scripting/src/Flow/Animations/Animations.cpp b/Scripting/src/Flow/Animations/Animations.cpp index baac9c1e4..872b6eef3 100644 --- a/Scripting/src/Flow/Animations/Animations.cpp +++ b/Scripting/src/Flow/Animations/Animations.cpp @@ -1,21 +1,21 @@ #include "frameworkandsol.h" -#include "GameScriptAnimations.h" +#include "Flow/Animations/Animations.h" /*** New custom animations which Lara can perform. -@pregameclass Animations +@tenclass Flow.Animations @pragma nostrip */ -void GameScriptAnimations::Register(sol::state* lua) +void Animations::Register(sol::table & parent) { - lua->new_usertype("Animations", - "crawlExtended", &GameScriptAnimations::CrawlExtended, - "crouchRoll", &GameScriptAnimations::CrouchRoll, - "crawlspaceSwandive", &GameScriptAnimations::CrawlspaceSwandive, - "monkeyTurn180", &GameScriptAnimations::MonkeyTurn180, - "monkeyAutoJump", &GameScriptAnimations::MonkeyAutoJump, - "oscillateHang", &GameScriptAnimations::OscillateHang, - "pose", &GameScriptAnimations::Pose + parent.new_usertype("Animations", + "crawlExtended", &Animations::CrawlExtended, + "crouchRoll", &Animations::CrouchRoll, + "crawlspaceSwandive", &Animations::CrawlspaceSwandive, + "monkeyTurn180", &Animations::MonkeyTurn180, + "monkeyAutoJump", &Animations::MonkeyAutoJump, + "oscillateHang", &Animations::OscillateHang, + "pose", &Animations::Pose ); } diff --git a/Scripting/src/Flow/Animations/Animations.h b/Scripting/src/Flow/Animations/Animations.h index 7d5fa4f6b..fab9b7932 100644 --- a/Scripting/src/Flow/Animations/Animations.h +++ b/Scripting/src/Flow/Animations/Animations.h @@ -7,7 +7,7 @@ namespace sol { class state; } -struct GameScriptAnimations +struct Animations { bool CrawlExtended; // Extended crawl moveset bool CrouchRoll; // Crouch roll @@ -17,5 +17,5 @@ struct GameScriptAnimations bool OscillateHang; // Grab thin ledge animation from TR1 and 2 bool Pose; // Crossed arms AFK posing - static void Register(sol::state* lua); + static void Register(sol::table &); }; diff --git a/Scripting/src/Flow/FlowHandler.cpp b/Scripting/src/Flow/FlowHandler.cpp index a3524b520..e5c23d212 100644 --- a/Scripting/src/Flow/FlowHandler.cpp +++ b/Scripting/src/Flow/FlowHandler.cpp @@ -25,15 +25,6 @@ ScriptInterfaceFlowHandler* g_GameFlow; FlowHandler::FlowHandler(sol::state* lua, sol::table & parent) : LuaHandler{ lua } { - GameScriptLevel::Register(m_lua); - GameScriptSkyLayer::Register(m_lua); - GameScriptFog::Register(m_lua); - GameScriptMirror::Register(m_lua); - GameScriptInventoryObject::Register(m_lua); - GameScriptSettings::Register(m_lua); - GameScriptAnimations::Register(m_lua); - GameScriptColor::Register(m_lua); - GameScriptRotation::Register(m_lua); /*** gameflow.lua. These functions are called in gameflow.lua, a file loosely equivalent to winroomedit's SCRIPT.DAT. @@ -110,6 +101,16 @@ Specify which translations in the strings table correspond to which languages. */ table_flow.set_function(ScriptReserved_SetLanguageNames, &FlowHandler::SetLanguageNames, this); + GameScriptLevel::Register(m_lua); + GameScriptSkyLayer::Register(m_lua); + GameScriptMirror::Register(m_lua); + GameScriptInventoryObject::Register(m_lua); + GameScriptSettings::Register(m_lua); + Animations::Register(table_flow); + GameScriptColor::Register(m_lua); + GameScriptRotation::Register(m_lua); + GameScriptFog::Register(m_lua); + MakeReadOnlyTable(ScriptReserved_WeatherType, kWeatherTypes); MakeReadOnlyTable(ScriptReserved_LaraType, kLaraTypes); MakeReadOnlyTable(ScriptReserved_InvItem, kInventorySlots); @@ -141,9 +142,9 @@ void FlowHandler::SetSettings(GameScriptSettings const & src) m_settings = src; } -void FlowHandler::SetAnimations(GameScriptAnimations const& src) +void FlowHandler::SetAnimations(Animations const& src) { - Animations = src; + Anims = src; } void FlowHandler::AddLevel(GameScriptLevel const& level) diff --git a/Scripting/src/Flow/FlowHandler.h b/Scripting/src/Flow/FlowHandler.h index 44a92c5a0..2759a5108 100644 --- a/Scripting/src/Flow/FlowHandler.h +++ b/Scripting/src/Flow/FlowHandler.h @@ -5,7 +5,7 @@ #include "GameScriptColor.h" #include "GameScriptLevel.h" #include "GameScriptSettings.h" -#include "GameScriptAnimations.h" +#include "Flow/Animations/Animations.h" #include "ScriptInterfaceGame.h" #include "Flow/ScriptInterfaceFlowHandler.h" @@ -28,7 +28,7 @@ public: byte GameFarView{ 0 }; // New animation flag table - GameScriptAnimations Animations{}; + Animations Anims{}; // Selected language set std::vector Levels; @@ -41,7 +41,7 @@ public: char const * GetString(const char* id) const; void SetStrings(sol::nested>> && src); void SetLanguageNames(sol::as_table_t> && src); - void SetAnimations(GameScriptAnimations const & src); + void SetAnimations(Animations const & src); void SetSettings(GameScriptSettings const & src); GameScriptSettings* GetSettings(); GameScriptLevel* GetLevel(int id); @@ -52,13 +52,13 @@ public: bool IsFlyCheatEnabled() const; bool CanPlayAnyLevel() const; - bool HasCrawlExtended() const override { return Animations.CrawlExtended; } - bool HasCrouchRoll() const override { return Animations.CrouchRoll; } - bool HasCrawlspaceSwandive() const override { return Animations.CrawlspaceSwandive; } - bool HasMonkeyTurn180() const override { return Animations.MonkeyTurn180; } - bool HasMonkeyAutoJump() const override { return Animations.MonkeyAutoJump; } - bool HasOscillateHang() const override { return Animations.OscillateHang; } - bool HasAFKPose() const override { return Animations.Pose; } + bool HasCrawlExtended() const override { return Anims.CrawlExtended; } + bool HasCrouchRoll() const override { return Anims.CrouchRoll; } + bool HasCrawlspaceSwandive() const override { return Anims.CrawlspaceSwandive; } + bool HasMonkeyTurn180() const override { return Anims.MonkeyTurn180; } + bool HasMonkeyAutoJump() const override { return Anims.MonkeyAutoJump; } + bool HasOscillateHang() const override { return Anims.OscillateHang; } + bool HasAFKPose() const override { return Anims.Pose; } bool DoFlow() override; };