Etterna 0.74.4
Loading...
Searching...
No Matches
SongUtil.h
1
3#ifndef SONG_UTIL_H
4#define SONG_UTIL_H
5
6#include "Etterna/Models/Misc/Difficulty.h"
7#include "Etterna/Models/Misc/GameConstantsAndTypes.h"
8#include "RageUtil/Utils/RageUtil_CachedObject.h"
9#include <utility>
10
11using std::vector;
12
13class Song;
14class Steps;
15class Profile;
16class XNode;
17
18void
19AppendOctal(int n, int digits, std::string& out);
20
22namespace SongUtil {
23void
24GetSteps(const Song* pSong,
25 std::vector<Steps*>& arrayAddTo,
26 StepsType st = StepsType_Invalid,
27 Difficulty dc = Difficulty_Invalid,
28 int iMeterLow = -1,
29 int iMeterHigh = -1,
30 bool filteringSteps = false,
31 const std::string& sDescription = "",
32 const std::string& sCredit = "",
33 bool bIncludeAutoGen = true,
34 unsigned uHash = 0,
35 int iMaxToGet = -1);
36auto
37GetOneSteps(const Song* pSong,
38 StepsType st = StepsType_Invalid,
39 Difficulty dc = Difficulty_Invalid,
40 int iMeterLow = -1,
41 int iMeterHigh = -1,
42 bool filteringSteps = false,
43 const std::string& sDescription = "",
44 const std::string& sCredit = "",
45 unsigned uHash = 0,
46 bool bIncludeAutoGen = true) -> Steps*;
47auto
48GetStepsByDifficulty(const Song* pSong,
49 StepsType st,
50 Difficulty dc,
51 bool bIncludeAutoGen = true) -> Steps*;
52auto
53GetStepsByMeter(const Song* pSong, StepsType st, int iMeterLow, int iMeterHigh)
54 -> Steps*;
55auto
56GetStepsByDescription(const Song* pSong,
57 StepsType st,
58 const std::string& sDescription) -> Steps*;
59auto
60GetStepsByCredit(const Song* pSong, StepsType st, const std::string& sCredit)
61 -> Steps*;
62auto
63GetClosestNotes(const Song* pSong,
64 StepsType st,
65 Difficulty dc,
66 bool bIgnoreLocked = false) -> Steps*;
67
68void
69AdjustDuplicateSteps(Song* pSong); // part of TidyUpData
70void
71DeleteDuplicateSteps(Song* pSong, std::vector<Steps*>& vSteps);
72
73void
74MakeSortString(std::string& s);
75auto
76MakeSortString(const std::string& in) -> std::string;
77void
78SortSongPointerArrayByTitle(std::vector<Song*>& vpSongsInOut);
79void
80SortSongPointerArrayByBPM(std::vector<Song*>& vpSongsInOut);
81void
82SortSongPointerArrayByWifeScore(std::vector<Song*>& v);
83void
84SortSongPointerArrayByArtist(std::vector<Song*>& vpSongsInOut);
85void
86SortSongPointerArrayByDisplayArtist(std::vector<Song*>& vpSongsInOut);
87void
88SortSongPointerArrayByGenre(std::vector<Song*>& vpSongsInOut);
89void
90SortSongPointerArrayByGroupAndTitle(std::vector<Song*>& vpSongsInOut);
91void
92SortSongPointerArrayByGroupAndMSD(std::vector<Song*>& vpSongsInOut, Skillset ss);
93void
94SortSongPointerArrayByNumPlays(std::vector<Song*>& vpSongsInOut,
95 ProfileSlot slot,
96 bool bDescending);
97void
98SortSongPointerArrayByNumPlays(std::vector<Song*>& vpSongsInOut,
99 const Profile* pProfile,
100 bool bDescending);
101void
102SortSongPointerArrayByStepsTypeAndMeter(std::vector<Song*>& vpSongsInOut,
103 StepsType st,
104 Difficulty dc);
105auto
106GetSectionNameFromSongAndSort(const Song* pSong, SortOrder so) -> std::string;
107void
108SortSongPointerArrayBySectionName(std::vector<Song*>& vpSongsInOut, SortOrder so);
109void
110SortSongPointerArrayByLength(std::vector<Song*>& vpSongsInOut);
111void
112SortSongPointerArrayByDateAdded(std::vector<Song*>& vpSongsInOut);
113void
114SortSongPointerArrayByAuthor(std::vector<Song*>& vpSongsInOut);
115
116auto
117CompareSongPointersByGroup(const Song* pSong1, const Song* pSong2) -> int;
118
127auto
128IsEditDescriptionUnique(const Song* pSong,
129 StepsType st,
130 const std::string& sPreferredDescription,
131 const Steps* pExclude) -> bool;
132auto
133IsChartNameUnique(const Song* pSong,
134 StepsType st,
135 const std::string& name,
136 const Steps* pExclude) -> bool;
137auto
138MakeUniqueEditDescription(const Song* pSong,
139 StepsType st,
140 const std::string& sPreferredDescription)
141 -> std::string;
142auto
143ValidateCurrentEditStepsDescription(const std::string& sAnswer,
144 std::string& sErrorOut) -> bool;
145auto
146ValidateCurrentStepsDescription(const std::string& sAnswer,
147 std::string& sErrorOut) -> bool;
148auto
149ValidateCurrentStepsCredit(const std::string& sAnswer, std::string& sErrorOut)
150 -> bool;
151auto
152ValidateCurrentStepsChartName(const std::string& answer, std::string& error)
153 -> bool;
154auto
155ValidateCurrentSongPreview(const std::string& answer, std::string& error)
156 -> bool;
157auto
158ValidateCurrentStepsMusic(const std::string& answer, std::string& error)
159 -> bool;
160
161void
162GetAllSongGenres(std::vector<std::string>& vsOut);
163void
164GetPlayableStepsTypes(const Song* pSong, std::set<StepsType>& vOut);
165void
166GetPlayableSteps(const Song* pSong, std::vector<Steps*>& vOut, bool filteringSteps = false);
167auto
168IsStepsTypePlayable(Song* pSong, StepsType st) -> bool;
169auto
170IsStepsPlayable(Song* pSong, Steps* pSteps) -> bool;
171
176auto
177IsSongPlayable(Song* s) -> bool;
178
179auto
180GetStepsTypeAndDifficultyFromSortOrder(SortOrder so,
181 StepsType& st,
182 Difficulty& dc) -> bool;
183} // namespace SongUtil
184
186{
187 std::string sDir;
188 mutable CachedObjectPointer<Song> m_Cache;
189
190 public:
196 : sDir("")
197 {
198 m_Cache.Unset();
199 }
200 void Unset() { FromSong(nullptr); }
201 void FromSong(const Song* p);
202 auto ToSong() const -> Song*;
203 auto operator<(const SongID& other) const -> bool
204 {
205 return sDir < other.sDir;
206 }
207 auto operator==(const SongID& other) const -> bool
208 {
209 return sDir == other.sDir;
210 }
211
212 auto CreateNode() const -> XNode*;
213 void LoadFromNode(const XNode* pNode);
214 void LoadFromString(const char* dir);
215 void FromString(std::string _sDir) { sDir = std::move(_sDir); }
216 auto ToString() const -> std::string;
217 auto IsValid() const -> bool;
218};
219
220#endif
Definition RageUtil_CachedObject.h:117
Player data that persists between sessions.
Definition Profile.h:130
Definition SongUtil.h:186
SongID()
Set up the SongID with default values.
Definition SongUtil.h:195
Holds all music metadata and steps for one song.
Definition Song.h:65
Holds note information for a Song.
Definition Steps.h:42
Definition XmlFile.h:95
A set of song utilities to make working with songs easier.
Definition SongUtil.h:22
auto IsSongPlayable(Song *s) -> bool
Determine if the song has any playable steps in the present game.
Definition SongUtil.cpp:1166
auto IsEditDescriptionUnique(const Song *pSong, StepsType st, const std::string &sPreferredDescription, const Steps *pExclude) -> bool
Determine if the requested description for an edit is unique.
Definition SongUtil.cpp:890