-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathActivePlaylist.cpp
More file actions
203 lines (139 loc) · 4.94 KB
/
ActivePlaylist.cpp
File metadata and controls
203 lines (139 loc) · 4.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#include "ActivePlaylist.h"
ActivePlaylist::ActivePlaylist (const char *name, MusicType musicType, SpecialMusicType specialMusicType) : name (name), musicType (musicType), specialMusicType (specialMusicType) {}
void ActivePlaylist::initialize (int i, Playlist *vanillaPlaylist) {
vanillaPlaylists[i] = defaultPlaylist = playlist = vanillaPlaylist;
}
bool ActivePlaylist::restorePlaylist () {
if (playlist != defaultPlaylist) {
playlist = defaultPlaylist;
return true;
}
return false;
}
ActivePlaylist apl_Explore ("Explore", MusicType::mtExplore, SpecialMusicType::spNotKnown);
ActivePlaylist apl_Public ("Public", MusicType::mtPublic, SpecialMusicType::spNotKnown);
ActivePlaylist apl_Dungeon ("Dungeon", MusicType::mtDungeon, SpecialMusicType::spNotKnown);
ActivePlaylist apl_Custom ("Custom", MusicType::mtCustom, SpecialMusicType::spNotKnown);
ActivePlaylist apl_Battle ("Battle", MusicType::mtBattle, SpecialMusicType::spNotKnown);
ActivePlaylist apl_Death ("Death", MusicType::mtSpecial, SpecialMusicType::spDeath);
ActivePlaylist apl_Success ("Success", MusicType::mtSpecial, SpecialMusicType::spSuccess);
ActivePlaylist apl_Title ("Title", MusicType::mtSpecial, SpecialMusicType::spTitle);
ActivePlaylist apl_NULL ("<Invalid>", MusicType::mtNotKnown, SpecialMusicType::spNotKnown);
ActivePlaylist *activePlaylists[8] = {
&apl_Explore,
&apl_Public,
&apl_Dungeon,
&apl_Custom,
&apl_Battle,
&apl_Death,
&apl_Success,
&apl_Title
};
ActivePlaylist* selectedActivePlaylist = &apl_NULL;
void ActivePlaylist::operator= (Playlist *playlist) {
ActivePlaylist::playlist = playlist;
}
void ActivePlaylist::operator= (const ActivePlaylist &apl) {
ActivePlaylist::playlist = apl.playlist;
}
void ActivePlaylist::operator= (const ActivePlaylist *apl) {
ActivePlaylist::playlist = apl->playlist;
}
void ActivePlaylist::operator+= (const string &path) {
playlist->addPath (path);
}
bool operator== (const ActivePlaylist &apl1, const ActivePlaylist &apl2) {
return apl1.playlist == apl2.playlist;
}
bool operator== (const ActivePlaylist &apl, const Playlist *playlist) {
return apl.playlist == playlist;
}
bool operator== (const Playlist *playlist, const ActivePlaylist &apl) {
return apl.playlist == playlist;
}
bool operator== (const ActivePlaylist &apl, const Playlist &playlist) {
return *apl.playlist == playlist;
}
bool operator== (const Playlist& playlist, const ActivePlaylist& apl) {
return *apl.playlist == playlist;
}
bool operator!= (const ActivePlaylist &apl1, const ActivePlaylist &apl2) {
return apl1.playlist != apl2.playlist;
}
bool operator!= (const ActivePlaylist &apl, const Playlist *playlist) {
return apl.playlist != playlist;
}
bool operator!= (const Playlist *playlist, const ActivePlaylist &apl) {
return apl.playlist != playlist;
}
bool operator!= (const ActivePlaylist &apl, const Playlist &playlist) {
return *apl.playlist != playlist;
}
bool operator!= (const Playlist& playlist, const ActivePlaylist& apl) {
return *apl.playlist != playlist;
}
bool isPlaylistActive (const char *playlistName) {
if (playlistName[0] != '\0') { //Not empty
for (ActivePlaylist* apl : activePlaylists) {
if (strcmp (playlistName, apl->playlist->name) != 0) {
return true;
}
}
}
return false;
}
inline bool isPlaylistActive (string &playlistName) {
return isPlaylistActive (playlistName.c_str ());
}
bool isPlaylistActive (Playlist *playlist) {
for (ActivePlaylist* apl : activePlaylists) {
if (playlist == apl->playlist) {
return true;
}
}
return false;
}
ActivePlaylist* getActivePlaylist (const char *playlistName) {
if (playlistName[0] != '\0') { //Not empty
for (ActivePlaylist* apl : activePlaylists) {
if (strcmp (playlistName, apl->playlist->name) != 0) {
return apl;
}
}
}
return nullptr;
}
inline ActivePlaylist* getActivePlaylist (string& playlistName) {
return getActivePlaylist(playlistName.c_str ());
}
ActivePlaylist* getActivePlaylist (Playlist *playlist) {
for (ActivePlaylist* apl : activePlaylists) {
if (playlist == apl->playlist) {
return apl;
}
}
return nullptr;
}
ActivePlaylist* getActivePlaylist (MusicType musicType) {
switch (musicType) {
case MusicType::mtExplore: return &apl_Explore;
case MusicType::mtPublic: return &apl_Public;
case MusicType::mtDungeon: return &apl_Dungeon;
case MusicType::mtCustom: return &apl_Custom;
case MusicType::mtBattle: return &apl_Battle;
default: return &apl_NULL;
}
}
ActivePlaylist* getActivePlaylist (SpecialMusicType specialMusicType) {
switch (specialMusicType) {
case SpecialMusicType::spDeath: return &apl_Death;
case SpecialMusicType::spSuccess: return &apl_Success;
case SpecialMusicType::spTitle: return &apl_Title;
default: return &apl_NULL;
}
}
bool samePlaylist (MusicType musicType1, MusicType musicType2) {
ActivePlaylist* apl1 = getActivePlaylist (musicType1);
ActivePlaylist* apl2 = getActivePlaylist (musicType2);
return apl1 != &apl_NULL && apl2 != &apl_NULL && apl1->playlist == apl2->playlist;
}