Etterna 0.74.4
Loading...
Searching...
No Matches
ReplayManager.h
1#pragma once
2#ifndef REPLAYMAN
3#define REPLAYMAN
4
5#include "Etterna/Models/Lua/LuaBinding.h"
6#include "Etterna/Models/HighScore/Replay.h"
7#include "Etterna/Models/Misc/PlayerStageStats.h"
8
9#include <unordered_map>
10
16{
17 bool replayUsedMirror = false;
18 float replayRate = 1.F;
19 std::string replayModifiers{};
20 std::string oldModifiers{};
21 float oldRate = 1.F;
22 std::string oldNoteskin{};
23 FailType oldFailType = FailType_Immediate;
24 int replayRngSeed = 0;
25 int oldRngSeed = 0;
26
27 void reset()
28 {
29 replayRate = 1.F;
30 replayModifiers = std::string();
31 replayUsedMirror = false;
32 replayRngSeed = 0;
33 oldModifiers = std::string();
34 oldRate = 1.F;
35 oldNoteskin = std::string();
36 oldFailType = FailType_Immediate;
37 oldRngSeed = 0;
38 }
39};
40
41struct HighScore;
43{
44 public:
47
49 Replay* GetReplay(const HighScore* hs);
50 void ReleaseReplay(Replay* replay);
51
56 float timingScale = 1.F,
57 int startRow = 0);
58
59 void UnsetActiveReplay();
60
63
64 HighScore* GetActiveReplayScore();
65
66 void StoreActiveReplaySettings(float replayRate,
67 std::string& replayModifiers,
68 bool replayUsedMirror,
69 int replayRngSeed);
70
71 void StoreOldSettings(float oldRate,
72 std::string& oldModifiers,
73 FailType oldFailType,
74 std::string& oldNoteskin,
75 int oldRngSeed);
76
77 TemporaryReplaySettings GetActiveReplaySettings();
78 void ResetActiveReplaySettings();
79
80 static TapNoteScore GetTapNoteScoreForReplay(float fNoteOffset,
81 float timingScale = 1.F);
82
83 auto CalculateRadarValuesForReplay(Replay& replay,
84 RadarValues& rv,
85 RadarValues& possibleRV) -> bool;
86
87 auto RescoreReplay(Replay& replay,
89 float timingScale = 1.F) -> bool;
90
91 auto GenerateLifeRecordForReplay(Replay& replay, float timingScale = 1.F)
92 -> std::map<float, float>;
93
94 auto GenerateComboListForReplay(Replay& replay, float timingScale = 1.F)
95 -> std::vector<PlayerStageStats::Combo_t>;
96
97 void EnableCustomScoringFunctions() {
98 customScoringFunctionsEnabled = true;
99 }
100 void DisableCustomScoringFunctions() {
101 customScoringFunctionsEnabled = false;
102 }
103 bool isCustomScoringFunctionsEnabled() {
104 return customScoringFunctionsEnabled;
105 }
106
108 // custom scoring functions
109 // these will default to base game behavior if the custom functions arent set
110
114 auto CustomTapScoringFunction(float fOffsetSeconds,
115 TapNoteScore tns,
116 float timingScale) -> float;
120 auto CustomHoldNoteScoreScoringFunction(HoldNoteScore hns) -> float;
124 auto CustomMineScoringFunction() -> float;
128 auto CustomTotalWifePointsCalculation(TapNoteType tnt) -> float;
132 auto CustomOffsetJudgingFunction(float fOffsetSeconds, float timingScale)
133 -> TapNoteScore;
137 auto CustomMissWindowFunction() -> float;
138
139 void SetTotalWifePointsCalcFunction(const LuaReference& ref) {
140 m_totalWifePointsCalcFunc = ref;
141 }
142 void SetMineScoringFunction(const LuaReference& ref) {
143 m_mineScoringFunc = ref;
144 }
145 void SetHoldNoteScoringFunction(const LuaReference& ref) {
146 m_holdNoteScoreScoringFunc = ref;
147 }
148 void SetTapScoringFunction(const LuaReference& ref) {
149 m_tapScoringFunc = ref;
150 }
151 void SetOffsetJudgingFunction(const LuaReference& ref) {
152 m_offsetJudgingFunc = ref;
153 }
154 void SetMissWindowFunction(const LuaReference& ref) {
155 m_missWindowFunc = ref;
156 }
157 //
159
161 void PushSelf(lua_State* L);
162
163 private:
165 std::unordered_map<std::string, std::pair<unsigned, Replay*>>
166 scoresToReplays{};
167
168 LuaReference m_totalWifePointsCalcFunc;
169 LuaReference m_mineScoringFunc;
170 LuaReference m_holdNoteScoreScoringFunc;
171 LuaReference m_tapScoringFunc;
172 LuaReference m_offsetJudgingFunc;
173 LuaReference m_missWindowFunc;
174
175 bool customScoringFunctionsEnabled = false;
176
177};
178
179extern std::shared_ptr<ReplayManager> REPLAYS;
180
181#endif
A self-cleaning Lua reference.
Definition LuaReference.h:10
Contains statistics for one stage of play - either one song, or a whole course.
Definition PlayerStageStats.h:19
Definition ReplayManager.h:43
auto CustomMissWindowFunction() -> float
Definition ReplayManager.cpp:725
auto CustomHoldNoteScoreScoringFunction(HoldNoteScore hns) -> float
Definition ReplayManager.cpp:571
auto CustomMineScoringFunction() -> float
Definition ReplayManager.cpp:618
auto CustomOffsetJudgingFunction(float fOffsetSeconds, float timingScale) -> TapNoteScore
Definition ReplayManager.cpp:694
auto CustomTapScoringFunction(float fOffsetSeconds, TapNoteScore tns, float timingScale) -> float
Definition ReplayManager.cpp:532
Replay * GetActiveReplay()
Returns the Replay being watched by the player. Never null.
Definition ReplayManager.cpp:140
void PushSelf(lua_State *L)
Lua.
auto CustomTotalWifePointsCalculation(TapNoteType tnt) -> float
Definition ReplayManager.cpp:651
Replay * InitReplayPlaybackForScore(HighScore *hs, float timingScale=1.F, int startRow=0)
Definition ReplayManager.cpp:115
Replay * GetReplay(const HighScore *hs)
Return the Replay for this HighScore. Never null.
Definition ReplayManager.cpp:17
Definition Replay.h:15
The high score that is earned by a player.
Definition HighScore.h:18
Cached song statistics.
Definition RadarValues.h:14
Definition ReplayManager.h:16