Etterna 0.74.4
Loading...
Searching...
No Matches
Steps.h
1#ifndef STEPS_H
2#define STEPS_H
3
4#include "Etterna/Models/Misc/Difficulty.h"
5#include "Etterna/Models/Misc/GameConstantsAndTypes.h"
6#include "Etterna/Models/Misc/Grade.h"
7#include "Etterna/Models/Misc/RadarValues.h"
8#include "RageUtil/Utils/RageUtil_CachedObject.h"
9#include "Etterna/Models/Misc/TimingData.h"
10#include "Etterna/Models/NoteData/NoteData.h"
11
12class Profile;
13struct lua_State;
14class Song;
15class Calc;
16
22const int MAX_STEPS_DESCRIPTION_LENGTH = 255;
23
25enum DisplayBPM
26{
27 DISPLAY_BPM_ACTUAL,
28 DISPLAY_BPM_SPECIFIED,
29 DISPLAY_BPM_RANDOM,
30 NUM_DisplayBPM,
31 DisplayBPM_Invalid
32};
33auto
34DisplayBPMToString(DisplayBPM x) -> const std::string&;
35LuaDeclareType(DisplayBPM);
36
41class Steps
42{
43 public:
45 Steps(Song* song);
48
49 auto operator=(const Steps &) -> Steps&;
50
51 // initializers
52 void CopyFrom(Steps* pSource, StepsType ntTo);
53 void CreateBlank(StepsType ntTo);
54
55 void Compress() const;
56 void Decompress() const;
57 void Decompress();
58
63 auto GetDescription() const -> const std::string& { return m_sDescription; }
68 auto GetChartStyle() const -> const std::string& { return m_sChartStyle; }
73 auto GetDifficulty() const -> const Difficulty { return m_Difficulty; }
78 auto GetMeter() const -> int { return m_iMeter; }
79 auto GetRadarValues() const -> const RadarValues&
80 {
81 return m_CachedRadarValues;
82 }
87 auto GetCredit() const -> const std::string& { return m_sCredit; }
88
89 auto GetChartName() const -> const std::string& { return chartName; }
90 void SetChartName(const std::string& name) { this->chartName = name; }
91 void SetFilename(const std::string& fn) { m_sFilename = fn; }
92 auto GetFilename() const -> const std::string& { return m_sFilename; }
93 void SetSavedToDisk(bool b) { m_bSavedToDisk = b; }
94 auto GetSavedToDisk() const -> bool { return m_bSavedToDisk; }
95 void SetDifficulty(Difficulty dc)
96 {
97 SetDifficultyAndDescription(dc, GetDescription());
98 }
99 void SetDescription(const std::string& sDescription)
100 {
101 SetDifficultyAndDescription(this->GetDifficulty(), sDescription);
102 }
103 void SetDifficultyAndDescription(Difficulty dc,
104 const std::string& sDescription);
105 void SetCredit(const std::string& sCredit);
106 void SetChartStyle(const std::string& sChartStyle);
107 void SetDupeDiff(bool state) { m_bDuplicateDifficulty = state; }
108 auto IsDupeDiff() -> bool { return m_bDuplicateDifficulty; }
109 static auto MakeValidEditDescription(std::string& sPreferredDescription)
110 -> bool; // return true if was modified
111
112 void SetLoadedFromProfile(ProfileSlot slot) { m_LoadedFromProfile = slot; }
113 void SetMeter(int meter);
114 void SetCachedRadarValues(const RadarValues& v);
115
116 // self exaplanatory -mina
117 static auto GetNPSVector(const NoteData& nd,
118 const std::vector<float>& etaner,
119 const std::vector<int>& nerv,
120 float rate) -> std::vector<int>;
121
122 auto GetNPSPerMeasure(const NoteData& nd,
123 const std::vector<float>& etaner,
124 const std::vector<int>& nerv,
125 float rate) -> std::vector<float>;
126
127 // takes size of chord and counts how many -NOTES- are in
128 // chords of that exact size (this functionally means
129 // multiplying chord counter by chord size) in a row -mina
130 // (jumps won't count as hands, etc)
131 static auto GetCNPSVector(const NoteData& nd,
132 const std::vector<int>& nerv,
133 const std::vector<float>& etaner,
134 int chordsize,
135 float rate) -> std::vector<int>;
136
137 auto GetHash() const -> unsigned;
138 void GetNoteData(NoteData& noteDataOut) const;
139 auto GetNoteData() const -> NoteData;
140 void SetNoteData(const NoteData& noteDataNew) const;
141 void SetSMNoteData(const std::string& notes_comp);
142 void GetSMNoteData(std::string& notes_comp_out) const;
143
147 auto GetNoteDataFromSimfile() -> bool;
148
154 auto IsNoteDataEmpty() const -> bool;
155
156 void GetETTNoteData(std::string& notes_comp_out) const;
157 void TidyUpData();
158 void CalculateRadarValues();
159
165
169 auto GetTimingData() const -> const TimingData*;
170 auto GetTimingData() -> TimingData*
171 {
172 return const_cast<TimingData*>(
173 static_cast<const Steps*>(this)->GetTimingData());
174 };
175
176 /* Now for half the reason I'm bothering to do this... generate a chart key
177 using note data and timingdata in conjuction. Do it during load and save it
178 in the steps data so that we have to do it as few times as possible.*/
179 auto GetChartKey() const -> const std::string& { return ChartKey; }
180 std::vector<float> dummy = { 0.F, 0.F, 0.F, 0.F, 0.F, 0.F, 0.F, 0.F };
181 std::vector<std::vector<float>> diffByRate = {
182 dummy, dummy, dummy, dummy, dummy, dummy, dummy,
183 dummy, dummy, dummy, dummy, dummy, dummy, dummy,
184 dummy, dummy, dummy, dummy, dummy, dummy, dummy
185 };
186 void SetChartKey(const std::string& k) { ChartKey = k; }
187 void SetAllMSD(const std::vector<std::vector<float>>& msd)
188 {
189 diffByRate = msd;
190 }
191 auto GetAllMSD() const -> std::vector<std::vector<float>>
192 {
193 return diffByRate;
194 }
195 auto SortSkillsetsAtRate(float x, bool includeoverall)
196 -> std::vector<std::pair<Skillset, float>>;
197
198 void CalcEtternaMetadata(Calc* calc = nullptr);
199 auto DoATestThing(float ev, Skillset ss, float rate, Calc* calc) -> float;
200 void GetCalcDebugOutput(); // now spits out everything with 1 calc call
201 std::vector<std::vector<std::vector<std::vector<float>>>>
202 calcdebugoutput; // probably should clear this periodically
203 void UnloadCalcDebugOutput();
204
205 float firstsecond = 0.F;
206 float lastsecond = 0.F;
207
208 // this is bugged and returns true for files with negative bpms when it
209 // shouldn't - mina
210 auto IsRecalcValid() -> bool;
211
212 auto GetMSD(float rate, int ss) const -> float
213 {
214 return GetMSD(rate, static_cast<Skillset>(ss));
215 }
216 auto GetMSD(float rate, Skillset ss) const -> float;
217
218 /* This is a reimplementation of the lua version of the script to generate
219 chart keys, except this time using the notedata stored in game memory
220 immediately after reading it than parsing it using lua. - Mina */
221 static auto GenerateChartKey(NoteData& nd, TimingData* td) -> std::string;
222
227 auto HasSignificantTimingChanges() const -> bool;
228
229 auto IsPlayableForCurrentGame() const -> bool;
230
231 auto GetMusicPath() const
232 -> const std::string; // Returns the path for loading.
233 auto GetMusicFile() const
234 -> const std::string&; // Returns the filename for the simfile.
235 void SetMusicFile(const std::string& file);
236
237 // Lua
238 void PushSelf(lua_State* L);
239
240 StepsType m_StepsType;
243 std::string m_StepsTypeStr;
246
247 std::vector<NoteInfo> serializenotedatacache;
248
249 CachedObject<Steps> m_CachedObject;
250
251 void SetDisplayBPM(const DisplayBPM type) { this->displayBPMType = type; }
252 auto GetDisplayBPM() const -> DisplayBPM { return this->displayBPMType; }
253 void SetMinBPM(const float f) { this->specifiedBPMMin = f; }
254 auto GetMinBPM() const -> float { return this->specifiedBPMMin; }
255 void SetMaxBPM(const float f) { this->specifiedBPMMax = f; }
256 void SetFirstSecond(const float f) { this->firstsecond = f; }
257 void SetLastSecond(const float f) { this->lastsecond = f; }
258 auto GetMaxBPM() const -> float { return this->specifiedBPMMax; }
259 void GetDisplayBpms(DisplayBpms& addTo,
260 bool bIgnoreCurrentRate = false) const;
263 auto GetLengthSeconds(float rate = 1) const -> float
264 {
265 return (lastsecond - firstsecond) / rate;
266 }
267
268 auto Getdebugstrings() -> const std::vector<std::string>&
269 {
270 return debugstrings;
271 }
272 auto IsSkillsetHighestOfChart(Skillset skill, float rate) -> bool;
273
274 auto IsFavorited() const -> bool { return isFavorited; }
275 auto SetFavorited(bool b) -> void { isFavorited = b; }
276 auto HasGoal() const -> bool { return hasGoal; }
277 auto SetHasGoal(bool b) -> void { hasGoal = b; }
278 auto IsPermaMirror() const -> bool { return isPermamirror; }
279 auto SetPermaMirror(bool b) -> void { isPermamirror = b; }
280
281 private:
282 std::string ChartKey = "";
283 struct UniquePtrNoteData {
284 std::unique_ptr<NoteData> p;
285 UniquePtrNoteData(): p(std::make_unique<NoteData>()) { }
286 UniquePtrNoteData(UniquePtrNoteData& rhs) {
287 p = rhs.p ? std::make_unique<NoteData>(*rhs.p) : nullptr;
288 }
289 UniquePtrNoteData &operator=(const UniquePtrNoteData& rhs) {
290 p = rhs.p ? std::make_unique<NoteData>(*rhs.p) : nullptr;
291 return *this;
292 }
293 NoteData *operator->() { return &*p; }
294 NoteData &operator*() { return *p; }
295 };
296 /* We can have one or both of these; if we have both, they're always
297 * identical. Call Compress() to force us to only have
298 * m_sNoteDataCompressed; otherwise, creation of these is transparent. */
299 mutable UniquePtrNoteData m_pNoteData;
300 mutable bool m_bNoteDataIsFilled;
301 mutable std::string m_sNoteDataCompressed;
302
304 std::string m_sFilename;
306 bool m_bSavedToDisk;
308 std::string m_MusicFile;
311 ProfileSlot m_LoadedFromProfile;
312
313 /* These values are pulled from the autogen source first, if there is one.
314 */
316 mutable unsigned m_iHash;
319 std::string m_sDescription;
321 std::string m_sChartStyle;
323 Difficulty m_Difficulty;
326 int m_iMeter;
328 RadarValues m_CachedRadarValues;
329 bool m_bAreCachedRadarValuesJustLoaded;
331 std::string m_sCredit;
333 std::string chartName;
335 DisplayBPM displayBPMType;
337 float specifiedBPMMin;
341 float specifiedBPMMax;
342
343 bool hasGoal = false;
344 bool isFavorited = false;
345 bool isPermamirror = false;
346
347 bool m_bDuplicateDifficulty = false;
348 std::vector<std::string> debugstrings;
349};
350
351#endif
Cached object pointers with automatic invalidation.
Definition RageUtil_CachedObject.h:21
Main driver class for the difficulty calculator as a whole.
Definition MinaCalc.h:82
Holds data about the notes that the player is supposed to hit.
Definition NoteData.h:43
Player data that persists between sessions.
Definition Profile.h:130
Holds all music metadata and steps for one song.
Definition Song.h:65
Holds note information for a Song.
Definition Steps.h:42
auto GetTimingData() const -> const TimingData *
Retrieves the appropriate timing data for the Steps. Falls back on the Song if needed.
Definition Steps.cpp:660
auto GetCredit() const -> const std::string &
Retrieve the author credit used for this edit.
Definition Steps.h:87
Song * m_pSong
The Song these Steps are associated with.
Definition Steps.h:245
auto GetDifficulty() const -> const Difficulty
Retrieve the difficulty used for this edit.
Definition Steps.h:73
auto GetMeter() const -> int
Retrieve the meter used for this edit.
Definition Steps.h:78
auto GetDescription() const -> const std::string &
Retrieve the description used for this edit.
Definition Steps.h:63
auto GetLengthSeconds(float rate=1) const -> float
Returns length of step in seconds. If a rate is supplied, the returned length is scaled by it.
Definition Steps.h:263
auto GetNoteDataFromSimfile() -> bool
Retrieve the NoteData from the original source.
Definition Steps.cpp:120
auto HasSignificantTimingChanges() const -> bool
Determine if the Steps have any major timing changes during gameplay.
Definition Steps.cpp:666
~Steps()
Destroy the Steps that are no longer needed.
std::string m_StepsTypeStr
The std::string form of the StepsType, for dealing with unrecognized styles.
Definition Steps.h:243
TimingData m_Timing
The TimingData used by the Steps.
Definition Steps.h:164
auto IsNoteDataEmpty() const -> bool
Determine if we are missing any note data.
Definition Steps.cpp:114
auto GetChartStyle() const -> const std::string &
Retrieve the ChartStyle used for this chart.
Definition Steps.h:68
Holds data for translating beats<->seconds.
Definition TimingData.h:54
The list of BPMs to display.
Definition GameConstantsAndTypes.h:402
Definition NoteDataStructures.h:7
Cached song statistics.
Definition RadarValues.h:14