private void _FillCategories() { if (!_Changed) { return; } _Categories.Clear(); if (_Tabs != EOffOn.TR_CONFIG_OFF) { _CreateCategories(); } else { //No categories. So don't create them! _Categories.Add(new CCategory("")); _Categories[0].Songs.AddRange(CSongs.Sorter.SortedSongs); } foreach (CCategory cat in _Categories) { cat.CoverTextureSmall = CCover.Cover(cat.Name); if (cat.CoverTextureSmall == CCover.NoCover) { cat.CoverTextureSmall = CCover.GenerateCover(cat.Name, CCover._SongSortingToType(CSongs.Sorter.SongSorting), cat.GetSong(0)); } } _Changed = false; }
private static void _Sort(ESongSorting sorting, EOffOn Tabs, string SearchString) { if (_Songs.Count == 0) { return; } _Categories.Clear(); string category = String.Empty; _Tabs = Tabs; List <SongPointer> _SortList = new List <SongPointer>(); List <CSong> _SongList = new List <CSong>(); foreach (CSong song in _Songs) { if (SearchString == String.Empty) { _SongList.Add(song); } else { if (song.Title.ToUpper().Contains(SearchString.ToUpper()) || song.Artist.ToUpper().Contains(SearchString.ToUpper())) { _SongList.Add(song); } } } switch (sorting) { 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) { 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) { 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) { 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) { 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) { _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) { 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[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) { _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) { 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[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) { 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) { 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) { 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; } if (_Tabs == EOffOn.TR_CONFIG_OFF) { _Categories.Clear(); _Categories.Add(new CCategory("", new STexture(-1), new STexture(-1))); for (int i = 0; i < _SongsSortList.Length; i++) { _SongsSortList[i].CatIndex = 0; } } foreach (CCategory cat in _Categories) { STexture cover = CCover.Cover(cat.Name); cat.CoverTextureSmall = cover; } }
public CTextureRef GenerateCover(string text, ECoverGeneratorType type, CSong firstSong) { return(CCover.GenerateCover(text, type, firstSong)); }