Etterna 0.75.1
Loading...
Searching...
No Matches
ReplayManager.h
1#pragma once
2#ifndef REPLAYMAN_H
3#define REPLAYMAN_H
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 Replay* GetSpectateReplay(const std::string& playerID);
52
57 float timingScale = 1.F,
58 int startRow = 0);
59
60 Replay* InitReplayPlaybackForSpectate(std::string playerID,
61 std::string chartKey,
62 float musicRate,
63 float songOffset,
64 float globalOffset,
65 int rngSeed,
66 std::string mods);
67
68 void UnsetActiveReplay();
69
72
73 HighScore* GetActiveReplayScore();
74
75 void StoreActiveReplaySettings(float replayRate,
76 std::string& replayModifiers,
77 bool replayUsedMirror,
78 int replayRngSeed);
79
80 void StoreOldSettings(float oldRate,
81 std::string& oldModifiers,
82 FailType oldFailType,
83 std::string& oldNoteskin,
84 int oldRngSeed);
85
86 TemporaryReplaySettings GetActiveReplaySettings();
87 void ResetActiveReplaySettings();
88
89 static TapNoteScore GetTapNoteScoreForReplay(float fNoteOffset,
90 float timingScale = 1.F);
91
92 auto CalculateRadarValuesForReplay(Replay& replay,
93 RadarValues& rv,
94 RadarValues& possibleRV) -> bool;
95
96 auto RescoreReplay(Replay& replay,
98 float timingScale = 1.F) -> bool;
99
100 auto GenerateLifeRecordForReplay(Replay& replay, float timingScale = 1.F)
101 -> std::map<float, float>;
102
103 auto GenerateComboListForReplay(Replay& replay, float timingScale = 1.F)
104 -> std::vector<PlayerStageStats::Combo_t>;
105
106 void EnableCustomScoringFunctions() {
107 customScoringFunctionsEnabled = true;
108 }
109 void DisableCustomScoringFunctions() {
110 customScoringFunctionsEnabled = false;
111 }
112 bool isCustomScoringFunctionsEnabled() {
113 return customScoringFunctionsEnabled;
114 }
115
117 // custom scoring functions
118 // these will default to base game behavior if the custom functions arent set
119
123 auto CustomTapScoringFunction(float fOffsetSeconds,
124 TapNoteScore tns,
125 float timingScale) -> float;
129 auto CustomHoldNoteScoreScoringFunction(HoldNoteScore hns) -> float;
133 auto CustomMineScoringFunction() -> float;
137 auto CustomTotalWifePointsCalculation(TapNoteType tnt) -> float;
141 auto CustomOffsetJudgingFunction(float fOffsetSeconds, float timingScale)
142 -> TapNoteScore;
146 auto CustomMissWindowFunction() -> float;
147
148 void SetTotalWifePointsCalcFunction(const LuaReference& ref) {
149 m_totalWifePointsCalcFunc = ref;
150 }
151 void SetMineScoringFunction(const LuaReference& ref) {
152 m_mineScoringFunc = ref;
153 }
154 void SetHoldNoteScoringFunction(const LuaReference& ref) {
155 m_holdNoteScoreScoringFunc = ref;
156 }
157 void SetTapScoringFunction(const LuaReference& ref) {
158 m_tapScoringFunc = ref;
159 }
160 void SetOffsetJudgingFunction(const LuaReference& ref) {
161 m_offsetJudgingFunc = ref;
162 }
163 void SetMissWindowFunction(const LuaReference& ref) {
164 m_missWindowFunc = ref;
165 }
166 //
168
170 void PushSelf(lua_State* L);
171
172 private:
174 std::unordered_map<std::string, std::pair<unsigned, Replay*>>
175 scoresToReplays{};
176
178 std::unordered_map<std::string, Replay*> spectatorReplays{};
179
180 LuaReference m_totalWifePointsCalcFunc;
181 LuaReference m_mineScoringFunc;
182 LuaReference m_holdNoteScoreScoringFunc;
183 LuaReference m_tapScoringFunc;
184 LuaReference m_offsetJudgingFunc;
185 LuaReference m_missWindowFunc;
186
187 bool customScoringFunctionsEnabled = false;
188
189};
190
191extern std::shared_ptr<ReplayManager> REPLAYS;
192
193#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:760
auto CustomHoldNoteScoreScoringFunction(HoldNoteScore hns) -> float
Definition ReplayManager.cpp:606
auto CustomMineScoringFunction() -> float
Definition ReplayManager.cpp:653
auto CustomOffsetJudgingFunction(float fOffsetSeconds, float timingScale) -> TapNoteScore
Definition ReplayManager.cpp:729
auto CustomTapScoringFunction(float fOffsetSeconds, TapNoteScore tns, float timingScale) -> float
Definition ReplayManager.cpp:567
Replay * GetActiveReplay()
Returns the Replay being watched by the player. Never null.
Definition ReplayManager.cpp:175
void PushSelf(lua_State *L)
Lua.
auto CustomTotalWifePointsCalculation(TapNoteType tnt) -> float
Definition ReplayManager.cpp:686
Replay * InitReplayPlaybackForScore(HighScore *hs, float timingScale=1.F, int startRow=0)
Definition ReplayManager.cpp:126
Replay * GetReplay(const HighScore *hs)
Return the Replay for this HighScore. Never null.
Definition ReplayManager.cpp:18
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