Etterna 0.75.1
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 static auto GetNPSVectorForType(const NoteData& nd,
122 const std::vector<float>& etaner,
123 const std::vector<int>& nerv,
124 float rate,
125 const TapNoteType tnt) -> std::vector<int>;
126
127 auto GetNPSPerMeasure(const NoteData& nd,
128 const std::vector<float>& etaner,
129 const std::vector<int>& nerv,
130 float rate) -> std::vector<float>;
131
132 // takes size of chord and counts how many -NOTES- are in
133 // chords of that exact size (this functionally means
134 // multiplying chord counter by chord size) in a row -mina
135 // (jumps won't count as hands, etc)
136 static auto GetCNPSVector(const NoteData& nd,
137 const std::vector<int>& nerv,
138 const std::vector<float>& etaner,
139 int chordsize,
140 float rate) -> std::vector<int>;
141
142 auto GetHash() const -> unsigned;
143 void GetNoteData(NoteData& noteDataOut) const;
144 auto GetNoteData() const -> NoteData;
145 void SetNoteData(const NoteData& noteDataNew) const;
146 void SetSMNoteData(const std::string& notes_comp);
147 void GetSMNoteData(std::string& notes_comp_out) const;
148
152 auto GetNoteDataFromSimfile() -> bool;
153
159 auto IsNoteDataEmpty() const -> bool;
160
161 void GetETTNoteData(std::string& notes_comp_out) const;
162 void TidyUpData();
163 void CalculateRadarValues();
164
170
174 auto GetTimingData() const -> const TimingData*;
175 auto GetTimingData() -> TimingData*
176 {
177 return const_cast<TimingData*>(
178 static_cast<const Steps*>(this)->GetTimingData());
179 };
180
181 /* Now for half the reason I'm bothering to do this... generate a chart key
182 using note data and timingdata in conjuction. Do it during load and save it
183 in the steps data so that we have to do it as few times as possible.*/
184 auto GetChartKey() const -> const std::string& { return ChartKey; }
185 std::vector<float> dummy = { 0.F, 0.F, 0.F, 0.F, 0.F, 0.F, 0.F, 0.F };
186 std::vector<std::vector<float>> diffByRate = {
187 dummy, dummy, dummy, dummy, dummy, dummy, dummy,
188 dummy, dummy, dummy, dummy, dummy, dummy, dummy,
189 dummy, dummy, dummy, dummy, dummy, dummy, dummy
190 };
191 void SetChartKey(const std::string& k) { ChartKey = k; }
192 void SetAllMSD(const std::vector<std::vector<float>>& msd)
193 {
194 diffByRate = msd;
195 }
196 auto GetAllMSD() const -> std::vector<std::vector<float>>
197 {
198 return diffByRate;
199 }
200 auto SortSkillsetsAtRate(float x, bool includeoverall)
201 -> std::vector<std::pair<Skillset, float>>;
202
203 void CalcEtternaMetadata(Calc* calc = nullptr);
204 auto DoATestThing(float ev, Skillset ss, float rate, Calc* calc) -> float;
205 void GetCalcDebugOutput(); // now spits out everything with 1 calc call
206 std::vector<std::vector<std::vector<std::vector<float>>>>
207 calcdebugoutput; // probably should clear this periodically
208 void UnloadCalcDebugOutput();
209
210 float firstsecond = 0.F;
211 float lastsecond = 0.F;
212
213 // this is bugged and returns true for files with negative bpms when it
214 // shouldn't - mina
215 auto IsRecalcValid() -> bool;
216
217 auto GetMSD(float rate, int ss) const -> float
218 {
219 return GetMSD(rate, static_cast<Skillset>(ss));
220 }
221 auto GetMSD(float rate, Skillset ss) const -> float;
222
223 /* This is a reimplementation of the lua version of the script to generate
224 chart keys, except this time using the notedata stored in game memory
225 immediately after reading it than parsing it using lua. - Mina */
226 static auto GenerateChartKey(NoteData& nd, TimingData* td) -> std::string;
227
232 auto HasSignificantTimingChanges() const -> bool;
233
234 auto IsPlayableForCurrentGame() const -> bool;
235
236 auto GetMusicPath() const
237 -> const std::string; // Returns the path for loading.
238 auto GetMusicFile() const
239 -> const std::string&; // Returns the filename for the simfile.
240 void SetMusicFile(const std::string& file);
241 auto GetPreviewMusicPath() const -> const std::string;
242
243 // Lua
244 void PushSelf(lua_State* L);
245
246 StepsType m_StepsType;
249 std::string m_StepsTypeStr;
252
253 std::vector<NoteInfo> serializenotedatacache;
254
255 CachedObject<Steps> m_CachedObject;
256
257 void SetDisplayBPM(const DisplayBPM type) { this->displayBPMType = type; }
258 auto GetDisplayBPM() const -> DisplayBPM { return this->displayBPMType; }
259 void SetMinBPM(const float f) { this->specifiedBPMMin = f; }
260 auto GetMinBPM() const -> float { return this->specifiedBPMMin; }
261 void SetMaxBPM(const float f) { this->specifiedBPMMax = f; }
262 void SetFirstSecond(const float f) { this->firstsecond = f; }
263 void SetLastSecond(const float f) { this->lastsecond = f; }
264 auto GetMaxBPM() const -> float { return this->specifiedBPMMax; }
265 void GetDisplayBpms(DisplayBpms& addTo,
266 bool bIgnoreCurrentRate = false) const;
269 auto GetLengthSeconds(float rate = 1) const -> float
270 {
271 return (lastsecond - firstsecond) / rate;
272 }
273
274 auto Getdebugstrings() -> const std::vector<std::string>&
275 {
276 return debugstrings;
277 }
278 auto IsSkillsetHighestOfChart(Skillset skill, float rate) -> bool;
279
280 auto IsFavorited() const -> bool { return isFavorited; }
281 auto SetFavorited(bool b) -> void { isFavorited = b; }
282 auto HasGoal() const -> bool { return hasGoal; }
283 auto SetHasGoal(bool b) -> void { hasGoal = b; }
284 auto IsPermaMirror() const -> bool { return isPermamirror; }
285 auto SetPermaMirror(bool b) -> void { isPermamirror = b; }
286
287 private:
288 std::string ChartKey = "";
289 struct UniquePtrNoteData {
290 std::unique_ptr<NoteData> p;
291 UniquePtrNoteData(): p(std::make_unique<NoteData>()) { }
292 UniquePtrNoteData(UniquePtrNoteData& rhs) {
293 p = rhs.p ? std::make_unique<NoteData>(*rhs.p) : nullptr;
294 }
295 UniquePtrNoteData &operator=(const UniquePtrNoteData& rhs) {
296 p = rhs.p ? std::make_unique<NoteData>(*rhs.p) : nullptr;
297 return *this;
298 }
299 NoteData *operator->() { return &*p; }
300 NoteData &operator*() { return *p; }
301 };
302 /* We can have one or both of these; if we have both, they're always
303 * identical. Call Compress() to force us to only have
304 * m_sNoteDataCompressed; otherwise, creation of these is transparent. */
305 mutable UniquePtrNoteData m_pNoteData;
306 mutable bool m_bNoteDataIsFilled;
307 mutable std::string m_sNoteDataCompressed;
308
310 std::string m_sFilename;
312 bool m_bSavedToDisk;
314 std::string m_MusicFile;
317 ProfileSlot m_LoadedFromProfile;
318
319 /* These values are pulled from the autogen source first, if there is one.
320 */
322 mutable unsigned m_iHash;
325 std::string m_sDescription;
327 std::string m_sChartStyle;
329 Difficulty m_Difficulty;
332 int m_iMeter;
334 RadarValues m_CachedRadarValues;
335 bool m_bAreCachedRadarValuesJustLoaded;
337 std::string m_sCredit;
339 std::string chartName;
341 DisplayBPM displayBPMType;
343 float specifiedBPMMin;
347 float specifiedBPMMax;
348
349 bool hasGoal = false;
350 bool isFavorited = false;
351 bool isPermamirror = false;
352
353 bool m_bDuplicateDifficulty = false;
354 std::vector<std::string> debugstrings;
355};
356
357#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:251
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:269
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:249
TimingData m_Timing
The TimingData used by the Steps.
Definition Steps.h:169
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:404
Definition NoteDataStructures.h:7
Cached song statistics.
Definition RadarValues.h:14