/// <summary> /// Sets the SortStrings of the songpointers to the actual category names /// </summary> private static void _AdjustCategoryNames() { ESongSorting sorting = CSongs.Sorter.SongSorting; switch (sorting) { case ESongSorting.TR_CONFIG_DECADE: foreach (CSongPointer songPointer in CSongs.Sorter.SortedSongs) { string year = songPointer.SortString; if (year != "") { year = year.Substring(0, 3); songPointer.SortString = year + "0 - " + year + "9"; } } break; case ESongSorting.TR_CONFIG_TITLE_LETTER: case ESongSorting.TR_CONFIG_ARTIST_LETTER: foreach (CSongPointer songPointer in CSongs.Sorter.SortedSongs) { songPointer.SortString = (songPointer.SortString.Length == 0 || !Char.IsLetter(songPointer.SortString, 0)) ? "#" : songPointer.SortString[0].ToString(); } break; case ESongSorting.TR_CONFIG_DATEADDED: foreach (CSongPointer songPointer in CSongs.Sorter.SortedSongs) { songPointer.SortString = CSongs.GetSong(songPointer.SongID).DateAdded.ToString("dd/MM/yyyy"); } break; } }
public override void OnShow() { base.OnShow(); _SongSortingOld = CConfig.SongSorting; _TabsOld = CConfig.Tabs; _LanguageOld = CConfig.Language; }
public void SetOptions(ESongSorting songSorting, EOffOn ignoreArticles) { if (songSorting != _SongSorting || ignoreArticles != _IgnoreArticles) { _SongSorting = songSorting; _IgnoreArticles = ignoreArticles; _SetChanged(); } }
/// <summary> /// Fill song list based on song configuration. This is basically needed for singing medleys, /// because we don't show song selection screen for these games. /// </summary> private void _UpdateSongList() { if (GameData.Songs.Count > 0) { return; } switch (GameData.SongSource) { case ESongSource.TR_SONGSOURCE_PLAYLIST: for (int i = 0; i < CBase.Playlist.GetSongCount(GameData.PlaylistID); i++) { int id = CBase.Playlist.GetSong(GameData.PlaylistID, i).SongID; if (CBase.Songs.GetSongByID(id).AvailableGameModes.Contains(EGameMode.TR_GAMEMODE_MEDLEY)) { GameData.Songs.Add(id); } } break; case ESongSource.TR_SONGSOURCE_ALLSONGS: ReadOnlyCollection <CSong> avSongs = CBase.Songs.GetSongs(); GameData.Songs.AddRange(avSongs.Where(song => song.AvailableGameModes.Contains(EGameMode.TR_GAMEMODE_MEDLEY)).Select(song => song.ID)); break; case ESongSource.TR_SONGSOURCE_CATEGORY: //Save old sorting to roll it back after getting songs for configured category ESongSorting oldSorting = CBase.Config.GetSongSorting(); CBase.Songs.SortSongs(GameData.Sorting, EOffOn.TR_CONFIG_ON, CBase.Config.GetIgnoreArticles(), String.Empty, EDuetOptions.NoDuets, -1); CBase.Songs.SetCategory(GameData.CategoryIndex); avSongs = CBase.Songs.GetVisibleSongs(); GameData.Songs.AddRange(avSongs.Where(song => song.AvailableGameModes.Contains(EGameMode.TR_GAMEMODE_MEDLEY)).Select(song => song.ID)); CBase.Songs.SetCategory(-1); CBase.Songs.SortSongs(oldSorting, CBase.Config.GetTabs(), CBase.Config.GetIgnoreArticles(), String.Empty, EDuetOptions.NoDuets, -1); break; } GameData.Songs.Shuffle(); }
public static ECoverGeneratorType _SongSortingToType(ESongSorting sorting) { switch (sorting) { case ESongSorting.TR_CONFIG_NONE: return(ECoverGeneratorType.Default); case ESongSorting.TR_CONFIG_FOLDER: return(ECoverGeneratorType.Folder); case ESongSorting.TR_CONFIG_ARTIST: return(ECoverGeneratorType.Artist); case ESongSorting.TR_CONFIG_ARTIST_LETTER: case ESongSorting.TR_CONFIG_TITLE_LETTER: return(ECoverGeneratorType.Letter); case ESongSorting.TR_CONFIG_EDITION: return(ECoverGeneratorType.Edition); case ESongSorting.TR_CONFIG_GENRE: return(ECoverGeneratorType.Genre); case ESongSorting.TR_CONFIG_LANGUAGE: return(ECoverGeneratorType.Language); case ESongSorting.TR_CONFIG_YEAR: return(ECoverGeneratorType.Year); case ESongSorting.TR_CONFIG_DECADE: return(ECoverGeneratorType.Decade); case ESongSorting.TR_CONFIG_DATEADDED: return(ECoverGeneratorType.Date); default: throw new ArgumentOutOfRangeException("sorting"); } }
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 static void Sort(ESongSorting sorting) { _Sort(sorting, CConfig.Tabs, String.Empty); }
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) { if (CConfig.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 (CConfig.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 (CConfig.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 (CConfig.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 (CConfig.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 (CConfig.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 (CConfig.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 (CConfig.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 (CConfig.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 (CConfig.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 (CConfig.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; } 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 static void Sort(ESongSorting sorting) { _Sort(sorting, CConfig.Tabs, String.Empty); }
public void SortSongs(ESongSorting sorting, EOffOn tabs, EOffOn ignoreArticles, String searchString, EDuetOptions duetOptions, int playlistID) { CSongs.Sort(sorting, tabs, ignoreArticles, searchString, duetOptions, playlistID); }
public static void Sort(ESongSorting sorting, EOffOn tabs, EOffOn ignoreArticles, String searchString, EDuetOptions duetOptions, int playlistID) { Filter.SetOptions(searchString, duetOptions, playlistID); Sorter.SetOptions(sorting, ignoreArticles); Categorizer.Tabs = tabs; }
public override void OnShow() { base.OnShow(); _SongSortingOld = CConfig.SongSorting; _TabsOld = CConfig.Tabs; _LanguageOld = CConfig.Language; }