Skip to content

Commit

Permalink
further replay redo wip
Browse files Browse the repository at this point in the history
  • Loading branch information
poco0317 committed May 29, 2022
1 parent 1df9cc3 commit a781a50
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 38 deletions.
15 changes: 15 additions & 0 deletions src/Etterna/Models/HighScore/Replay.cpp
Original file line number Diff line number Diff line change
@@ -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();
}
158 changes: 120 additions & 38 deletions src/Etterna/Models/HighScore/Replay.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>&;
[[nodiscard]] auto GetCopyOfOffsetVector() const -> std::vector<float>;

[[nodiscard]] auto GetNoteRowVector() const -> const std::vector<int>&;
[[nodiscard]] auto GetCopyOfNoteRowVector() const -> std::vector<int>;

[[nodiscard]] auto GetTrackVector() const -> const std::vector<int>&;
[[nodiscard]] auto GetCopyOfTrackVector() const -> std::vector<int>;

[[nodiscard]] auto GetTapNoteTypeVector() const
-> const std::vector<TapNoteType>&;
[[nodiscard]] auto GetCopyOfTapNoteTypeVector() const
-> std::vector<TapNoteType>;

[[nodiscard]] auto GetHoldReplayDataVector() const
-> const std::vector<HoldReplayResult>&;
[[nodiscard]] auto GetCopyOfHoldReplayDataVector() const
-> std::vector<HoldReplayResult>;

[[nodiscard]] auto GetMineReplayDataVector() const
-> const std::vector<MineReplayResult>&;
[[nodiscard]] auto GetCopyOfMineReplayDataVector() const
-> std::vector<MineReplayResult>;

[[nodiscard]] auto GetCopyOfSetOnlineReplayTimestampVector() const
-> std::vector<float>;

[[nodiscard]] auto GetInputDataVector() const
-> const std::vector<InputDataEvent>&;
[[nodiscard]] auto GetCopyOfInputDataVector() const
-> std::vector<InputDataEvent>;

[[nodiscard]] auto GetReplayType() const -> int;
auto GetOffsetVector() const -> const std::vector<float>& {
return vOffsetVector;
}
auto GetCopyOfOffsetVector() const -> std::vector<float> {
return vOffsetVector;
}

auto GetNoteRowVector() const -> const std::vector<int>& {
return vNoteRowVector;
}
auto GetCopyOfNoteRowVector() const -> std::vector<int> {
return vNoteRowVector;
}

auto GetTrackVector() const -> const std::vector<int>& {
return vTrackVector;
}
auto GetCopyOfTrackVector() const -> std::vector<int> {
return vTrackVector;
}

auto GetTapNoteTypeVector() const -> const std::vector<TapNoteType>& {
return vTapNoteTypeVector;
}
auto GetCopyOfTapNoteTypeVector() const -> std::vector<TapNoteType> {
return vTapNoteTypeVector;
}

auto GetHoldReplayDataVector() const -> const std::vector<HoldReplayResult>&
{
return vHoldReplayDataVector;
}
auto GetCopyOfHoldReplayDataVector() const -> std::vector<HoldReplayResult>
{
return vHoldReplayDataVector;
}

auto GetMineReplayDataVector() const -> const std::vector<MineReplayResult>&
{
return vMineReplayDataVector;
}
auto GetCopyOfMineReplayDataVector() const -> std::vector<MineReplayResult>
{
return vMineReplayDataVector;
}

auto GetOnlineReplayTimestampVector() const -> const std::vector<float>& {
return vOnlineReplayTimestampVector;
}
auto GetCopyOfOnlineReplayTimestampVector() const -> std::vector<float>
{
return vOnlineReplayTimestampVector;
}

auto GetInputDataVector() const -> const std::vector<InputDataEvent>& {
return InputData;
}
auto GetCopyOfInputDataVector() const -> std::vector<InputDataEvent> {
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{};

Expand Down

0 comments on commit a781a50

Please sign in to comment.