diff --git a/Vocaluxe/Base/CParty.cs b/Vocaluxe/Base/CParty.cs new file mode 100644 index 00000000..5b478f0d --- /dev/null +++ b/Vocaluxe/Base/CParty.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using Vocaluxe.Menu; +using Vocaluxe.PartyModes; + +namespace Vocaluxe.Base +{ + static class CParty + { + private static List _PartyModes; + private static int _CurrentModeNr; + + public static int NumModes + { + get { return _PartyModes.Count - 1; } //first mode is the dummy normal game mode + } + + public static void Init() + { + _PartyModes = new List(); + + //add dummy normal game mode + _PartyModes.Add(new CPartyModeNone()); + + _CurrentModeNr = 0; + } + + public static void SetNormalGameMode() + { + _CurrentModeNr = 0; + } + + public static EScreens GetStartScreen() + { + return _PartyModes[_CurrentModeNr].GetStartScreen(); + } + + public static EScreens GetMainScreen() + { + return _PartyModes[_CurrentModeNr].GetMainScreen(); + } + + public static ScreenSongOptions GetSongSelectionOptions() + { + return _PartyModes[_CurrentModeNr].GetScreenSongOptions(); + } + + public static void SetSearchString(string SearchString, bool Visible) + { + _PartyModes[_CurrentModeNr].SetSearchString(SearchString, Visible); + } + } +} diff --git a/Vocaluxe/Base/CSongs.cs b/Vocaluxe/Base/CSongs.cs index 72f9732c..45c14e9d 100644 --- a/Vocaluxe/Base/CSongs.cs +++ b/Vocaluxe/Base/CSongs.cs @@ -72,14 +72,13 @@ namespace Vocaluxe.Base get { return _SearchFilter; } set { - _SearchFilter = value; - if (_SearchFilter.Length > 0) + if (value.Length > 0) { - _Sort(_SongSorting, EOffOn.TR_CONFIG_OFF, _IgnoreArticles, _SearchFilter); + _Sort(_SongSorting, EOffOn.TR_CONFIG_OFF, _IgnoreArticles, value, false); } else { - _Sort(_SongSorting, _Tabs, _IgnoreArticles, _SearchFilter); + _Sort(_SongSorting, _Tabs, _IgnoreArticles, value, false); } } } @@ -336,29 +335,19 @@ namespace Vocaluxe.Base get { return _Categories.ToArray(); } } - /* - public static void Sort() + public static void Sort(ESongSorting Sorting, EOffOn Tabs, EOffOn IgnoreArticles, String SearchString) { - _Sort(_SongSorting, _Tabs, _IgnoreArticles, String.Empty); + _Sort(Sorting, Tabs, IgnoreArticles, SearchString, false); } - public static void Sort(ESongSorting sorting) - { - _SongSorting = sorting; - _Sort(_SongSorting, _Tabs, _IgnoreArticles, String.Empty); - } - * */ - - public static void Sort(ESongSorting Sorting, EOffOn Tabs, EOffOn IgnoreArticles) - { - _Sort(Sorting, _Tabs, IgnoreArticles, String.Empty); - } - - private static void _Sort(ESongSorting Sorting, EOffOn Tabs, EOffOn IgnoreArticles, string SearchString) + private static void _Sort(ESongSorting Sorting, EOffOn Tabs, EOffOn IgnoreArticles, string SearchString, bool force) { if (_Songs.Count == 0) return; + if (!force && Sorting == _SongSorting && Tabs == _Tabs && IgnoreArticles == _IgnoreArticles && SearchString == _SearchFilter) + return; //nothing to do + _Categories.Clear(); string category = String.Empty; @@ -366,16 +355,18 @@ namespace Vocaluxe.Base _SongSorting = Sorting; _Tabs = Tabs; + _SearchFilter = SearchString; + List _SortList = new List(); List _SongList = new List(); foreach (CSong song in _Songs) { - if (SearchString == String.Empty) + if (_SearchFilter == String.Empty) _SongList.Add(song); else { - if (song.Title.ToUpper().Contains(SearchString.ToUpper()) || song.Artist.ToUpper().Contains(SearchString.ToUpper())) + if (song.Title.ToUpper().Contains(_SearchFilter.ToUpper()) || song.Artist.ToUpper().Contains(_SearchFilter.ToUpper())) _SongList.Add(song); } } @@ -977,7 +968,7 @@ namespace Vocaluxe.Base CLog.StopBenchmark(2, "Read TXTs"); CLog.StartBenchmark(2, "Sort Songs"); - _Sort(CConfig.SongSorting, CConfig.Tabs, CConfig.IgnoreArticles, String.Empty); + _Sort(CConfig.SongSorting, CConfig.Tabs, CConfig.IgnoreArticles, String.Empty, true); CLog.StopBenchmark(2, "Sort Songs"); Category = -1; _SongsLoaded = true; diff --git a/Vocaluxe/PartyModes/CPartyMode.cs b/Vocaluxe/PartyModes/CPartyMode.cs new file mode 100644 index 00000000..0c64369f --- /dev/null +++ b/Vocaluxe/PartyModes/CPartyMode.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using Vocaluxe.Menu; + +namespace Vocaluxe.PartyModes +{ + abstract class CPartyMode : IPartyMode + { + #region Implementation + public virtual void Init() + { + } + + public virtual EScreens GetStartScreen() + { + return EScreens.ScreenSong; + } + + public virtual EScreens GetMainScreen() + { + return EScreens.ScreenSong; + } + + public virtual ScreenSongOptions GetScreenSongOptions() + { + return new ScreenSongOptions(); + } + + public virtual void SetSearchString(string SearchString, bool Visible) + { + } + #endregion Implementation + } +} diff --git a/Vocaluxe/PartyModes/CPartyModeNone.cs b/Vocaluxe/PartyModes/CPartyModeNone.cs new file mode 100644 index 00000000..5e3e20cd --- /dev/null +++ b/Vocaluxe/PartyModes/CPartyModeNone.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using Vocaluxe.Base; + +namespace Vocaluxe.PartyModes +{ + class CPartyModeNone : CPartyMode + { + //just a dummy for normal game mode + private ScreenSongOptions _ScreenSongOptions; + + public CPartyModeNone() + { + _ScreenSongOptions = new ScreenSongOptions(); + _ScreenSongOptions.SongSelection = new SongSelectionOptions(); + _ScreenSongOptions.SongSorting = new SongSortingOptions(); + + _ScreenSongOptions.SongSelection.RandomOnly = false; + _ScreenSongOptions.SongSelection.NumJokers = 0; + _ScreenSongOptions.SongSelection.NumTeams = 0; + + _ScreenSongOptions.SongSorting.SearchString = String.Empty; + _ScreenSongOptions.SongSorting.SearchStringVisible = false; + } + + public override ScreenSongOptions GetScreenSongOptions() + { + _ScreenSongOptions.SongSorting.SongSorting = CConfig.SongSorting; + _ScreenSongOptions.SongSorting.Tabs = CConfig.Tabs; + _ScreenSongOptions.SongSorting.IgnoreArticles = CConfig.IgnoreArticles; + + return _ScreenSongOptions; + } + + public override void SetSearchString(string SearchString, bool Visible) + { + _ScreenSongOptions.SongSorting.SearchString = SearchString; + _ScreenSongOptions.SongSorting.SearchStringVisible = Visible; + } + } +} diff --git a/Vocaluxe/PartyModes/IPartyMode.cs b/Vocaluxe/PartyModes/IPartyMode.cs new file mode 100644 index 00000000..d9dda2f4 --- /dev/null +++ b/Vocaluxe/PartyModes/IPartyMode.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using Vocaluxe.Base; +using Vocaluxe.Menu; + +namespace Vocaluxe.PartyModes +{ + #region Structs + public struct ScreenSongOptions + { + public SongSortingOptions SongSorting; + public SongSelectionOptions SongSelection; + } + + public struct SongSortingOptions + { + public ESongSorting SongSorting; + public EOffOn Tabs; + public EOffOn IgnoreArticles; + public string SearchString; + public bool SearchStringVisible; + } + + public struct SongSelectionOptions + { + public bool RandomOnly; + public int NumJokers; + public int NumTeams; + } + #endregion Structs + + interface IPartyMode + { + void Init(); + + EScreens GetStartScreen(); + EScreens GetMainScreen(); + ScreenSongOptions GetScreenSongOptions(); + + void SetSearchString(string SearchString, bool Visible); + } +} diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs index 92d59f0b..90e583d8 100644 --- a/Vocaluxe/Program.cs +++ b/Vocaluxe/Program.cs @@ -154,6 +154,11 @@ namespace Vocaluxe CLog.StartBenchmark(0, "Init Game"); CGame.Init(); CLog.StopBenchmark(0, "Init Game"); + + // Init Party Modes; + CLog.StartBenchmark(0, "Init Party Modes"); + CParty.Init(); + CLog.StopBenchmark(0, "Init Party Modes"); } catch (Exception e) { diff --git a/Vocaluxe/Screens/CScreenMain.cs b/Vocaluxe/Screens/CScreenMain.cs index 1ff107ce..4dea3cfb 100644 --- a/Vocaluxe/Screens/CScreenMain.cs +++ b/Vocaluxe/Screens/CScreenMain.cs @@ -76,7 +76,10 @@ namespace Vocaluxe.Screens case Keys.Enter: if (Buttons[htButtons(ButtonSing)].Selected) + { + CParty.SetNormalGameMode(); CGraphics.FadeTo(EScreens.ScreenSong); + } if (Buttons[htButtons(ButtonParty)].Selected) CGraphics.FadeTo(EScreens.ScreenParty); @@ -103,7 +106,10 @@ namespace Vocaluxe.Screens if (MouseEvent.LB && IsMouseOver(MouseEvent)) { if (Buttons[htButtons(ButtonSing)].Selected) + { + CParty.SetNormalGameMode(); CGraphics.FadeTo(EScreens.ScreenSong); + } if (Buttons[htButtons(ButtonParty)].Selected) CGraphics.FadeTo(EScreens.ScreenParty); diff --git a/Vocaluxe/Screens/CScreenOptions.cs b/Vocaluxe/Screens/CScreenOptions.cs index 851919bf..e3353ee2 100644 --- a/Vocaluxe/Screens/CScreenOptions.cs +++ b/Vocaluxe/Screens/CScreenOptions.cs @@ -53,6 +53,7 @@ namespace Vocaluxe.Screens break; case Keys.S: + CParty.SetNormalGameMode(); CGraphics.FadeTo(EScreens.ScreenSong); break; diff --git a/Vocaluxe/Screens/CScreenOptionsGame.cs b/Vocaluxe/Screens/CScreenOptionsGame.cs index 13c3e8f4..96acb672 100644 --- a/Vocaluxe/Screens/CScreenOptionsGame.cs +++ b/Vocaluxe/Screens/CScreenOptionsGame.cs @@ -89,6 +89,7 @@ namespace Vocaluxe.Screens break; case Keys.S: + CParty.SetNormalGameMode(); CGraphics.FadeTo(EScreens.ScreenSong); break; @@ -166,11 +167,15 @@ namespace Vocaluxe.Screens if (_SongSortingOld != CConfig.SongSorting || _TabsOld != CConfig.Tabs || _LanguageOld != CConfig.Language) { - CSongs.Sort(CConfig.SongSorting, CConfig.Tabs, CConfig.IgnoreArticles); + CSongs.Sort(CConfig.SongSorting, CConfig.Tabs, CConfig.IgnoreArticles, String.Empty); CSongs.Category = -1; } CLanguage.SetLanguage(CConfig.Language); + + _SongSortingOld = CConfig.SongSorting; + _TabsOld = CConfig.Tabs; + _LanguageOld = CConfig.Language; } } } diff --git a/Vocaluxe/Screens/CScreenOptionsLyrics.cs b/Vocaluxe/Screens/CScreenOptionsLyrics.cs index 6224f0fa..c6574c31 100644 --- a/Vocaluxe/Screens/CScreenOptionsLyrics.cs +++ b/Vocaluxe/Screens/CScreenOptionsLyrics.cs @@ -60,6 +60,7 @@ namespace Vocaluxe.Screens break; case Keys.S: + CParty.SetNormalGameMode(); CGraphics.FadeTo(EScreens.ScreenSong); break; diff --git a/Vocaluxe/Screens/CScreenOptionsRecord.cs b/Vocaluxe/Screens/CScreenOptionsRecord.cs index c4566428..7c0dae2d 100644 --- a/Vocaluxe/Screens/CScreenOptionsRecord.cs +++ b/Vocaluxe/Screens/CScreenOptionsRecord.cs @@ -133,6 +133,7 @@ namespace Vocaluxe.Screens break; case Keys.S: + CParty.SetNormalGameMode(); CGraphics.FadeTo(EScreens.ScreenSong); break; diff --git a/Vocaluxe/Screens/CScreenOptionsSound.cs b/Vocaluxe/Screens/CScreenOptionsSound.cs index 519fddfc..ca4a7a86 100644 --- a/Vocaluxe/Screens/CScreenOptionsSound.cs +++ b/Vocaluxe/Screens/CScreenOptionsSound.cs @@ -75,6 +75,7 @@ namespace Vocaluxe.Screens break; case Keys.S: + CParty.SetNormalGameMode(); CGraphics.FadeTo(EScreens.ScreenSong); break; diff --git a/Vocaluxe/Screens/CScreenOptionsTheme.cs b/Vocaluxe/Screens/CScreenOptionsTheme.cs index 60aa6653..a8862dd7 100644 --- a/Vocaluxe/Screens/CScreenOptionsTheme.cs +++ b/Vocaluxe/Screens/CScreenOptionsTheme.cs @@ -91,6 +91,11 @@ namespace Vocaluxe.Screens Close(); break; + case Keys.S: + CParty.SetNormalGameMode(); + CGraphics.FadeTo(EScreens.ScreenSong); + break; + case Keys.Enter: if (Buttons[htButtons(ButtonExit)].Selected) { @@ -174,7 +179,7 @@ namespace Vocaluxe.Screens if (_OldCoverTheme != SelectSlides[htSelectSlides(SelectSlideCover)].Selection) { CCover.ReloadCover(); - CSongs.Sort(CConfig.SongSorting, CConfig.Tabs, CConfig.IgnoreArticles); + CSongs.Sort(CConfig.SongSorting, CConfig.Tabs, CConfig.IgnoreArticles, String.Empty); } if (_OldTheme != SelectSlides[htSelectSlides(SelectSlideTheme)].Selection) diff --git a/Vocaluxe/Screens/CScreenOptionsVideo.cs b/Vocaluxe/Screens/CScreenOptionsVideo.cs index 3e15a258..fa5f5f1f 100644 --- a/Vocaluxe/Screens/CScreenOptionsVideo.cs +++ b/Vocaluxe/Screens/CScreenOptionsVideo.cs @@ -77,6 +77,7 @@ namespace Vocaluxe.Screens break; case Keys.S: + CParty.SetNormalGameMode(); CGraphics.FadeTo(EScreens.ScreenSong); break; diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 3544bae7..56d703c9 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -12,6 +12,7 @@ using Vocaluxe.Lib.Draw; using Vocaluxe.Lib.Song; using Vocaluxe.Menu; using Vocaluxe.Menu.SongMenu; +using Vocaluxe.PartyModes; namespace Vocaluxe.Screens { @@ -58,6 +59,7 @@ namespace Vocaluxe.Screens private bool _SongOptionsActive = false; private bool _PlaylistActive = false; private List _AvailableGameModes; + private ScreenSongOptions _sso; private CStatic DragAndDropCover; private bool DragAndDropActive; @@ -529,6 +531,12 @@ namespace Vocaluxe.Screens public override void OnShow() { base.OnShow(); + + _sso = CParty.GetSongSelectionOptions(); + CSongs.Sort(_sso.SongSorting.SongSorting, _sso.SongSorting.Tabs, _sso.SongSorting.IgnoreArticles, _sso.SongSorting.SearchString); + _SearchActive = _sso.SongSorting.SearchStringVisible; + _SearchText = _sso.SongSorting.SearchString; + CGame.EnterNormalGame(); SongMenus[htSongMenus(SongMenu)].OnShow(); SongMenus[htSongMenus(SongMenu)].SetActive(!_PlaylistActive); @@ -602,6 +610,8 @@ namespace Vocaluxe.Screens base.OnClose(); CBackgroundMusic.Disabled = false; SongMenus[htSongMenus(SongMenu)].OnHide(); + + CParty.SetSearchString(_SearchText, _SearchActive); } public override void ApplyVolume() diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj index a2f3d82a..18fd9697 100644 --- a/Vocaluxe/Vocaluxe.csproj +++ b/Vocaluxe/Vocaluxe.csproj @@ -180,6 +180,7 @@ + @@ -249,6 +250,9 @@ + + + Form