From a781a509decc8f9653c09ca7f4f4280d6b988a8d Mon Sep 17 00:00:00 2001 From: Barinade Date: Sat, 28 May 2022 19:32:33 -0500 Subject: [PATCH] further replay redo wip --- src/Etterna/Models/HighScore/Replay.cpp | 15 +++ src/Etterna/Models/HighScore/Replay.h | 158 ++++++++++++++++++------ 2 files changed, 135 insertions(+), 38 deletions(-) diff --git a/src/Etterna/Models/HighScore/Replay.cpp b/src/Etterna/Models/HighScore/Replay.cpp index e112220baf..03e944e08b 100644 --- a/src/Etterna/Models/HighScore/Replay.cpp +++ b/src/Etterna/Models/HighScore/Replay.cpp @@ -1,3 +1,18 @@ +#include "Etterna/Globals/global.h" #include "Replay.h" +#include "HighScore.h" +Replay::Replay() { +} + +Replay::Replay(HighScore* hs) + : scoreKey(hs->GetScoreKey()) + , chartKey(hs->GetChartKey()) +{ + +} + +Replay::~Replay() { + Unload(); +} diff --git a/src/Etterna/Models/HighScore/Replay.h b/src/Etterna/Models/HighScore/Replay.h index 1720ed36e3..7c6340a8ea 100644 --- a/src/Etterna/Models/HighScore/Replay.h +++ b/src/Etterna/Models/HighScore/Replay.h @@ -4,57 +4,139 @@ #include "Etterna/Models/Misc/EnumHelper.h" #include "ReplayConstantsAndTypes.h" +struct HighScore; + class Replay { Replay(); + Replay(HighScore* hs); + ~Replay(); public: - [[nodiscard]] auto GetOffsetVector() const -> const std::vector&; - [[nodiscard]] auto GetCopyOfOffsetVector() const -> std::vector; - - [[nodiscard]] auto GetNoteRowVector() const -> const std::vector&; - [[nodiscard]] auto GetCopyOfNoteRowVector() const -> std::vector; - - [[nodiscard]] auto GetTrackVector() const -> const std::vector&; - [[nodiscard]] auto GetCopyOfTrackVector() const -> std::vector; - - [[nodiscard]] auto GetTapNoteTypeVector() const - -> const std::vector&; - [[nodiscard]] auto GetCopyOfTapNoteTypeVector() const - -> std::vector; - - [[nodiscard]] auto GetHoldReplayDataVector() const - -> const std::vector&; - [[nodiscard]] auto GetCopyOfHoldReplayDataVector() const - -> std::vector; - - [[nodiscard]] auto GetMineReplayDataVector() const - -> const std::vector&; - [[nodiscard]] auto GetCopyOfMineReplayDataVector() const - -> std::vector; - - [[nodiscard]] auto GetCopyOfSetOnlineReplayTimestampVector() const - -> std::vector; - - [[nodiscard]] auto GetInputDataVector() const - -> const std::vector&; - [[nodiscard]] auto GetCopyOfInputDataVector() const - -> std::vector; - - [[nodiscard]] auto GetReplayType() const -> int; + auto GetOffsetVector() const -> const std::vector& { + return vOffsetVector; + } + auto GetCopyOfOffsetVector() const -> std::vector { + return vOffsetVector; + } + + auto GetNoteRowVector() const -> const std::vector& { + return vNoteRowVector; + } + auto GetCopyOfNoteRowVector() const -> std::vector { + return vNoteRowVector; + } + + auto GetTrackVector() const -> const std::vector& { + return vTrackVector; + } + auto GetCopyOfTrackVector() const -> std::vector { + return vTrackVector; + } + + auto GetTapNoteTypeVector() const -> const std::vector& { + return vTapNoteTypeVector; + } + auto GetCopyOfTapNoteTypeVector() const -> std::vector { + return vTapNoteTypeVector; + } + + auto GetHoldReplayDataVector() const -> const std::vector& + { + return vHoldReplayDataVector; + } + auto GetCopyOfHoldReplayDataVector() const -> std::vector + { + return vHoldReplayDataVector; + } + + auto GetMineReplayDataVector() const -> const std::vector& + { + return vMineReplayDataVector; + } + auto GetCopyOfMineReplayDataVector() const -> std::vector + { + return vMineReplayDataVector; + } + + auto GetOnlineReplayTimestampVector() const -> const std::vector& { + return vOnlineReplayTimestampVector; + } + auto GetCopyOfOnlineReplayTimestampVector() const -> std::vector + { + return vOnlineReplayTimestampVector; + } + + auto GetInputDataVector() const -> const std::vector& { + return InputData; + } + auto GetCopyOfInputDataVector() const -> std::vector { + return InputData; + } + + auto GetScoreKey() const -> std::string { + return scoreKey; + } + void SetScoreKey(std::string& key) { + scoreKey = key; + } + auto GetChartKey() const -> std::string { + return chartKey; + } + void SetChartKey(std::string& key) { + chartKey = key; + } + + ReplayType GetReplayType() const + { + if (!InputData.empty()) { + // detailed data + return ReplayType_Input; + } else if (!vTrackVector.empty()) { + // column data + return ReplayType_V2; + } else if (!vNoteRowVector.empty()) { + // no column/extra data + return ReplayType_V1; + } else { + // it probably isn't loaded + return ReplayType_Invalid; + } + } auto WriteReplayData() -> bool; auto WriteInputData() -> bool; auto LoadInputData() -> bool; auto LoadReplayData() -> bool; - auto LoadReplayDataBasic(const std::string& dir) -> bool; - auto LoadReplayDataFull(const std::string& dir) -> bool; - virtual auto HasReplayData() -> bool; - void UnloadReplayData(); - + auto HasReplayData() -> bool; + + void Unload() { + vNoteRowVector.clear(); + vOffsetVector.clear(); + vTrackVector.clear(); + vTapNoteTypeVector.clear(); + vHoldReplayDataVector.clear(); + vMineReplayDataVector.clear(); + vOnlineReplayTimestampVector.clear(); + InputData.clear(); + + vNoteRowVector.shrink_to_fit(); + vOffsetVector.shrink_to_fit(); + vTrackVector.shrink_to_fit(); + vTapNoteTypeVector.shrink_to_fit(); + vHoldReplayDataVector.shrink_to_fit(); + vMineReplayDataVector.shrink_to_fit(); + vOnlineReplayTimestampVector.shrink_to_fit(); + InputData.shrink_to_fit(); + } + + // Lua void PushSelf(lua_State* L); private: + auto LoadReplayDataBasic(const std::string& dir) -> bool; + auto LoadReplayDataFull(const std::string& dir) -> bool; + std::string scoreKey{}; std::string chartKey{};