diff --git a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs index 8479323b..29ca14c1 100644 --- a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs +++ b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs @@ -308,7 +308,7 @@ namespace VocaluxeLib.PartyModes.Challenge _Screens.TryGetValue("CPartyScreenChallengeMain", out screen); if (screen != null) { - CBase.Songs.ResetPartySongSung(); + CBase.Songs.ResetSongSung(); _ToScreenMain.ResultTable = new List(); _GameData.ResultTable = new List(); _GameData.Rounds = new CChallengeRounds(_GameData.NumRounds, _GameData.NumPlayer, _GameData.NumPlayerAtOnce); diff --git a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs index cd0e61f3..0803558d 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs @@ -187,14 +187,11 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley { _Stage = EStage.NotStarted; - _ScreenSongOptions.Sorting.IgnoreArticles = CBase.Config.GetIgnoreArticles(); - _ScreenSongOptions.Sorting.SongSorting = CBase.Config.GetSongSorting(); + _ScreenSongOptions.Sorting.IgnoreArticles = EOffOn.TR_CONFIG_OFF; + _ScreenSongOptions.Sorting.SongSorting = ESongSorting.TR_CONFIG_NONE; _ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_OFF; _ScreenSongOptions.Selection.SongIndex = -1; - if (CBase.Config.GetTabs() == EOffOn.TR_CONFIG_ON && _ScreenSongOptions.Sorting.SongSorting != ESongSorting.TR_CONFIG_NONE) - _ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_ON; - _ToScreenMain.ResultTable = new List(); _GameData.ResultTable = new List(); @@ -313,7 +310,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley _Screens.TryGetValue("CPartyScreenChallengeMedleyMain", out screen); if (screen != null) { - CBase.Songs.ResetPartySongSung(); + CBase.Songs.ResetSongSung(); _ToScreenMain.ResultTable = new List(); _GameData.ResultTable = new List(); _GameData.Rounds = new CChallengeRounds(_GameData.NumRounds, _GameData.NumPlayer, _GameData.NumPlayerAtOnce); @@ -502,26 +499,25 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley #endregion PlayerNames #region SongQueue - if (CBase.Songs.GetNumVisibleSongs() < _NumSongs) - CBase.Songs.ResetPartySongSung(); + if (CBase.Songs.GetNumSongsVisible() < _NumSongs) + CBase.Songs.ResetSongSung(); - const EGameMode gm = EGameMode.TR_GAMEMODE_MEDLEY; List ids = new List(); - CSong[] visSongs = CBase.Songs.GetSongsNotSung(); - if (visSongs == null) + var visibleSongs = CBase.Songs.GetVisibleSongs(); + if (visibleSongs.Count == 0) { CBase.Log.LogError("CPartyChallengeMedleyMode Error: There are no songs!"); CBase.Graphics.FadeTo(EScreens.ScreenParty); return false; } - for (int i = 0; i < visSongs.Length; i++) + foreach (CSong song in visibleSongs) { - foreach (EGameMode mode in visSongs[i].AvailableGameModes) + foreach (EGameMode mode in song.AvailableGameModes) { if (mode == EGameMode.TR_GAMEMODE_MEDLEY) - ids.Add(visSongs[i].ID); + ids.Add(song.ID); } } @@ -536,7 +532,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley while (s < _NumSongs && ids.Count > 0) { int songID = ids[CBase.Game.GetRandom(ids.Count)]; - CBase.Game.AddSong(songID, gm); + CBase.Game.AddSong(songID, EGameMode.TR_GAMEMODE_MEDLEY); CBase.Songs.AddPartySongSung(songID); ids.Remove(songID); s++; diff --git a/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs b/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs index 21e9f455..649cce67 100644 --- a/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs +++ b/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs @@ -374,7 +374,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe if (screen != null) { _GameData.Team = _GameData.Team == 1 ? 0 : 1; - CBase.Songs.ResetPartySongSung(); + CBase.Songs.ResetSongSung(); _GameData.CurrentRoundNr = 1; _ToScreenMain.CurrentRoundNr = 1; _ToScreenMain.NumFields = _GameData.NumFields; diff --git a/Vocaluxe/Base/CGraphics.cs b/Vocaluxe/Base/CGraphics.cs index bab0a646..23e0c7ec 100644 --- a/Vocaluxe/Base/CGraphics.cs +++ b/Vocaluxe/Base/CGraphics.cs @@ -505,7 +505,7 @@ namespace Vocaluxe.Base bool popupVolumeControlAllowed = _CurrentScreen != EScreens.ScreenCredits && _CurrentScreen != EScreens.ScreenOptionsRecord; //Hide volume control for bg-music if bg-music is disabled - if (popupVolumeControlAllowed && (_CurrentScreen != EScreens.ScreenSong || (_CurrentScreen == EScreens.ScreenSong && CSongs.Category == -1)) + if (popupVolumeControlAllowed && (_CurrentScreen != EScreens.ScreenSong || CSongs.Category == -1) && _CurrentScreen != EScreens.ScreenSing && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_OFF) popupVolumeControlAllowed = false; diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index 84ee348e..6b3781a8 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Drawing; using Vocaluxe.Base.Font; using VocaluxeLib.Menu; @@ -568,9 +569,9 @@ namespace Vocaluxe.Base return CSongs.NumAllSongs; } - public int GetNumVisibleSongs() + public int GetNumSongsVisible() { - return CSongs.NumVisibleSongs; + return CSongs.NumSongsVisible; } public int GetNumCategories() @@ -618,14 +619,14 @@ namespace Vocaluxe.Base return CSongs.GetSong(songID); } - public CSong[] GetSongs() + public ReadOnlyCollection GetSongs() { return CSongs.AllSongs; } - public CSong[] GetSongsNotSung() + public ReadOnlyCollection GetVisibleSongs() { - return CSongs.SongsNotSung; + return CSongs.VisibleSongs; } public CCategory GetCategory(int index) @@ -641,12 +642,12 @@ namespace Vocaluxe.Base CSongs.AddPartySongSung(songID); } - public void ResetPartySongSung() + public void ResetSongSung() { CSongs.ResetPartySongSung(); } - public void ResetPartySongSung(int catIndex) + public void ResetSongSung(int catIndex) { CSongs.ResetPartySongSung(catIndex); } diff --git a/Vocaluxe/Base/CPlaylists.cs b/Vocaluxe/Base/CPlaylists.cs index a740bc97..ca3e8e34 100644 --- a/Vocaluxe/Base/CPlaylists.cs +++ b/Vocaluxe/Base/CPlaylists.cs @@ -223,7 +223,7 @@ namespace Vocaluxe.Base private static CPlaylistFile _ConvertUSDXPlaylist(string file) { CPlaylistFile pl = new CPlaylistFile(); - CSong[] allSongs = CSongs.AllSongs; + var allSongs = CSongs.AllSongs; if (!File.Exists(file)) return null; diff --git a/Vocaluxe/Base/CSongCategorizer.cs b/Vocaluxe/Base/CSongCategorizer.cs index a9aedb6b..3e4e4706 100644 --- a/Vocaluxe/Base/CSongCategorizer.cs +++ b/Vocaluxe/Base/CSongCategorizer.cs @@ -32,7 +32,7 @@ namespace Vocaluxe.Base public CSongCategorizer() { - CSongs.Filter.ObjectChanged += _HandleSortedSongsChanged; + CSongs.Sorter.ObjectChanged += _HandleSortedSongsChanged; } public List Categories @@ -49,11 +49,10 @@ namespace Vocaluxe.Base get { return _Tabs; } set { - if (value != _Tabs) - { - _Tabs = value; - _SetChanged(); - } + if (value == _Tabs) + return; + _Tabs = value; + _SetChanged(); } } @@ -64,58 +63,55 @@ namespace Vocaluxe.Base private void _CreateCategoriesLetter() { - string category = ""; - int notLetterCat = -1; + CCategory lastCategory = null; + CCategory notLetterCat = null; for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++) { Char firstLetter = Char.ToUpper(CSongs.Sorter.SortedSongs[i].SortString.Normalize(NormalizationForm.FormD)[0]); - - if (!Char.IsLetter(firstLetter)) - firstLetter = '#'; - if (firstLetter.ToString() != category) + if (Char.IsLetter(firstLetter)) { - if (firstLetter != '#' || notLetterCat == -1) + if (lastCategory == null || CSongs.Sorter.SortedSongs[i].SortString != lastCategory.Name) { - category = firstLetter.ToString(); - _Categories.Add(new CCategory(category)); - - CSongs.Sorter.SortedSongs[i].CatIndex = _Categories.Count - 1; - - if (firstLetter == '#') - notLetterCat = CSongs.Sorter.SortedSongs[i].CatIndex; + lastCategory = new CCategory(CSongs.Sorter.SortedSongs[i].SortString); + _Categories.Add(lastCategory); } - else - CSongs.Sorter.SortedSongs[i].CatIndex = notLetterCat; + lastCategory.Songs.Add(CSongs.Sorter.SortedSongs[i]); } else - CSongs.Sorter.SortedSongs[i].CatIndex = _Categories.Count - 1; + { + if (notLetterCat == null) + { + notLetterCat = new CCategory("#"); + _Categories.Add(notLetterCat); + } + notLetterCat.Songs.Add(CSongs.Sorter.SortedSongs[i]); + } } } private void _CreateCategoriesNormal(string noCategoryName) { - string category = ""; - int noCategoryIndex = -1; + CCategory lastCategory = null; + CCategory noCategory = null; for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++) { if (CSongs.Sorter.SortedSongs[i].SortString != "") { - if (CSongs.Sorter.SortedSongs[i].SortString != category) + if (lastCategory == null || CSongs.Sorter.SortedSongs[i].SortString != lastCategory.Name) { - category = CSongs.Sorter.SortedSongs[i].SortString; - _Categories.Add(new CCategory(category)); + lastCategory = new CCategory(CSongs.Sorter.SortedSongs[i].SortString); + _Categories.Add(lastCategory); } - CSongs.Sorter.SortedSongs[i].CatIndex = _Categories.Count - 1; + lastCategory.Songs.Add(CSongs.Sorter.SortedSongs[i]); } else { - if (noCategoryIndex < 0) + if (noCategory == null) { - category = noCategoryName; - _Categories.Add(new CCategory(category)); - noCategoryIndex = _Categories.Count - 1; + noCategory = new CCategory(noCategoryName); + _Categories.Add(noCategory); } - CSongs.Sorter.SortedSongs[i].CatIndex = noCategoryIndex; + noCategory.Songs.Add(CSongs.Sorter.SortedSongs[i]); } } } @@ -172,15 +168,14 @@ namespace Vocaluxe.Base _Categories.Clear(); - if (_Tabs == EOffOn.TR_CONFIG_OFF) + if (_Tabs != EOffOn.TR_CONFIG_OFF) + _CreateCategories(); + else { //No categories. So don't create them! _Categories.Add(new CCategory("")); - for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++) - CSongs.Sorter.SortedSongs[i].CatIndex = 0; + _Categories[0].Songs.AddRange(CSongs.Sorter.SortedSongs); } - else - _CreateCategories(); foreach (CCategory cat in _Categories) cat.CoverTextureSmall = CCover.Cover(cat.Name); diff --git a/Vocaluxe/Base/CSongSorter.cs b/Vocaluxe/Base/CSongSorter.cs index 6d10957b..743f9506 100644 --- a/Vocaluxe/Base/CSongSorter.cs +++ b/Vocaluxe/Base/CSongSorter.cs @@ -27,7 +27,7 @@ namespace Vocaluxe.Base { class CSongSorter : CObservable { - private SSongPointer[] _SortedSongs = new SSongPointer[0]; + private CSongPointer[] _SortedSongs = new CSongPointer[0]; private EOffOn _IgnoreArticles = CConfig.IgnoreArticles; private ESongSorting _SongSorting = CConfig.SongSorting; @@ -36,7 +36,7 @@ namespace Vocaluxe.Base CSongs.Filter.ObjectChanged += _HandleFilteredSongsChanged; } - public SSongPointer[] SortedSongs + public CSongPointer[] SortedSongs { get { @@ -84,7 +84,7 @@ namespace Vocaluxe.Base _SetChanged(); } - private int _SortByFieldArtistTitle(SSongPointer s1, SSongPointer s2) + private int _SortByFieldArtistTitle(CSongPointer s1, CSongPointer s2) { int res = String.Compare(s1.SortString, s2.SortString, StringComparison.OrdinalIgnoreCase); if (res == 0) @@ -100,7 +100,7 @@ namespace Vocaluxe.Base return res; } - private int _SortByFieldTitle(SSongPointer s1, SSongPointer s2) + private int _SortByFieldTitle(CSongPointer s1, CSongPointer s2) { int res = String.Compare(s1.SortString, s2.SortString, StringComparison.OrdinalIgnoreCase); if (res == 0) @@ -112,11 +112,11 @@ namespace Vocaluxe.Base return res; } - private List _CreateSortList(string fieldName) + private List _CreateSortList(string fieldName) { - List sortList = new List(); + List sortList = new List(); if (fieldName == "") - CSongs.Filter.FilteredSongs.ForEach(song => sortList.Add(new SSongPointer(song.ID, ""))); + CSongs.Filter.FilteredSongs.ForEach(song => sortList.Add(new CSongPointer(song.ID, ""))); else { FieldInfo field = typeof(CSong).GetField(fieldName, BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public); @@ -132,16 +132,16 @@ namespace Vocaluxe.Base { object value = field.GetValue(song); if (isString) - sortList.Add(new SSongPointer(song.ID, (String)value)); + sortList.Add(new CSongPointer(song.ID, (String)value)); else { List values = (List)value; if (values.Count == 0) - sortList.Add(new SSongPointer(song.ID, "")); + sortList.Add(new CSongPointer(song.ID, "")); else { foreach (String sortString in values) - sortList.Add(new SSongPointer(song.ID, sortString)); + sortList.Add(new CSongPointer(song.ID, sortString)); } } } @@ -183,7 +183,7 @@ namespace Vocaluxe.Base fieldName = ""; break; } - List sortList = _CreateSortList(fieldName); + List sortList = _CreateSortList(fieldName); switch (_SongSorting) { case ESongSorting.TR_CONFIG_ARTIST_LETTER: diff --git a/Vocaluxe/Base/CSongs.cs b/Vocaluxe/Base/CSongs.cs index c498eafb..b52dbd36 100644 --- a/Vocaluxe/Base/CSongs.cs +++ b/Vocaluxe/Base/CSongs.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Threading; using VocaluxeLib.Menu; @@ -26,31 +27,11 @@ using VocaluxeLib.Menu.SongMenu; namespace Vocaluxe.Base { - public struct SSongPointer - { - public readonly int SongID; - public string SortString; - - public int CatIndex; - public bool Visible; - public bool PartyHidden; - - public SSongPointer(int id, string sortString) - { - SongID = id; - SortString = sortString; - CatIndex = -1; - Visible = false; - PartyHidden = false; - } - } - static class CSongs { private static readonly List _Songs = new List(); private static readonly List _SongsForRandom = new List(); - private static bool _SongsLoaded; private static bool _CoverLoaded; private static int _CatIndex = -1; private static readonly List _CategoriesForRandom = new List(); @@ -66,16 +47,13 @@ namespace Vocaluxe.Base get { return _Songs; } } - public static bool SongsLoaded - { - get { return _SongsLoaded; } - } + public static bool SongsLoaded { get; private set; } public static bool CoverLoaded { get { - if (_SongsLoaded && NumAllSongs == 0) + if (SongsLoaded && NumAllSongs == 0) _CoverLoaded = true; return _CoverLoaded; } @@ -86,14 +64,14 @@ namespace Vocaluxe.Base get { return _Songs.Count; } } - public static int NumVisibleSongs + public static int NumSongsVisible { - get { return Sorter.SortedSongs.Count(sp => sp.Visible); } + get { return _CatIndex < 0 ? 0 : Categories[_CatIndex].Songs.Count(sp => !sp.IsSung); } } public static int NumCategories { - get { return Categorizer.Categories.Count; } + get { return Categories.Count; } } public static int Category @@ -101,13 +79,8 @@ namespace Vocaluxe.Base get { return _CatIndex; } set { - if (value >= -1 && value < Categorizer.Categories.Count) - { + if (value == -1 || IsCatIndexValid(value)) _CatIndex = value; - - for (int i = 0; i < Sorter.SortedSongs.Length; i++) - Sorter.SortedSongs[i].Visible = Sorter.SortedSongs[i].CatIndex == _CatIndex && !Sorter.SortedSongs[i].PartyHidden; - } } } @@ -116,6 +89,11 @@ namespace Vocaluxe.Base get { return _CatIndex >= 0; } } + private static bool IsCatIndexValid(int catIndex) + { + return catIndex >= 0 && catIndex < Categories.Count; + } + /// /// Returns the number of song in the category specified with CatIndex /// @@ -123,21 +101,12 @@ namespace Vocaluxe.Base /// public static int NumSongsInCategory(int catIndex) { - if (Categorizer.Categories.Count <= catIndex || catIndex < 0) - return 0; - - int num = 0; - for (int i = 0; i < Sorter.SortedSongs.Length; i++) - { - if (Sorter.SortedSongs[i].CatIndex == catIndex && !Sorter.SortedSongs[i].PartyHidden) - num++; - } - return num; + return IsCatIndexValid(catIndex) ? Categories[catIndex].Songs.Count(sp => !sp.IsSung) : 0; } public static void NextCategory() { - if (Category == Categorizer.Categories.Count - 1) + if (Category == Categories.Count - 1) Category = 0; else Category++; @@ -146,7 +115,7 @@ namespace Vocaluxe.Base public static void PrevCategory() { if (Category == 0) - Category = Categorizer.Categories.Count - 1; + Category = Categories.Count - 1; else Category--; } @@ -168,29 +137,9 @@ namespace Vocaluxe.Base public static int NumSongsWithCoverLoaded { get; private set; } - public static void SetCoverSmall(int songIndex, STexture texture) - { - if (!_SongsLoaded) - return; - - if (songIndex < _Songs.Count) - _Songs[songIndex].CoverTextureSmall = texture; - } - - public static void SetCoverBig(int songIndex, STexture texture) - { - if (!_SongsLoaded) - return; - - if (songIndex < _Songs.Count) - _Songs[songIndex].CoverTextureBig = texture; - } - public static string GetCurrentCategoryName() { - if ((Categorizer.Categories.Count > 0) && (_CatIndex >= 0) && (Categorizer.Categories.Count > _CatIndex)) - return Categorizer.Categories[_CatIndex].Name; - return String.Empty; + return IsCatIndexValid(_CatIndex) ? Categories[_CatIndex].Name : ""; } public static CSong GetSong(int songID) @@ -200,43 +149,31 @@ namespace Vocaluxe.Base public static void AddPartySongSung(int songID) { - int cat = -1; - for (int i = 0; i < Sorter.SortedSongs.Length; i++) + foreach (CCategory category in Categories) { - if (songID == Sorter.SortedSongs[i].SongID) + foreach (CSongPointer song in category.Songs.Where(song => song.SongID == songID)) { - Sorter.SortedSongs[i].PartyHidden = true; - Sorter.SortedSongs[i].Visible = false; - cat = Sorter.SortedSongs[i].CatIndex; - break; + song.IsSung = true; + int catIndex = _GetCategoryNumber(category); + if (NumSongsInCategory(catIndex) == 0) + ResetPartySongSung(catIndex); + return; } } - - if (cat != -1) - { - if (NumSongsInCategory(cat) == 0) - ResetPartySongSung(cat); - } } public static void ResetPartySongSung() { - for (int i = 0; i < Sorter.SortedSongs.Length; i++) - { - Sorter.SortedSongs[i].PartyHidden = false; - Sorter.SortedSongs[i].Visible = Sorter.SortedSongs[i].CatIndex == _CatIndex && !Sorter.SortedSongs[i].PartyHidden; - } + foreach (CSongPointer song in Sorter.SortedSongs) + song.IsSung = false; } public static void ResetPartySongSung(int catIndex) { - for (int i = 0; i < Sorter.SortedSongs.Length; i++) + if (IsCatIndexValid(catIndex)) { - if (Sorter.SortedSongs[i].CatIndex == catIndex) - { - Sorter.SortedSongs[i].PartyHidden = false; - Sorter.SortedSongs[i].Visible = Sorter.SortedSongs[i].CatIndex == _CatIndex && !Sorter.SortedSongs[i].PartyHidden; - } + foreach (CSongPointer song in Categories[catIndex].Songs) + song.IsSung = false; } } @@ -292,7 +229,7 @@ namespace Vocaluxe.Base private static int _GetCategoryNumber(CCategory category) { - for (int i = 0; i < Categories.Length; i++) + for (int i = 0; i < Categories.Count; i++) { if (Categories[i] == category) return i; @@ -300,59 +237,39 @@ namespace Vocaluxe.Base return -1; } - public static CSong[] AllSongs + public static ReadOnlyCollection AllSongs { - get { return _Songs.ToArray(); } + get { return _Songs.AsReadOnly(); } } - public static CSong[] SongsNotSung + public static ReadOnlyCollection VisibleSongs { get { List songs = new List(); - foreach (SSongPointer sp in Sorter.SortedSongs) + if (IsCatIndexValid(_CatIndex)) { - if (sp.Visible) - songs.Add(_Songs[sp.SongID]); + foreach (CSongPointer sp in Categories[_CatIndex].Songs) + { + if (!sp.IsSung) + songs.Add(_Songs[sp.SongID]); + } } - return songs.ToArray(); + return songs.AsReadOnly(); } } - public static CSong[] VisibleSongs + public static ReadOnlyCollection Categories { - get - { - List songs = new List(); - foreach (SSongPointer sp in Sorter.SortedSongs) - { - if (sp.Visible) - songs.Add(_Songs[sp.SongID]); - } - return songs.ToArray(); - } - } - - public static CCategory[] Categories - { - get { return Categorizer.Categories.ToArray(); } + get { return Categorizer.Categories.AsReadOnly(); } } public static CSong GetVisibleSongByIndex(int index) { if (index < 0) return null; - - foreach (SSongPointer sp in Sorter.SortedSongs) - { - if (sp.Visible) - { - if (index == 0) - return _Songs[sp.SongID]; - index--; - } - } - return null; + var visSongs = VisibleSongs; + return (index < visSongs.Count) ? visSongs[index] : null; } private static void _HandleCategoriesChanged(object sender, EventArgs args) @@ -371,7 +288,7 @@ namespace Vocaluxe.Base public static void LoadSongs() { CLog.StartBenchmark(1, "Load Songs"); - _SongsLoaded = false; + SongsLoaded = false; _Songs.Clear(); CLog.StartBenchmark(2, "List Songs"); @@ -403,7 +320,7 @@ namespace Vocaluxe.Base Categorizer.ObjectChanged += _HandleCategoriesChanged; CLog.StopBenchmark(2, "Sort Songs"); Category = -1; - _SongsLoaded = true; + SongsLoaded = true; if (CConfig.CoverLoading == ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART) { diff --git a/Vocaluxe/Base/Font/CGlyph.cs b/Vocaluxe/Base/Font/CGlyph.cs index 56ac78cd..bca65ad9 100644 --- a/Vocaluxe/Base/Font/CGlyph.cs +++ b/Vocaluxe/Base/Font/CGlyph.cs @@ -82,7 +82,7 @@ namespace Vocaluxe.Base.Font point); * */ Texture = CDraw.AddTexture(bmp); - bmp.Save("font/" + chr + CFonts.Style + ".png", ImageFormat.Png); + //bmp.Save("font/" + chr + CFonts.Style + ".png", ImageFormat.Png); Width = (int)((1f + outline / 2f) * sizeB.Width * Texture.Width / factor / bmp.Width); g.Dispose(); } diff --git a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs index 08593a50..f0603d78 100644 --- a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs +++ b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs @@ -155,9 +155,8 @@ namespace Vocaluxe.Lib.Playlist xmlReader.TryGetEnumValue("//root/Songs/" + song + "/GameMode", ref gm); CPlaylistSong playlistSong = new CPlaylistSong {SongID = -1}; - CSong[] allSongs = CSongs.AllSongs; - foreach (CSong curSong in allSongs) + foreach (CSong curSong in CSongs.AllSongs) { if (curSong.Artist != artist || curSong.Title != title) continue; diff --git a/Vocaluxe/Screens/CScreenOptionsTheme.cs b/Vocaluxe/Screens/CScreenOptionsTheme.cs index 1ba85dd1..5ad72a24 100644 --- a/Vocaluxe/Screens/CScreenOptionsTheme.cs +++ b/Vocaluxe/Screens/CScreenOptionsTheme.cs @@ -181,12 +181,7 @@ namespace Vocaluxe.Screens CConfig.SaveConfig(); if (_OldCoverTheme != _SelectSlides[_SelectSlideCover].Selection) - { CCover.ReloadCover(); - CSongs.Filter.SearchString = String.Empty; - CSongs.Sorter.SetOptions(CConfig.SongSorting, CConfig.IgnoreArticles); - CSongs.Categorizer.Tabs = CConfig.Tabs; - } if (_OldTheme != _SelectSlides[_SelectSlideTheme].Selection) { diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 6f0d83b7..6495e45a 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -213,7 +213,7 @@ namespace Vocaluxe.Screens if (_Buttons[_ButtonStart].Selected) _HandlePartySongSelection(_SongMenus[_SongMenu].GetSelectedSong()); } - if (CSongs.NumVisibleSongs > 0 && !_Sso.Selection.PartyMode) + if (CSongs.NumSongsVisible > 0 && !_Sso.Selection.PartyMode) { if (_SongMenus[_SongMenu].GetSelectedSong() != -1 && !_SongOptionsActive) { @@ -276,7 +276,7 @@ namespace Vocaluxe.Screens break; case Keys.S: - if (keyEvent.Mod == EModifier.Ctrl && CSongs.NumVisibleSongs > 0 && !_Sso.Selection.PartyMode) + if (keyEvent.Mod == EModifier.Ctrl && CSongs.NumSongsVisible > 0 && !_Sso.Selection.PartyMode) _StartMedleySong(_SongMenus[_SongMenu].GetSelectedSong()); break; @@ -442,7 +442,7 @@ namespace Vocaluxe.Screens { //TODO: Causes Bug if you select a song (e.g. with Select random song) and double click a normal button. //E.g. clicking to fast on Select random song starts the next random song. is this OK? - if (CSongs.NumVisibleSongs > 0 && _SongMenus[_SongMenu].GetActualSelection() != -1) + if (CSongs.NumSongsVisible > 0 && _SongMenus[_SongMenu].GetActualSelection() != -1) { _ToggleSongOptions(ESongOptionsView.None); _StartVisibleSong(_SongMenus[_SongMenu].GetActualSelection()); @@ -558,7 +558,7 @@ namespace Vocaluxe.Screens } } - if (CSongs.NumVisibleSongs > 0 && _SongMenus[_SongMenu].GetActualSelection() != -1 && !_Sso.Selection.PartyMode) + if (CSongs.NumSongsVisible > 0 && _SongMenus[_SongMenu].GetActualSelection() != -1 && !_Sso.Selection.PartyMode) { if (_SongMenus[_SongMenu].GetSelectedSong() != -1 && !_SongOptionsActive) { @@ -572,7 +572,7 @@ namespace Vocaluxe.Screens if (mouseEvent.LBH) { - if (!_DragAndDropActive && _Playlists[_Playlist].Visible && CSongs.NumVisibleSongs > 0 && _SongMenus[_SongMenu].GetActualSelection() != -1) + if (!_DragAndDropActive && _Playlists[_Playlist].Visible && CSongs.NumSongsVisible > 0 && _SongMenus[_SongMenu].GetActualSelection() != -1) { _DragAndDropCover = _SongMenus[_SongMenu].GetSelectedSongCover(); _DragAndDropCover.Rect.Z = CSettings.ZNear; @@ -653,9 +653,9 @@ namespace Vocaluxe.Screens CBackgroundMusic.Disabled = false; int song = _SongMenus[_SongMenu].GetActualSelection(); - if ((CSongs.Category >= 0 || CConfig.Tabs == EOffOn.TR_CONFIG_OFF) && song >= 0 && song < CSongs.VisibleSongs.Length) + if ((CSongs.Category >= 0 || CConfig.Tabs == EOffOn.TR_CONFIG_OFF) && song >= 0 && song < CSongs.VisibleSongs.Count) _Texts[_TextSelection].Text = CSongs.VisibleSongs[song].Artist + " - " + CSongs.VisibleSongs[song].Title; - else if (!CSongs.IsInCategory && song >= 0 && song < CSongs.Categories.Length) + else if (!CSongs.IsInCategory && song >= 0 && song < CSongs.Categories.Count) _Texts[_TextSelection].Text = CSongs.Categories[song].Name; else _Texts[_TextSelection].Text = String.Empty; @@ -822,7 +822,7 @@ namespace Vocaluxe.Screens private void _StartVisibleSong(int songNr) { - if (CSongs.Category >= 0 && songNr >= 0 && CSongs.NumVisibleSongs > songNr) + if (CSongs.Category >= 0 && songNr >= 0 && CSongs.NumSongsVisible > songNr) { EGameMode gm = CSongs.VisibleSongs[songNr].IsDuet ? EGameMode.TR_GAMEMODE_DUET : EGameMode.TR_GAMEMODE_NORMAL; @@ -856,7 +856,7 @@ namespace Vocaluxe.Screens CGame.ClearSongs(); List ids = new List(); - for (int i = 0; i < CSongs.AllSongs.Length; i++) + for (int i = 0; i < CSongs.AllSongs.Count; i++) ids.Add(i); while (ids.Count > 0) @@ -882,7 +882,7 @@ namespace Vocaluxe.Screens CGame.ClearSongs(); List ids = new List(); - for (int i = 0; i < CSongs.VisibleSongs.Length; i++) + for (int i = 0; i < CSongs.VisibleSongs.Count; i++) ids.Add(CSongs.VisibleSongs[i].ID); while (ids.Count > 0) @@ -910,12 +910,12 @@ namespace Vocaluxe.Screens List ids = new List(); if (allSongs) { - for (int i = 0; i < CSongs.AllSongs.Length; i++) + for (int i = 0; i < CSongs.AllSongs.Count; i++) ids.Add(i); } else { - for (int i = 0; i < CSongs.VisibleSongs.Length; i++) + for (int i = 0; i < CSongs.VisibleSongs.Count; i++) ids.Add(CSongs.VisibleSongs[i].ID); } int s = 0; @@ -985,6 +985,21 @@ namespace Vocaluxe.Screens return false; } + private int _FindIndex(IList list, int start, Predicate match) + { + for (int i = start; i < list.Count; i++) + { + if (match(list[i])) + return i; + } + for (int i = 0; i < start; i++) + { + if (match(list[i])) + return i; + } + return -1; + } + private void _JumpTo(char letter) { int start = 0; @@ -992,29 +1007,21 @@ namespace Vocaluxe.Screens if (CSongs.IsInCategory) { //TODO: Check and use sorting method - CSong[] songs = CSongs.VisibleSongs; - int ct = songs.Length; - if (curSelected >= 0 && curSelected < ct - 1) - { - CSong currentSong = CSongs.GetVisibleSongByIndex(curSelected); - if (currentSong != null && currentSong.Artist.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)) - start = curSelected + 1; - } - int visibleID = Array.FindIndex(songs, start, ct - start, element => element.Artist.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)); - if (visibleID < 0 && start > 1) - visibleID = Array.FindIndex(songs, 0, start - 1, element => element.Artist.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)); + var songs = CSongs.VisibleSongs; + int ct = songs.Count; + if (curSelected >= 0 && curSelected < ct - 1 && songs[curSelected].Artist.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)) + start = curSelected + 1; + int visibleID = _FindIndex(songs, start, element => element.Artist.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)); if (visibleID > -1) _SongMenus[_SongMenu].SetSelectedSong(visibleID); } else { - CCategory[] categories = CSongs.Categories; - int ct = categories.Length; + var categories = CSongs.Categories; + int ct = categories.Count; if (curSelected >= 0 && curSelected < ct - 1 && categories[curSelected].Name.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)) start = curSelected + 1; - int visibleID = Array.FindIndex(categories, start, ct - start, element => element.Name.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)); - if (visibleID < 0 && start > 1) - visibleID = Array.FindIndex(categories, 0, start - 1, element => element.Name.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)); + int visibleID = _FindIndex(categories, start, element => element.Name.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase)); if (visibleID > -1) _SongMenus[_SongMenu].SetSelectedCategory(visibleID); } @@ -1030,7 +1037,7 @@ namespace Vocaluxe.Screens int songIndex = _SongMenus[_SongMenu].GetSelectedSong(); int songID = -1; - if (songIndex != -1 && CSongs.NumVisibleSongs > 0 && CSongs.NumVisibleSongs > songIndex) + if (songIndex != -1 && CSongs.NumSongsVisible > 0 && CSongs.NumSongsVisible > songIndex) songID = CSongs.VisibleSongs[songIndex].ID; if (newFilterString == "" && _Sso.Sorting.Tabs == EOffOn.TR_CONFIG_ON) @@ -1047,7 +1054,7 @@ namespace Vocaluxe.Screens CSongs.Sort(_Sso.Sorting.SongSorting, _Sso.Sorting.Tabs, _Sso.Sorting.IgnoreArticles, newFilterString, _Sso.Sorting.DuetOptions); - if (songID == -1 || CSongs.NumVisibleSongs == 0 || CSongs.NumVisibleSongs <= songIndex || CSongs.GetVisibleSongByIndex(songIndex).ID != songID) + if (songID == -1 || CSongs.NumSongsVisible == 0 || CSongs.NumSongsVisible <= songIndex || CSongs.GetVisibleSongByIndex(songIndex).ID != songID) refresh = true; if (refresh) @@ -1162,12 +1169,12 @@ namespace Vocaluxe.Screens _SelectSlides[_SelectSlideOptionsNumMedleySongs].Clear(); if (CSongs.IsInCategory) { - for (int i = 1; i <= CSongs.VisibleSongs.Length; i++) + for (int i = 1; i <= CSongs.VisibleSongs.Count; i++) _SelectSlides[_SelectSlideOptionsNumMedleySongs].AddValue(i.ToString()); } else { - for (int i = 1; i <= CSongs.AllSongs.Length; i++) + for (int i = 1; i <= CSongs.AllSongs.Count; i++) _SelectSlides[_SelectSlideOptionsNumMedleySongs].AddValue(i.ToString()); } if (_SelectSlides[_SelectSlideOptionsNumMedleySongs].NumValues >= 5) diff --git a/Vocaluxe/SongQueue/CSongQueue.cs b/Vocaluxe/SongQueue/CSongQueue.cs index 62a3814c..eb32c0e5 100644 --- a/Vocaluxe/SongQueue/CSongQueue.cs +++ b/Vocaluxe/SongQueue/CSongQueue.cs @@ -60,12 +60,12 @@ namespace Vocaluxe.SongQueue public bool AddVisibleSong(int visibleIndex, EGameMode gameMode) { - return CSongs.VisibleSongs.Length > visibleIndex && _AddSong(CSongs.VisibleSongs[visibleIndex].ID, gameMode); + return CSongs.VisibleSongs.Count > visibleIndex && _AddSong(CSongs.VisibleSongs[visibleIndex].ID, gameMode); } public bool AddSong(int absoluteIndex, EGameMode gameMode) { - return CSongs.AllSongs.Length > absoluteIndex && _AddSong(CSongs.AllSongs[absoluteIndex].ID, gameMode); + return CSongs.AllSongs.Count > absoluteIndex && _AddSong(CSongs.AllSongs[absoluteIndex].ID, gameMode); } private bool _AddSong(int songID, EGameMode gameMode) @@ -79,12 +79,12 @@ namespace Vocaluxe.SongQueue public bool RemoveVisibleSong(int visibleIndex) { - return CSongs.VisibleSongs.Length > visibleIndex && _RemoveSong(CSongs.VisibleSongs[visibleIndex].ID); + return CSongs.VisibleSongs.Count > visibleIndex && _RemoveSong(CSongs.VisibleSongs[visibleIndex].ID); } public bool RemoveSong(int absoluteIndex) { - return CSongs.AllSongs.Length > absoluteIndex && _RemoveSong(CSongs.AllSongs[absoluteIndex].ID); + return CSongs.AllSongs.Count > absoluteIndex && _RemoveSong(CSongs.AllSongs[absoluteIndex].ID); } private bool _RemoveSong(int songID) diff --git a/VocaluxeLib/Menu/IMenu.cs b/VocaluxeLib/Menu/IMenu.cs index 38af4ff1..979328e2 100644 --- a/VocaluxeLib/Menu/IMenu.cs +++ b/VocaluxeLib/Menu/IMenu.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Drawing; using VocaluxeLib.Menu.SongMenu; using VocaluxeLib.PartyModes; @@ -240,7 +241,7 @@ namespace VocaluxeLib.Menu public interface ISongs { int GetNumSongs(); - int GetNumVisibleSongs(); + int GetNumSongsVisible(); int GetNumCategories(); int NumSongsInCategory(int categoryIndex); @@ -253,13 +254,11 @@ namespace VocaluxeLib.Menu CSong GetVisibleSong(int visibleIndex); CSong GetSongByID(int songID); - CSong[] GetSongs(); - CSong[] GetSongsNotSung(); + ReadOnlyCollection GetVisibleSongs(); CCategory GetCategory(int index); void AddPartySongSung(int songID); - void ResetPartySongSung(); - void ResetPartySongSung(int catIndex); + void ResetSongSung(int catIndex = -1); void SortSongs(ESongSorting sorting, EOffOn tabs, EOffOn ignoreArticles, String searchString, EDuetOptions duetOptions); diff --git a/VocaluxeLib/Menu/SongMenu/CSong.cs b/VocaluxeLib/Menu/SongMenu/CSong.cs index e4396d48..c3598585 100644 --- a/VocaluxeLib/Menu/SongMenu/CSong.cs +++ b/VocaluxeLib/Menu/SongMenu/CSong.cs @@ -26,6 +26,19 @@ using VocaluxeLib.Menu.SingNotes; namespace VocaluxeLib.Menu.SongMenu { + public class CSongPointer + { + public readonly int SongID; + public string SortString; + public bool IsSung; + + public CSongPointer(int id, string sortString) + { + SongID = id; + SortString = sortString; + } + } + [Flags] enum EHeaderFlags { @@ -40,58 +53,11 @@ namespace VocaluxeLib.Menu.SongMenu public enum EMedleySource { - None, + None = 0, Calculated, Tag } - public class CCategory - { - public readonly string Name; - private STexture _CoverTextureSmall = new STexture(-1); - private STexture _CoverTextureBig = new STexture(-1); - private bool _CoverBigLoaded; - - public CCategory(string name) - { - Name = name; - } - - public STexture CoverTextureSmall - { - get { return _CoverTextureSmall; } - - set { _CoverTextureSmall = value; } - } - - public STexture CoverTextureBig - { - get { return _CoverBigLoaded ? _CoverTextureBig : _CoverTextureSmall; } - set - { - if (value.Index != -1) - { - _CoverTextureBig = value; - _CoverBigLoaded = true; - } - } - } - - public CCategory(string name, STexture coverSmall, STexture coverBig) - { - Name = name; - CoverTextureSmall = coverSmall; - CoverTextureBig = coverBig; - } - - public CCategory(CCategory cat) - { - Name = cat.Name; - CoverTextureSmall = cat.CoverTextureSmall; - CoverTextureBig = cat.CoverTextureBig; - } - } - public struct SMedley { public EMedleySource Source; @@ -99,17 +65,6 @@ namespace VocaluxeLib.Menu.SongMenu public int EndBeat; public float FadeInTime; public float FadeOutTime; - - // ReSharper disable UnusedParameter.Local - public SMedley(int dummy) - // ReSharper restore UnusedParameter.Local - { - Source = EMedleySource.None; - StartBeat = 0; - EndBeat = 0; - FadeInTime = 0f; - FadeOutTime = 0f; - } } public class CSong @@ -119,7 +74,7 @@ namespace VocaluxeLib.Menu.SongMenu private STexture _CoverTextureSmall = new STexture(-1); private STexture _CoverTextureBig = new STexture(-1); - public SMedley Medley = new SMedley(0); + public SMedley Medley; public bool CalculateMedley = true; public float PreviewStart; @@ -159,10 +114,7 @@ namespace VocaluxeLib.Menu.SongMenu public STexture CoverTextureBig { - get - { - return _CoverBigLoaded ? _CoverTextureBig : _CoverTextureSmall; - } + get { return _CoverBigLoaded ? _CoverTextureBig : _CoverTextureSmall; } set { _CoverTextureBig = value; diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenu.cs b/VocaluxeLib/Menu/SongMenu/CSongMenu.cs index d70f4393..b4c3f32a 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenu.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenu.cs @@ -35,12 +35,6 @@ namespace VocaluxeLib.Menu.SongMenu _CreateSongMenu(); } - public void UpdateSongMenuType() - { - if (_Type != CBase.Config.GetSongMenuType()) - _CreateSongMenu(); - } - public bool Selected { get { return _SongMenu.IsSelected(); } diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs index 77d3f50b..e3329358 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs @@ -252,8 +252,6 @@ namespace VocaluxeLib.Menu.SongMenu StaticMedleyTagIcon = new CStatic(_PartyModeID) } }; - - _ThemeLoaded = false; } public string GetThemeName() @@ -598,7 +596,7 @@ namespace VocaluxeLib.Menu.SongMenu protected void _SelectSong(int nr) { - if (CBase.Songs.GetCurrentCategoryIndex() >= 0 && (CBase.Songs.GetNumVisibleSongs() > 0) && (nr >= 0) && ((_Actsong != nr) || (_Streams.Count == 0))) + if (CBase.Songs.GetCurrentCategoryIndex() >= 0 && (CBase.Songs.GetNumSongsVisible() > 0) && (nr >= 0) && ((_Actsong != nr) || (_Streams.Count == 0))) { _Streams.ForEach(soundStream => CBase.Sound.FadeAndStop(soundStream, 0f, 1f)); _Streams.Clear(); @@ -609,7 +607,7 @@ namespace VocaluxeLib.Menu.SongMenu CBase.Drawing.RemoveTexture(ref _Vidtex); _Actsong = nr; - if (_Actsong >= CBase.Songs.GetNumVisibleSongs()) + if (_Actsong >= CBase.Songs.GetNumSongsVisible()) _Actsong = 0; diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs index 6a81f68e..35932a34 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs @@ -138,7 +138,6 @@ namespace VocaluxeLib.Menu.SongMenu //AfterCategoryChange(); SetSelectedSong(_ActSong); _AfterCategoryChange(); - CBase.Songs.UpdateRandomSongList(); int actcat = _PreviewSelected; if ((CBase.Songs.GetNumCategories() > 0) && (actcat < 0)) @@ -155,7 +154,7 @@ namespace VocaluxeLib.Menu.SongMenu _MedleyTagIcon.Visible = false; } - if (CBase.Songs.GetNumVisibleSongs() == 0 && CBase.Songs.GetSearchFilter() != "") + if (CBase.Songs.GetNumSongsVisible() == 0 && CBase.Songs.GetSearchFilter() != "") { _CoverBig.Texture = _CoverBigTexture; _Artist.Text = String.Empty; @@ -253,7 +252,7 @@ namespace VocaluxeLib.Menu.SongMenu } else { - if (CBase.Songs.GetCurrentCategoryIndex() != -1 && _Locked < CBase.Songs.GetNumVisibleSongs() - 1 && !songOptions.Selection.RandomOnly) + if (CBase.Songs.GetCurrentCategoryIndex() != -1 && _Locked < CBase.Songs.GetNumSongsVisible() - 1 && !songOptions.Selection.RandomOnly) { _Locked++; _UpdateList(); @@ -291,7 +290,7 @@ namespace VocaluxeLib.Menu.SongMenu _UpdateList(); } } - else if (_Locked < CBase.Songs.GetNumVisibleSongs() - _NumW && !songOptions.Selection.RandomOnly) + else if (_Locked < CBase.Songs.GetNumSongsVisible() - _NumW && !songOptions.Selection.RandomOnly) { _Locked += _NumW; _UpdateList(); @@ -403,7 +402,7 @@ namespace VocaluxeLib.Menu.SongMenu if (CBase.Songs.GetCurrentCategoryIndex() >= 0) { int actsong = _PreviewSelected; - if ((CBase.Songs.GetNumVisibleSongs() > actsong) && (actsong >= 0)) + if ((CBase.Songs.GetNumSongsVisible() > actsong) && (actsong >= 0)) { CSong song = CBase.Songs.GetVisibleSong(actsong); @@ -529,7 +528,7 @@ namespace VocaluxeLib.Menu.SongMenu { base.SetSelectedSong(visibleSongNr); - if (visibleSongNr >= 0 && visibleSongNr < CBase.Songs.GetNumVisibleSongs()) + if (visibleSongNr >= 0 && visibleSongNr < CBase.Songs.GetNumSongsVisible()) _SetSelectedTile(visibleSongNr); } @@ -592,11 +591,11 @@ namespace VocaluxeLib.Menu.SongMenu if (_ActualSelection >= 0 && _ActualSelection < _Tiles.Count) _Tiles[_ActualSelection].Selected = true; - if ((_LastKnownNumSongs == CBase.Songs.GetNumVisibleSongs()) && (_LastKnownCategory == CBase.Songs.GetCurrentCategoryIndex())) + if ((_LastKnownNumSongs == CBase.Songs.GetNumSongsVisible()) && (_LastKnownCategory == CBase.Songs.GetCurrentCategoryIndex())) return; _LastKnownCategory = CBase.Songs.GetCurrentCategoryIndex(); - _LastKnownNumSongs = CBase.Songs.GetNumVisibleSongs(); + _LastKnownNumSongs = CBase.Songs.GetNumSongsVisible(); _UpdateList(0, true); CBase.Songs.UpdateRandomSongList(); } @@ -609,7 +608,7 @@ namespace VocaluxeLib.Menu.SongMenu private void _UpdateList(int offset, bool force = false) { bool isInCategory = CBase.Songs.GetCurrentCategoryIndex() >= 0; - int itemCount = isInCategory ? CBase.Songs.GetNumVisibleSongs() : CBase.Songs.GetNumCategories(); + int itemCount = isInCategory ? CBase.Songs.GetNumSongsVisible() : CBase.Songs.GetNumCategories(); if (offset >= (itemCount / _NumW) * _NumW - (_NumW * (_NumH - 1))) offset = (itemCount / _NumW) * _NumW - (_NumW * (_NumH - 1)); diff --git a/VocaluxeLib/VocaluxeLib.csproj b/VocaluxeLib/VocaluxeLib.csproj index e9d4bd1e..2c437927 100644 --- a/VocaluxeLib/VocaluxeLib.csproj +++ b/VocaluxeLib/VocaluxeLib.csproj @@ -137,6 +137,7 @@ +