From 3c55e4c963686b346595dbae7fdb574bcb973f8f Mon Sep 17 00:00:00 2001 From: Barinade Date: Fri, 28 Oct 2022 22:02:35 -0500 Subject: [PATCH] add lua access to inputdata from replays --- src/Etterna/Models/HighScore/Replay.cpp | 33 +++++++++++++++++-- .../HighScore/ReplayConstantsAndTypes.h | 3 ++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/Etterna/Models/HighScore/Replay.cpp b/src/Etterna/Models/HighScore/Replay.cpp index 20b2f2b909..3210b103eb 100644 --- a/src/Etterna/Models/HighScore/Replay.cpp +++ b/src/Etterna/Models/HighScore/Replay.cpp @@ -2196,6 +2196,12 @@ class LunaReplay : public Luna return 1; } + static auto GetInputData(T* p, lua_State* L) -> int + { + LuaHelpers::CreateTableFromArray(p->GetInputDataVector(), L); + return 1; + } + DEFINE_METHOD(HasReplayData, HasReplayData()) DEFINE_METHOD(GetChartKey, GetChartKey()) DEFINE_METHOD(GetScoreKey, GetScoreKey()) @@ -2213,10 +2219,10 @@ class LunaReplay : public Luna ADD_METHOD(GetTapNoteTypeVector); ADD_METHOD(GetHoldNoteVector); ADD_METHOD(GetMineHitVector); + ADD_METHOD(GetInputData); ADD_METHOD(GetReplaySnapshotForNoterow); } }; - LUA_REGISTER_CLASS(Replay) class LunaReplaySnapshot : public Luna @@ -2269,5 +2275,28 @@ class LunaReplaySnapshot : public Luna ADD_METHOD(GetWifePercent); } }; - LUA_REGISTER_CLASS(ReplaySnapshot) + +class LunaInputDataEvent : public Luna +{ + public: + + DEFINE_METHOD(IsPress, is_press); + DEFINE_METHOD(GetColumn, column); + DEFINE_METHOD(GetSongPositionSeconds, songPositionSeconds); + DEFINE_METHOD(GetNearestTapNoterow, nearestTapNoterow); + DEFINE_METHOD(GetOffsetFromNearest, offsetFromNearest); + DEFINE_METHOD(GetNearestTapNoteType, nearestTapNoteType); + DEFINE_METHOD(GetNearestTapNoteSubType, nearestTapNoteSubType); + + LunaInputDataEvent() { + ADD_METHOD(IsPress); + ADD_METHOD(GetColumn); + ADD_METHOD(GetSongPositionSeconds); + ADD_METHOD(GetNearestTapNoterow); + ADD_METHOD(GetOffsetFromNearest); + ADD_METHOD(GetNearestTapNoteType); + ADD_METHOD(GetNearestTapNoteSubType); + } +}; +LUA_REGISTER_CLASS(InputDataEvent) diff --git a/src/Etterna/Models/HighScore/ReplayConstantsAndTypes.h b/src/Etterna/Models/HighScore/ReplayConstantsAndTypes.h index 0d996a66e6..a43008d4a3 100644 --- a/src/Etterna/Models/HighScore/ReplayConstantsAndTypes.h +++ b/src/Etterna/Models/HighScore/ReplayConstantsAndTypes.h @@ -78,6 +78,9 @@ struct InputDataEvent nearestTapNoteType = other.nearestTapNoteType; nearestTapNoteSubType = other.nearestTapNoteSubType; } + + /// Lua + void PushSelf(lua_State* L); }; struct MineReplayResult