From aabfc72af5da6ae5d8f265622c4b710600851b92 Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Wed, 19 Dec 2012 21:15:58 +0100 Subject: [PATCH] added duet filter --- PartyModeChallenge/PartyModeChallenge.cs | 1 + Vocaluxe/Base/CSongs.cs | 30 ++++++++++++++++-------- Vocaluxe/Screens/CScreenSong.cs | 4 ++-- VocaluxeLib/PartyModes/CPartyModeNone.cs | 1 + VocaluxeLib/PartyModes/IPartyMode.cs | 1 + 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/PartyModeChallenge/PartyModeChallenge.cs b/PartyModeChallenge/PartyModeChallenge.cs index 9743c5ec..e38fb9f9 100644 --- a/PartyModeChallenge/PartyModeChallenge.cs +++ b/PartyModeChallenge/PartyModeChallenge.cs @@ -149,6 +149,7 @@ namespace Vocaluxe.PartyModes _ScreenSongOptions.Sorting.SearchString = String.Empty; _ScreenSongOptions.Sorting.SearchStringVisible = false; + _ScreenSongOptions.Sorting.ShowDuetSongs = false; _Stage = EStage.NotStarted; diff --git a/Vocaluxe/Base/CSongs.cs b/Vocaluxe/Base/CSongs.cs index 905262e9..c4f84cd4 100644 --- a/Vocaluxe/Base/CSongs.cs +++ b/Vocaluxe/Base/CSongs.cs @@ -51,6 +51,7 @@ namespace Vocaluxe.Base private static EOffOn _Tabs = CConfig.Tabs; private static EOffOn _IgnoreArticles = CConfig.IgnoreArticles; private static ESongSorting _SongSorting = CConfig.SongSorting; + private static bool _ShowDuetSongs = true; private static Thread _CoverLoaderThread = new Thread(new ThreadStart(_LoadCover)); @@ -61,11 +62,11 @@ namespace Vocaluxe.Base { if (value.Length > 0) { - _Sort(_SongSorting, EOffOn.TR_CONFIG_OFF, _IgnoreArticles, value, false); + _Sort(_SongSorting, EOffOn.TR_CONFIG_OFF, _IgnoreArticles, value, false, _ShowDuetSongs); } else { - _Sort(_SongSorting, _Tabs, _IgnoreArticles, value, false); + _Sort(_SongSorting, _Tabs, _IgnoreArticles, value, false, _ShowDuetSongs); } } } @@ -324,15 +325,20 @@ namespace Vocaluxe.Base public static void Sort(ESongSorting Sorting, EOffOn Tabs, EOffOn IgnoreArticles, String SearchString) { - _Sort(Sorting, Tabs, IgnoreArticles, SearchString, false); + _Sort(Sorting, Tabs, IgnoreArticles, SearchString, false, _ShowDuetSongs); } - private static void _Sort(ESongSorting Sorting, EOffOn Tabs, EOffOn IgnoreArticles, string SearchString, bool force) + public static void Sort(ESongSorting Sorting, EOffOn Tabs, EOffOn IgnoreArticles, String SearchString, bool ShowDuetSongs) + { + _Sort(Sorting, Tabs, IgnoreArticles, SearchString, false, ShowDuetSongs); + } + + private static void _Sort(ESongSorting Sorting, EOffOn Tabs, EOffOn IgnoreArticles, string SearchString, bool force, bool ShowDuetSongs) { if (_Songs.Count == 0) return; - if (!force && Sorting == _SongSorting && Tabs == _Tabs && IgnoreArticles == _IgnoreArticles && SearchString == _SearchFilter) + if (!force && Sorting == _SongSorting && Tabs == _Tabs && IgnoreArticles == _IgnoreArticles && SearchString == _SearchFilter && ShowDuetSongs == _ShowDuetSongs) return; //nothing to do _Categories.Clear(); @@ -341,6 +347,7 @@ namespace Vocaluxe.Base _IgnoreArticles = IgnoreArticles; _SongSorting = Sorting; _Tabs = Tabs; + _ShowDuetSongs = ShowDuetSongs; _SearchFilter = SearchString; @@ -349,12 +356,15 @@ namespace Vocaluxe.Base foreach (CSong song in _Songs) { - if (_SearchFilter == String.Empty) - _SongList.Add(song); - else + if (!song.IsDuet || _ShowDuetSongs) { - if (song.Title.ToUpper().Contains(_SearchFilter.ToUpper()) || song.Artist.ToUpper().Contains(_SearchFilter.ToUpper())) + if (_SearchFilter == String.Empty) _SongList.Add(song); + else + { + if (song.Title.ToUpper().Contains(_SearchFilter.ToUpper()) || song.Artist.ToUpper().Contains(_SearchFilter.ToUpper())) + _SongList.Add(song); + } } } @@ -955,7 +965,7 @@ namespace Vocaluxe.Base CLog.StopBenchmark(2, "Read TXTs"); CLog.StartBenchmark(2, "Sort Songs"); - _Sort(CConfig.SongSorting, CConfig.Tabs, CConfig.IgnoreArticles, String.Empty, true); + _Sort(CConfig.SongSorting, CConfig.Tabs, CConfig.IgnoreArticles, String.Empty, true, true); CLog.StopBenchmark(2, "Sort Songs"); Category = -1; _SongsLoaded = true; diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 54fe8db8..43c21b97 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -615,7 +615,7 @@ namespace Vocaluxe.Screens base.OnShow(); _sso = CParty.GetSongSelectionOptions(); - CSongs.Sort(_sso.Sorting.SongSorting, _sso.Sorting.Tabs, _sso.Sorting.IgnoreArticles, _sso.Sorting.SearchString); + CSongs.Sort(_sso.Sorting.SongSorting, _sso.Sorting.Tabs, _sso.Sorting.IgnoreArticles, _sso.Sorting.SearchString, _sso.Sorting.ShowDuetSongs); _SearchActive = _sso.Sorting.SearchStringVisible; _SearchText = _sso.Sorting.SearchString; @@ -644,7 +644,7 @@ namespace Vocaluxe.Screens public override bool UpdateGame() { _sso = CParty.GetSongSelectionOptions(); - CSongs.Sort(_sso.Sorting.SongSorting, _sso.Sorting.Tabs, _sso.Sorting.IgnoreArticles, _sso.Sorting.SearchString); + CSongs.Sort(_sso.Sorting.SongSorting, _sso.Sorting.Tabs, _sso.Sorting.IgnoreArticles, _sso.Sorting.SearchString, _sso.Sorting.ShowDuetSongs); _SearchActive = _sso.Sorting.SearchStringVisible; _SearchText = _sso.Sorting.SearchString; diff --git a/VocaluxeLib/PartyModes/CPartyModeNone.cs b/VocaluxeLib/PartyModes/CPartyModeNone.cs index e78a06c9..3fbff589 100644 --- a/VocaluxeLib/PartyModes/CPartyModeNone.cs +++ b/VocaluxeLib/PartyModes/CPartyModeNone.cs @@ -19,6 +19,7 @@ namespace Vocaluxe.PartyModes _ScreenSongOptions.Sorting.SearchString = String.Empty; _ScreenSongOptions.Sorting.SearchStringVisible = false; + _ScreenSongOptions.Sorting.ShowDuetSongs = true; } public override ScreenSongOptions GetScreenSongOptions() diff --git a/VocaluxeLib/PartyModes/IPartyMode.cs b/VocaluxeLib/PartyModes/IPartyMode.cs index 524271f9..94efc342 100644 --- a/VocaluxeLib/PartyModes/IPartyMode.cs +++ b/VocaluxeLib/PartyModes/IPartyMode.cs @@ -20,6 +20,7 @@ namespace Vocaluxe.PartyModes public EOffOn IgnoreArticles; public string SearchString; public bool SearchStringVisible; + public bool ShowDuetSongs; } ///