Refactored sorting and filtering
This commit is contained in:
1 parent
22d6eb7487
commit
ce9e426bae
3 files changed
+289
-588
No files matched your search
@@ -28,3 +28,7 @@ Output/Songs
|
|||||||
/Vocaluxe/Vocaluxe.csproj.user
|
/Vocaluxe/Vocaluxe.csproj.user
|
||||||
|
|
||||||
/Output/Config.xml
|
/Output/Config.xml
|
||||||
|
|
||||||
|
*.ipch
|
||||||
|
|
||||||
|
*.log
|
||||||
+278
-586
@@ -36,6 +36,7 @@ namespace Vocaluxe.Base
|
|||||||
static class CSongs
|
static class CSongs
|
||||||
{
|
{
|
||||||
private static List<CSong> _Songs = new List<CSong>();
|
private static List<CSong> _Songs = new List<CSong>();
|
||||||
|
private static List<CSong> _FilteredSongs = new List<CSong>();
|
||||||
private static SongPointer[] _SongsSortList = new SongPointer[0];
|
private static SongPointer[] _SongsSortList = new SongPointer[0];
|
||||||
private static List<CSong> _SongsForRandom = new List<CSong>();
|
private static List<CSong> _SongsForRandom = new List<CSong>();
|
||||||
|
|
||||||
@@ -44,6 +45,7 @@ namespace Vocaluxe.Base
|
|||||||
private static bool _CoverLoaded = false;
|
private static bool _CoverLoaded = false;
|
||||||
private static int _CoverLoadIndex = -1;
|
private static int _CoverLoadIndex = -1;
|
||||||
private static int _CatIndex = -1;
|
private static int _CatIndex = -1;
|
||||||
|
private static bool _Init = false;
|
||||||
private static List<CCategory> _Categories = new List<CCategory>();
|
private static List<CCategory> _Categories = new List<CCategory>();
|
||||||
private static List<CCategory> _CategoriesForRandom = new List<CCategory>();
|
private static List<CCategory> _CategoriesForRandom = new List<CCategory>();
|
||||||
|
|
||||||
@@ -379,6 +381,274 @@ namespace Vocaluxe.Base
|
|||||||
get { return _Categories.ToArray(); }
|
get { return _Categories.ToArray(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void FilterSongs(String SearchFilter, bool ShowDuetSongs)
|
||||||
|
{
|
||||||
|
if (_Init && _SearchFilter == SearchFilter && _ShowDuetSongs == ShowDuetSongs)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_Init = true;
|
||||||
|
_SearchFilter = SearchFilter;
|
||||||
|
_ShowDuetSongs = ShowDuetSongs;
|
||||||
|
_FilteredSongs.Clear();
|
||||||
|
|
||||||
|
string[] searchStrings = null;
|
||||||
|
if (_SearchFilter != String.Empty)
|
||||||
|
searchStrings = _SearchFilter.ToUpper().Split(new char[] { ' ' });
|
||||||
|
|
||||||
|
foreach (CSong song in _Songs)
|
||||||
|
{
|
||||||
|
if (!song.IsDuet || _ShowDuetSongs)
|
||||||
|
{
|
||||||
|
if (_SearchFilter == String.Empty)
|
||||||
|
_FilteredSongs.Add(song);
|
||||||
|
else if (searchStrings != null)
|
||||||
|
{
|
||||||
|
string search = song.Title.ToUpper() + " " + song.Artist.ToUpper() + " " + song.FolderName.ToUpper() + " " + song.FileName.ToUpper();
|
||||||
|
|
||||||
|
bool contains = true;
|
||||||
|
|
||||||
|
foreach (string str in searchStrings)
|
||||||
|
{
|
||||||
|
contains &= search.Contains(str);
|
||||||
|
}
|
||||||
|
if (contains)
|
||||||
|
_FilteredSongs.Add(song);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SortSongs()
|
||||||
|
{
|
||||||
|
List<SongPointer> SortList = new List<SongPointer>();
|
||||||
|
switch (_SongSorting)
|
||||||
|
{
|
||||||
|
case ESongSorting.TR_CONFIG_EDITION:
|
||||||
|
foreach (CSong song in _FilteredSongs)
|
||||||
|
{
|
||||||
|
if (song.Edition.Count == 0)
|
||||||
|
SortList.Add(new SongPointer(song.ID, ""));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (String edition in song.Edition)
|
||||||
|
{
|
||||||
|
SortList.Add(new SongPointer(song.ID, edition));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ESongSorting.TR_CONFIG_GENRE:
|
||||||
|
foreach (CSong song in _FilteredSongs)
|
||||||
|
{
|
||||||
|
if (song.Genre.Count == 0)
|
||||||
|
SortList.Add(new SongPointer(song.ID, ""));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (String genre in song.Genre)
|
||||||
|
{
|
||||||
|
SortList.Add(new SongPointer(song.ID, genre));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ESongSorting.TR_CONFIG_FOLDER:
|
||||||
|
foreach (CSong song in _FilteredSongs)
|
||||||
|
{
|
||||||
|
SortList.Add(new SongPointer(song.ID, song.FolderName));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ESongSorting.TR_CONFIG_ARTIST:
|
||||||
|
foreach (CSong song in _FilteredSongs)
|
||||||
|
{
|
||||||
|
SortList.Add(new SongPointer(song.ID, song.Artist));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ESongSorting.TR_CONFIG_ARTIST_LETTER:
|
||||||
|
foreach (CSong song in _FilteredSongs)
|
||||||
|
{
|
||||||
|
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
|
||||||
|
SortList.Add(new SongPointer(song.ID, song.ArtistSorting));
|
||||||
|
else
|
||||||
|
SortList.Add(new SongPointer(song.ID, song.Artist));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ESongSorting.TR_CONFIG_NONE:
|
||||||
|
case ESongSorting.TR_CONFIG_TITLE_LETTER:
|
||||||
|
foreach (CSong song in _FilteredSongs)
|
||||||
|
{
|
||||||
|
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
|
||||||
|
SortList.Add(new SongPointer(song.ID, song.TitleSorting));
|
||||||
|
else
|
||||||
|
SortList.Add(new SongPointer(song.ID, song.Title));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ESongSorting.TR_CONFIG_DECADE:
|
||||||
|
foreach (CSong song in _FilteredSongs)
|
||||||
|
{
|
||||||
|
string sortString = song.Year;
|
||||||
|
if (sortString == "0000")
|
||||||
|
sortString = "";
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sortString = sortString.Substring(0, 3);
|
||||||
|
sortString += "0 - " + sortString + "9";
|
||||||
|
}
|
||||||
|
SortList.Add(new SongPointer(song.ID, sortString));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ESongSorting.TR_CONFIG_YEAR:
|
||||||
|
foreach (CSong song in _FilteredSongs)
|
||||||
|
{
|
||||||
|
SortList.Add(new SongPointer(song.ID, song.Year));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ESongSorting.TR_CONFIG_LANGUAGE:
|
||||||
|
foreach (CSong song in _FilteredSongs)
|
||||||
|
{
|
||||||
|
if (song.Language.Count == 0)
|
||||||
|
SortList.Add(new SongPointer(song.ID, ""));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (String language in song.Language)
|
||||||
|
{
|
||||||
|
SortList.Add(new SongPointer(song.ID, language));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
SortList.Sort(delegate(SongPointer s1, SongPointer s2)
|
||||||
|
{
|
||||||
|
int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper());
|
||||||
|
if (res == 0)
|
||||||
|
{
|
||||||
|
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
|
||||||
|
{
|
||||||
|
res = _Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(_Songs[s2.SongID].ArtistSorting.ToUpper());
|
||||||
|
if (res == 0)
|
||||||
|
{
|
||||||
|
return _Songs[s1.SongID].TitleSorting.ToUpper().CompareTo(_Songs[s2.SongID].TitleSorting.ToUpper());
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
res = _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper());
|
||||||
|
if (res == 0)
|
||||||
|
{
|
||||||
|
return _Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper());
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
});
|
||||||
|
_SongsSortList = SortList.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void FillCategories()
|
||||||
|
{
|
||||||
|
string category = "";
|
||||||
|
string NoCategoryName = "";
|
||||||
|
bool done = false;
|
||||||
|
|
||||||
|
switch (_SongSorting)
|
||||||
|
{
|
||||||
|
case ESongSorting.TR_CONFIG_EDITION:
|
||||||
|
NoCategoryName = CLanguage.Translate("TR_SCREENSONG_NOEDITION");
|
||||||
|
break;
|
||||||
|
case ESongSorting.TR_CONFIG_GENRE:
|
||||||
|
NoCategoryName = CLanguage.Translate("TR_SCREENSONG_NOGENRE");
|
||||||
|
break;
|
||||||
|
case ESongSorting.TR_CONFIG_DECADE:
|
||||||
|
case ESongSorting.TR_CONFIG_YEAR:
|
||||||
|
NoCategoryName = CLanguage.Translate("TR_SCREENSONG_NOYEAR");
|
||||||
|
break;
|
||||||
|
case ESongSorting.TR_CONFIG_LANGUAGE:
|
||||||
|
NoCategoryName = CLanguage.Translate("TR_SCREENSONG_NOLANGUAGE");
|
||||||
|
break;
|
||||||
|
case ESongSorting.TR_CONFIG_FOLDER:
|
||||||
|
case ESongSorting.TR_CONFIG_ARTIST:
|
||||||
|
break;
|
||||||
|
case ESongSorting.TR_CONFIG_NONE:
|
||||||
|
for (int i = 0; i < _SongsSortList.Length; i++)
|
||||||
|
{
|
||||||
|
_SongsSortList[i].CatIndex = 0;
|
||||||
|
}
|
||||||
|
category = CLanguage.Translate("TR_SCREENSONG_ALLSONGS");
|
||||||
|
_Categories.Add(new CCategory(category));
|
||||||
|
done = true;
|
||||||
|
break;
|
||||||
|
case ESongSorting.TR_CONFIG_ARTIST_LETTER:
|
||||||
|
case ESongSorting.TR_CONFIG_TITLE_LETTER:
|
||||||
|
int NotLetterCat = -1;
|
||||||
|
for (int i = 0; i < _SongsSortList.Length; i++)
|
||||||
|
{
|
||||||
|
Char firstLetter = Char.ToUpper(_SongsSortList[i].SortString.Normalize(NormalizationForm.FormD)[0]);
|
||||||
|
|
||||||
|
if (!Char.IsLetter(firstLetter))
|
||||||
|
{
|
||||||
|
firstLetter = '#';
|
||||||
|
}
|
||||||
|
if (firstLetter.ToString() != category)
|
||||||
|
{
|
||||||
|
if (firstLetter != '#' || NotLetterCat == -1)
|
||||||
|
{
|
||||||
|
category = firstLetter.ToString();
|
||||||
|
_Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
|
||||||
|
|
||||||
|
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
||||||
|
|
||||||
|
if (firstLetter == '#')
|
||||||
|
NotLetterCat = _SongsSortList[i].CatIndex;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_SongsSortList[i].CatIndex = NotLetterCat;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
||||||
|
}
|
||||||
|
done = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!done)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _SongsSortList.Length; i++)
|
||||||
|
{
|
||||||
|
if (_SongsSortList[i].SortString.Length > 0)
|
||||||
|
{
|
||||||
|
if (_SongsSortList[i].SortString != category)
|
||||||
|
{
|
||||||
|
category = _SongsSortList[i].SortString;
|
||||||
|
_Categories.Add(new CCategory(category));
|
||||||
|
}
|
||||||
|
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (NoCategoryName != category)
|
||||||
|
{
|
||||||
|
category = NoCategoryName;
|
||||||
|
_Categories.Add(new CCategory(category));
|
||||||
|
}
|
||||||
|
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void Sort(ESongSorting Sorting, EOffOn Tabs, EOffOn IgnoreArticles, String SearchString)
|
public static void Sort(ESongSorting Sorting, EOffOn Tabs, EOffOn IgnoreArticles, String SearchString)
|
||||||
{
|
{
|
||||||
_Sort(Sorting, Tabs, IgnoreArticles, SearchString, false, _ShowDuetSongs);
|
_Sort(Sorting, Tabs, IgnoreArticles, SearchString, false, _ShowDuetSongs);
|
||||||
@@ -397,606 +667,28 @@ namespace Vocaluxe.Base
|
|||||||
if (!force && Sorting == _SongSorting && Tabs == _Tabs && IgnoreArticles == _IgnoreArticles && SearchString == _SearchFilter && ShowDuetSongs == _ShowDuetSongs)
|
if (!force && Sorting == _SongSorting && Tabs == _Tabs && IgnoreArticles == _IgnoreArticles && SearchString == _SearchFilter && ShowDuetSongs == _ShowDuetSongs)
|
||||||
return; //nothing to do
|
return; //nothing to do
|
||||||
|
|
||||||
_Categories.Clear();
|
|
||||||
string category = String.Empty;
|
|
||||||
|
|
||||||
_IgnoreArticles = IgnoreArticles;
|
_IgnoreArticles = IgnoreArticles;
|
||||||
_SongSorting = Sorting;
|
_SongSorting = Sorting;
|
||||||
_Tabs = Tabs;
|
_Tabs = Tabs;
|
||||||
_ShowDuetSongs = ShowDuetSongs;
|
|
||||||
|
|
||||||
_SearchFilter = SearchString;
|
|
||||||
|
|
||||||
List<SongPointer> _SortList = new List<SongPointer>();
|
|
||||||
List<CSong> _SongList = new List<CSong>();
|
|
||||||
|
|
||||||
foreach (CSong song in _Songs)
|
|
||||||
{
|
|
||||||
if (!song.IsDuet || _ShowDuetSongs)
|
|
||||||
{
|
|
||||||
if (_SearchFilter == String.Empty)
|
|
||||||
_SongList.Add(song);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string search = song.Title.ToUpper() + " " + song.Artist.ToUpper() + " " + song.FolderName.ToUpper() + " " + song.FileName.ToUpper();
|
|
||||||
string[] searchStrings = _SearchFilter.ToUpper().Split(new char[]{' '});
|
|
||||||
bool contains = searchStrings != null;
|
|
||||||
|
|
||||||
foreach (string str in searchStrings)
|
|
||||||
{
|
|
||||||
contains &= search.Contains(str);
|
|
||||||
}
|
|
||||||
if (contains)
|
|
||||||
_SongList.Add(song);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (_SongSorting)
|
|
||||||
{
|
|
||||||
case ESongSorting.TR_CONFIG_EDITION:
|
|
||||||
foreach (CSong song in _SongList)
|
|
||||||
{
|
|
||||||
if (song.Edition.Count == 0)
|
|
||||||
_SortList.Add(new SongPointer(song.ID, String.Empty));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (int i = 0; i < song.Edition.Count; i++)
|
|
||||||
{
|
|
||||||
_SortList.Add(new SongPointer(song.ID, song.Edition[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_SortList.Sort(delegate(SongPointer s1, SongPointer s2)
|
|
||||||
{
|
|
||||||
int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
|
|
||||||
{
|
|
||||||
res = _Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(_Songs[s2.SongID].ArtistSorting.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
return _Songs[s1.SongID].TitleSorting.ToUpper().CompareTo(_Songs[s2.SongID].TitleSorting.ToUpper());
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
res = _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
return _Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper());
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
});
|
|
||||||
|
|
||||||
_SongsSortList = _SortList.ToArray();
|
|
||||||
_Categories.Clear();
|
|
||||||
for (int i = 0; i < _SongsSortList.Length; i++ )
|
|
||||||
{
|
|
||||||
if (_SongsSortList[i].SortString.Length > 0)
|
|
||||||
{
|
|
||||||
if (_SongsSortList[i].SortString != category)
|
|
||||||
{
|
|
||||||
category = _SongsSortList[i].SortString;
|
|
||||||
_Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
|
|
||||||
}
|
|
||||||
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (CLanguage.Translate("TR_SCREENSONG_NOEDITION") != category)
|
|
||||||
{
|
|
||||||
category = CLanguage.Translate("TR_SCREENSONG_NOEDITION");
|
|
||||||
_Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
|
|
||||||
}
|
|
||||||
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ESongSorting.TR_CONFIG_GENRE:
|
|
||||||
foreach (CSong song in _SongList)
|
|
||||||
{
|
|
||||||
if (song.Genre.Count == 0)
|
|
||||||
_SortList.Add(new SongPointer(song.ID, String.Empty));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (int i = 0; i < song.Genre.Count; i++)
|
|
||||||
{
|
|
||||||
_SortList.Add(new SongPointer(song.ID, song.Genre[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_SortList.Sort(delegate(SongPointer s1, SongPointer s2)
|
|
||||||
{
|
|
||||||
int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
|
|
||||||
{
|
|
||||||
res = _Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(_Songs[s2.SongID].ArtistSorting.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
return _Songs[s1.SongID].TitleSorting.ToUpper().CompareTo(_Songs[s2.SongID].TitleSorting.ToUpper());
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
res = _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
return _Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper());
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
});
|
|
||||||
|
|
||||||
_SongsSortList = _SortList.ToArray();
|
|
||||||
_Categories.Clear();
|
|
||||||
for (int i = 0; i < _SongsSortList.Length; i++)
|
|
||||||
{
|
|
||||||
if (_SongsSortList[i].SortString.Length > 0)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (_SongsSortList[i].SortString != category)
|
|
||||||
{
|
|
||||||
category = _SongsSortList[i].SortString;
|
|
||||||
_Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
|
|
||||||
}
|
|
||||||
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (CLanguage.Translate("TR_SCREENSONG_NOGENRE") != category)
|
|
||||||
{
|
|
||||||
category = CLanguage.Translate("TR_SCREENSONG_NOGENRE");
|
|
||||||
_Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
|
|
||||||
}
|
|
||||||
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ESongSorting.TR_CONFIG_NONE:
|
|
||||||
foreach (CSong song in _SongList)
|
|
||||||
{
|
|
||||||
_SortList.Add(new SongPointer(song.ID, String.Empty));
|
|
||||||
}
|
|
||||||
|
|
||||||
_SortList.Sort(delegate(SongPointer s1, SongPointer s2)
|
|
||||||
{
|
|
||||||
int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
return _Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper());
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
});
|
|
||||||
|
|
||||||
_SongsSortList = _SortList.ToArray();
|
|
||||||
_Categories.Clear();
|
|
||||||
for (int i = 0; i < _SongsSortList.Length; i++)
|
|
||||||
{
|
|
||||||
_SongsSortList[i].CatIndex = 0;
|
|
||||||
}
|
|
||||||
category = CLanguage.Translate("TR_SCREENSONG_ALLSONGS");
|
|
||||||
_Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ESongSorting.TR_CONFIG_FOLDER:
|
|
||||||
foreach (CSong song in _SongList)
|
|
||||||
{
|
|
||||||
_SortList.Add(new SongPointer(song.ID, song.FolderName));
|
|
||||||
}
|
|
||||||
|
|
||||||
_SortList.Sort(delegate(SongPointer s1, SongPointer s2)
|
|
||||||
{
|
|
||||||
int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
|
|
||||||
{
|
|
||||||
res = _Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(_Songs[s2.SongID].ArtistSorting.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
return _Songs[s1.SongID].TitleSorting.ToUpper().CompareTo(_Songs[s2.SongID].TitleSorting.ToUpper());
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
res = _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
return _Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper());
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
});
|
|
||||||
|
|
||||||
_SongsSortList = _SortList.ToArray();
|
|
||||||
_Categories.Clear();
|
|
||||||
for (int i = 0; i < _SongsSortList.Length; i++)
|
|
||||||
{
|
|
||||||
if (_SongsSortList[i].SortString != category)
|
|
||||||
{
|
|
||||||
category = _SongsSortList[i].SortString;
|
|
||||||
_Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
|
|
||||||
}
|
|
||||||
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ESongSorting.TR_CONFIG_ARTIST:
|
|
||||||
foreach (CSong song in _SongList)
|
|
||||||
{
|
|
||||||
_SortList.Add(new SongPointer(song.ID, song.Artist));
|
|
||||||
}
|
|
||||||
|
|
||||||
_SortList.Sort(delegate(SongPointer s1, SongPointer s2)
|
|
||||||
{
|
|
||||||
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
|
|
||||||
{
|
|
||||||
int res = _Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(_Songs[s2.SongID].ArtistSorting.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
return _Songs[s1.SongID].TitleSorting.ToUpper().CompareTo(_Songs[s2.SongID].TitleSorting.ToUpper());
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
return _Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper());
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
_SongsSortList = _SortList.ToArray();
|
|
||||||
_Categories.Clear();
|
|
||||||
for (int i = 0; i < _SongsSortList.Length; i++)
|
|
||||||
{
|
|
||||||
if (_SongsSortList[i].SortString != category)
|
|
||||||
{
|
|
||||||
category = _SongsSortList[i].SortString;
|
|
||||||
_Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
|
|
||||||
}
|
|
||||||
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ESongSorting.TR_CONFIG_ARTIST_LETTER:
|
|
||||||
foreach (CSong song in _SongList)
|
|
||||||
{
|
|
||||||
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
|
|
||||||
_SortList.Add(new SongPointer(song.ID, song.ArtistSorting));
|
|
||||||
else
|
|
||||||
_SortList.Add(new SongPointer(song.ID, song.Artist));
|
|
||||||
}
|
|
||||||
|
|
||||||
_SortList.Sort(delegate(SongPointer s1, SongPointer s2)
|
|
||||||
{
|
|
||||||
int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
|
|
||||||
{
|
|
||||||
return _Songs[s1.SongID].TitleSorting.ToUpper().CompareTo(_Songs[s2.SongID].TitleSorting.ToUpper());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return _Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
});
|
|
||||||
|
|
||||||
_SongsSortList = _SortList.ToArray();
|
|
||||||
_Categories.Clear();
|
|
||||||
|
|
||||||
int NotLetterCat = -1;
|
|
||||||
for (int i=0; i < _SongsSortList.Length; i++)
|
|
||||||
{
|
|
||||||
Char firstLetter = Char.ToUpper(_SongsSortList[i].SortString.Normalize(NormalizationForm.FormD)[0]);
|
|
||||||
|
|
||||||
if (!Char.IsLetter(firstLetter))
|
|
||||||
{
|
|
||||||
firstLetter = '#';
|
|
||||||
}
|
|
||||||
if (firstLetter.ToString() != category)
|
|
||||||
{
|
|
||||||
if (firstLetter != '#' || NotLetterCat == -1)
|
|
||||||
{
|
|
||||||
category = firstLetter.ToString();
|
|
||||||
_Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
|
|
||||||
|
|
||||||
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
|
||||||
|
|
||||||
if (firstLetter == '#')
|
|
||||||
NotLetterCat = _SongsSortList[i].CatIndex;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_SongsSortList[i].CatIndex = NotLetterCat;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ESongSorting.TR_CONFIG_TITLE_LETTER:
|
|
||||||
foreach (CSong song in _SongList)
|
|
||||||
{
|
|
||||||
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
|
|
||||||
_SortList.Add(new SongPointer(song.ID, song.TitleSorting));
|
|
||||||
else
|
|
||||||
_SortList.Add(new SongPointer(song.ID, song.Title));
|
|
||||||
}
|
|
||||||
|
|
||||||
_SortList.Sort(delegate(SongPointer s1, SongPointer s2)
|
|
||||||
{
|
|
||||||
int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
|
|
||||||
{
|
|
||||||
return _Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(_Songs[s2.SongID].ArtistSorting.ToUpper());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
});
|
|
||||||
|
|
||||||
_SongsSortList = _SortList.ToArray();
|
|
||||||
_Categories.Clear();
|
|
||||||
|
|
||||||
NotLetterCat = -1;
|
|
||||||
for (int i=0; i < _SongsSortList.Length; i++)
|
|
||||||
{
|
|
||||||
Char firstLetter = Char.ToUpper(_SongsSortList[i].SortString.Normalize(NormalizationForm.FormD)[0]);
|
|
||||||
|
|
||||||
if (!Char.IsLetter(firstLetter))
|
|
||||||
{
|
|
||||||
firstLetter = '#';
|
|
||||||
}
|
|
||||||
if (firstLetter.ToString() != category)
|
|
||||||
{
|
|
||||||
if (firstLetter != '#' || NotLetterCat == -1)
|
|
||||||
{
|
|
||||||
category = firstLetter.ToString();
|
|
||||||
_Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
|
|
||||||
|
|
||||||
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
|
||||||
|
|
||||||
if (firstLetter == '#')
|
|
||||||
NotLetterCat = _SongsSortList[i].CatIndex;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_SongsSortList[i].CatIndex = NotLetterCat;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ESongSorting.TR_CONFIG_DECADE:
|
|
||||||
foreach (CSong song in _SongList)
|
|
||||||
{
|
|
||||||
_SortList.Add(new SongPointer(song.ID, song.Year));
|
|
||||||
}
|
|
||||||
|
|
||||||
_SortList.Sort(delegate(SongPointer s1, SongPointer s2)
|
|
||||||
{
|
|
||||||
int res = s1.SortString.CompareTo(s2.SortString);
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
|
|
||||||
{
|
|
||||||
res = _Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(_Songs[s2.SongID].ArtistSorting.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
return _Songs[s1.SongID].TitleSorting.ToUpper().CompareTo(_Songs[s2.SongID].TitleSorting.ToUpper());
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
res = _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
return _Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper());
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
});
|
|
||||||
|
|
||||||
_SongsSortList = _SortList.ToArray();
|
|
||||||
_Categories.Clear();
|
|
||||||
for (int i=0; i < _SongsSortList.Length; i++)
|
|
||||||
{
|
|
||||||
if (_SongsSortList[i].SortString.Length > 0 && !_SongsSortList[i].SortString.Equals("0000"))
|
|
||||||
{
|
|
||||||
String decade = _SongsSortList[i].SortString.Substring(0, 3) + "0 - " + _SongsSortList[i].SortString.Substring(0, 3) + "9";
|
|
||||||
if (decade != category)
|
|
||||||
{
|
|
||||||
category = decade;
|
|
||||||
_Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
|
|
||||||
}
|
|
||||||
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (CLanguage.Translate("TR_SCREENSONG_NOYEAR") != category)
|
|
||||||
{
|
|
||||||
category = CLanguage.Translate("TR_SCREENSONG_NOYEAR");
|
|
||||||
_Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
|
|
||||||
}
|
|
||||||
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ESongSorting.TR_CONFIG_YEAR:
|
|
||||||
foreach (CSong song in _SongList)
|
|
||||||
{
|
|
||||||
_SortList.Add(new SongPointer(song.ID, song.Year));
|
|
||||||
}
|
|
||||||
|
|
||||||
_SortList.Sort(delegate(SongPointer s1, SongPointer s2)
|
|
||||||
{
|
|
||||||
int res = s1.SortString.CompareTo(s2.SortString);
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
|
|
||||||
{
|
|
||||||
res = _Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(_Songs[s2.SongID].ArtistSorting.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
return _Songs[s1.SongID].TitleSorting.ToUpper().CompareTo(_Songs[s2.SongID].TitleSorting.ToUpper());
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
res = _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
return _Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper());
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
});
|
|
||||||
|
|
||||||
_SongsSortList = _SortList.ToArray();
|
|
||||||
_Categories.Clear();
|
|
||||||
for (int i=0; i < _SongsSortList.Length; i++)
|
|
||||||
{
|
|
||||||
if (_SongsSortList[i].SortString.Length > 0 && !_SongsSortList[i].SortString.Equals("0000"))
|
|
||||||
{
|
|
||||||
if (_SongsSortList[i].SortString != category)
|
|
||||||
{
|
|
||||||
category = _SongsSortList[i].SortString;
|
|
||||||
_Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
|
|
||||||
}
|
|
||||||
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (CLanguage.Translate("TR_SCREENSONG_NOYEAR") != category)
|
|
||||||
{
|
|
||||||
category = CLanguage.Translate("TR_SCREENSONG_NOYEAR");
|
|
||||||
_Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
|
|
||||||
}
|
|
||||||
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ESongSorting.TR_CONFIG_LANGUAGE:
|
|
||||||
foreach (CSong song in _SongList)
|
|
||||||
{
|
|
||||||
if (song.Language.Count == 0)
|
|
||||||
_SortList.Add(new SongPointer(song.ID, String.Empty));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (int i = 0; i < song.Language.Count; i++)
|
|
||||||
{
|
|
||||||
_SortList.Add(new SongPointer(song.ID, song.Language[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_SortList.Sort(delegate(SongPointer s1, SongPointer s2)
|
|
||||||
{
|
|
||||||
int res = s1.SortString.CompareTo(s2.SortString);
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
|
|
||||||
{
|
|
||||||
res = _Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(_Songs[s2.SongID].ArtistSorting.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
return _Songs[s1.SongID].TitleSorting.ToUpper().CompareTo(_Songs[s2.SongID].TitleSorting.ToUpper());
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
res = _Songs[s1.SongID].Artist.ToUpper().CompareTo(_Songs[s2.SongID].Artist.ToUpper());
|
|
||||||
if (res == 0)
|
|
||||||
{
|
|
||||||
return _Songs[s1.SongID].Title.ToUpper().CompareTo(_Songs[s2.SongID].Title.ToUpper());
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
});
|
|
||||||
|
|
||||||
_SongsSortList = _SortList.ToArray();
|
|
||||||
_Categories.Clear();
|
|
||||||
for (int i=0; i < _SongsSortList.Length; i++)
|
|
||||||
{
|
|
||||||
if (_SongsSortList[i].SortString.Length > 0)
|
|
||||||
{
|
|
||||||
if (_SongsSortList[i].SortString != category)
|
|
||||||
{
|
|
||||||
category = _SongsSortList[i].SortString;
|
|
||||||
_Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
|
|
||||||
}
|
|
||||||
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (CLanguage.Translate("TR_SCREENSONG_NOLANGUAGE") != category)
|
|
||||||
{
|
|
||||||
category = CLanguage.Translate("TR_SCREENSONG_NOLANGUAGE");
|
|
||||||
_Categories.Add(new CCategory(category, new STexture(-1), new STexture(-1)));
|
|
||||||
}
|
|
||||||
_SongsSortList[i].CatIndex = _Categories.Count - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
FilterSongs(SearchString, ShowDuetSongs);
|
||||||
|
SortSongs();
|
||||||
|
_Categories.Clear();
|
||||||
|
|
||||||
if (_Tabs == EOffOn.TR_CONFIG_OFF)
|
if (_Tabs == EOffOn.TR_CONFIG_OFF)
|
||||||
{
|
{
|
||||||
_Categories.Clear();
|
//No categories. So don't create them!
|
||||||
_Categories.Add(new CCategory("", new STexture(-1), new STexture(-1)));
|
_Categories.Add(new CCategory(""));
|
||||||
for (int i = 0; i < _SongsSortList.Length; i++)
|
for (int i = 0; i < _SongsSortList.Length; i++)
|
||||||
{
|
{
|
||||||
_SongsSortList[i].CatIndex = 0;
|
_SongsSortList[i].CatIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}else
|
||||||
|
FillCategories();
|
||||||
|
|
||||||
foreach (CCategory cat in _Categories)
|
foreach (CCategory cat in _Categories)
|
||||||
{
|
{
|
||||||
STexture cover = CCover.Cover(cat.Name);
|
cat.CoverTextureSmall = CCover.Cover(cat.Name);
|
||||||
cat.CoverTextureSmall = cover;
|
|
||||||
}
|
}
|
||||||
Category = _CatIndex;
|
Category = _CatIndex;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,13 @@ namespace Vocaluxe.Menu.SongMenu
|
|||||||
public class CCategory
|
public class CCategory
|
||||||
{
|
{
|
||||||
public string Name = String.Empty;
|
public string Name = String.Empty;
|
||||||
public STexture CoverTextureSmall = new STexture();
|
public STexture CoverTextureSmall = new STexture(-1);
|
||||||
public STexture CoverTextureBig = new STexture();
|
public STexture CoverTextureBig = new STexture(-1);
|
||||||
|
|
||||||
|
public CCategory(string name)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
}
|
||||||
|
|
||||||
public CCategory(string name, STexture CoverSmall, STexture CoverBig)
|
public CCategory(string name, STexture CoverSmall, STexture CoverBig)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user