added PartyModes classes

This commit is contained in:
Alexander Eckart committed 2012-12-10 21:55:27 +01:00
1 parent 2d0387fb71
commit a73a371dfc
16 files changed
+234 -25

No files matched your search

+55
View File
@@ -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<IPartyMode> _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<IPartyMode>();
//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);
}
}
}
+14 -23
View File
@@ -72,14 +72,13 @@ namespace Vocaluxe.Base
get { return _SearchFilter; } get { return _SearchFilter; }
set set
{ {
_SearchFilter = value; if (value.Length > 0)
if (_SearchFilter.Length > 0)
{ {
_Sort(_SongSorting, EOffOn.TR_CONFIG_OFF, _IgnoreArticles, _SearchFilter); _Sort(_SongSorting, EOffOn.TR_CONFIG_OFF, _IgnoreArticles, value, false);
} }
else else
{ {
_Sort(_SongSorting, _Tabs, _IgnoreArticles, _SearchFilter); _Sort(_SongSorting, _Tabs, _IgnoreArticles, value, false);
} }
} }
} }
@@ -336,29 +335,19 @@ namespace Vocaluxe.Base
get { return _Categories.ToArray(); } get { return _Categories.ToArray(); }
} }
/* public static void Sort(ESongSorting Sorting, EOffOn Tabs, EOffOn IgnoreArticles, String SearchString)
public static void Sort()
{ {
_Sort(_SongSorting, _Tabs, _IgnoreArticles, String.Empty); _Sort(Sorting, Tabs, IgnoreArticles, SearchString, false);
} }
public static void Sort(ESongSorting sorting) private static void _Sort(ESongSorting Sorting, EOffOn Tabs, EOffOn IgnoreArticles, string SearchString, bool force)
{
_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)
{ {
if (_Songs.Count == 0) if (_Songs.Count == 0)
return; return;
if (!force && Sorting == _SongSorting && Tabs == _Tabs && IgnoreArticles == _IgnoreArticles && SearchString == _SearchFilter)
return; //nothing to do
_Categories.Clear(); _Categories.Clear();
string category = String.Empty; string category = String.Empty;
@@ -366,16 +355,18 @@ namespace Vocaluxe.Base
_SongSorting = Sorting; _SongSorting = Sorting;
_Tabs = Tabs; _Tabs = Tabs;
_SearchFilter = SearchString;
List<SongPointer> _SortList = new List<SongPointer>(); List<SongPointer> _SortList = new List<SongPointer>();
List<CSong> _SongList = new List<CSong>(); List<CSong> _SongList = new List<CSong>();
foreach (CSong song in _Songs) foreach (CSong song in _Songs)
{ {
if (SearchString == String.Empty) if (_SearchFilter == String.Empty)
_SongList.Add(song); _SongList.Add(song);
else 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); _SongList.Add(song);
} }
} }
@@ -977,7 +968,7 @@ namespace Vocaluxe.Base
CLog.StopBenchmark(2, "Read TXTs"); CLog.StopBenchmark(2, "Read TXTs");
CLog.StartBenchmark(2, "Sort Songs"); 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"); CLog.StopBenchmark(2, "Sort Songs");
Category = -1; Category = -1;
_SongsLoaded = true; _SongsLoaded = true;
+36
View File
@@ -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
}
}
+43
View File
@@ -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;
}
}
}
+44
View File
@@ -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);
}
}
+5
View File
@@ -154,6 +154,11 @@ namespace Vocaluxe
CLog.StartBenchmark(0, "Init Game"); CLog.StartBenchmark(0, "Init Game");
CGame.Init(); CGame.Init();
CLog.StopBenchmark(0, "Init Game"); 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) catch (Exception e)
{ {
+6
View File
@@ -76,7 +76,10 @@ namespace Vocaluxe.Screens
case Keys.Enter: case Keys.Enter:
if (Buttons[htButtons(ButtonSing)].Selected) if (Buttons[htButtons(ButtonSing)].Selected)
{
CParty.SetNormalGameMode();
CGraphics.FadeTo(EScreens.ScreenSong); CGraphics.FadeTo(EScreens.ScreenSong);
}
if (Buttons[htButtons(ButtonParty)].Selected) if (Buttons[htButtons(ButtonParty)].Selected)
CGraphics.FadeTo(EScreens.ScreenParty); CGraphics.FadeTo(EScreens.ScreenParty);
@@ -103,7 +106,10 @@ namespace Vocaluxe.Screens
if (MouseEvent.LB && IsMouseOver(MouseEvent)) if (MouseEvent.LB && IsMouseOver(MouseEvent))
{ {
if (Buttons[htButtons(ButtonSing)].Selected) if (Buttons[htButtons(ButtonSing)].Selected)
{
CParty.SetNormalGameMode();
CGraphics.FadeTo(EScreens.ScreenSong); CGraphics.FadeTo(EScreens.ScreenSong);
}
if (Buttons[htButtons(ButtonParty)].Selected) if (Buttons[htButtons(ButtonParty)].Selected)
CGraphics.FadeTo(EScreens.ScreenParty); CGraphics.FadeTo(EScreens.ScreenParty);
+1
View File
@@ -53,6 +53,7 @@ namespace Vocaluxe.Screens
break; break;
case Keys.S: case Keys.S:
CParty.SetNormalGameMode();
CGraphics.FadeTo(EScreens.ScreenSong); CGraphics.FadeTo(EScreens.ScreenSong);
break; break;
+6 -1
View File
@@ -89,6 +89,7 @@ namespace Vocaluxe.Screens
break; break;
case Keys.S: case Keys.S:
CParty.SetNormalGameMode();
CGraphics.FadeTo(EScreens.ScreenSong); CGraphics.FadeTo(EScreens.ScreenSong);
break; break;
@@ -166,11 +167,15 @@ namespace Vocaluxe.Screens
if (_SongSortingOld != CConfig.SongSorting || _TabsOld != CConfig.Tabs || _LanguageOld != CConfig.Language) 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; CSongs.Category = -1;
} }
CLanguage.SetLanguage(CConfig.Language); CLanguage.SetLanguage(CConfig.Language);
_SongSortingOld = CConfig.SongSorting;
_TabsOld = CConfig.Tabs;
_LanguageOld = CConfig.Language;
} }
} }
} }
+1
View File
@@ -60,6 +60,7 @@ namespace Vocaluxe.Screens
break; break;
case Keys.S: case Keys.S:
CParty.SetNormalGameMode();
CGraphics.FadeTo(EScreens.ScreenSong); CGraphics.FadeTo(EScreens.ScreenSong);
break; break;
+1
View File
@@ -133,6 +133,7 @@ namespace Vocaluxe.Screens
break; break;
case Keys.S: case Keys.S:
CParty.SetNormalGameMode();
CGraphics.FadeTo(EScreens.ScreenSong); CGraphics.FadeTo(EScreens.ScreenSong);
break; break;
+1
View File
@@ -75,6 +75,7 @@ namespace Vocaluxe.Screens
break; break;
case Keys.S: case Keys.S:
CParty.SetNormalGameMode();
CGraphics.FadeTo(EScreens.ScreenSong); CGraphics.FadeTo(EScreens.ScreenSong);
break; break;
+6 -1
View File
@@ -91,6 +91,11 @@ namespace Vocaluxe.Screens
Close(); Close();
break; break;
case Keys.S:
CParty.SetNormalGameMode();
CGraphics.FadeTo(EScreens.ScreenSong);
break;
case Keys.Enter: case Keys.Enter:
if (Buttons[htButtons(ButtonExit)].Selected) if (Buttons[htButtons(ButtonExit)].Selected)
{ {
@@ -174,7 +179,7 @@ namespace Vocaluxe.Screens
if (_OldCoverTheme != SelectSlides[htSelectSlides(SelectSlideCover)].Selection) if (_OldCoverTheme != SelectSlides[htSelectSlides(SelectSlideCover)].Selection)
{ {
CCover.ReloadCover(); 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) if (_OldTheme != SelectSlides[htSelectSlides(SelectSlideTheme)].Selection)
+1
View File
@@ -77,6 +77,7 @@ namespace Vocaluxe.Screens
break; break;
case Keys.S: case Keys.S:
CParty.SetNormalGameMode();
CGraphics.FadeTo(EScreens.ScreenSong); CGraphics.FadeTo(EScreens.ScreenSong);
break; break;
+10
View File
@@ -12,6 +12,7 @@ using Vocaluxe.Lib.Draw;
using Vocaluxe.Lib.Song; using Vocaluxe.Lib.Song;
using Vocaluxe.Menu; using Vocaluxe.Menu;
using Vocaluxe.Menu.SongMenu; using Vocaluxe.Menu.SongMenu;
using Vocaluxe.PartyModes;
namespace Vocaluxe.Screens namespace Vocaluxe.Screens
{ {
@@ -58,6 +59,7 @@ namespace Vocaluxe.Screens
private bool _SongOptionsActive = false; private bool _SongOptionsActive = false;
private bool _PlaylistActive = false; private bool _PlaylistActive = false;
private List<GameModes.EGameMode> _AvailableGameModes; private List<GameModes.EGameMode> _AvailableGameModes;
private ScreenSongOptions _sso;
private CStatic DragAndDropCover; private CStatic DragAndDropCover;
private bool DragAndDropActive; private bool DragAndDropActive;
@@ -529,6 +531,12 @@ namespace Vocaluxe.Screens
public override void OnShow() public override void OnShow()
{ {
base.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(); CGame.EnterNormalGame();
SongMenus[htSongMenus(SongMenu)].OnShow(); SongMenus[htSongMenus(SongMenu)].OnShow();
SongMenus[htSongMenus(SongMenu)].SetActive(!_PlaylistActive); SongMenus[htSongMenus(SongMenu)].SetActive(!_PlaylistActive);
@@ -602,6 +610,8 @@ namespace Vocaluxe.Screens
base.OnClose(); base.OnClose();
CBackgroundMusic.Disabled = false; CBackgroundMusic.Disabled = false;
SongMenus[htSongMenus(SongMenu)].OnHide(); SongMenus[htSongMenus(SongMenu)].OnHide();
CParty.SetSearchString(_SearchText, _SearchActive);
} }
public override void ApplyVolume() public override void ApplyVolume()
+4
View File
@@ -180,6 +180,7 @@
<Compile Include="Base\CInput.cs" /> <Compile Include="Base\CInput.cs" />
<Compile Include="Base\CLanguage.cs" /> <Compile Include="Base\CLanguage.cs" />
<Compile Include="Base\CLog.cs" /> <Compile Include="Base\CLog.cs" />
<Compile Include="Base\CParty.cs" />
<Compile Include="Base\CPlaylists.cs" /> <Compile Include="Base\CPlaylists.cs" />
<Compile Include="Base\CProfiles.cs" /> <Compile Include="Base\CProfiles.cs" />
<Compile Include="Base\CUtility.cs" /> <Compile Include="Base\CUtility.cs" />
@@ -249,6 +250,9 @@
<Compile Include="Menu\SongMenu\CSongMenuList.cs" /> <Compile Include="Menu\SongMenu\CSongMenuList.cs" />
<Compile Include="Menu\SongMenu\CSongMenuTileBoard.cs" /> <Compile Include="Menu\SongMenu\CSongMenuTileBoard.cs" />
<Compile Include="Menu\SongMenu\ISongMenu.cs" /> <Compile Include="Menu\SongMenu\ISongMenu.cs" />
<Compile Include="PartyModes\CPartyMode.cs" />
<Compile Include="PartyModes\CPartyModeNone.cs" />
<Compile Include="PartyModes\IPartyMode.cs" />
<Compile Include="Program.cs"> <Compile Include="Program.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>