Etterna 0.74.4
Loading...
Searching...
No Matches
SongManager.h
1#ifndef SONGMANAGER_H
2#define SONGMANAGER_H
3
4#include "Etterna/Models/Misc/Difficulty.h"
5#include "Etterna/Models/Misc/GameConstantsAndTypes.h"
6#include "Etterna/Models/Misc/ImageCache.h"
7#include "RageUtil/Misc/RageTypes.h"
8#include "RageUtil/Utils/RageUtil.h"
9#include "Etterna/Models/Misc/ThemeMetric.h"
10
11#include <unordered_map>
12
13class LoadingWindow;
14class Song;
15class Style;
16class Steps;
17class PlayerOptions;
18class Calc;
19struct lua_State;
20struct GoalsForChart;
21
22auto
23SONG_GROUP_COLOR_NAME(size_t i) -> std::string;
24auto
25CompareNotesPointersForExtra(const Steps* n1, const Steps* n2) -> bool;
26
29{
30 public:
33
34 void InitSongsFromDisk(LoadingWindow* ld);
35 void CalcTestStuff();
36 void FreeSongs();
37 void Cleanup();
38
39 void UnlistSong(Song* song);
40
41
42 void Invalidate(const Song* pStaleSong);
43 static auto GetPlaylists() -> std::map<std::string, Playlist>&;
44 static void SaveEnabledSongsToPref();
45 static void LoadEnabledSongsFromPref();
46
47 void InitAll(LoadingWindow* ld); // songs, groups - everything.
48 auto DifferentialReload() -> int;
49 auto DifferentialReloadDir(std::string dir) -> int;
50
51 auto IsGroupNeverCached(const std::string& group) const -> bool;
52 void SetFavoritedStatus(std::set<std::string>& favs);
53 void SetPermaMirroredStatus(std::set<std::string>& pmir);
54 void SetHasGoal(std::unordered_map<std::string, GoalsForChart>& goalmap);
55
56 auto GetSongGroupBannerPath(const std::string& sSongGroup) const
57 -> std::string;
58 auto GetSongGroupBannerPaths() const -> std::vector<std::string>
59 {
60 return m_sSongGroupBannerPaths;
61 }
62 // std::string GetSongGroupBackgroundPath( std::string sSongGroup ) const;
63 void GetSongGroupNames(std::vector<std::string>& AddTo) const;
64 auto GetSongGroupNames() const -> const std::vector<std::string>&;
65 auto DoesSongGroupExist(const std::string& sSongGroup) const -> bool;
66 auto GetSongGroupColor(const std::string& sSongGroupName,
67 std::map<std::string, Playlist>& playlists =
68 GetPlaylists()) const -> RageColor;
69 auto GetSongColor(const Song* pSong) const -> RageColor;
70
71 // temporary solution to reorganizing the entire songid/stepsid system -
72 // mina
73 auto GetStepsByChartkey(const std::string& ck) -> Steps*;
74 auto GetSongByChartkey(const std::string& ck) -> Song*;
75 void UnloadAllCalcDebugOutput();
76 auto IsChartLoaded(const std::string& ck) const -> bool
77 {
78 return SongsByKey.count(ck) == 1 &&
79 StepsByKey.count(ck) ==
80 1; // shouldn't be necessary but apparently it is -mina
81 }
82
83 void ResetGroupColors();
84
85 static auto ShortenGroupName(const std::string& sLongGroupName)
86 -> std::string;
87
88 // Lookup
93 auto GetSongs(const std::string& sGroupName) const
94 -> const std::vector<Song*>&;
95 void ForceReloadSongGroup(const std::string& sGroupName) const;
96 void GenerateCachefilesForGroup(const std::string& sGroupName) const;
100 auto GetAllSongs() const -> const std::vector<Song*>&
101 {
102 return GetSongs(GROUP_ALL);
103 }
110 auto GetPopularSongs() const -> const std::vector<Song*>&
111 {
112 return m_pPopularSongs;
113 }
114
115 void GetFavoriteSongs(std::vector<Song*>& songs) const;
119 auto GetNumSongs() const -> int;
120 auto GetNumAdditionalSongs() const -> int;
121 auto GetNumSongGroups() const -> int;
122 // sm-ssc addition:
123 auto GetSongGroupByIndex(const unsigned index) -> std::string
124 {
125 return m_sSongGroupNames[index];
126 }
127
128 static void DeleteSteps(Steps* pSteps); // transfers ownership of pSteps
129 static auto WasLoadedFromAdditionalSongs(const Song* pSong) -> bool;
130
131 auto GetSongFromDir(std::string sDir) const -> Song*;
132
133 void SortSongs(); // sort m_pSongs by CompareSongPointersByTitle
134
135 // Lua
136 void PushSelf(lua_State* L);
137
138 std::string activeplaylist = "";
139 std::string playlistcourse = "";
140 void ReconcileChartKeysForReloadedSong(
141 Song* reloadedSong,
142 const std::vector<std::string>& oldChartkeys);
143 void MakeSongGroupsFromPlaylists(
144 std::map<std::string, Playlist>& playlists = GetPlaylists());
145 void DeletePlaylist(
146 const std::string& pl,
147 std::map<std::string, Playlist>& playlists = GetPlaylists());
148 static void MakePlaylistFromFavorites(
149 std::set<std::string>& favs,
150 std::map<std::string, Playlist>& playlists = GetPlaylists());
151
152 std::map<std::string, std::vector<Song*>> groupderps;
153 std::vector<std::string> playlistGroups; // To delete from groupderps when
154 // rebuilding
155 // playlist groups
156
157 static void FinalizeSong(Song* pNewSong, const std::string& dir);
158 bool OpenSongFolder(const Song* pSong);
159
160 // calc test stuff
161 auto SaveCalcTestCreateNode() const -> XNode*;
162 static void LoadCalcTestNode();
163 void SaveCalcTestXmlToDir() const;
164 std::map<Skillset, CalcTestList> testChartList;
165 std::unique_ptr<Calc> calc;
166
167 // Indexed by chartkeys
168 void AddKeyedPointers(Song* new_song);
169 std::unordered_map<std::string, Song*> SongsByKey;
170 std::unordered_map<std::string, Steps*> StepsByKey;
171
173 // External static util
174 static bool InstallSmzip(const std::string& zipFile);
175
176 protected:
177 void LoadStepManiaSongDir(std::string sDir, LoadingWindow* ld);
178 static auto IsSongDir(const std::string& sDir) -> bool;
179 auto AddGroup(const std::string& sDir, const std::string& sGroupDirName)
180 -> bool;
181
182 void AddSongToList(Song* new_song);
184 std::vector<Song*> m_pSongs;
185 std::map<std::string, Song*> m_SongsByDir;
186
187 std::vector<std::pair<std::pair<std::string, unsigned int>, Song*>*> cache;
188
189 std::set<std::string> m_GroupsToNeverCache;
192 std::vector<Song*> m_pDeletedSongs;
193
194 std::vector<Song*> m_pPopularSongs;
195
196 std::vector<std::string> m_sSongGroupNames;
197 std::vector<std::string>
198 m_sSongGroupBannerPaths; // each song group may have a
199 // banner associated with it
200 // std::vector<std::string> m_sSongGroupBackgroundPaths; // each song group
201 // may have a background associated with it (very rarely)
202
203 struct Comp
204 {
205 auto operator()(const std::string& s, const std::string& t) const
206 -> bool
207 {
208 return CompareStringsAsc(s, t);
209 }
210 };
211 using SongPointerVector = std::vector<Song*>;
212 std::map<std::string, SongPointerVector, Comp> m_mapSongGroupIndex;
213
214 ThemeMetric<int> NUM_SONG_GROUP_COLORS;
215 ThemeMetric1D<RageColor> SONG_GROUP_COLOR;
216};
217
218extern SongManager*
219 SONGMAN; // global and accessible from anywhere in our program
220
221#endif
Main driver class for the difficulty calculator as a whole.
Definition MinaCalc.h:82
Opens and displays the loading banner.
Definition LoadingWindow.h:9
Per-player options that are not saved between sessions.
Definition PlayerOptions.h:48
The holder for the Songs and its Steps.
Definition SongManager.h:29
auto GetSongs(const std::string &sGroupName) const -> const std::vector< Song * > &
Retrieve all of the songs that belong to a particular group.
Definition SongManager.cpp:1292
auto GetNumSongs() const -> int
Retrieve the number of songs in the game.
Definition SongManager.cpp:1499
std::vector< Song * > m_pSongs
All of the songs that can be played.
Definition SongManager.h:184
auto GetPopularSongs() const -> const std::vector< Song * > &
Retrieve all of the popular songs.
Definition SongManager.h:110
auto GetAllSongs() const -> const std::vector< Song * > &
Retrieve all of the songs in the game.
Definition SongManager.h:100
std::vector< Song * > m_pDeletedSongs
The most popular songs ranked by number of plays.
Definition SongManager.h:192
Holds all music metadata and steps for one song.
Definition Song.h:65
Holds note information for a Song.
Definition Steps.h:42
Definition Style.h:22
Definition ThemeMetric.h:192
The theme specific data.
Definition ThemeMetric.h:52
Definition XmlFile.h:95
Definition Difficulty.h:95
Definition Profile.h:115
Definition RageTypes.h:332
Definition SongManager.h:204