From d356d08846b53ba2826d7ef68b3559768804496a Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Mon, 10 Dec 2012 18:47:35 +0100 Subject: [PATCH 001/110] new branch for party mode - separated some config values from song sorting --- Vocaluxe/Base/CSongs.cs | 53 ++++++++++++++++--------- Vocaluxe/Screens/CScreenOptionsGame.cs | 2 +- Vocaluxe/Screens/CScreenOptionsTheme.cs | 2 +- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/Vocaluxe/Base/CSongs.cs b/Vocaluxe/Base/CSongs.cs index 147e1c01..72f9732c 100644 --- a/Vocaluxe/Base/CSongs.cs +++ b/Vocaluxe/Base/CSongs.cs @@ -62,6 +62,8 @@ namespace Vocaluxe.Base private static string _SearchFilter = String.Empty; private static EOffOn _Tabs = CConfig.Tabs; + private static EOffOn _IgnoreArticles = CConfig.IgnoreArticles; + private static ESongSorting _SongSorting = CConfig.SongSorting; private static Thread _CoverLoaderThread = new Thread(new ThreadStart(_LoadCover)); @@ -73,11 +75,11 @@ namespace Vocaluxe.Base _SearchFilter = value; if (_SearchFilter.Length > 0) { - _Sort(CConfig.SongSorting, EOffOn.TR_CONFIG_OFF, _SearchFilter); + _Sort(_SongSorting, EOffOn.TR_CONFIG_OFF, _IgnoreArticles, _SearchFilter); } else { - Sort(); + _Sort(_SongSorting, _Tabs, _IgnoreArticles, _SearchFilter); } } } @@ -87,6 +89,11 @@ namespace Vocaluxe.Base get { return _Tabs; } } + public static EOffOn IgnoreArticles + { + get { return _IgnoreArticles; } + } + public static bool SongsLoaded { get { return _SongsLoaded; } @@ -329,17 +336,25 @@ namespace Vocaluxe.Base get { return _Categories.ToArray(); } } + /* public static void Sort() { - _Sort(CConfig.SongSorting, CConfig.Tabs, String.Empty); + _Sort(_SongSorting, _Tabs, _IgnoreArticles, String.Empty); } public static void Sort(ESongSorting sorting) { - _Sort(sorting, CConfig.Tabs, String.Empty); + _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, string SearchString) + private static void _Sort(ESongSorting Sorting, EOffOn Tabs, EOffOn IgnoreArticles, string SearchString) { if (_Songs.Count == 0) return; @@ -347,6 +362,8 @@ namespace Vocaluxe.Base _Categories.Clear(); string category = String.Empty; + _IgnoreArticles = IgnoreArticles; + _SongSorting = Sorting; _Tabs = Tabs; List _SortList = new List(); @@ -363,7 +380,7 @@ namespace Vocaluxe.Base } } - switch (sorting) + switch (_SongSorting) { case ESongSorting.TR_CONFIG_EDITION: foreach (CSong song in _SongList) @@ -384,7 +401,7 @@ namespace Vocaluxe.Base int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper()); if (res == 0) { - if (CConfig.IgnoreArticles == EOffOn.TR_CONFIG_ON) + if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) { res = _Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(_Songs[s2.SongID].ArtistSorting.ToUpper()); if (res == 0) @@ -450,7 +467,7 @@ namespace Vocaluxe.Base int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper()); if (res == 0) { - if (CConfig.IgnoreArticles == EOffOn.TR_CONFIG_ON) + if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) { res = _Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(_Songs[s2.SongID].ArtistSorting.ToUpper()); if (res == 0) @@ -535,7 +552,7 @@ namespace Vocaluxe.Base int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper()); if (res == 0) { - if (CConfig.IgnoreArticles == EOffOn.TR_CONFIG_ON) + if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) { res = _Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(_Songs[s2.SongID].ArtistSorting.ToUpper()); if (res == 0) @@ -578,7 +595,7 @@ namespace Vocaluxe.Base _SortList.Sort(delegate(SongPointer s1, SongPointer s2) { - if (CConfig.IgnoreArticles == EOffOn.TR_CONFIG_ON) + if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) { int res = _Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(_Songs[s2.SongID].ArtistSorting.ToUpper()); if (res == 0) @@ -614,7 +631,7 @@ namespace Vocaluxe.Base case ESongSorting.TR_CONFIG_ARTIST_LETTER: foreach (CSong song in _SongList) { - if (CConfig.IgnoreArticles == EOffOn.TR_CONFIG_ON) + if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) _SortList.Add(new SongPointer(song.ID, song.ArtistSorting)); else _SortList.Add(new SongPointer(song.ID, song.Artist)); @@ -625,7 +642,7 @@ namespace Vocaluxe.Base int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper()); if (res == 0) { - if (CConfig.IgnoreArticles == EOffOn.TR_CONFIG_ON) + if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) { return _Songs[s1.SongID].TitleSorting.ToUpper().CompareTo(_Songs[s2.SongID].TitleSorting.ToUpper()); } @@ -672,7 +689,7 @@ namespace Vocaluxe.Base case ESongSorting.TR_CONFIG_TITLE_LETTER: foreach (CSong song in _SongList) { - if (CConfig.IgnoreArticles == EOffOn.TR_CONFIG_ON) + if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) _SortList.Add(new SongPointer(song.ID, song.TitleSorting)); else _SortList.Add(new SongPointer(song.ID, song.Title)); @@ -683,7 +700,7 @@ namespace Vocaluxe.Base int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper()); if (res == 0) { - if (CConfig.IgnoreArticles == EOffOn.TR_CONFIG_ON) + if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) { return _Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(_Songs[s2.SongID].ArtistSorting.ToUpper()); } @@ -738,7 +755,7 @@ namespace Vocaluxe.Base int res = s1.SortString.CompareTo(s2.SortString); if (res == 0) { - if (CConfig.IgnoreArticles == EOffOn.TR_CONFIG_ON) + if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) { res = _Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(_Songs[s2.SongID].ArtistSorting.ToUpper()); if (res == 0) @@ -797,7 +814,7 @@ namespace Vocaluxe.Base int res = s1.SortString.CompareTo(s2.SortString); if (res == 0) { - if (CConfig.IgnoreArticles == EOffOn.TR_CONFIG_ON) + if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) { res = _Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(_Songs[s2.SongID].ArtistSorting.ToUpper()); if (res == 0) @@ -863,7 +880,7 @@ namespace Vocaluxe.Base int res = s1.SortString.CompareTo(s2.SortString); if (res == 0) { - if (CConfig.IgnoreArticles == EOffOn.TR_CONFIG_ON) + if (_IgnoreArticles == EOffOn.TR_CONFIG_ON) { res = _Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(_Songs[s2.SongID].ArtistSorting.ToUpper()); if (res == 0) @@ -960,7 +977,7 @@ namespace Vocaluxe.Base CLog.StopBenchmark(2, "Read TXTs"); CLog.StartBenchmark(2, "Sort Songs"); - Sort(CConfig.SongSorting); + _Sort(CConfig.SongSorting, CConfig.Tabs, CConfig.IgnoreArticles, String.Empty); CLog.StopBenchmark(2, "Sort Songs"); Category = -1; _SongsLoaded = true; diff --git a/Vocaluxe/Screens/CScreenOptionsGame.cs b/Vocaluxe/Screens/CScreenOptionsGame.cs index be4224ea..13c3e8f4 100644 --- a/Vocaluxe/Screens/CScreenOptionsGame.cs +++ b/Vocaluxe/Screens/CScreenOptionsGame.cs @@ -166,7 +166,7 @@ namespace Vocaluxe.Screens if (_SongSortingOld != CConfig.SongSorting || _TabsOld != CConfig.Tabs || _LanguageOld != CConfig.Language) { - CSongs.Sort(CConfig.SongSorting); + CSongs.Sort(CConfig.SongSorting, CConfig.Tabs, CConfig.IgnoreArticles); CSongs.Category = -1; } diff --git a/Vocaluxe/Screens/CScreenOptionsTheme.cs b/Vocaluxe/Screens/CScreenOptionsTheme.cs index 7250b268..60aa6653 100644 --- a/Vocaluxe/Screens/CScreenOptionsTheme.cs +++ b/Vocaluxe/Screens/CScreenOptionsTheme.cs @@ -174,7 +174,7 @@ namespace Vocaluxe.Screens if (_OldCoverTheme != SelectSlides[htSelectSlides(SelectSlideCover)].Selection) { CCover.ReloadCover(); - CSongs.Sort(CConfig.SongSorting); + CSongs.Sort(CConfig.SongSorting, CConfig.Tabs, CConfig.IgnoreArticles); } if (_OldTheme != SelectSlides[htSelectSlides(SelectSlideTheme)].Selection) From 2d0387fb719030e85d95efdda79ea67dc136f1b2 Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Mon, 10 Dec 2012 20:01:41 +0100 Subject: [PATCH 002/110] added party selection screen --- Output/Languages/Deutsch.xml | 3 + Output/Languages/English.xml | 3 + Output/Languages/French.xml | 3 + Output/Languages/Spanish.xml | 3 + Output/Themes/Ambient/Screens/ScreenMain.xml | 57 +++++++++ Output/Themes/Ambient/Screens/ScreenParty.xml | 119 ++++++++++++++++++ Vocaluxe/Menu/CGraphics.cs | 3 +- Vocaluxe/Screens/CScreenMain.cs | 9 +- Vocaluxe/Screens/CScreenParty.cs | 104 +++++++++++++++ Vocaluxe/Vocaluxe.csproj | 1 + 10 files changed, 303 insertions(+), 2 deletions(-) create mode 100644 Output/Themes/Ambient/Screens/ScreenParty.xml create mode 100644 Vocaluxe/Screens/CScreenParty.cs diff --git a/Output/Languages/Deutsch.xml b/Output/Languages/Deutsch.xml index 98c84333..535fc040 100644 --- a/Output/Languages/Deutsch.xml +++ b/Output/Languages/Deutsch.xml @@ -103,8 +103,11 @@ Hauptmenü Singen + Party Optionen Profile + + Party-Modus Auswahl Spielerauswahl Spieler diff --git a/Output/Languages/English.xml b/Output/Languages/English.xml index c07c4636..a6e01df6 100644 --- a/Output/Languages/English.xml +++ b/Output/Languages/English.xml @@ -103,8 +103,11 @@ Main Menu Sing + Party Options Profiles + + Party Mode Selection Player Selection Player diff --git a/Output/Languages/French.xml b/Output/Languages/French.xml index c4a7f455..bdcb6150 100644 --- a/Output/Languages/French.xml +++ b/Output/Languages/French.xml @@ -103,8 +103,11 @@ Menu Principal Chanter + TODO: Party Options Profils + + TODO: Party Mode Selection Sélection des joueurs Joueur diff --git a/Output/Languages/Spanish.xml b/Output/Languages/Spanish.xml index 12adb00e..219c18f3 100644 --- a/Output/Languages/Spanish.xml +++ b/Output/Languages/Spanish.xml @@ -97,8 +97,11 @@ Menú Principal Cantar + TODO: Party Opciones Perfiles + + TODO: Party Mode Selection Selección de Jugadores Jugador diff --git a/Output/Themes/Ambient/Screens/ScreenMain.xml b/Output/Themes/Ambient/Screens/ScreenMain.xml index 71116b93..cff309a2 100644 --- a/Output/Themes/Ambient/Screens/ScreenMain.xml +++ b/Output/Themes/Ambient/Screens/ScreenMain.xml @@ -86,6 +86,63 @@ 26 + + + Button + + Button + + 355 + 600 + 0,00 + 150 + 50 + + + ButtonColor + + + ButtonSColor + + + 75 + 10 + + 32 + + 142 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + TR_SCREENMAIN_BUTTON_PARTY + + + + + + 10 + 26 + + + + + + 10 + 26 + + Button diff --git a/Output/Themes/Ambient/Screens/ScreenParty.xml b/Output/Themes/Ambient/Screens/ScreenParty.xml new file mode 100644 index 00000000..d39aed15 --- /dev/null +++ b/Output/Themes/Ambient/Screens/ScreenParty.xml @@ -0,0 +1,119 @@ + + + + 1 + + + Video + + + + BG_Default + + + BackgroundColor + + + + Menu + + 40 + 40 + 0,00 + 1200 + 50 + + + StaticColor + + + + + + + 640 + 48 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Center + + Center + + + + Outline + + TR_SCREENPARTY_TITLE + + + + + + + Button + + Button + + 985 + 600 + 0,00 + 150 + 50 + + + ButtonColor + + + ButtonSColor + + + 75 + 10 + + 32 + + 142 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + TR_BUTTON_EXIT + + + + + + 10 + 26 + + + + + + 10 + 26 + + + + \ No newline at end of file diff --git a/Vocaluxe/Menu/CGraphics.cs b/Vocaluxe/Menu/CGraphics.cs index 75b8b52e..d9f220ae 100644 --- a/Vocaluxe/Menu/CGraphics.cs +++ b/Vocaluxe/Menu/CGraphics.cs @@ -31,8 +31,8 @@ namespace Vocaluxe.Menu ScreenOptionsTheme = 14, ScreenNames = 15, - ScreenCredits = 16, + ScreenParty = 17, ScreenNull = -1 } @@ -244,6 +244,7 @@ namespace Vocaluxe.Menu _Screens.Add(new CScreenOptionsTheme()); _Screens.Add(new CScreenNames()); _Screens.Add(new CScreenCredits()); + _Screens.Add(new CScreenParty()); _PopupScreens.Add(new CPopupScreenPlayerControl()); _PopupScreens.Add(new CPopupScreenVolumeControl()); diff --git a/Vocaluxe/Screens/CScreenMain.cs b/Vocaluxe/Screens/CScreenMain.cs index 76dd28c0..1ff107ce 100644 --- a/Vocaluxe/Screens/CScreenMain.cs +++ b/Vocaluxe/Screens/CScreenMain.cs @@ -19,6 +19,7 @@ namespace Vocaluxe.Screens const int ScreenVersion = 1; const string ButtonSing = "ButtonSing"; + const string ButtonParty = "ButtonParty"; const string ButtonOptions = "ButtonOptions"; const string ButtonProfiles = "ButtonProfiles"; const string ButtonExit = "ButtonExit"; @@ -37,7 +38,7 @@ namespace Vocaluxe.Screens _ThemeName = "ScreenMain"; _ScreenVersion = ScreenVersion; _ThemeStatics = new string[] { "StaticMenuBar" }; - _ThemeButtons = new string[] { ButtonSing, ButtonOptions, ButtonProfiles, ButtonExit }; + _ThemeButtons = new string[] { ButtonSing, ButtonParty, ButtonOptions, ButtonProfiles, ButtonExit }; } public override void LoadTheme() @@ -77,6 +78,9 @@ namespace Vocaluxe.Screens if (Buttons[htButtons(ButtonSing)].Selected) CGraphics.FadeTo(EScreens.ScreenSong); + if (Buttons[htButtons(ButtonParty)].Selected) + CGraphics.FadeTo(EScreens.ScreenParty); + if (Buttons[htButtons(ButtonOptions)].Selected) CGraphics.FadeTo(EScreens.ScreenOptions); @@ -101,6 +105,9 @@ namespace Vocaluxe.Screens if (Buttons[htButtons(ButtonSing)].Selected) CGraphics.FadeTo(EScreens.ScreenSong); + if (Buttons[htButtons(ButtonParty)].Selected) + CGraphics.FadeTo(EScreens.ScreenParty); + if (Buttons[htButtons(ButtonOptions)].Selected) CGraphics.FadeTo(EScreens.ScreenOptions); diff --git a/Vocaluxe/Screens/CScreenParty.cs b/Vocaluxe/Screens/CScreenParty.cs new file mode 100644 index 00000000..0d397743 --- /dev/null +++ b/Vocaluxe/Screens/CScreenParty.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; + +using Vocaluxe.Base; +using Vocaluxe.Menu; + +namespace Vocaluxe.Screens +{ + class CScreenParty : CMenu + {// Version number for theme files. Increment it, if you've changed something on the theme files! + const int ScreenVersion = 1; + + const string ButtonExit = "ButtonExit"; + + public CScreenParty() + { + Init(); + } + + protected override void Init() + { + base.Init(); + + _ThemeName = "ScreenParty"; + _ScreenVersion = ScreenVersion; + _ThemeButtons = new string[] { ButtonExit }; + } + + public override void LoadTheme() + { + base.LoadTheme(); + } + + public override bool HandleInput(KeyEvent KeyEvent) + { + base.HandleInput(KeyEvent); + + if (KeyEvent.KeyPressed) + { + + } + else + { + switch (KeyEvent.Key) + { + case Keys.Back: + case Keys.Escape: + CGraphics.FadeTo(EScreens.ScreenMain); + break; + + case Keys.Enter: + if (Buttons[htButtons(ButtonExit)].Selected) + CGraphics.FadeTo(EScreens.ScreenMain); + break; + } + } + return true; + } + + public override bool HandleMouse(MouseEvent MouseEvent) + { + base.HandleMouse(MouseEvent); + + if (MouseEvent.LB && IsMouseOver(MouseEvent)) + { + + if (Buttons[htButtons(ButtonExit)].Selected) + CGraphics.FadeTo(EScreens.ScreenMain); + } + + if (MouseEvent.RB) + { + CGraphics.FadeTo(EScreens.ScreenMain); + } + + return true; + } + + public override void OnShow() + { + base.OnShow(); + } + + public override bool UpdateGame() + { + return true; + } + + public override bool Draw() + { + base.DrawBG(); + base.DrawFG(); + + return true; + } + + public override void OnClose() + { + base.OnClose(); + } + } +} diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj index 35339243..a2f3d82a 100644 --- a/Vocaluxe/Vocaluxe.csproj +++ b/Vocaluxe/Vocaluxe.csproj @@ -262,6 +262,7 @@ + From a73a371dfc24835097c76543bc984ecca2edd246 Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Mon, 10 Dec 2012 21:55:27 +0100 Subject: [PATCH 003/110] added PartyModes classes --- Vocaluxe/Base/CParty.cs | 55 ++++++++++++++++++++++++ Vocaluxe/Base/CSongs.cs | 37 ++++++---------- Vocaluxe/PartyModes/CPartyMode.cs | 36 ++++++++++++++++ Vocaluxe/PartyModes/CPartyModeNone.cs | 43 ++++++++++++++++++ Vocaluxe/PartyModes/IPartyMode.cs | 44 +++++++++++++++++++ Vocaluxe/Program.cs | 5 +++ Vocaluxe/Screens/CScreenMain.cs | 6 +++ Vocaluxe/Screens/CScreenOptions.cs | 1 + Vocaluxe/Screens/CScreenOptionsGame.cs | 7 ++- Vocaluxe/Screens/CScreenOptionsLyrics.cs | 1 + Vocaluxe/Screens/CScreenOptionsRecord.cs | 1 + Vocaluxe/Screens/CScreenOptionsSound.cs | 1 + Vocaluxe/Screens/CScreenOptionsTheme.cs | 7 ++- Vocaluxe/Screens/CScreenOptionsVideo.cs | 1 + Vocaluxe/Screens/CScreenSong.cs | 10 +++++ Vocaluxe/Vocaluxe.csproj | 4 ++ 16 files changed, 234 insertions(+), 25 deletions(-) create mode 100644 Vocaluxe/Base/CParty.cs create mode 100644 Vocaluxe/PartyModes/CPartyMode.cs create mode 100644 Vocaluxe/PartyModes/CPartyModeNone.cs create mode 100644 Vocaluxe/PartyModes/IPartyMode.cs 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 From 7ae8b32348fe5c2a59575ca3991a8df2660a5f11 Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Mon, 10 Dec 2012 23:11:28 +0100 Subject: [PATCH 004/110] prepared ScreenSong for party mode (it is not finished yet) --- Vocaluxe/Menu/SongMenu/CSongMenu.cs | 9 +-- Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs | 5 +- Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs | 69 +++++++++++--------- Vocaluxe/Menu/SongMenu/ISongMenu.cs | 5 +- Vocaluxe/PartyModes/CPartyModeNone.cs | 25 +++---- Vocaluxe/PartyModes/IPartyMode.cs | 9 +-- Vocaluxe/Screens/CScreenSong.cs | 58 +++++++++++----- 7 files changed, 107 insertions(+), 73 deletions(-) diff --git a/Vocaluxe/Menu/SongMenu/CSongMenu.cs b/Vocaluxe/Menu/SongMenu/CSongMenu.cs index 3163d783..dbb09697 100644 --- a/Vocaluxe/Menu/SongMenu/CSongMenu.cs +++ b/Vocaluxe/Menu/SongMenu/CSongMenu.cs @@ -6,6 +6,7 @@ using System.Xml.XPath; using Vocaluxe.Base; using Vocaluxe.Lib.Draw; +using Vocaluxe.PartyModes; namespace Vocaluxe.Menu.SongMenu { @@ -58,14 +59,14 @@ namespace Vocaluxe.Menu.SongMenu _SongMenu.OnHide(); } - public void HandleInput(ref KeyEvent KeyEvent) + public void HandleInput(ref KeyEvent KeyEvent, ScreenSongOptions SongOptions) { - _SongMenu.HandleInput(ref KeyEvent); + _SongMenu.HandleInput(ref KeyEvent, SongOptions); } - public void HandleMouse(ref MouseEvent MouseEvent) + public void HandleMouse(ref MouseEvent MouseEvent, ScreenSongOptions SongOptions) { - _SongMenu.HandleMouse(ref MouseEvent); + _SongMenu.HandleMouse(ref MouseEvent, SongOptions); } public void Draw() diff --git a/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs b/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs index 7f29d380..deaa6f5c 100644 --- a/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs +++ b/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs @@ -8,6 +8,7 @@ using System.Xml.XPath; using Vocaluxe.Base; using Vocaluxe.Lib.Draw; +using Vocaluxe.PartyModes; namespace Vocaluxe.Menu.SongMenu { @@ -488,13 +489,13 @@ namespace Vocaluxe.Menu.SongMenu _SelectedInternal = _SelectedPending; } - public virtual void HandleInput(ref KeyEvent KeyEvent) + public virtual void HandleInput(ref KeyEvent KeyEvent, ScreenSongOptions SongOptions) { if (!_Initialized) return; } - public virtual void HandleMouse(ref MouseEvent MouseEvent) + public virtual void HandleMouse(ref MouseEvent MouseEvent, ScreenSongOptions SongOptions) { if (!_Initialized) return; diff --git a/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs b/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs index e0342575..69d6f642 100644 --- a/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs @@ -7,6 +7,7 @@ using System.Windows.Forms; using Vocaluxe.Base; using Vocaluxe.Lib.Draw; using Vocaluxe.Lib.Song; +using Vocaluxe.PartyModes; namespace Vocaluxe.Menu.SongMenu { @@ -140,9 +141,9 @@ namespace Vocaluxe.Menu.SongMenu } } - public override void HandleInput(ref KeyEvent KeyEvent) + public override void HandleInput(ref KeyEvent KeyEvent, ScreenSongOptions SongOptions) { - base.HandleInput(ref KeyEvent); + base.HandleInput(ref KeyEvent, SongOptions); if (KeyEvent.KeyPressed) { @@ -225,7 +226,7 @@ namespace Vocaluxe.Menu.SongMenu break; case Keys.Left: - if (_Locked > 0) + if (_Locked > 0 && !SongOptions.Selection.RandomOnly && !SongOptions.Selection.RandomOnly) { _Locked--; if (CSongs.Category < 0 && _Locked < CSongs.NumCategories - _NumW || @@ -247,7 +248,7 @@ namespace Vocaluxe.Menu.SongMenu } else { - if (_Locked < CSongs.NumVisibleSongs - 1) + if (_Locked < CSongs.NumVisibleSongs - 1 && !SongOptions.Selection.RandomOnly) { _Locked++; if (_Locked < CSongs.NumVisibleSongs - _NumW) @@ -257,13 +258,13 @@ namespace Vocaluxe.Menu.SongMenu break; case Keys.Up: - if (KeyEvent.ModSHIFT && CSongs.Tabs == EOffOn.TR_CONFIG_ON) + if (KeyEvent.ModSHIFT && CSongs.Tabs == EOffOn.TR_CONFIG_ON && !SongOptions.Selection.RandomOnly) { PrevCategory(); break; } - - if (_Locked > _NumW - 1) + + if (_Locked > _NumW - 1 && (!SongOptions.Selection.RandomOnly || CSongs.Category < 0)) { _Locked -= _NumW; UpdateList((_Locked / _NumW) * _NumW - (_NumW * (_NumH - 2))); @@ -271,7 +272,7 @@ namespace Vocaluxe.Menu.SongMenu break; case Keys.Down: - if (KeyEvent.ModSHIFT && CSongs.Tabs == EOffOn.TR_CONFIG_ON) + if (KeyEvent.ModSHIFT && CSongs.Tabs == EOffOn.TR_CONFIG_ON && !SongOptions.Selection.RandomOnly) { NextCategory(); break; @@ -289,7 +290,7 @@ namespace Vocaluxe.Menu.SongMenu } else { - if (_Locked < CSongs.NumVisibleSongs - _NumW) + if (_Locked < CSongs.NumVisibleSongs - _NumW && !SongOptions.Selection.RandomOnly) { _Locked += _NumW; if (_Locked < CSongs.NumVisibleSongs - _NumW) @@ -314,37 +315,43 @@ namespace Vocaluxe.Menu.SongMenu } } - public override void HandleMouse(ref MouseEvent MouseEvent) + public override void HandleMouse(ref MouseEvent MouseEvent, ScreenSongOptions SongOptions) { - base.HandleMouse(ref MouseEvent); + base.HandleMouse(ref MouseEvent, SongOptions); int i = 0; bool sel = false; int lastselection = _actualSelection; - foreach (CStatic tile in _Tiles) + + if (!SongOptions.Selection.RandomOnly) { - if ((tile.Texture.index != _CoverTexture.index) && CHelper.IsInBounds(tile.Rect, MouseEvent) && !sel) + foreach (CStatic tile in _Tiles) { - if (MouseEvent.LB || CSongs.Category == -1) + if ((tile.Texture.index != _CoverTexture.index) && CHelper.IsInBounds(tile.Rect, MouseEvent) && !sel) { - if (_PreviewSelected == i + _Offset) - _Locked = _PreviewSelected; - else + if (MouseEvent.LB || CSongs.Category == -1) { - _PreviewSelected = i + _Offset; - _Locked = -1; + if (_PreviewSelected == i + _Offset) + _Locked = _PreviewSelected; + else + { + _PreviewSelected = i + _Offset; + _Locked = -1; + } } + tile.Selected = true; + _actualSelection = i + _Offset; + sel = true; } - tile.Selected = true; - _actualSelection = i + _Offset; - sel = true; + else + { + tile.Selected = false; + } + i++; } - else - { - tile.Selected = false; - } - i++; } + else + sel = true; if (MouseEvent.Sender == ESender.WiiMote && _actualSelection != lastselection && _actualSelection != -1) CInput.SetRumble(0.050f); @@ -357,11 +364,11 @@ namespace Vocaluxe.Menu.SongMenu ShowCategories(); return; } - else if (MouseEvent.RB && CSongs.Tabs == EOffOn.TR_CONFIG_OFF) + else if (MouseEvent.RB && CSongs.Tabs == EOffOn.TR_CONFIG_OFF && !SongOptions.Selection.PartyMode) { CGraphics.FadeTo(EScreens.ScreenMain); } - else if (_PreviewSelected != -1 && MouseEvent.LB && CSongs.Category != -1) + else if (_PreviewSelected != -1 && MouseEvent.LB && CSongs.Category != -1 && !SongOptions.Selection.PartyMode) { if (CHelper.IsInBounds(_CoverBig.Rect, MouseEvent) || CHelper.IsInBounds(_TextBG.Rect, MouseEvent)) { @@ -382,7 +389,7 @@ namespace Vocaluxe.Menu.SongMenu if (MouseEvent.Wheel > 0) { - if (CHelper.IsInBounds(_ScrollRect, MouseEvent)) + if (CHelper.IsInBounds(_ScrollRect, MouseEvent) && !SongOptions.Selection.PartyMode) { if (CSongs.Category >= 0 && CSongs.NumVisibleSongs > _Offset + _NumW * MouseEvent.Wheel + _NumW * (_NumH - 1) || CSongs.Category < 0 && CSongs.NumCategories > _Offset + _NumW * MouseEvent.Wheel + _NumW * (_NumH - 1)) @@ -395,7 +402,7 @@ namespace Vocaluxe.Menu.SongMenu if (MouseEvent.Wheel < 0) { - if (CHelper.IsInBounds(_ScrollRect, MouseEvent)) + if (CHelper.IsInBounds(_ScrollRect, MouseEvent) && !SongOptions.Selection.PartyMode) { _Offset += _NumW * MouseEvent.Wheel; if (_Offset < 0) diff --git a/Vocaluxe/Menu/SongMenu/ISongMenu.cs b/Vocaluxe/Menu/SongMenu/ISongMenu.cs index 21d0015a..8a63a8cb 100644 --- a/Vocaluxe/Menu/SongMenu/ISongMenu.cs +++ b/Vocaluxe/Menu/SongMenu/ISongMenu.cs @@ -4,6 +4,7 @@ using System.Text; using Vocaluxe.Base; using Vocaluxe.Lib.Draw; +using Vocaluxe.PartyModes; namespace Vocaluxe.Menu.SongMenu { @@ -13,8 +14,8 @@ namespace Vocaluxe.Menu.SongMenu void OnShow(); void OnHide(); - void HandleInput(ref KeyEvent KeyEvent); - void HandleMouse(ref MouseEvent MouseEvent); + void HandleInput(ref KeyEvent KeyEvent, ScreenSongOptions SongOptions); + void HandleMouse(ref MouseEvent MouseEvent, ScreenSongOptions SongOptions); void Draw(); void ApplyVolume(float VolumeMax); diff --git a/Vocaluxe/PartyModes/CPartyModeNone.cs b/Vocaluxe/PartyModes/CPartyModeNone.cs index 5e3e20cd..77e0fd09 100644 --- a/Vocaluxe/PartyModes/CPartyModeNone.cs +++ b/Vocaluxe/PartyModes/CPartyModeNone.cs @@ -14,30 +14,31 @@ namespace Vocaluxe.PartyModes public CPartyModeNone() { _ScreenSongOptions = new ScreenSongOptions(); - _ScreenSongOptions.SongSelection = new SongSelectionOptions(); - _ScreenSongOptions.SongSorting = new SongSortingOptions(); + _ScreenSongOptions.Selection = new SelectionOptions(); + _ScreenSongOptions.Sorting = new SortingOptions(); - _ScreenSongOptions.SongSelection.RandomOnly = false; - _ScreenSongOptions.SongSelection.NumJokers = 0; - _ScreenSongOptions.SongSelection.NumTeams = 0; + _ScreenSongOptions.Selection.RandomOnly = false; + _ScreenSongOptions.Selection.PartyMode = false; + _ScreenSongOptions.Selection.NumJokers = 0; + _ScreenSongOptions.Selection.NumTeams = 0; - _ScreenSongOptions.SongSorting.SearchString = String.Empty; - _ScreenSongOptions.SongSorting.SearchStringVisible = false; + _ScreenSongOptions.Sorting.SearchString = String.Empty; + _ScreenSongOptions.Sorting.SearchStringVisible = false; } public override ScreenSongOptions GetScreenSongOptions() { - _ScreenSongOptions.SongSorting.SongSorting = CConfig.SongSorting; - _ScreenSongOptions.SongSorting.Tabs = CConfig.Tabs; - _ScreenSongOptions.SongSorting.IgnoreArticles = CConfig.IgnoreArticles; + _ScreenSongOptions.Sorting.SongSorting = CConfig.SongSorting; + _ScreenSongOptions.Sorting.Tabs = CConfig.Tabs; + _ScreenSongOptions.Sorting.IgnoreArticles = CConfig.IgnoreArticles; return _ScreenSongOptions; } public override void SetSearchString(string SearchString, bool Visible) { - _ScreenSongOptions.SongSorting.SearchString = SearchString; - _ScreenSongOptions.SongSorting.SearchStringVisible = Visible; + _ScreenSongOptions.Sorting.SearchString = SearchString; + _ScreenSongOptions.Sorting.SearchStringVisible = Visible; } } } diff --git a/Vocaluxe/PartyModes/IPartyMode.cs b/Vocaluxe/PartyModes/IPartyMode.cs index d9dda2f4..5426a8bf 100644 --- a/Vocaluxe/PartyModes/IPartyMode.cs +++ b/Vocaluxe/PartyModes/IPartyMode.cs @@ -10,11 +10,11 @@ namespace Vocaluxe.PartyModes #region Structs public struct ScreenSongOptions { - public SongSortingOptions SongSorting; - public SongSelectionOptions SongSelection; + public SortingOptions Sorting; + public SelectionOptions Selection; } - public struct SongSortingOptions + public struct SortingOptions { public ESongSorting SongSorting; public EOffOn Tabs; @@ -23,9 +23,10 @@ namespace Vocaluxe.PartyModes public bool SearchStringVisible; } - public struct SongSelectionOptions + public struct SelectionOptions { public bool RandomOnly; + public bool PartyMode; public int NumJokers; public int NumTeams; } diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 56d703c9..b018626c 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -153,14 +153,14 @@ namespace Vocaluxe.Screens } else { - SongMenus[htSongMenus(SongMenu)].HandleInput(ref KeyEvent); + SongMenus[htSongMenus(SongMenu)].HandleInput(ref KeyEvent, _sso); if (KeyEvent.Handled) return true; switch (KeyEvent.Key) { case Keys.Escape: - if (CSongs.Category < 0 || CConfig.Tabs == EOffOn.TR_CONFIG_OFF) + if ((CSongs.Category < 0 || !(_sso.Sorting.Tabs == EOffOn.TR_CONFIG_OFF)) && !_sso.Selection.PartyMode) CGraphics.FadeTo(EScreens.ScreenMain); break; @@ -168,7 +168,12 @@ namespace Vocaluxe.Screens if (CSongs.NumVisibleSongs > 0) { if (SongMenus[htSongMenus(SongMenu)].GetSelectedSong() != -1 && !_SongOptionsActive) - ToggleSongOptions(ESongOptionsView.Song); + { + if (!_sso.Selection.PartyMode) + ToggleSongOptions(ESongOptionsView.Song); + else + HandlePartySongSelection(SongMenus[htSongMenus(SongMenu)].GetSelectedSong()); + } } break; @@ -187,13 +192,15 @@ namespace Vocaluxe.Screens ApplyNewSearchFilter(_SearchText.Remove(_SearchText.Length - 1)); } - if (!_SearchActive && CSongs.Category < 0) + if (!_SearchActive && (CSongs.Category < 0) && !_sso.Selection.PartyMode) + { CGraphics.FadeTo(EScreens.ScreenMain); + } break; case Keys.Space: - if (!_SearchActive) + if (!_SearchActive && !_sso.Selection.PartyMode) ToggleSongOptions(ESongOptionsView.General); break; @@ -204,7 +211,7 @@ namespace Vocaluxe.Screens _SearchText = String.Empty; ApplyNewSearchFilter(_SearchText); } - else + else if (!_sso.Selection.PartyMode) { _SearchActive = true; } @@ -212,11 +219,11 @@ namespace Vocaluxe.Screens //TODO: Delete it! ??? Shouldn't we keep this as shortcut? case Keys.A: - if (!_SearchActive && KeyEvent.Mod == EModifier.None) + if (!_SearchActive && KeyEvent.Mod == EModifier.None && !_sso.Selection.PartyMode) { StartRandomAllSongs(); } - if (KeyEvent.Mod == EModifier.Ctrl) + if (KeyEvent.Mod == EModifier.Ctrl && !_sso.Selection.PartyMode) { StartRandomVisibleSongs(); } @@ -232,7 +239,7 @@ namespace Vocaluxe.Screens _SearchText = String.Empty; ApplyNewSearchFilter(_SearchText); } - else + else if (!_sso.Selection.PartyMode) { _SearchActive = true; } @@ -253,7 +260,7 @@ namespace Vocaluxe.Screens //TODO: Delete that! case Keys.S: - if (!_SearchActive && CSongs.NumVisibleSongs > 0) + if (!_SearchActive && CSongs.NumVisibleSongs > 0 && !_sso.Selection.PartyMode) { StartMedleySong(SongMenus[htSongMenus(SongMenu)].GetSelectedSong()); } @@ -385,7 +392,7 @@ namespace Vocaluxe.Screens return true; } - if (CSongs.Category < 0) + if (CSongs.Category < 0 && !_sso.Selection.PartyMode) { CGraphics.FadeTo(EScreens.ScreenMain); return true; @@ -409,7 +416,7 @@ namespace Vocaluxe.Screens } } - if (MouseEvent.LD) + if (MouseEvent.LD && !_sso.Selection.PartyMode) { if (CSongs.NumVisibleSongs > 0 && SongMenus[htSongMenus(SongMenu)].GetActualSelection() != -1) { @@ -418,7 +425,7 @@ namespace Vocaluxe.Screens } } - SongMenus[htSongMenus(SongMenu)].HandleMouse(ref MouseEvent); + SongMenus[htSongMenus(SongMenu)].HandleMouse(ref MouseEvent, _sso); if (MouseEvent.LB) { @@ -494,7 +501,10 @@ namespace Vocaluxe.Screens { if (SongMenus[htSongMenus(SongMenu)].GetSelectedSong() != -1 && !_SongOptionsActive) { - ToggleSongOptions(ESongOptionsView.Song); + if (!_sso.Selection.PartyMode) + ToggleSongOptions(ESongOptionsView.Song); + else + HandlePartySongSelection(SongMenus[htSongMenus(SongMenu)].GetSelectedSong()); return true; } else @@ -504,7 +514,7 @@ namespace Vocaluxe.Screens } } } - + if (MouseEvent.LBH) { if (!DragAndDropActive && Playlists[htPlaylists(Playlist)].Visible && CSongs.NumVisibleSongs > 0 && SongMenus[htSongMenus(SongMenu)].GetActualSelection() != -1) @@ -533,12 +543,19 @@ namespace Vocaluxe.Screens 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; + CSongs.Sort(_sso.Sorting.SongSorting, _sso.Sorting.Tabs, _sso.Sorting.IgnoreArticles, _sso.Sorting.SearchString); + _SearchActive = _sso.Sorting.SearchStringVisible; + _SearchText = _sso.Sorting.SearchString; CGame.EnterNormalGame(); SongMenus[htSongMenus(SongMenu)].OnShow(); + + if (_sso.Selection.PartyMode) + _PlaylistActive = false; + + if (_sso.Selection.PartyMode) + ToggleSongOptions(ESongOptionsView.None); + SongMenus[htSongMenus(SongMenu)].SetActive(!_PlaylistActive); SongMenus[htSongMenus(SongMenu)].SetSmallView(Playlists[htPlaylists(Playlist)].Visible); @@ -619,6 +636,11 @@ namespace Vocaluxe.Screens SongMenus[htSongMenus(SongMenu)].ApplyVolume(CConfig.PreviewMusicVolume); } + private void HandlePartySongSelection(int SongNr) + { + + } + private void StartSong(int SongNr) { if ((CSongs.Category >= 0) && (SongNr >= 0)) From bf3fdeb69a8220912ceab09e06ca0775b60d59fd Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Tue, 11 Dec 2012 18:11:26 +0100 Subject: [PATCH 005/110] changes on ScreenSong for party mode are nearly completed --- Vocaluxe/Base/CParty.cs | 5 ++ Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs | 28 +++--- Vocaluxe/PartyModes/CPartyMode.cs | 21 +++++ Vocaluxe/PartyModes/CPartyModeNone.cs | 11 +-- Vocaluxe/PartyModes/IPartyMode.cs | 24 ++++- Vocaluxe/Screens/CScreenSong.cs | 94 +++++++++++++++----- 6 files changed, 136 insertions(+), 47 deletions(-) diff --git a/Vocaluxe/Base/CParty.cs b/Vocaluxe/Base/CParty.cs index 5b478f0d..bcda5fa8 100644 --- a/Vocaluxe/Base/CParty.cs +++ b/Vocaluxe/Base/CParty.cs @@ -51,5 +51,10 @@ namespace Vocaluxe.Base { _PartyModes[_CurrentModeNr].SetSearchString(SearchString, Visible); } + + public static void JokerUsed(int TeamNr) + { + _PartyModes[_CurrentModeNr].JokerUsed(TeamNr); + } } } diff --git a/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs b/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs index 69d6f642..ad0c44b6 100644 --- a/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs @@ -200,7 +200,7 @@ namespace Vocaluxe.Menu.SongMenu case Keys.Escape: case Keys.Back: - if (CSongs.Category > -1 && CSongs.Tabs == EOffOn.TR_CONFIG_ON) + if (CSongs.Category > -1 && CSongs.Tabs == EOffOn.TR_CONFIG_ON && SongOptions.Selection.CategoryChangeAllowed) { ShowCategories(); KeyEvent.Handled = true; @@ -212,21 +212,21 @@ namespace Vocaluxe.Menu.SongMenu break; case Keys.PageUp: - if (CSongs.Tabs == EOffOn.TR_CONFIG_ON) + if (CSongs.Tabs == EOffOn.TR_CONFIG_ON && SongOptions.Selection.CategoryChangeAllowed) { PrevCategory(); } break; case Keys.PageDown: - if (CSongs.Tabs == EOffOn.TR_CONFIG_ON) + if (CSongs.Tabs == EOffOn.TR_CONFIG_ON && SongOptions.Selection.CategoryChangeAllowed) { NextCategory(); } break; case Keys.Left: - if (_Locked > 0 && !SongOptions.Selection.RandomOnly && !SongOptions.Selection.RandomOnly) + if (_Locked > 0 && (!SongOptions.Selection.RandomOnly || SongOptions.Selection.CategoryChangeAllowed && CSongs.Category < 0)) { _Locked--; if (CSongs.Category < 0 && _Locked < CSongs.NumCategories - _NumW || @@ -236,7 +236,7 @@ namespace Vocaluxe.Menu.SongMenu break; case Keys.Right: - if (CSongs.Category < 0) + if (CSongs.Category < 0 && SongOptions.Selection.CategoryChangeAllowed) { if (_Locked < CSongs.NumCategories - 1) { @@ -248,7 +248,7 @@ namespace Vocaluxe.Menu.SongMenu } else { - if (_Locked < CSongs.NumVisibleSongs - 1 && !SongOptions.Selection.RandomOnly) + if (CSongs.Category != -1 && _Locked < CSongs.NumVisibleSongs - 1 && !SongOptions.Selection.RandomOnly) { _Locked++; if (_Locked < CSongs.NumVisibleSongs - _NumW) @@ -258,13 +258,13 @@ namespace Vocaluxe.Menu.SongMenu break; case Keys.Up: - if (KeyEvent.ModSHIFT && CSongs.Tabs == EOffOn.TR_CONFIG_ON && !SongOptions.Selection.RandomOnly) + if (KeyEvent.ModSHIFT && CSongs.Tabs == EOffOn.TR_CONFIG_ON && SongOptions.Selection.CategoryChangeAllowed) { PrevCategory(); break; } - if (_Locked > _NumW - 1 && (!SongOptions.Selection.RandomOnly || CSongs.Category < 0)) + if (_Locked > _NumW - 1 && (!SongOptions.Selection.RandomOnly || SongOptions.Selection.CategoryChangeAllowed && CSongs.Category < 0)) { _Locked -= _NumW; UpdateList((_Locked / _NumW) * _NumW - (_NumW * (_NumH - 2))); @@ -272,13 +272,13 @@ namespace Vocaluxe.Menu.SongMenu break; case Keys.Down: - if (KeyEvent.ModSHIFT && CSongs.Tabs == EOffOn.TR_CONFIG_ON && !SongOptions.Selection.RandomOnly) + if (KeyEvent.ModSHIFT && CSongs.Tabs == EOffOn.TR_CONFIG_ON && SongOptions.Selection.CategoryChangeAllowed) { NextCategory(); break; } - if (CSongs.Category < 0) + if (CSongs.Category < 0 && SongOptions.Selection.CategoryChangeAllowed) { if (_Locked < CSongs.NumCategories - _NumW) { @@ -323,7 +323,7 @@ namespace Vocaluxe.Menu.SongMenu bool sel = false; int lastselection = _actualSelection; - if (!SongOptions.Selection.RandomOnly) + if (!SongOptions.Selection.RandomOnly || CSongs.Category < 0 && SongOptions.Selection.CategoryChangeAllowed) { foreach (CStatic tile in _Tiles) { @@ -359,7 +359,7 @@ namespace Vocaluxe.Menu.SongMenu if (!sel) _actualSelection = -1; - if ((MouseEvent.RB) && (CSongs.NumCategories > 0) && CSongs.Category >= 0 && CSongs.Tabs == EOffOn.TR_CONFIG_ON) + if ((MouseEvent.RB) && (CSongs.NumCategories > 0) && CSongs.Category >= 0 && CSongs.Tabs == EOffOn.TR_CONFIG_ON && SongOptions.Selection.CategoryChangeAllowed) { ShowCategories(); return; @@ -389,7 +389,7 @@ namespace Vocaluxe.Menu.SongMenu if (MouseEvent.Wheel > 0) { - if (CHelper.IsInBounds(_ScrollRect, MouseEvent) && !SongOptions.Selection.PartyMode) + if (CHelper.IsInBounds(_ScrollRect, MouseEvent) && (!SongOptions.Selection.RandomOnly || CSongs.Category < 0 && SongOptions.Selection.CategoryChangeAllowed)) { if (CSongs.Category >= 0 && CSongs.NumVisibleSongs > _Offset + _NumW * MouseEvent.Wheel + _NumW * (_NumH - 1) || CSongs.Category < 0 && CSongs.NumCategories > _Offset + _NumW * MouseEvent.Wheel + _NumW * (_NumH - 1)) @@ -402,7 +402,7 @@ namespace Vocaluxe.Menu.SongMenu if (MouseEvent.Wheel < 0) { - if (CHelper.IsInBounds(_ScrollRect, MouseEvent) && !SongOptions.Selection.PartyMode) + if (CHelper.IsInBounds(_ScrollRect, MouseEvent) && (!SongOptions.Selection.RandomOnly || CSongs.Category < 0 && SongOptions.Selection.CategoryChangeAllowed)) { _Offset += _NumW * MouseEvent.Wheel; if (_Offset < 0) diff --git a/Vocaluxe/PartyModes/CPartyMode.cs b/Vocaluxe/PartyModes/CPartyMode.cs index 0c64369f..8ba4ee1d 100644 --- a/Vocaluxe/PartyModes/CPartyMode.cs +++ b/Vocaluxe/PartyModes/CPartyMode.cs @@ -8,6 +8,15 @@ namespace Vocaluxe.PartyModes { abstract class CPartyMode : IPartyMode { + protected ScreenSongOptions _ScreenSongOptions; + + public CPartyMode() + { + _ScreenSongOptions = new ScreenSongOptions(); + _ScreenSongOptions.Selection = new SelectionOptions(); + _ScreenSongOptions.Sorting = new SortingOptions(); + } + #region Implementation public virtual void Init() { @@ -31,6 +40,18 @@ namespace Vocaluxe.PartyModes public virtual void SetSearchString(string SearchString, bool Visible) { } + + public virtual void JokerUsed(int TeamNr) + { + if (_ScreenSongOptions.Selection.NumJokers == null) + return; + + if (_ScreenSongOptions.Selection.NumJokers.Length < TeamNr) + return; + + if (_ScreenSongOptions.Selection.NumJokers[TeamNr] > 0) + _ScreenSongOptions.Selection.NumJokers[TeamNr]--; + } #endregion Implementation } } diff --git a/Vocaluxe/PartyModes/CPartyModeNone.cs b/Vocaluxe/PartyModes/CPartyModeNone.cs index 77e0fd09..84b13581 100644 --- a/Vocaluxe/PartyModes/CPartyModeNone.cs +++ b/Vocaluxe/PartyModes/CPartyModeNone.cs @@ -9,18 +9,12 @@ namespace Vocaluxe.PartyModes class CPartyModeNone : CPartyMode { //just a dummy for normal game mode - private ScreenSongOptions _ScreenSongOptions; - public CPartyModeNone() { - _ScreenSongOptions = new ScreenSongOptions(); - _ScreenSongOptions.Selection = new SelectionOptions(); - _ScreenSongOptions.Sorting = new SortingOptions(); - _ScreenSongOptions.Selection.RandomOnly = false; _ScreenSongOptions.Selection.PartyMode = false; - _ScreenSongOptions.Selection.NumJokers = 0; - _ScreenSongOptions.Selection.NumTeams = 0; + _ScreenSongOptions.Selection.CategoryChangeAllowed = true; + _ScreenSongOptions.Selection.NumJokers = null; _ScreenSongOptions.Sorting.SearchString = String.Empty; _ScreenSongOptions.Sorting.SearchStringVisible = false; @@ -40,5 +34,6 @@ namespace Vocaluxe.PartyModes _ScreenSongOptions.Sorting.SearchString = SearchString; _ScreenSongOptions.Sorting.SearchStringVisible = Visible; } + } } diff --git a/Vocaluxe/PartyModes/IPartyMode.cs b/Vocaluxe/PartyModes/IPartyMode.cs index 5426a8bf..99179fb0 100644 --- a/Vocaluxe/PartyModes/IPartyMode.cs +++ b/Vocaluxe/PartyModes/IPartyMode.cs @@ -23,12 +23,30 @@ namespace Vocaluxe.PartyModes public bool SearchStringVisible; } + /// + /// Configuration of song selection options + /// public struct SelectionOptions { + /// + /// Choosing song only by random + /// public bool RandomOnly; + + /// + /// If true, it is not allowed to go to MainScreen nor open the playlist nor open the song menu + /// public bool PartyMode; - public int NumJokers; - public int NumTeams; + + /// + /// If true, it is not alled to change or leave the category. It's only valid if Tabs=On. + /// + public bool CategoryChangeAllowed; + + /// + /// The number of jokers left for each team + /// + public int[] NumJokers; } #endregion Structs @@ -41,5 +59,7 @@ namespace Vocaluxe.PartyModes ScreenSongOptions GetScreenSongOptions(); void SetSearchString(string SearchString, bool Visible); + + void JokerUsed(int TeamNr); } } diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index b018626c..11e84a48 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -140,7 +140,7 @@ namespace Vocaluxe.Screens if (!_SongOptionsActive) { - if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode)) + if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode) && KeyEvent.Mod != EModifier.Ctrl) { if (_SearchActive) ApplyNewSearchFilter(_SearchText + KeyEvent.Unicode); @@ -248,14 +248,8 @@ namespace Vocaluxe.Screens //TODO: We need another key for random! case Keys.R: - if (!_SearchActive && CSongs.Category != -1 && KeyEvent.Mod == EModifier.Ctrl) - { - SongMenus[htSongMenus(SongMenu)].SetSelectedSong(CSongs.GetRandomSong()); - } - else if (CSongs.Category == -1 && KeyEvent.Mod == EModifier.Ctrl) - { - SongMenus[htSongMenus(SongMenu)].SetSelectedCategory(CSongs.GetRandomCategory()); - } + if (KeyEvent.Mod == EModifier.Ctrl && !_sso.Selection.RandomOnly) + SelectNextRandom(-1); break; //TODO: Delete that! @@ -266,6 +260,30 @@ namespace Vocaluxe.Screens } break; + case Keys.D1: + SelectNextRandom(0); + break; + + case Keys.D2: + SelectNextRandom(1); + break; + + case Keys.D3: + SelectNextRandom(2); + break; + + case Keys.D4: + SelectNextRandom(3); + break; + + case Keys.D5: + SelectNextRandom(4); + break; + + case Keys.D6: + SelectNextRandom(5); + break; + } } } @@ -399,21 +417,9 @@ namespace Vocaluxe.Screens } } - if (MouseEvent.MB) + if (MouseEvent.MB && !_sso.Selection.PartyMode) { - if (CSongs.Category != -1) - { - ToggleSongOptions(ESongOptionsView.None); - SongMenus[htSongMenus(SongMenu)].SetSelectedSong(CSongs.GetRandomSong()); - return true; - } - - if (CSongs.Category == -1) - { - ToggleSongOptions(ESongOptionsView.None); - SongMenus[htSongMenus(SongMenu)].SetSelectedCategory(CSongs.GetRandomCategory()); - return true; - } + return SelectNextRandom(-1); } if (MouseEvent.LD && !_sso.Selection.PartyMode) @@ -759,6 +765,48 @@ namespace Vocaluxe.Screens CGraphics.FadeTo(EScreens.ScreenNames); } + private bool SelectNextRandom(int TeamNr) + { + if (TeamNr != -1 && _sso.Selection.RandomOnly && _sso.Selection.NumJokers != null) + { + bool result = false; + if (_sso.Selection.NumJokers.Length > TeamNr) + { + if (_sso.Selection.NumJokers[TeamNr] > 0) + { + result = SelectNextRandomSong(TeamNr) || SelectNextRandomCategory(); + CParty.JokerUsed(TeamNr); + _sso = CParty.GetSongSelectionOptions(); + } + } + return result; + } + + return SelectNextRandomSong(TeamNr) || SelectNextRandomCategory(); + } + + private bool SelectNextRandomSong(int TeamNr) + { + if (CSongs.Category != -1) + { + ToggleSongOptions(ESongOptionsView.None); + SongMenus[htSongMenus(SongMenu)].SetSelectedSong(CSongs.GetRandomSong()); + return true; + } + return false; + } + + private bool SelectNextRandomCategory() + { + if (CSongs.Category == -1) + { + ToggleSongOptions(ESongOptionsView.None); + SongMenus[htSongMenus(SongMenu)].SetSelectedCategory(CSongs.GetRandomCategory()); + return true; + } + return false; + } + private void JumpTo(char Letter) { int song = SongMenus[htSongMenus(SongMenu)].GetSelectedSong(); From e9f9ecc5f4e327da50f8ef2dbd1f93f311c01286 Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Tue, 11 Dec 2012 19:37:57 +0100 Subject: [PATCH 006/110] added party dummy screen and CMenuParty class (not finished) --- Vocaluxe/Base/CParty.cs | 23 +++- Vocaluxe/Menu/CGraphics.cs | 7 +- Vocaluxe/PartyModes/CPartyMode.cs | 6 ++ Vocaluxe/PartyModes/IPartyMode.cs | 1 + Vocaluxe/Screens/CScreenParty.cs | 4 + Vocaluxe/Screens/CScreenPartyDummy.cs | 112 ++++++++++++++++++++ Vocaluxe/Screens/CScreenSong.cs | 4 +- Vocaluxe/Screens/PartyScreens/CMenuParty.cs | 29 +++++ Vocaluxe/Vocaluxe.csproj | 2 + 9 files changed, 183 insertions(+), 5 deletions(-) create mode 100644 Vocaluxe/Screens/CScreenPartyDummy.cs create mode 100644 Vocaluxe/Screens/PartyScreens/CMenuParty.cs diff --git a/Vocaluxe/Base/CParty.cs b/Vocaluxe/Base/CParty.cs index bcda5fa8..65d13dc7 100644 --- a/Vocaluxe/Base/CParty.cs +++ b/Vocaluxe/Base/CParty.cs @@ -12,6 +12,7 @@ namespace Vocaluxe.Base private static List _PartyModes; private static int _CurrentModeNr; + #region public stuff public static int NumModes { get { return _PartyModes.Count - 1; } //first mode is the dummy normal game mode @@ -21,17 +22,26 @@ namespace Vocaluxe.Base { _PartyModes = new List(); - //add dummy normal game mode + //add dummy normal game mode and set it as default _PartyModes.Add(new CPartyModeNone()); - _CurrentModeNr = 0; - } + //load other party modes + LoadPartyModes(); + } + public static void SetNormalGameMode() { _CurrentModeNr = 0; } + public static CMenu GetNextPartyScreen() + { + return _PartyModes[_CurrentModeNr].GetNextPartyScreen(); + } + #endregion public stuff + + #region Interface public static EScreens GetStartScreen() { return _PartyModes[_CurrentModeNr].GetStartScreen(); @@ -56,5 +66,12 @@ namespace Vocaluxe.Base { _PartyModes[_CurrentModeNr].JokerUsed(TeamNr); } + #endregion Interface + + #region private stuff + private static void LoadPartyModes() + { + } + #endregion private stuff } } diff --git a/Vocaluxe/Menu/CGraphics.cs b/Vocaluxe/Menu/CGraphics.cs index d9f220ae..7c64de84 100644 --- a/Vocaluxe/Menu/CGraphics.cs +++ b/Vocaluxe/Menu/CGraphics.cs @@ -33,6 +33,7 @@ namespace Vocaluxe.Menu ScreenNames = 15, ScreenCredits = 16, ScreenParty = 17, + ScreenPartyDummy = 18, ScreenNull = -1 } @@ -245,6 +246,7 @@ namespace Vocaluxe.Menu _Screens.Add(new CScreenNames()); _Screens.Add(new CScreenCredits()); _Screens.Add(new CScreenParty()); + _Screens.Add(new CScreenPartyDummy()); _PopupScreens.Add(new CPopupScreenPlayerControl()); _PopupScreens.Add(new CPopupScreenVolumeControl()); @@ -433,9 +435,12 @@ namespace Vocaluxe.Menu public static void FadeTo(EScreens Screen) { + if (Screen == EScreens.ScreenPartyDummy) + _Screens[(int)EScreens.ScreenPartyDummy] = CParty.GetNextPartyScreen(); + _NextScreen = Screen; } - + public static void ShowPopup(EPopupScreens PopupScreen) { _PopupScreens[(int)PopupScreen].OnShow(); diff --git a/Vocaluxe/PartyModes/CPartyMode.cs b/Vocaluxe/PartyModes/CPartyMode.cs index 8ba4ee1d..d7ade268 100644 --- a/Vocaluxe/PartyModes/CPartyMode.cs +++ b/Vocaluxe/PartyModes/CPartyMode.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Text; using Vocaluxe.Menu; +using Vocaluxe.Screens; namespace Vocaluxe.PartyModes { @@ -22,6 +23,11 @@ namespace Vocaluxe.PartyModes { } + public virtual CMenu GetNextPartyScreen() + { + return new CScreenPartyDummy(); + } + public virtual EScreens GetStartScreen() { return EScreens.ScreenSong; diff --git a/Vocaluxe/PartyModes/IPartyMode.cs b/Vocaluxe/PartyModes/IPartyMode.cs index 99179fb0..ef959509 100644 --- a/Vocaluxe/PartyModes/IPartyMode.cs +++ b/Vocaluxe/PartyModes/IPartyMode.cs @@ -54,6 +54,7 @@ namespace Vocaluxe.PartyModes { void Init(); + CMenu GetNextPartyScreen(); EScreens GetStartScreen(); EScreens GetMainScreen(); ScreenSongOptions GetScreenSongOptions(); diff --git a/Vocaluxe/Screens/CScreenParty.cs b/Vocaluxe/Screens/CScreenParty.cs index 0d397743..0d0a6d38 100644 --- a/Vocaluxe/Screens/CScreenParty.cs +++ b/Vocaluxe/Screens/CScreenParty.cs @@ -49,6 +49,10 @@ namespace Vocaluxe.Screens case Keys.Escape: CGraphics.FadeTo(EScreens.ScreenMain); break; + + case Keys.C: + //CGraphics.FadeTo(EScreens.ScreenPartyDummy); + break; case Keys.Enter: if (Buttons[htButtons(ButtonExit)].Selected) diff --git a/Vocaluxe/Screens/CScreenPartyDummy.cs b/Vocaluxe/Screens/CScreenPartyDummy.cs new file mode 100644 index 00000000..a414c419 --- /dev/null +++ b/Vocaluxe/Screens/CScreenPartyDummy.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; + +using Vocaluxe.Base; +using Vocaluxe.Menu; + +namespace Vocaluxe.Screens +{ + class CScreenPartyDummy : CMenu + {// Version number for theme files. Increment it, if you've changed something on the theme files! + const int ScreenVersion = 1; + + public CScreenPartyDummy() + { + Init(); + } + + protected override void Init() + { + base.Init(); + + _ThemeName = "ScreenPartyDummy"; + _ScreenVersion = ScreenVersion; + } + + public override void LoadTheme() + { + } + + public override void ReloadTheme() + { + } + + public override void ReloadTextures() + { + } + + public override void SaveTheme() + { + } + + public override void UnloadTextures() + { + } + + public override bool HandleInput(KeyEvent KeyEvent) + { + base.HandleInput(KeyEvent); + + if (KeyEvent.KeyPressed) + { + + } + else + { + switch (KeyEvent.Key) + { + case Keys.Back: + case Keys.Escape: + CGraphics.FadeTo(EScreens.ScreenParty); + break; + } + } + return true; + } + + public override bool HandleMouse(MouseEvent MouseEvent) + { + base.HandleMouse(MouseEvent); + + if (MouseEvent.LB && IsMouseOver(MouseEvent)) + { + + } + + if (MouseEvent.RB) + { + CGraphics.FadeTo(EScreens.ScreenParty); + } + + return true; + } + + public override void OnShow() + { + base.OnShow(); + } + + public override bool UpdateGame() + { + return true; + } + + public override bool Draw() + { + base.Draw(); + + CFonts.SetFont("Normal"); + CFonts.Style = EStyle.Normal; + CDraw.DrawText("SOMETHING WENT WRONG!", 150, 300, 80); + + return true; + } + + public override void OnClose() + { + base.OnClose(); + } + } +} diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 11e84a48..9325e95c 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -644,7 +644,7 @@ namespace Vocaluxe.Screens private void HandlePartySongSelection(int SongNr) { - + CGraphics.FadeTo(EScreens.ScreenPartyDummy); } private void StartSong(int SongNr) @@ -945,6 +945,7 @@ namespace Vocaluxe.Screens } } + #region Playlist Actions public void CheckPlaylist() { if (Playlists[htPlaylists(Playlist)].ActivePlaylistID == -1) @@ -1075,5 +1076,6 @@ namespace Vocaluxe.Screens else SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistAdd)].Selection = 0; } + #endregion Playlist Actions } } diff --git a/Vocaluxe/Screens/PartyScreens/CMenuParty.cs b/Vocaluxe/Screens/PartyScreens/CMenuParty.cs new file mode 100644 index 00000000..332f93e9 --- /dev/null +++ b/Vocaluxe/Screens/PartyScreens/CMenuParty.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using Vocaluxe.Menu; + +namespace Vocaluxe.Screens.PartyScreens +{ + abstract class CMenuParty : CMenu + { + public sealed override void LoadTheme() + { + } + + public sealed override void ReloadTextures() + { + } + + public sealed override void ReloadTheme() + { + } + + public override void UnloadTextures() + { + } + + + } +} diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj index 18fd9697..94b05046 100644 --- a/Vocaluxe/Vocaluxe.csproj +++ b/Vocaluxe/Vocaluxe.csproj @@ -276,6 +276,8 @@ + + Designer From bc7aa797fae7343dc77012baf0f8ef11ea8733ac Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Tue, 11 Dec 2012 22:15:58 +0100 Subject: [PATCH 007/110] some preparations for party mode screens --- Vocaluxe/Base/CFont.cs | 105 ++++++++++++++++++++- Vocaluxe/Base/CLanguage.cs | 149 +++++++++++++++++++++++++++--- Vocaluxe/Base/CParty.cs | 113 ++++++++++++++++++++-- Vocaluxe/Base/CSettings.cs | 1 + Vocaluxe/Base/CTheme.cs | 2 - Vocaluxe/Menu/CGraphics.cs | 52 ++++++++++- Vocaluxe/PartyModes/CPartyMode.cs | 7 +- Vocaluxe/PartyModes/IPartyMode.cs | 2 +- 8 files changed, 399 insertions(+), 32 deletions(-) diff --git a/Vocaluxe/Base/CFont.cs b/Vocaluxe/Base/CFont.cs index 0c3fa048..4e558b9e 100644 --- a/Vocaluxe/Base/CFont.cs +++ b/Vocaluxe/Base/CFont.cs @@ -298,6 +298,7 @@ namespace Vocaluxe.Base public string Name; public bool IsThemeFont; + public int PartyModeID; public string ThemeName; public string Folder; @@ -323,6 +324,9 @@ namespace Vocaluxe.Base private static int _CurrentFont; private static float _Height = 1f; + public static int PartyModeID + { get; set; } + public static EStyle Style = EStyle.Normal; public static int CurrentFont @@ -377,6 +381,7 @@ namespace Vocaluxe.Base _settings.ConformanceLevel = ConformanceLevel.Document; _CurrentFont = 0; + PartyModeID = -1; BuildFonts(); } @@ -586,7 +591,20 @@ namespace Vocaluxe.Base public static void SetFont(string FontName) { - int Index = GetFontIndex(CConfig.Theme, FontName); + int Index = -1; + + if (PartyModeID != -1) + { + Index = GetFontIndexParty(PartyModeID, FontName); + + if (Index >= 0 && Index < _Fonts.Count) + { + _CurrentFont = Index; + return; + } + } + + Index = GetFontIndex(CConfig.Theme, FontName); if (Index >= 0 && Index < _Fonts.Count) { @@ -720,6 +738,7 @@ namespace Vocaluxe.Base sf.Name = name; sf.IsThemeFont = false; sf.ThemeName = String.Empty; + sf.PartyModeID = -1; CHelper.GetValueFromXML("//root/Font" + i.ToString() + "/FileItalic", navigator, ref value, value); value = Path.Combine(Directory.GetCurrentDirectory(), @@ -769,6 +788,7 @@ namespace Vocaluxe.Base sf.IsThemeFont = true; sf.ThemeName = ThemeName; + sf.PartyModeID = -1; bool ok = true; @@ -889,6 +909,75 @@ namespace Vocaluxe.Base } } + /// + /// Loads party mode fonts from skin file + /// + public static void LoadPartyModeFonts(int PartyModeID, string FontFolder, XPathNavigator navigator) + { + string value = string.Empty; + int i = 1; + while (CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/Folder", navigator, ref value, value)) + { + SFont sf = new SFont(); + sf.Folder = value; + + sf.IsThemeFont = false; + sf.ThemeName = String.Empty; + sf.PartyModeID = PartyModeID; + + bool ok = true; + + ok &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileNormal", navigator, ref value, value); + sf.FileNormal = value; + value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value)); + CFont f = new CFont(value); + sf.Normal = f; + + string name = String.Empty; + ok &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/Name", navigator, ref name, value); + sf.Name = name; + + ok &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileItalic", navigator, ref value, value); + sf.FileItalic = value; + value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value)); + f = new CFont(value); + sf.Italic = f; + + ok &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileBold", navigator, ref value, value); + sf.FileBold = value; + value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value)); + f = new CFont(value); + sf.Bold = f; + + ok &= CHelper.GetValueFromXML("//root/Fonts/Font" + i.ToString() + "/FileBoldItalic", navigator, ref value, value); + sf.FileBoldItalic = value; + value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value)); + f = new CFont(value); + sf.BoldItalic = f; + + sf.Outline = 0f; + ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/Outline", navigator, ref sf.Outline); + + sf.OutlineColor = new SColorF(0f, 0f, 0f, 1f); + ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorR", navigator, ref sf.OutlineColor.R); + ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorG", navigator, ref sf.OutlineColor.G); + ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorB", navigator, ref sf.OutlineColor.B); + ok &= CHelper.TryGetFloatValueFromXML("//root/Fonts/Font" + i.ToString() + "/OutlineColorA", navigator, ref sf.OutlineColor.A); + + if (ok) + _Fonts.Add(sf); + else + { + CLog.LogError("Error loading theme fonts for party mode from Folder \"" + FontFolder + "\": Error in Font" + i.ToString()); + } + i++; + } + + CLog.StartBenchmark(1, "BuildGlyphs"); + BuildGlyphs(); + CLog.StopBenchmark(1, "BuildGlyphs"); + } + private static int GetFontIndex(string ThemeName, string FontName) { if (ThemeName == String.Empty || FontName == String.Empty) @@ -903,6 +992,20 @@ namespace Vocaluxe.Base return -1; } + private static int GetFontIndexParty(int PartyModeID, string FontName) + { + if (PartyModeID == -1 || FontName == String.Empty) + return -1; + + for (int i = 0; i < _Fonts.Count; i++) + { + if (!_Fonts[i].IsThemeFont && _Fonts[i].Name == FontName && _Fonts[i].PartyModeID == PartyModeID) + return i; + } + + return -1; + } + private static void BuildGlyphs() { string Text = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPGRSTUVWGXZ1234567890"; diff --git a/Vocaluxe/Base/CLanguage.cs b/Vocaluxe/Base/CLanguage.cs index 6b209bba..9e8474ed 100644 --- a/Vocaluxe/Base/CLanguage.cs +++ b/Vocaluxe/Base/CLanguage.cs @@ -14,6 +14,13 @@ namespace Vocaluxe.Base public string LanguageFilePath; public Hashtable Texts; + public List PartyModeTexts; + } + + struct SPartyLanguage + { + public int PartyModeID; + public Hashtable Texts; } static class CLanguage @@ -63,16 +70,24 @@ namespace Vocaluxe.Base } public static bool SetLanguage(string Language) + { + int nr = GetLanguageNr(Language); + if (nr != -1) + { + _CurrentLanguage = nr; + return true; + } + return false; + } + + public static int GetLanguageNr(string Language) { for (int i = 0; i < _Languages.Count; i++) { if (_Languages[i].Name == Language) - { - _CurrentLanguage = i; - return true; - } + return i; } - return false; + return -1; } public static string Translate(string KeyWord) @@ -126,13 +141,37 @@ namespace Vocaluxe.Base return false; string result = String.Empty; - try + + int PartyModeNr = GetPartyModeNr(CFonts.PartyModeID, _CurrentLanguage); + if (CFonts.PartyModeID != -1) { - result = (string)_Languages[_CurrentLanguage].Texts[KeyWord]; + if (PartyModeNr != -1) + { + try + { + result = (string)_Languages[_CurrentLanguage].PartyModeTexts[CFonts.PartyModeID].Texts[KeyWord]; + } + catch { } + } + + if (result == null && (PartyModeNr = GetPartyModeNr(CFonts.PartyModeID, _FallbackLanguage)) != -1) + { + try + { + result = (string)_Languages[_FallbackLanguage].PartyModeTexts[CFonts.PartyModeID].Texts[KeyWord]; + } + catch { } + } } - catch (Exception) + + + if (result == null) { - ; + try + { + result = (string)_Languages[_CurrentLanguage].Texts[KeyWord]; + } + catch { } } if (result == null) @@ -142,10 +181,7 @@ namespace Vocaluxe.Base { result = (string)_Languages[_FallbackLanguage].Texts[KeyWord]; } - catch (Exception) - { - ; - } + catch { } if (result == null) return false; @@ -154,6 +190,82 @@ namespace Vocaluxe.Base return true; } + public static bool LoadPartyLanguageFiles(int PartyModeID, string Path) + { + List files = new List(); + files.AddRange(Helper.ListFiles(CSettings.sFolderLanguages, "*.xml", true, true)); + + foreach (string file in files) + { + if (!LoadPartyLanguageFile(PartyModeID, file)) + return false; + } + return true; + } + + private static bool LoadPartyLanguageFile(int PartyModeID, string file) + { + bool loaded = false; + XPathDocument xPathDoc = null; + XPathNavigator navigator = null; + + try + { + xPathDoc = new XPathDocument(file); + navigator = xPathDoc.CreateNavigator(); + loaded = true; + } + catch (Exception e) + { + loaded = false; + if (navigator != null) + navigator = null; + + if (xPathDoc != null) + xPathDoc = null; + + CLog.LogError("Error opening Party Language File " + file + ": " + e.Message); + } + + if (loaded) + { + string value = string.Empty; + if (loaded == CHelper.GetValueFromXML("//root/Info/Name", navigator, ref value, value)) + { + int nr = GetLanguageNr(value); + + if (nr == -1) + return true; + + SPartyLanguage lang = new SPartyLanguage(); + lang.PartyModeID = PartyModeID; + lang.Texts = new Hashtable(); + + List texts = CHelper.GetValuesFromXML("Texts", navigator); + for (int i = 0; i < texts.Count; i++) + { + if (CHelper.GetValueFromXML("//root/Texts/" + texts[i], navigator, ref value, value)) + { + try + { + lang.Texts.Add(texts[i], value); + } + catch (Exception e) + { + CLog.LogError("Error reading Party Language File " + file + ": " + e.Message); + return false; + } + } + + } + _Languages[nr].PartyModeTexts.Add(lang); + return true; + } + } + CLog.LogError("Error reading Party Language File " + file); + return false; + } + private static void LoadLanguageFile(string FileName) { bool loaded = false; @@ -191,6 +303,7 @@ namespace Vocaluxe.Base _FallbackLanguage = _Languages.Count; lang.Texts = new Hashtable(); + lang.PartyModeTexts = new List(); List texts = CHelper.GetValuesFromXML("Texts", navigator); for (int i = 0; i < texts.Count; i++) @@ -213,5 +326,15 @@ namespace Vocaluxe.Base } } } + + private static int GetPartyModeNr(int PartyModeID, int Language) + { + for (int i = 0; i < _Languages[Language].PartyModeTexts.Count; i++) + { + if (_Languages[Language].PartyModeTexts[i].PartyModeID == PartyModeID) + return i; + } + return -1; + } } } diff --git a/Vocaluxe/Base/CParty.cs b/Vocaluxe/Base/CParty.cs index 65d13dc7..2751b8a6 100644 --- a/Vocaluxe/Base/CParty.cs +++ b/Vocaluxe/Base/CParty.cs @@ -1,16 +1,47 @@ using System; using System.Collections.Generic; using System.Text; +using System.Xml; +using System.Xml.XPath; using Vocaluxe.Menu; using Vocaluxe.PartyModes; namespace Vocaluxe.Base { + #region Structs + struct SPartyMode + { + public int PartyModeSystemVersion; + public string Name; + public string Author; + public string Folder; + public int PartyModeVersionMajor; + public int PartyModeVersionMinor; + public bool NoErrors; + public IPartyMode PartyMode; + } + #endregion Structs + + static class CParty { - private static List _PartyModes; + const int PartyModeSystemVersion = 1; + + private static CHelper Helper; + private static List _PartyModes; + private static int _CurrentModeNr; + public static int CurrentPartyModeID + { + get + { + if (_CurrentModeNr == 0) + return -1; + + return _CurrentModeNr - 1; + } + } #region public stuff public static int NumModes @@ -20,10 +51,13 @@ namespace Vocaluxe.Base public static void Init() { - _PartyModes = new List(); + Helper = new CHelper(); + _PartyModes = new List(); //add dummy normal game mode and set it as default - _PartyModes.Add(new CPartyModeNone()); + SPartyMode pm = new SPartyMode(); + pm.PartyMode = new CPartyModeNone(); + _PartyModes.Add(pm); _CurrentModeNr = 0; //load other party modes @@ -37,40 +71,101 @@ namespace Vocaluxe.Base public static CMenu GetNextPartyScreen() { - return _PartyModes[_CurrentModeNr].GetNextPartyScreen(); + return _PartyModes[_CurrentModeNr].PartyMode.GetNextPartyScreen(); } #endregion public stuff #region Interface public static EScreens GetStartScreen() { - return _PartyModes[_CurrentModeNr].GetStartScreen(); + return _PartyModes[_CurrentModeNr].PartyMode.GetStartScreen(); } public static EScreens GetMainScreen() { - return _PartyModes[_CurrentModeNr].GetMainScreen(); + return _PartyModes[_CurrentModeNr].PartyMode.GetMainScreen(); } public static ScreenSongOptions GetSongSelectionOptions() { - return _PartyModes[_CurrentModeNr].GetScreenSongOptions(); + return _PartyModes[_CurrentModeNr].PartyMode.GetScreenSongOptions(); } public static void SetSearchString(string SearchString, bool Visible) { - _PartyModes[_CurrentModeNr].SetSearchString(SearchString, Visible); + _PartyModes[_CurrentModeNr].PartyMode.SetSearchString(SearchString, Visible); } public static void JokerUsed(int TeamNr) { - _PartyModes[_CurrentModeNr].JokerUsed(TeamNr); + _PartyModes[_CurrentModeNr].PartyMode.JokerUsed(TeamNr); } #endregion Interface #region private stuff private static void LoadPartyModes() { + List files = new List(); + files.AddRange(Helper.ListFiles(CSettings.sFolderPartyModes, "*.xml", false, true)); + + foreach (string file in files) + { + _PartyModes.Add(LoadPartyMode(file)); + } + } + + private static SPartyMode LoadPartyMode(string file) + { + SPartyMode pm = new SPartyMode(); + pm.NoErrors = false; + + bool loaded = false; + XPathDocument xPathDoc = null; + XPathNavigator navigator = null; + + try + { + xPathDoc = new XPathDocument(file); + navigator = xPathDoc.CreateNavigator(); + loaded = true; + } + catch (Exception e) + { + loaded = false; + if (navigator != null) + navigator = null; + + if (xPathDoc != null) + xPathDoc = null; + + CLog.LogError("Error opening party mode file " + file + ": " + e.Message); + } + + if (loaded) + { + loaded &= CHelper.TryGetIntValueFromXML("//root/Info/PartyModeSystemVersion", navigator, ref pm.PartyModeSystemVersion); + loaded &= CHelper.GetValueFromXML("//root/Info/Name", navigator, ref pm.Name, "ERROR Name"); + loaded &= CHelper.GetValueFromXML("//root/Info/Author", navigator, ref pm.Author, "ERROR Author"); + loaded &= CHelper.GetValueFromXML("//root/Info/Folder", navigator, ref pm.Folder, "ERROR Folder"); + loaded &= CHelper.TryGetIntValueFromXML("//root/Info/PartyModeSystemVersion", navigator, ref pm.PartyModeVersionMajor); + loaded &= CHelper.TryGetIntValueFromXML("//root/Info/PartyModeSystemVersion", navigator, ref pm.PartyModeVersionMinor); + + if (pm.PartyModeSystemVersion != PartyModeSystemVersion) + { + CLog.LogError("Error loading PartyMode file (wrong PartyModeSystemVersion): " + file); + return pm; + } + } + + if (!loaded) + { + CLog.LogError("Error loading PartyMode file: " + file); + return pm; + } + + + + return pm; } #endregion private stuff } diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs index da827ca0..16fb0475 100644 --- a/Vocaluxe/Base/CSettings.cs +++ b/Vocaluxe/Base/CSettings.cs @@ -95,6 +95,7 @@ namespace Vocaluxe.Base public const string sFolderScreenshots = "Screenshots"; public const string sFolderBackgroundMusic = "BackgroundMusic"; public static string sFolderPlaylists = "Playlists"; + public static string sFolderPartyModes = "PartyModes"; //public const String[] ToneStrings = new String[]{ "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" }; public const int ToneMin = -36; diff --git a/Vocaluxe/Base/CTheme.cs b/Vocaluxe/Base/CTheme.cs index 66ee9023..da75d10e 100644 --- a/Vocaluxe/Base/CTheme.cs +++ b/Vocaluxe/Base/CTheme.cs @@ -126,8 +126,6 @@ namespace Vocaluxe.Base _settings.Encoding = Encoding.UTF8; _settings.ConformanceLevel = ConformanceLevel.Document; - //ThemeColors.Player = new SColorF[6]; - ListThemes(); ListSkins(); diff --git a/Vocaluxe/Menu/CGraphics.cs b/Vocaluxe/Menu/CGraphics.cs index 7c64de84..0e5ca85e 100644 --- a/Vocaluxe/Menu/CGraphics.cs +++ b/Vocaluxe/Menu/CGraphics.cs @@ -377,7 +377,16 @@ namespace Vocaluxe.Menu _Fading = true; _FadingTimer.Reset(); _FadingTimer.Start(); - _Screens[(int)_NextScreen].OnShow(); + + if (_NextScreen == EScreens.ScreenPartyDummy) + { + CFonts.PartyModeID = CParty.CurrentPartyModeID; + _Screens[(int)_NextScreen].OnShow(); + CFonts.PartyModeID = -1; + } + else + _Screens[(int)_NextScreen].OnShow(); + HidePopup(EPopupScreens.PopupPlayerControl); } @@ -395,11 +404,28 @@ namespace Vocaluxe.Menu _GlobalAlpha = 1f;// -factor / 100f; _ZOffset = CSettings.zFar/2; - _Screens[(int)_CurrentScreen].Draw(); + + if (_CurrentScreen == EScreens.ScreenPartyDummy) + { + CFonts.PartyModeID = CParty.CurrentPartyModeID; + _Screens[(int)_CurrentScreen].Draw(); + CFonts.PartyModeID = -1; + } + else + _Screens[(int)_CurrentScreen].Draw(); + _GlobalAlpha = factor; _ZOffset = 0f; - _Screens[(int)_NextScreen].Draw(); + + if (_NextScreen == EScreens.ScreenPartyDummy) + { + CFonts.PartyModeID = CParty.CurrentPartyModeID; + _Screens[(int)_NextScreen].Draw(); + CFonts.PartyModeID = -1; + } + else + _Screens[(int)_NextScreen].Draw(); _GlobalAlpha = 1f; } @@ -412,14 +438,30 @@ namespace Vocaluxe.Menu CBackgroundMusic.Play(); _Screens[(int)_CurrentScreen].OnShowFinish(); _Screens[(int)_CurrentScreen].ProcessMouseMove(_Cursor.X, _Cursor.Y); - _Screens[(int)_CurrentScreen].Draw(); + + if (_CurrentScreen == EScreens.ScreenPartyDummy) + { + CFonts.PartyModeID = CParty.CurrentPartyModeID; + _Screens[(int)_CurrentScreen].Draw(); + CFonts.PartyModeID = -1; + } + else + _Screens[(int)_CurrentScreen].Draw(); + _Fading = false; _FadingTimer.Stop(); } } else { - _Screens[(int)_CurrentScreen].Draw(); + if (_CurrentScreen == EScreens.ScreenPartyDummy) + { + CFonts.PartyModeID = CParty.CurrentPartyModeID; + _Screens[(int)_CurrentScreen].Draw(); + CFonts.PartyModeID = -1; + } + else + _Screens[(int)_CurrentScreen].Draw(); } for (int i = 0; i < _PopupScreens.Count; i++) diff --git a/Vocaluxe/PartyModes/CPartyMode.cs b/Vocaluxe/PartyModes/CPartyMode.cs index d7ade268..f8e47254 100644 --- a/Vocaluxe/PartyModes/CPartyMode.cs +++ b/Vocaluxe/PartyModes/CPartyMode.cs @@ -10,17 +10,22 @@ namespace Vocaluxe.PartyModes abstract class CPartyMode : IPartyMode { protected ScreenSongOptions _ScreenSongOptions; + protected List _Screens; + protected string _Folder; public CPartyMode() { + _Screens = new List(); + _Folder = String.Empty; _ScreenSongOptions = new ScreenSongOptions(); _ScreenSongOptions.Selection = new SelectionOptions(); _ScreenSongOptions.Sorting = new SortingOptions(); } #region Implementation - public virtual void Init() + public virtual bool Init(string Folder) { + return false; } public virtual CMenu GetNextPartyScreen() diff --git a/Vocaluxe/PartyModes/IPartyMode.cs b/Vocaluxe/PartyModes/IPartyMode.cs index ef959509..d3a1220e 100644 --- a/Vocaluxe/PartyModes/IPartyMode.cs +++ b/Vocaluxe/PartyModes/IPartyMode.cs @@ -52,7 +52,7 @@ namespace Vocaluxe.PartyModes interface IPartyMode { - void Init(); + bool Init(string Folder); CMenu GetNextPartyScreen(); EScreens GetStartScreen(); From 7676840932fc04aaf66aad3f2f090656f9a0e5d5 Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Wed, 12 Dec 2012 20:14:03 +0100 Subject: [PATCH 008/110] added IMenu, moved CGraphics to Base --- Vocaluxe/{Menu => Base}/CGraphics.cs | 9 +++--- Vocaluxe/Menu/CMenu.cs | 7 ++++- Vocaluxe/Menu/IMenu.cs | 41 ++++++++++++++++++++++++++++ Vocaluxe/Vocaluxe.csproj | 3 +- 4 files changed, 54 insertions(+), 6 deletions(-) rename Vocaluxe/{Menu => Base}/CGraphics.cs (98%) create mode 100644 Vocaluxe/Menu/IMenu.cs diff --git a/Vocaluxe/Menu/CGraphics.cs b/Vocaluxe/Base/CGraphics.cs similarity index 98% rename from Vocaluxe/Menu/CGraphics.cs rename to Vocaluxe/Base/CGraphics.cs index 0e5ca85e..4b314ae3 100644 --- a/Vocaluxe/Menu/CGraphics.cs +++ b/Vocaluxe/Base/CGraphics.cs @@ -8,6 +8,7 @@ using System.Windows.Forms; using Vocaluxe.Base; using Vocaluxe.Lib.Draw; using Vocaluxe.Screens; +using Vocaluxe.Screens.PartyScreens; namespace Vocaluxe.Menu { @@ -199,8 +200,8 @@ namespace Vocaluxe.Menu private static EScreens _NextScreen; private static EPopupScreens _CurrentPopupScreen; - private static List _Screens = new List(); - private static List _PopupScreens = new List(); + private static List _Screens = new List(); + private static List _PopupScreens = new List(); private static float _SavedBackgroundMusicVolume; private static float _SavedPreviewMusicVolume; @@ -591,7 +592,7 @@ namespace Vocaluxe.Menu UpdateMousePosition(MouseEvent.X, MouseEvent.Y); - bool isOverPopupPlayerControl = CHelper.IsInBounds(_PopupScreens[(int)EPopupScreens.PopupPlayerControl].ScreenArea, MouseEvent); + bool isOverPopupPlayerControl = CHelper.IsInBounds(_PopupScreens[(int)EPopupScreens.PopupPlayerControl].GetScreenArea(), MouseEvent); if (PopupPlayerControlAllowed && isOverPopupPlayerControl) { if (_CurrentPopupScreen == EPopupScreens.NoPopup && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON) @@ -601,7 +602,7 @@ namespace Vocaluxe.Menu if (!isOverPopupPlayerControl && _CurrentPopupScreen == EPopupScreens.PopupPlayerControl) HidePopup(EPopupScreens.PopupPlayerControl); - bool isOverPopupVolumeControl = CHelper.IsInBounds(_PopupScreens[(int)EPopupScreens.PopupVolumeControl].ScreenArea, MouseEvent); + bool isOverPopupVolumeControl = CHelper.IsInBounds(_PopupScreens[(int)EPopupScreens.PopupVolumeControl].GetScreenArea(), MouseEvent); if (PopupVolumeControlAllowed && isOverPopupVolumeControl) { if (_CurrentPopupScreen == EPopupScreens.NoPopup) diff --git a/Vocaluxe/Menu/CMenu.cs b/Vocaluxe/Menu/CMenu.cs index d639d91e..91fc6bf4 100644 --- a/Vocaluxe/Menu/CMenu.cs +++ b/Vocaluxe/Menu/CMenu.cs @@ -22,7 +22,7 @@ namespace Vocaluxe.Menu public float z; } - abstract class CMenu + abstract class CMenu : IMenu { private List _Interactions; private int _Selection = 0; @@ -81,6 +81,11 @@ namespace Vocaluxe.Menu get { return _ScreenArea; } } + public SRectF GetScreenArea() + { + return _ScreenArea; + } + public int ThemeScreenVersion { get { return _ScreenVersion; } diff --git a/Vocaluxe/Menu/IMenu.cs b/Vocaluxe/Menu/IMenu.cs new file mode 100644 index 00000000..cc65ede5 --- /dev/null +++ b/Vocaluxe/Menu/IMenu.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using Vocaluxe.Base; +using Vocaluxe.Lib.Draw; + +namespace Vocaluxe.Menu +{ + interface IMenu + { + void LoadTheme(); + void SaveTheme(); + void ReloadTextures(); + void UnloadTextures(); + void ReloadTheme(); + + bool HandleInput(KeyEvent KeyEvent); + bool HandleMouse(MouseEvent MouseEvent); + bool HandleInputThemeEditor(KeyEvent KeyEvent); + bool HandleMouseThemeEditor(MouseEvent MouseEvent); + + bool UpdateGame(); + void ApplyVolume(); + void OnShow(); + void OnShowFinish(); + void OnClose(); + + bool Draw(); + SRectF GetScreenArea(); + + void NextInteraction(); + void PrevInteraction(); + + bool NextElement(); + bool PrevElement(); + + void ProcessMouseClick(int x, int y); + void ProcessMouseMove(int x, int y); + } +} diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj index 94b05046..42c754cc 100644 --- a/Vocaluxe/Vocaluxe.csproj +++ b/Vocaluxe/Vocaluxe.csproj @@ -229,7 +229,7 @@ - + @@ -239,6 +239,7 @@ + From 79946a17c5592f6ab2ab8d304e58dcea02a879c5 Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Thu, 13 Dec 2012 18:19:08 +0100 Subject: [PATCH 009/110] First step to eliminate the namespace Vocaluxe.Base from all Vocaluxe.Menu classe. There is still a lot of work... --- Vocaluxe/Base/CConfig.cs | 4 +- Vocaluxe/Base/CCover.cs | 1 + Vocaluxe/Base/CDataBase.cs | 1 + Vocaluxe/Base/CGraphics.cs | 2 + Vocaluxe/Base/CInput.cs | 1 + Vocaluxe/Base/CLanguage.cs | 2 + Vocaluxe/Base/CPlaylists.cs | 1 + Vocaluxe/Base/CProfiles.cs | 1 + Vocaluxe/Base/CSettings.cs | 9 +- Vocaluxe/Base/CUtility.cs | 406 +----------------- Vocaluxe/Base/CVideo.cs | 2 +- Vocaluxe/Base/CWebcam.cs | 4 +- Vocaluxe/Lib/Draw/IDraw.cs | 116 ----- Vocaluxe/Lib/Input/IInput.cs | 1 + Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs | 1 + Vocaluxe/Lib/Input/WiiMote/WiiMoteLib.cs | 1 + Vocaluxe/Lib/Playlist/CPlaylistFile.cs | 1 + Vocaluxe/Lib/Video/CVideoDecoder.cs | 2 +- Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs | 1 + Vocaluxe/Lib/Video/IVideoDecoder.cs | 1 + Vocaluxe/Lib/Webcam/CAForgeNet.cs | 2 + Vocaluxe/Lib/Webcam/IWebcam.cs | 2 + Vocaluxe/Menu/CMenu.cs | 143 +++--- Vocaluxe/Menu/IMenu.cs | 309 +++++++++++++ Vocaluxe/Screens/CPopupScreenPlayerControl.cs | 1 - Vocaluxe/Screens/CPopupScreenVolumeControl.cs | 1 - Vocaluxe/Screens/CScreenCredits.cs | 1 - Vocaluxe/Screens/CScreenHighscore.cs | 1 - Vocaluxe/Screens/CScreenLoad.cs | 1 - Vocaluxe/Screens/CScreenMain.cs | 1 - Vocaluxe/Screens/CScreenNames.cs | 1 - Vocaluxe/Screens/CScreenOptions.cs | 1 - Vocaluxe/Screens/CScreenOptionsGame.cs | 1 - Vocaluxe/Screens/CScreenOptionsLyrics.cs | 1 - Vocaluxe/Screens/CScreenOptionsRecord.cs | 1 - Vocaluxe/Screens/CScreenOptionsSound.cs | 1 - Vocaluxe/Screens/CScreenOptionsTheme.cs | 1 - Vocaluxe/Screens/CScreenOptionsVideo.cs | 3 +- Vocaluxe/Screens/CScreenParty.cs | 1 - Vocaluxe/Screens/CScreenPartyDummy.cs | 1 - Vocaluxe/Screens/CScreenProfiles.cs | 3 +- Vocaluxe/Screens/CScreenScore.cs | 3 +- Vocaluxe/Screens/CScreenSing.cs | 1 - Vocaluxe/Screens/CScreenSong.cs | 2 - Vocaluxe/Screens/CScreenTest.cs | 1 - Vocaluxe/Screens/PartyScreens/CMenuParty.cs | 9 +- Vocaluxe/Vocaluxe.csproj | 2 + 47 files changed, 426 insertions(+), 627 deletions(-) diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index 14ecf859..4e3d96d6 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -12,6 +12,7 @@ using OpenTK.Platform; using Vocaluxe.Lib.Sound; using Vocaluxe.Lib.Webcam; +using Vocaluxe.Menu; namespace Vocaluxe.Base { @@ -1098,8 +1099,5 @@ namespace Vocaluxe.Base } } } - - - } } diff --git a/Vocaluxe/Base/CCover.cs b/Vocaluxe/Base/CCover.cs index 22b699d9..c63082f8 100644 --- a/Vocaluxe/Base/CCover.cs +++ b/Vocaluxe/Base/CCover.cs @@ -6,6 +6,7 @@ using System.Xml; using System.Xml.XPath; using Vocaluxe.Lib.Draw; +using Vocaluxe.Menu; namespace Vocaluxe.Base { diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index cadb499f..591dca1a 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -21,6 +21,7 @@ using Community.CsharpSqlite; using Vocaluxe.Lib.Draw; using Vocaluxe.Lib.Song; +using Vocaluxe.Menu; namespace Vocaluxe.Base { diff --git a/Vocaluxe/Base/CGraphics.cs b/Vocaluxe/Base/CGraphics.cs index 4b314ae3..964f0398 100644 --- a/Vocaluxe/Base/CGraphics.cs +++ b/Vocaluxe/Base/CGraphics.cs @@ -280,12 +280,14 @@ namespace Vocaluxe.Menu for (int i = 0; i < _Screens.Count; i++) { CLog.StartBenchmark(1, "Load Theme " + Enum.GetNames(typeof(EScreens))[i]); + _Screens[i].Initialize(CMain.Config, CMain.Settings, CMain.Theme, CMain.Helper, CMain.Log, CMain.BackgroundMusic, CMain.Draw, CMain.Graphics); _Screens[i].LoadTheme(); CLog.StopBenchmark(1, "Load Theme " + Enum.GetNames(typeof(EScreens))[i]); } for (int i = 0; i < _PopupScreens.Count; i++) { + _PopupScreens[i].Initialize(CMain.Config, CMain.Settings, CMain.Theme, CMain.Helper, CMain.Log, CMain.BackgroundMusic, CMain.Draw, CMain.Graphics); _PopupScreens[i].LoadTheme(); } } diff --git a/Vocaluxe/Base/CInput.cs b/Vocaluxe/Base/CInput.cs index 28af9bf8..e6465d31 100644 --- a/Vocaluxe/Base/CInput.cs +++ b/Vocaluxe/Base/CInput.cs @@ -4,6 +4,7 @@ using System.Text; using Vocaluxe.Lib.Input; using Vocaluxe.Lib.Input.WiiMote; +using Vocaluxe.Menu; namespace Vocaluxe.Base { diff --git a/Vocaluxe/Base/CLanguage.cs b/Vocaluxe/Base/CLanguage.cs index 9e8474ed..40ca03a6 100644 --- a/Vocaluxe/Base/CLanguage.cs +++ b/Vocaluxe/Base/CLanguage.cs @@ -6,6 +6,8 @@ using System.Text; using System.Xml; using System.Xml.XPath; +using Vocaluxe.Menu; + namespace Vocaluxe.Base { struct SLanguage diff --git a/Vocaluxe/Base/CPlaylists.cs b/Vocaluxe/Base/CPlaylists.cs index c509f4f6..0c2daa0e 100644 --- a/Vocaluxe/Base/CPlaylists.cs +++ b/Vocaluxe/Base/CPlaylists.cs @@ -7,6 +7,7 @@ using System.Xml.XPath; using Vocaluxe.Lib.Song; using Vocaluxe.Lib.Playlist; +using Vocaluxe.Menu; namespace Vocaluxe.Base { diff --git a/Vocaluxe/Base/CProfiles.cs b/Vocaluxe/Base/CProfiles.cs index ed73ed31..6f282051 100644 --- a/Vocaluxe/Base/CProfiles.cs +++ b/Vocaluxe/Base/CProfiles.cs @@ -6,6 +6,7 @@ using System.Xml; using System.Xml.XPath; using Vocaluxe.Lib.Draw; +using Vocaluxe.Menu; namespace Vocaluxe.Base { diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs index 16fb0475..3cf5209b 100644 --- a/Vocaluxe/Base/CSettings.cs +++ b/Vocaluxe/Base/CSettings.cs @@ -3,15 +3,10 @@ using System.Collections.Generic; using System.IO; using System.Text; +using Vocaluxe.Menu; + namespace Vocaluxe.Base { - public enum EGameState - { - Start, - Normal, - EditTheme - } - enum ERevision { Alpha, diff --git a/Vocaluxe/Base/CUtility.cs b/Vocaluxe/Base/CUtility.cs index 4f98fbc4..d3f97704 100644 --- a/Vocaluxe/Base/CUtility.cs +++ b/Vocaluxe/Base/CUtility.cs @@ -10,130 +10,10 @@ using System.Xml; using System.Xml.XPath; using Vocaluxe.Lib.Draw; +using Vocaluxe.Menu; namespace Vocaluxe.Base { - [Flags] - public enum EModifier - { - None, - Shift, - Alt, - Ctrl - } - - public enum ESender - { - Mouse, - Keyboard, - WiiMote, - Gamepad - } - - public struct KeyEvent - { - public ESender Sender; - public bool ModALT; - public bool ModSHIFT; - public bool ModCTRL; - public bool KeyPressed; - public bool Handled; - public Keys Key; - public Char Unicode; - public EModifier Mod; - - public KeyEvent(ESender sender, bool alt, bool shift, bool ctrl, bool pressed, char unicode, Keys key) - { - Sender = sender; - ModALT = alt; - ModSHIFT = shift; - ModCTRL = ctrl; - KeyPressed = pressed; - Unicode = unicode; - Key = key; - Handled = false; - - EModifier mALT = EModifier.None; - EModifier mSHIFT = EModifier.None; - EModifier mCTRL = EModifier.None; - - if (alt) - mALT = EModifier.Alt; - - if (shift) - mSHIFT = EModifier.Shift; - - if (ctrl) - mCTRL = EModifier.Ctrl; - - if (!alt && !shift && !ctrl) - Mod = EModifier.None; - else - Mod = mALT | mSHIFT | mCTRL; - } - } - - public struct MouseEvent - { - public ESender Sender; - public int X; - public int Y; - public bool LB; //left button click - public bool LD; //left button double click - public bool RB; //right button click - public bool MB; //middle button click - - public bool LBH; //left button hold (when moving) - public bool RBH; //right button hold (when moving) - public bool MBH; //middle button hold (when moving) - - public bool ModALT; - public bool ModSHIFT; - public bool ModCTRL; - - public EModifier Mod; - public int Wheel; - - public MouseEvent(ESender sender, bool alt, bool shift, bool ctrl, int x, int y, bool lb, bool ld, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh) - { - Sender = sender; - X = x; - Y = y; - LB = lb; - LD = ld; - RB = rb; - MB = mb; - - LBH = lbh; - RBH = rbh; - MBH = mbh; - - ModALT = alt; - ModSHIFT = shift; - ModCTRL = ctrl; - - EModifier mALT = EModifier.None; - EModifier mSHIFT = EModifier.None; - EModifier mCTRL = EModifier.None; - - if (alt) - mALT = EModifier.Alt; - - if (shift) - mSHIFT = EModifier.Shift; - - if (ctrl) - mCTRL = EModifier.Ctrl; - - if (!alt && !shift && !ctrl) - Mod = EModifier.None; - else - Mod = mALT | mSHIFT | mCTRL; - - Wheel = wheel; - } - } - static class CTime { private static Stopwatch _Stopwatch = new Stopwatch(); @@ -469,290 +349,6 @@ namespace Vocaluxe.Base } - class CHelper - { - public static int TryReadInt(StreamReader sr) - { - char chr = '0'; - string value = String.Empty; - - try - { - chr = (char)sr.Peek(); - while ((chr.CompareTo(' ') != 0) && ((int)chr != 19) && ((int)chr != 16) && ((int)chr != 13)) - { - chr = (char)sr.Read(); - value += chr.ToString(); - chr = (char)sr.Peek(); - } - } - catch (Exception) - { - return 0; - } - int result = 0; - int.TryParse(value, out result); - return result; - } - - public static void SetRect(RectangleF Bounds, ref RectangleF Rect, float RectAspect, EAspect Aspect) - { - float rW = Bounds.Right - Bounds.Left; - float rH = Bounds.Bottom - Bounds.Top; - float rA = rW / rH; - - float ScaledWidth = rW; - float ScaledHeight = rH; - - switch (Aspect) - { - case EAspect.Crop: - if (rA >= RectAspect) - { - ScaledWidth = rW; - ScaledHeight = rH * rA / RectAspect; - } - else - { - ScaledHeight = rH; - ScaledWidth = rW * RectAspect / rA; - } - break; - case EAspect.LetterBox: - if (RectAspect >= 1) - { - ScaledWidth = rW; - ScaledHeight = rH * rA / RectAspect; - } - else - { - ScaledHeight = rH; - ScaledWidth = rW * RectAspect / rA; - } - break; - default: - ScaledWidth = rW; - ScaledHeight = rH; - break; - } - - float Left = (rW - ScaledWidth) / 2 + Bounds.Left; - float Rigth = Left + ScaledWidth; - - float Upper = (rH - ScaledHeight) / 2 + Bounds.Top; - float Lower = Upper + ScaledHeight; - - Rect = new RectangleF(Left, Upper, Rigth - Left, Lower - Upper); - } - - public static bool TryGetEnumValueFromXML(string Cast, XPathNavigator Navigator, ref T value) - where T : struct - { - string val = String.Empty; - if (GetValueFromXML(Cast, Navigator, ref val, Enum.GetName(typeof(T), value))) - { - TryParse(val, out value, true); - return true; - } - return false; - } - - public static bool TryGetIntValueFromXML(string Cast, XPathNavigator Navigator, ref int value) - { - string val = String.Empty; - if (GetValueFromXML(Cast, Navigator, ref val, value.ToString())) - { - int res = 0; - if (int.TryParse(val, out res)) - { - value = res; - return true; - } - } - return false; - } - - public static bool TryGetFloatValueFromXML(string Cast, XPathNavigator Navigator, ref float value) - { - string val = String.Empty; - if (GetValueFromXML(Cast, Navigator, ref val, value.ToString())) - { - float res = 0; - if (TryParse(val, out res)) - { - value = res; - return true; - } - } - return false; - } - - public static bool GetValueFromXML(string Cast, XPathNavigator Navigator, ref string Value, string DefaultValue) - { - XPathNodeIterator iterator; - int results = 0; - string val = string.Empty; - - try - { - Navigator.MoveToFirstChild(); - iterator = Navigator.Select(Cast); - - while (iterator.MoveNext()) - { - val = iterator.Current.Value; - results++; - } - } - catch (Exception) - { - results = 0; - } - - if ((results == 0) || (results > 1)) - { - Value = DefaultValue; - return false; - } - else - { - Value = val; - return true; - } - - } - - public static List GetValuesFromXML(string Cast, XPathNavigator Navigator) - { - List values = new List(); - - try - { - Navigator.MoveToRoot(); - Navigator.MoveToFirstChild(); - Navigator.MoveToFirstChild(); - - while (Navigator.Name != Cast) - Navigator.MoveToNext(); - - Navigator.MoveToFirstChild(); - - values.Add(Navigator.LocalName); - while(Navigator.MoveToNext()) - values.Add(Navigator.LocalName); - - } - catch (Exception) - { - - } - - return values; - } - - public static bool ItemExistsInXML(string Cast, XPathNavigator Navigator) - { - XPathNodeIterator iterator; - int results = 0; - - try - { - Navigator.MoveToFirstChild(); - iterator = Navigator.Select(Cast); - - while (iterator.MoveNext()) - results++; - } - catch (Exception) - { - results = 0; - } - - if (results == 0) - return false; - - return true; - } - - public List ListFiles(string path, string cast) - { - return ListFiles(path, cast, false, false); - } - - public List ListFiles(string path, string cast, bool recursive) - { - return ListFiles(path, cast, recursive, false); - } - - public List ListFiles(string path, string cast, bool recursive, bool fullpath) - { - List files = new List(); - DirectoryInfo dir = new DirectoryInfo(path); - - try - { - - foreach (FileInfo file in dir.GetFiles(cast)) - { - if (!fullpath) - files.Add(file.Name); - else - //files.Add(Path.Combine(file.DirectoryName, file.Name)); - files.Add(file.FullName); - } - - if (recursive) - { - foreach (DirectoryInfo di in dir.GetDirectories()) - { - files.AddRange(ListFiles(di.FullName, cast, recursive, fullpath)); - } - } - } catch (Exception) - { - - } - - return files; - } - - public static bool TryParse(string value, out T result) - where T : struct - { - return TryParse(value, out result, false); - } - - public static bool TryParse(string value, out T result, bool ignoreCase) - where T : struct - { - result = default(T); - try - { - result = (T)Enum.Parse(typeof(T), value, ignoreCase); - return true; - } - catch { } - - return false; - } - - public static bool TryParse(string value, out float result) - { - value = value.Replace(',', '.'); - return float.TryParse(value, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, NumberFormatInfo.InvariantInfo, out result); - } - - public static bool IsInBounds(SRectF bounds, MouseEvent MouseEvent) - { - return IsInBounds(bounds, MouseEvent.X, MouseEvent.Y); - } - - public static bool IsInBounds(SRectF bounds, int x, int y) - { - return ((bounds.X <= x) && (bounds.X + bounds.W >= x) && (bounds.Y <= y) && (bounds.Y + bounds.H >= y)); - } - } - static class CEncoding { public static Encoding GetEncoding(string EncodingName) diff --git a/Vocaluxe/Base/CVideo.cs b/Vocaluxe/Base/CVideo.cs index 718222b4..04dad94b 100644 --- a/Vocaluxe/Base/CVideo.cs +++ b/Vocaluxe/Base/CVideo.cs @@ -4,7 +4,7 @@ using System.Diagnostics; using System.Drawing; using System.Text; -using Vocaluxe.Lib.Draw; +using Vocaluxe.Menu; using Vocaluxe.Lib.Video; namespace Vocaluxe.Base diff --git a/Vocaluxe/Base/CWebcam.cs b/Vocaluxe/Base/CWebcam.cs index cb735d77..5b8c4a64 100644 --- a/Vocaluxe/Base/CWebcam.cs +++ b/Vocaluxe/Base/CWebcam.cs @@ -1,10 +1,12 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Text; using Vocaluxe.Lib.Webcam; using Vocaluxe.Lib.Draw; -using System.Drawing; +using Vocaluxe.Menu; + namespace Vocaluxe.Base { diff --git a/Vocaluxe/Lib/Draw/IDraw.cs b/Vocaluxe/Lib/Draw/IDraw.cs index 7f39b5b0..fe6fcf42 100644 --- a/Vocaluxe/Lib/Draw/IDraw.cs +++ b/Vocaluxe/Lib/Draw/IDraw.cs @@ -8,122 +8,6 @@ using Vocaluxe.Menu; namespace Vocaluxe.Lib.Draw { - #region Structs - public struct SColorF - { - public float R; - public float G; - public float B; - public float A; - - public SColorF(float r, float g, float b, float a) - { - R = r; - G = g; - B = b; - A = a; - } - - public SColorF(SColorF Color) - { - R = Color.R; - G = Color.G; - B = Color.B; - A = Color.A; - } - } - - public struct SRectF - { - public float X; - public float Y; - public float W; - public float H; - public float Z; - public float Rotation; //0..360° - - public SRectF(float x, float y, float w, float h, float z) - { - X = x; - Y = y; - W = w; - H = h; - Z = z; - Rotation = 0f; - } - - public SRectF(SRectF rect) - { - X = rect.X; - Y = rect.Y; - W = rect.W; - H = rect.H; - Z = rect.Z; - Rotation = 0f; - } - } - - public struct SPoint3f - { - public float X; - public float Y; - public float Z; - } - - public struct SPoint3 - { - public int X; - public int Y; - public int Z; - } - - public struct STexture - { - public int index; - public int PBO; - public int ID; - - public string TexturePath; - - public float width; - public float height; - public SRectF rect; - - public float w2; //power of 2 width - public float h2; //power of 2 height - public float width_ratio; - public float height_ratio; - - public SColorF color; - - public STexture(int Index) - { - index = Index; - PBO = 0; - ID = -1; - TexturePath = String.Empty; - - width = 1f; - height = 1f; - rect = new SRectF(0f, 0f, 1f, 1f, 0f); - - w2 = 2f; - h2 = 2f; - width_ratio = 0.5f; - height_ratio = 0.5f; - - color = new SColorF(1f, 1f, 1f, 1f); - } - } - #endregion Structs - - enum EAspect - { - Crop, - LetterBox, - Stretch - } - interface IDraw { bool Init(); diff --git a/Vocaluxe/Lib/Input/IInput.cs b/Vocaluxe/Lib/Input/IInput.cs index 86dcde04..9ccfa247 100644 --- a/Vocaluxe/Lib/Input/IInput.cs +++ b/Vocaluxe/Lib/Input/IInput.cs @@ -5,6 +5,7 @@ using System.Drawing; using System.Text; using Vocaluxe.Base; +using Vocaluxe.Menu; namespace Vocaluxe.Lib.Input { diff --git a/Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs b/Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs index 4578723c..8af2e202 100644 --- a/Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs +++ b/Vocaluxe/Lib/Input/WiiMote/CWiiMote.cs @@ -7,6 +7,7 @@ using System.Text; using System.Threading; using Vocaluxe.Base; +using Vocaluxe.Menu; namespace Vocaluxe.Lib.Input.WiiMote { diff --git a/Vocaluxe/Lib/Input/WiiMote/WiiMoteLib.cs b/Vocaluxe/Lib/Input/WiiMote/WiiMoteLib.cs index 71322681..9d15f5b0 100644 --- a/Vocaluxe/Lib/Input/WiiMote/WiiMoteLib.cs +++ b/Vocaluxe/Lib/Input/WiiMote/WiiMoteLib.cs @@ -10,6 +10,7 @@ using System.Windows.Forms; using Vocaluxe.Base; using Vocaluxe.Lib.Draw; using Vocaluxe.Lib.Input; +using Vocaluxe.Menu; namespace Vocaluxe.Lib.Input.WiiMote { diff --git a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs index 57e9fb55..c22cb99e 100644 --- a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs +++ b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs @@ -8,6 +8,7 @@ using System.Xml.XPath; using Vocaluxe.Base; using Vocaluxe.GameModes; using Vocaluxe.Lib.Song; +using Vocaluxe.Menu; namespace Vocaluxe.Lib.Playlist diff --git a/Vocaluxe/Lib/Video/CVideoDecoder.cs b/Vocaluxe/Lib/Video/CVideoDecoder.cs index 1c6d673c..da4150db 100644 --- a/Vocaluxe/Lib/Video/CVideoDecoder.cs +++ b/Vocaluxe/Lib/Video/CVideoDecoder.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -using Vocaluxe.Lib.Draw; +using Vocaluxe.Menu; namespace Vocaluxe.Lib.Video { diff --git a/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs b/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs index a9cacb6d..9b0f7828 100644 --- a/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs +++ b/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs @@ -9,6 +9,7 @@ using System.Threading; using Vocaluxe.Base; using Vocaluxe.Lib.Draw; using Vocaluxe.Lib.Video.Acinerella; +using Vocaluxe.Menu; namespace Vocaluxe.Lib.Video { diff --git a/Vocaluxe/Lib/Video/IVideoDecoder.cs b/Vocaluxe/Lib/Video/IVideoDecoder.cs index 374964e0..2f12f2b3 100644 --- a/Vocaluxe/Lib/Video/IVideoDecoder.cs +++ b/Vocaluxe/Lib/Video/IVideoDecoder.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Text; using Vocaluxe.Lib.Draw; +using Vocaluxe.Menu; namespace Vocaluxe.Lib.Video { diff --git a/Vocaluxe/Lib/Webcam/CAForgeNet.cs b/Vocaluxe/Lib/Webcam/CAForgeNet.cs index 0d520e1a..cbddcedc 100644 --- a/Vocaluxe/Lib/Webcam/CAForgeNet.cs +++ b/Vocaluxe/Lib/Webcam/CAForgeNet.cs @@ -10,6 +10,8 @@ using System.Runtime.InteropServices; using Vocaluxe.Lib.Draw; using System.Threading; +using Vocaluxe.Menu; + namespace Vocaluxe.Lib.Webcam { class CAForgeNet : IWebcam diff --git a/Vocaluxe/Lib/Webcam/IWebcam.cs b/Vocaluxe/Lib/Webcam/IWebcam.cs index 5b0ed223..066b83c3 100644 --- a/Vocaluxe/Lib/Webcam/IWebcam.cs +++ b/Vocaluxe/Lib/Webcam/IWebcam.cs @@ -4,6 +4,8 @@ using System.Text; using Vocaluxe.Lib.Draw; using System.Drawing; +using Vocaluxe.Menu; + namespace Vocaluxe.Lib.Webcam { struct SWebcamDevice diff --git a/Vocaluxe/Menu/CMenu.cs b/Vocaluxe/Menu/CMenu.cs index 91fc6bf4..eaa8a4b3 100644 --- a/Vocaluxe/Menu/CMenu.cs +++ b/Vocaluxe/Menu/CMenu.cs @@ -8,7 +8,7 @@ using System.Windows.Forms; using System.Xml; using System.Xml.XPath; -using Vocaluxe.Base; +//using Vocaluxe.Base; using Vocaluxe.Lib.Draw; using Vocaluxe.Menu; using Vocaluxe.Menu.SingNotes; @@ -76,6 +76,15 @@ namespace Vocaluxe.Menu protected SRectF _ScreenArea; + private IConfig _Config; + private ISettings _Settings; + private ITheme _Theme; + private IHelper _Helper; + private ILog _Log; + private IBackgroundMusic _BackgroundMusic; + private IDrawing _Draw; + private IGraphics _Graphics; + public SRectF ScreenArea { get { return _ScreenArea; } @@ -92,7 +101,20 @@ namespace Vocaluxe.Menu } public CMenu() + { + } + + public void Initialize(IConfig Config, ISettings Settings, ITheme Theme, IHelper Helper, ILog Log, IBackgroundMusic BackgroundMusic, IDrawing Draw, IGraphics Graphics) { + _Config = Config; + _Settings = Settings; + _Theme = Theme; + _Helper = Helper; + _Log = Log; + _BackgroundMusic = BackgroundMusic; + _Draw = Draw; + _Graphics = Graphics; + Init(); } @@ -132,8 +154,8 @@ namespace Vocaluxe.Menu _MouseDY = 0; _Active = false; - _ScreenArea = new SRectF(0f, 0f, CSettings.iRenderW, CSettings.iRenderH, 0f); - + _ScreenArea = new SRectF(0f, 0f, _Settings.GetRenderW(), _Settings.GetRenderH(), 0f); + _ThemeName = String.Empty; _ThemeBackgrounds = null; _ThemeStatics = null; @@ -146,12 +168,11 @@ namespace Vocaluxe.Menu _ThemeNameSelections = null; _ThemeEqualizers = null; _ThemePlaylists = null; - } #region ThemeHandler public virtual void LoadTheme() { - string file = Path.Combine(CTheme.GetThemeScreensPath(), _ThemeName + ".xml"); + string file = Path.Combine(_Theme.GetThemeScreensPath(), _ThemeName + ".xml"); XPathDocument xPathDoc = null; XPathNavigator navigator = null; @@ -172,14 +193,14 @@ namespace Vocaluxe.Menu if (xPathDoc != null) xPathDoc = null; - CLog.LogError("Error loading theme file " + file + ": " + e.Message); + _Log.LogError("Error loading theme file " + file + ": " + e.Message); } bool VersionCheck = false; if (loaded) VersionCheck = CheckVersion(_ScreenVersion, navigator); - int SkinIndex = CTheme.GetSkinIndex(); + int SkinIndex = _Theme.GetSkinIndex(); if (loaded && VersionCheck && SkinIndex != -1) { @@ -196,7 +217,7 @@ namespace Vocaluxe.Menu } else { - CLog.LogError("Can't load Background \"" + _ThemeBackgrounds[i] + "\" in screen " + _ThemeName); + _Log.LogError("Can't load Background \"" + _ThemeBackgrounds[i] + "\" in screen " + _ThemeName); } } } @@ -212,7 +233,7 @@ namespace Vocaluxe.Menu } else { - CLog.LogError("Can't load Static \"" + _ThemeStatics[i] + "\" in screen " + _ThemeName); + _Log.LogError("Can't load Static \"" + _ThemeStatics[i] + "\" in screen " + _ThemeName); } } } @@ -228,7 +249,7 @@ namespace Vocaluxe.Menu } else { - CLog.LogError("Can't load Text \"" + _ThemeTexts[i] + "\" in screen " + _ThemeName); + _Log.LogError("Can't load Text \"" + _ThemeTexts[i] + "\" in screen " + _ThemeName); } } } @@ -244,7 +265,7 @@ namespace Vocaluxe.Menu } else { - CLog.LogError("Can't load Button \"" + _ThemeButtons[i] + "\" in screen " + _ThemeName); + _Log.LogError("Can't load Button \"" + _ThemeButtons[i] + "\" in screen " + _ThemeName); } } } @@ -260,7 +281,7 @@ namespace Vocaluxe.Menu } else { - CLog.LogError("Can't load SelectSlide \"" + _ThemeSelectSlides[i] + "\" in screen " + _ThemeName); + _Log.LogError("Can't load SelectSlide \"" + _ThemeSelectSlides[i] + "\" in screen " + _ThemeName); } } } @@ -276,7 +297,7 @@ namespace Vocaluxe.Menu } else { - CLog.LogError("Can't load SongMenu \"" + _ThemeSongMenus[i] + "\" in screen " + _ThemeName); + _Log.LogError("Can't load SongMenu \"" + _ThemeSongMenus[i] + "\" in screen " + _ThemeName); } } } @@ -292,7 +313,7 @@ namespace Vocaluxe.Menu } else { - CLog.LogError("Can't load Lyric \"" + _ThemeLyrics[i] + "\" in screen " + _ThemeName); + _Log.LogError("Can't load Lyric \"" + _ThemeLyrics[i] + "\" in screen " + _ThemeName); } } } @@ -308,7 +329,7 @@ namespace Vocaluxe.Menu } else { - CLog.LogError("Can't load SingBar \"" + _ThemeSingNotes[i] + "\" in screen " + _ThemeName); + _Log.LogError("Can't load SingBar \"" + _ThemeSingNotes[i] + "\" in screen " + _ThemeName); } } } @@ -324,7 +345,7 @@ namespace Vocaluxe.Menu } else { - CLog.LogError("Can't load NameSelection \"" + _ThemeNameSelections[i] + "\" in screen " + _ThemeName); + _Log.LogError("Can't load NameSelection \"" + _ThemeNameSelections[i] + "\" in screen " + _ThemeName); } } } @@ -340,7 +361,7 @@ namespace Vocaluxe.Menu } else { - CLog.LogError("Can't load equalizer \"" + _ThemeEqualizers[i] + "\" in screen " + _ThemeName); + _Log.LogError("Can't load equalizer \"" + _ThemeEqualizers[i] + "\" in screen " + _ThemeName); } } } @@ -356,7 +377,7 @@ namespace Vocaluxe.Menu } else { - CLog.LogError("Can't load Playlist \"" + _ThemePlaylists[i] + "\" in screen " + _ThemeName); + _Log.LogError("Can't load Playlist \"" + _ThemePlaylists[i] + "\" in screen " + _ThemeName); } } } @@ -374,7 +395,7 @@ namespace Vocaluxe.Menu settings.Encoding = Encoding.UTF8; settings.ConformanceLevel = ConformanceLevel.Document; - string file = Path.Combine(CTheme.GetThemeScreensPath(), _ThemeName + ".xml"); + string file = Path.Combine(_Theme.GetThemeScreensPath(), _ThemeName + ".xml"); XmlWriter writer = XmlWriter.Create(file, settings); writer.WriteStartDocument(); @@ -738,7 +759,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - CLog.LogError("Can't find Background Element \"" + key + "\" in Screen " + _ThemeName); + _Log.LogError("Can't find Background Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -751,7 +772,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - CLog.LogError("Can't find Statics Element \"" + key + "\" in Screen " + _ThemeName); + _Log.LogError("Can't find Statics Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -764,7 +785,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - CLog.LogError("Can't find Text Element \"" + key + "\" in Screen " + _ThemeName); + _Log.LogError("Can't find Text Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -777,7 +798,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - CLog.LogError("Can't find Button Element \"" + key + "\" in Screen " + _ThemeName); + _Log.LogError("Can't find Button Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -790,7 +811,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - CLog.LogError("Can't find SongMenu Element \"" + key + "\" in Screen " + _ThemeName); + _Log.LogError("Can't find SongMenu Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -803,7 +824,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - CLog.LogError("Can't find Lyric Element \"" + key + "\" in Screen " + _ThemeName); + _Log.LogError("Can't find Lyric Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -816,7 +837,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - CLog.LogError("Can't find SelectSlide Element \"" + key + "\" in Screen " + _ThemeName); + _Log.LogError("Can't find SelectSlide Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -829,7 +850,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - CLog.LogError("Can't find SingBar Element \"" + key + "\" in Screen " + _ThemeName); + _Log.LogError("Can't find SingBar Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -842,7 +863,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - CLog.LogError("Can't find NameSelection Element \"" + key + "\" in Screen " + _ThemeName); + _Log.LogError("Can't find NameSelection Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -855,7 +876,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - CLog.LogError("Can't find Equalizer Element \"" + key + "\" in Screen " + _ThemeName); + _Log.LogError("Can't find Equalizer Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -868,7 +889,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - CLog.LogError("Can't find Playlist Element \"" + key + "\" in Screen " + _ThemeName); + _Log.LogError("Can't find Playlist Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -878,7 +899,7 @@ namespace Vocaluxe.Menu #region MenuHandler public virtual bool HandleInput(KeyEvent KeyEvent) { - if (!CSettings.TabNavigation) + if (!_Settings.IsTabNavigation()) { if (KeyEvent.Key == Keys.Left) { @@ -917,35 +938,25 @@ namespace Vocaluxe.Menu if (KeyEvent.Key == Keys.Right) NextElement(); } - if (!CBackgroundMusic.Disabled) + if (_BackgroundMusic.IsDisabled()) { if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Add || KeyEvent.Key == Keys.PageUp)) - { - CConfig.BackgroundMusicVolume = CConfig.BackgroundMusicVolume + 5; - if (CConfig.BackgroundMusicVolume > 100) - CConfig.BackgroundMusicVolume = 100; - CConfig.SaveConfig(); - } + _Config.SetBackgroundMusicVolume(_Config.GetBackgroundMusicVolume() + 5); else if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Subtract || KeyEvent.Key == Keys.PageDown)) - { - CConfig.BackgroundMusicVolume = CConfig.BackgroundMusicVolume - 5; - if (CConfig.BackgroundMusicVolume < 0) - CConfig.BackgroundMusicVolume = 0; - CConfig.SaveConfig(); - } + _Config.SetBackgroundMusicVolume(_Config.GetBackgroundMusicVolume() - 5); else if (KeyEvent.Key == Keys.MediaNextTrack) - CBackgroundMusic.Next(); + _BackgroundMusic.Next(); else if (KeyEvent.Key == Keys.MediaPreviousTrack) - CBackgroundMusic.Previous(); + _BackgroundMusic.Previous(); else if (KeyEvent.Key == Keys.MediaPlayPause) { - if (CBackgroundMusic.Playing) - CBackgroundMusic.Pause(); + if (_BackgroundMusic.IsPlaying()) + _BackgroundMusic.Pause(); else - CBackgroundMusic.Play(); + _BackgroundMusic.Play(); } - - CBackgroundMusic.ApplyVolume(); + + _BackgroundMusic.ApplyVolume(); } return true; @@ -1356,10 +1367,10 @@ namespace Vocaluxe.Menu public void SelectByMouse(int x, int y) { - float z = CSettings.zFar; + float z = _Settings.GetZFar(); for (int i = 0; i < _Interactions.Count; i++) { - if ((CSettings.GameState == EGameState.EditTheme) || (!_Interactions[i].ThemeEditorOnly && _IsVisible(i))) + if ((_Settings.GetGameState() == EGameState.EditTheme) || (!_Interactions[i].ThemeEditorOnly && _IsVisible(i))) { if (_IsMouseOver(x, y, _Interactions[i])) { @@ -1410,7 +1421,7 @@ namespace Vocaluxe.Menu return true; break; case EType.TText: - RectangleF bounds = CDraw.GetTextBounds(_Texts[interact.Num]); + RectangleF bounds = _Draw.GetTextBounds(_Texts[interact.Num]); if (CHelper.IsInBounds(new SRectF(_Texts[interact.Num].X, _Texts[interact.Num].Y, bounds.Width, bounds.Height, _Texts[interact.Num].Z), x, y)) return true; break; @@ -1461,7 +1472,7 @@ namespace Vocaluxe.Menu case EType.TPlaylist: return _Playlists[interact.Num].Rect.Z; } - return CSettings.zFar; + return _Settings.GetZFar(); } private float _GetZValue(int interaction) @@ -1496,13 +1507,13 @@ namespace Vocaluxe.Menu return _Playlists[_Interactions[interaction].Num].Rect.Z; } - return CSettings.zFar; + return _Settings.GetZFar(); } private void _NextInteraction() { _UnsetSelected(); - if (CSettings.GameState != EGameState.EditTheme) + if (_Settings.GetGameState() != EGameState.EditTheme) { bool found = false; int start = _Selection; @@ -1529,7 +1540,7 @@ namespace Vocaluxe.Menu private void _PrevInteraction() { _UnsetSelected(); - if (CSettings.GameState != EGameState.EditTheme) + if (_Settings.GetGameState() != EGameState.EditTheme) { bool found = false; int start = _Selection; @@ -1676,13 +1687,13 @@ namespace Vocaluxe.Menu switch (Key.Key) { case Keys.Up: - actualRect = new SRectF(actualRect.X, CSettings.iRenderH, 1, 1, actualRect.Z); + actualRect = new SRectF(actualRect.X, _Settings.GetRenderH(), 1, 1, actualRect.Z); break; case Keys.Down: actualRect = new SRectF(actualRect.X, 0, 1, 1, actualRect.Z); break; case Keys.Left: - actualRect = new SRectF(CSettings.iRenderW, actualRect.Y, 1, 1, actualRect.Z); + actualRect = new SRectF(_Settings.GetRenderW(), actualRect.Y, 1, 1, actualRect.Z); break; case Keys.Right: actualRect = new SRectF(0, actualRect.Y, 1, 1, actualRect.Z); @@ -2200,7 +2211,7 @@ namespace Vocaluxe.Menu msg += "the file is for newer program versions! "; msg += "Current screen version is " + Version.ToString(); - CLog.LogError(msg); + _Log.LogError(msg); } return false; } @@ -2242,11 +2253,11 @@ namespace Vocaluxe.Menu private void ReloadThemeEditMode() { - CTheme.UnloadSkins(); - CTheme.ListSkins(); - CTheme.LoadSkins(); - CTheme.LoadTheme(); - CGraphics.ReloadTheme(); + _Theme.UnloadSkins(); + _Theme.ListSkins(); + _Theme.LoadSkins(); + _Theme.LoadTheme(); + _Graphics.ReloadTheme(); OnShow(); OnShowFinish(); diff --git a/Vocaluxe/Menu/IMenu.cs b/Vocaluxe/Menu/IMenu.cs index cc65ede5..192a12b5 100644 --- a/Vocaluxe/Menu/IMenu.cs +++ b/Vocaluxe/Menu/IMenu.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Text; +using System.Windows.Forms; using Vocaluxe.Base; using Vocaluxe.Lib.Draw; @@ -9,6 +11,8 @@ namespace Vocaluxe.Menu { interface IMenu { + void Initialize(IConfig Config, ISettings Settings, ITheme Theme, IHelper Helper, ILog Log, IBackgroundMusic BackgroundMusic, IDrawing Draw, IGraphics Graphics); + void LoadTheme(); void SaveTheme(); void ReloadTextures(); @@ -38,4 +42,309 @@ namespace Vocaluxe.Menu void ProcessMouseClick(int x, int y); void ProcessMouseMove(int x, int y); } + + interface IConfig + { + void SetBackgroundMusicVolume(int NewVolume); + int GetBackgroundMusicVolume(); + } + + interface ISettings + { + int GetRenderW(); + int GetRenderH(); + bool IsTabNavigation(); + + float GetZFar(); + float GetZNear(); + + EGameState GetGameState(); + } + + interface ITheme + { + string GetThemeScreensPath(); + int GetSkinIndex(); + + void UnloadSkins(); + void ListSkins(); + void LoadSkins(); + void LoadTheme(); + } + + interface IHelper + { + } + + interface IBackgroundMusic + { + bool IsDisabled(); + bool IsPlaying(); + + void Next(); + void Previous(); + void Pause(); + void Play(); + + void ApplyVolume(); + } + + interface IDrawing + { + RectangleF GetTextBounds(CText text); + } + + interface IGraphics + { + void ReloadTheme(); + } + + interface ILog + { + void LogError(string ErrorText); + } + + [Flags] + public enum EModifier + { + None, + Shift, + Alt, + Ctrl + } + + public enum ESender + { + Mouse, + Keyboard, + WiiMote, + Gamepad + } + + public struct KeyEvent + { + public ESender Sender; + public bool ModALT; + public bool ModSHIFT; + public bool ModCTRL; + public bool KeyPressed; + public bool Handled; + public Keys Key; + public Char Unicode; + public EModifier Mod; + + public KeyEvent(ESender sender, bool alt, bool shift, bool ctrl, bool pressed, char unicode, Keys key) + { + Sender = sender; + ModALT = alt; + ModSHIFT = shift; + ModCTRL = ctrl; + KeyPressed = pressed; + Unicode = unicode; + Key = key; + Handled = false; + + EModifier mALT = EModifier.None; + EModifier mSHIFT = EModifier.None; + EModifier mCTRL = EModifier.None; + + if (alt) + mALT = EModifier.Alt; + + if (shift) + mSHIFT = EModifier.Shift; + + if (ctrl) + mCTRL = EModifier.Ctrl; + + if (!alt && !shift && !ctrl) + Mod = EModifier.None; + else + Mod = mALT | mSHIFT | mCTRL; + } + } + + public struct MouseEvent + { + public ESender Sender; + public int X; + public int Y; + public bool LB; //left button click + public bool LD; //left button double click + public bool RB; //right button click + public bool MB; //middle button click + + public bool LBH; //left button hold (when moving) + public bool RBH; //right button hold (when moving) + public bool MBH; //middle button hold (when moving) + + public bool ModALT; + public bool ModSHIFT; + public bool ModCTRL; + + public EModifier Mod; + public int Wheel; + + public MouseEvent(ESender sender, bool alt, bool shift, bool ctrl, int x, int y, bool lb, bool ld, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh) + { + Sender = sender; + X = x; + Y = y; + LB = lb; + LD = ld; + RB = rb; + MB = mb; + + LBH = lbh; + RBH = rbh; + MBH = mbh; + + ModALT = alt; + ModSHIFT = shift; + ModCTRL = ctrl; + + EModifier mALT = EModifier.None; + EModifier mSHIFT = EModifier.None; + EModifier mCTRL = EModifier.None; + + if (alt) + mALT = EModifier.Alt; + + if (shift) + mSHIFT = EModifier.Shift; + + if (ctrl) + mCTRL = EModifier.Ctrl; + + if (!alt && !shift && !ctrl) + Mod = EModifier.None; + else + Mod = mALT | mSHIFT | mCTRL; + + Wheel = wheel; + } + } + + public enum EGameState + { + Start, + Normal, + EditTheme + } + + enum EAspect + { + Crop, + LetterBox, + Stretch + } + + #region Structs + public struct SColorF + { + public float R; + public float G; + public float B; + public float A; + + public SColorF(float r, float g, float b, float a) + { + R = r; + G = g; + B = b; + A = a; + } + + public SColorF(SColorF Color) + { + R = Color.R; + G = Color.G; + B = Color.B; + A = Color.A; + } + } + + public struct SRectF + { + public float X; + public float Y; + public float W; + public float H; + public float Z; + public float Rotation; //0..360° + + public SRectF(float x, float y, float w, float h, float z) + { + X = x; + Y = y; + W = w; + H = h; + Z = z; + Rotation = 0f; + } + + public SRectF(SRectF rect) + { + X = rect.X; + Y = rect.Y; + W = rect.W; + H = rect.H; + Z = rect.Z; + Rotation = 0f; + } + } + + public struct SPoint3f + { + public float X; + public float Y; + public float Z; + } + + public struct SPoint3 + { + public int X; + public int Y; + public int Z; + } + + public struct STexture + { + public int index; + public int PBO; + public int ID; + + public string TexturePath; + + public float width; + public float height; + public SRectF rect; + + public float w2; //power of 2 width + public float h2; //power of 2 height + public float width_ratio; + public float height_ratio; + + public SColorF color; + + public STexture(int Index) + { + index = Index; + PBO = 0; + ID = -1; + TexturePath = String.Empty; + + width = 1f; + height = 1f; + rect = new SRectF(0f, 0f, 1f, 1f, 0f); + + w2 = 2f; + h2 = 2f; + width_ratio = 0.5f; + height_ratio = 0.5f; + + color = new SColorF(1f, 1f, 1f, 1f); + } + } + #endregion Structs } diff --git a/Vocaluxe/Screens/CPopupScreenPlayerControl.cs b/Vocaluxe/Screens/CPopupScreenPlayerControl.cs index f1b206b2..16d0d3bd 100644 --- a/Vocaluxe/Screens/CPopupScreenPlayerControl.cs +++ b/Vocaluxe/Screens/CPopupScreenPlayerControl.cs @@ -76,7 +76,6 @@ namespace Vocaluxe.Screens public CPopupScreenPlayerControl() { - Init(); } protected override void Init() diff --git a/Vocaluxe/Screens/CPopupScreenVolumeControl.cs b/Vocaluxe/Screens/CPopupScreenVolumeControl.cs index a3c0f4aa..76624af1 100644 --- a/Vocaluxe/Screens/CPopupScreenVolumeControl.cs +++ b/Vocaluxe/Screens/CPopupScreenVolumeControl.cs @@ -24,7 +24,6 @@ namespace Vocaluxe.Screens public CPopupScreenVolumeControl() { - Init(); } protected override void Init() diff --git a/Vocaluxe/Screens/CScreenCredits.cs b/Vocaluxe/Screens/CScreenCredits.cs index 0327b38c..582a26bc 100644 --- a/Vocaluxe/Screens/CScreenCredits.cs +++ b/Vocaluxe/Screens/CScreenCredits.cs @@ -59,7 +59,6 @@ namespace Vocaluxe.Screens public CScreenCredits() { - Init(); } protected override void Init() diff --git a/Vocaluxe/Screens/CScreenHighscore.cs b/Vocaluxe/Screens/CScreenHighscore.cs index 5704ce63..06cb2c6d 100644 --- a/Vocaluxe/Screens/CScreenHighscore.cs +++ b/Vocaluxe/Screens/CScreenHighscore.cs @@ -31,7 +31,6 @@ namespace Vocaluxe.Screens public CScreenHighscore() { - Init(); } protected override void Init() diff --git a/Vocaluxe/Screens/CScreenLoad.cs b/Vocaluxe/Screens/CScreenLoad.cs index 41f373b2..77f3cab4 100644 --- a/Vocaluxe/Screens/CScreenLoad.cs +++ b/Vocaluxe/Screens/CScreenLoad.cs @@ -36,7 +36,6 @@ namespace Vocaluxe.Screens public CScreenLoad() { - Init(); } protected override void Init() diff --git a/Vocaluxe/Screens/CScreenMain.cs b/Vocaluxe/Screens/CScreenMain.cs index 4dea3cfb..a9dc6cc0 100644 --- a/Vocaluxe/Screens/CScreenMain.cs +++ b/Vocaluxe/Screens/CScreenMain.cs @@ -28,7 +28,6 @@ namespace Vocaluxe.Screens public CScreenMain() { - Init(); } protected override void Init() diff --git a/Vocaluxe/Screens/CScreenNames.cs b/Vocaluxe/Screens/CScreenNames.cs index 4e838086..5099dc36 100644 --- a/Vocaluxe/Screens/CScreenNames.cs +++ b/Vocaluxe/Screens/CScreenNames.cs @@ -43,7 +43,6 @@ namespace Vocaluxe.Screens public CScreenNames() { - Init(); } protected override void Init() diff --git a/Vocaluxe/Screens/CScreenOptions.cs b/Vocaluxe/Screens/CScreenOptions.cs index e3353ee2..755a03c3 100644 --- a/Vocaluxe/Screens/CScreenOptions.cs +++ b/Vocaluxe/Screens/CScreenOptions.cs @@ -23,7 +23,6 @@ namespace Vocaluxe.Screens public CScreenOptions() { - Init(); } protected override void Init() diff --git a/Vocaluxe/Screens/CScreenOptionsGame.cs b/Vocaluxe/Screens/CScreenOptionsGame.cs index 96acb672..72d335ba 100644 --- a/Vocaluxe/Screens/CScreenOptionsGame.cs +++ b/Vocaluxe/Screens/CScreenOptionsGame.cs @@ -32,7 +32,6 @@ namespace Vocaluxe.Screens public CScreenOptionsGame() { - Init(); } protected override void Init() diff --git a/Vocaluxe/Screens/CScreenOptionsLyrics.cs b/Vocaluxe/Screens/CScreenOptionsLyrics.cs index c6574c31..eef18019 100644 --- a/Vocaluxe/Screens/CScreenOptionsLyrics.cs +++ b/Vocaluxe/Screens/CScreenOptionsLyrics.cs @@ -20,7 +20,6 @@ namespace Vocaluxe.Screens public CScreenOptionsLyrics() { - Init(); } protected override void Init() diff --git a/Vocaluxe/Screens/CScreenOptionsRecord.cs b/Vocaluxe/Screens/CScreenOptionsRecord.cs index 7c0dae2d..2964d0f8 100644 --- a/Vocaluxe/Screens/CScreenOptionsRecord.cs +++ b/Vocaluxe/Screens/CScreenOptionsRecord.cs @@ -56,7 +56,6 @@ namespace Vocaluxe.Screens public CScreenOptionsRecord() { - Init(); } protected override void Init() diff --git a/Vocaluxe/Screens/CScreenOptionsSound.cs b/Vocaluxe/Screens/CScreenOptionsSound.cs index ca4a7a86..c6c91042 100644 --- a/Vocaluxe/Screens/CScreenOptionsSound.cs +++ b/Vocaluxe/Screens/CScreenOptionsSound.cs @@ -27,7 +27,6 @@ namespace Vocaluxe.Screens public CScreenOptionsSound() { - Init(); } protected override void Init() diff --git a/Vocaluxe/Screens/CScreenOptionsTheme.cs b/Vocaluxe/Screens/CScreenOptionsTheme.cs index a8862dd7..8f868bc3 100644 --- a/Vocaluxe/Screens/CScreenOptionsTheme.cs +++ b/Vocaluxe/Screens/CScreenOptionsTheme.cs @@ -33,7 +33,6 @@ namespace Vocaluxe.Screens public CScreenOptionsTheme() { - Init(); } protected override void Init() diff --git a/Vocaluxe/Screens/CScreenOptionsVideo.cs b/Vocaluxe/Screens/CScreenOptionsVideo.cs index fa5f5f1f..3221bdf0 100644 --- a/Vocaluxe/Screens/CScreenOptionsVideo.cs +++ b/Vocaluxe/Screens/CScreenOptionsVideo.cs @@ -27,13 +27,12 @@ namespace Vocaluxe.Screens private const string ButtonExit = "ButtonExit"; private SWebcamConfig _Config; - Lib.Draw.STexture _WebcamTexture = new Lib.Draw.STexture(-1); + STexture _WebcamTexture = new STexture(-1); private int _DeviceNr; private int _CapabilityNr; public CScreenOptionsVideo() { - Init(); } protected override void Init() diff --git a/Vocaluxe/Screens/CScreenParty.cs b/Vocaluxe/Screens/CScreenParty.cs index 0d0a6d38..aa003b4a 100644 --- a/Vocaluxe/Screens/CScreenParty.cs +++ b/Vocaluxe/Screens/CScreenParty.cs @@ -16,7 +16,6 @@ namespace Vocaluxe.Screens public CScreenParty() { - Init(); } protected override void Init() diff --git a/Vocaluxe/Screens/CScreenPartyDummy.cs b/Vocaluxe/Screens/CScreenPartyDummy.cs index a414c419..a506e5cd 100644 --- a/Vocaluxe/Screens/CScreenPartyDummy.cs +++ b/Vocaluxe/Screens/CScreenPartyDummy.cs @@ -14,7 +14,6 @@ namespace Vocaluxe.Screens public CScreenPartyDummy() { - Init(); } protected override void Init() diff --git a/Vocaluxe/Screens/CScreenProfiles.cs b/Vocaluxe/Screens/CScreenProfiles.cs index ec94f1e5..456cd8fd 100644 --- a/Vocaluxe/Screens/CScreenProfiles.cs +++ b/Vocaluxe/Screens/CScreenProfiles.cs @@ -41,12 +41,11 @@ namespace Vocaluxe.Screens private EEditMode _EditMode; - private Lib.Draw.STexture _WebcamTexture = new Lib.Draw.STexture(-1); + private STexture _WebcamTexture = new STexture(-1); private Bitmap _Snapshot = null; public CScreenProfiles() { - Init(); } protected override void Init() diff --git a/Vocaluxe/Screens/CScreenScore.cs b/Vocaluxe/Screens/CScreenScore.cs index 5f652325..7f0701fc 100644 --- a/Vocaluxe/Screens/CScreenScore.cs +++ b/Vocaluxe/Screens/CScreenScore.cs @@ -33,7 +33,6 @@ namespace Vocaluxe.Screens public CScreenScore() { - Init(); } protected override void Init() @@ -366,7 +365,7 @@ namespace Vocaluxe.Screens Statics[htStatics(StaticPointsBarBG[player, numplayer])].Visible = (numplayer + 1 == CGame.NumPlayer); Statics[htStatics(StaticAvatar[player, numplayer])].Visible = (numplayer + 1 == CGame.NumPlayer); - Statics[htStatics(StaticAvatar[player, numplayer])].Texture = new Lib.Draw.STexture(-1); + Statics[htStatics(StaticAvatar[player, numplayer])].Texture = new STexture(-1); } } } diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 11c57146..2e001911 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -97,7 +97,6 @@ namespace Vocaluxe.Screens public CScreenSing() { - Init(); } protected override void Init() diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 9325e95c..2cee62d6 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -68,8 +68,6 @@ namespace Vocaluxe.Screens public CScreenSong() { - Init(); - _AvailableGameModes = new List(); } diff --git a/Vocaluxe/Screens/CScreenTest.cs b/Vocaluxe/Screens/CScreenTest.cs index 9f387043..a203518e 100644 --- a/Vocaluxe/Screens/CScreenTest.cs +++ b/Vocaluxe/Screens/CScreenTest.cs @@ -19,7 +19,6 @@ namespace Vocaluxe.Screens public CScreenTest() { - Init(); } protected override void Init() diff --git a/Vocaluxe/Screens/PartyScreens/CMenuParty.cs b/Vocaluxe/Screens/PartyScreens/CMenuParty.cs index 332f93e9..94f90323 100644 --- a/Vocaluxe/Screens/PartyScreens/CMenuParty.cs +++ b/Vocaluxe/Screens/PartyScreens/CMenuParty.cs @@ -6,8 +6,13 @@ using Vocaluxe.Menu; namespace Vocaluxe.Screens.PartyScreens { - abstract class CMenuParty : CMenu + abstract class CMenuParty { + public CMenuParty() + { + } + + /* public sealed override void LoadTheme() { } @@ -23,7 +28,7 @@ namespace Vocaluxe.Screens.PartyScreens public override void UnloadTextures() { } - + */ } } diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj index 42c754cc..7a88a37f 100644 --- a/Vocaluxe/Vocaluxe.csproj +++ b/Vocaluxe/Vocaluxe.csproj @@ -180,6 +180,7 @@ + @@ -230,6 +231,7 @@ + From 99c956965e0760e0f957b0f0d2749fcaaef70251 Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Thu, 13 Dec 2012 20:44:59 +0100 Subject: [PATCH 010/110] just another small step --- Vocaluxe/Base/CConfig.cs | 174 ------------- Vocaluxe/Base/CFont.cs | 24 +- Vocaluxe/Base/CGame.cs | 1 + Vocaluxe/Base/CSound.cs | 1 + Vocaluxe/Menu/CBackground.cs | 4 +- Vocaluxe/Menu/CButton.cs | 8 +- Vocaluxe/Menu/CEqualizer.cs | 4 +- Vocaluxe/Menu/CLyric.cs | 8 +- Vocaluxe/Menu/CMenu.cs | 250 ++++++++++++------- Vocaluxe/Menu/CNameSelection.cs | 17 +- Vocaluxe/Menu/CPlaylist.cs | 36 +-- Vocaluxe/Menu/CSelectSlide.cs | 7 +- Vocaluxe/Menu/CStatic.cs | 33 +-- Vocaluxe/Menu/CText.cs | 19 +- Vocaluxe/Menu/IMenu.cs | 223 ++++++++++++++++- Vocaluxe/Menu/IMenuElement.cs | 1 + Vocaluxe/Menu/SingNotes/CSingNotes.cs | 4 +- Vocaluxe/Menu/SingNotes/CSingNotesClassic.cs | 7 + Vocaluxe/Menu/SongMenu/CSongMenu.cs | 16 +- Vocaluxe/Menu/SongMenu/CSongMenuBook.cs | 7 + Vocaluxe/Menu/SongMenu/CSongMenuDreidel.cs | 8 + Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs | 24 +- Vocaluxe/Menu/SongMenu/CSongMenuList.cs | 7 + Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs | 15 +- Vocaluxe/Menu/SongMenu/ISongMenu.cs | 2 - Vocaluxe/Screens/CScreenCredits.cs | 20 +- Vocaluxe/Screens/CScreenNames.cs | 2 +- Vocaluxe/Screens/CScreenSing.cs | 2 +- Vocaluxe/Screens/CScreenSong.cs | 2 +- 29 files changed, 543 insertions(+), 383 deletions(-) diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index 4e3d96d6..03d1e7d8 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -16,180 +16,6 @@ using Vocaluxe.Menu; namespace Vocaluxe.Base { - #region Enums - public enum ERenderer - { -#if WIN - TR_CONFIG_DIRECT3D, -#endif - TR_CONFIG_OPENGL, - TR_CONFIG_SOFTWARE - } - - public enum EAntiAliasingModes - { - x0 = 0, - x2 = 2, - x4 = 4, - x8 = 8, - x16 = 16, - x32 = 32 - } - - public enum EColorDeep - { - Bit8 = 8, - Bit16 = 16, - Bit24 = 24, - Bit32 = 32 - } - - public enum ETextureQuality - { - TR_CONFIG_TEXTURE_LOWEST, - TR_CONFIG_TEXTURE_LOW, - TR_CONFIG_TEXTURE_MEDIUM, - TR_CONFIG_TEXTURE_HIGH, - TR_CONFIG_TEXTURE_HIGHEST - } - - public enum EOffOn - { - TR_CONFIG_OFF, - TR_CONFIG_ON - } - - public enum EDebugLevel - { - // don't change the order! - TR_CONFIG_OFF, //no debug infos - TR_CONFIG_ONLY_FPS, - TR_CONFIG_LEVEL1, - TR_CONFIG_LEVEL2, - TR_CONFIG_LEVEL3, - TR_CONFIG_LEVEL_MAX //all debug infos - } - - public enum EBufferSize - { - b0 = 0, - b512 = 512, - b1024 = 1024, - b1536 = 1536, - b2048 = 2048, - b2560 = 2560, - b3072 = 3072, - b3584 = 3584, - b4096 = 4096 - } - - public enum EPlaybackLib - { - PortAudio, - OpenAL - } - - public enum EWebcamLib - { - OpenCV, - AForgeNet - } - - public enum ERecordLib - { -#if WIN - DirectSound, -#endif - PortAudio - } - - public enum EVideoDecoder - { - FFmpeg - } - - public enum ESongMenu - { - //TR_CONFIG_LIST, //a simple list - //TR_CONFIG_DREIDEL, //as in ultrastar deluxe - TR_CONFIG_TILE_BOARD, //chessboard like - //TR_CONFIG_BOOK //for playlists - } - - public enum ESongSorting - { - TR_CONFIG_NONE, - //TR_CONFIG_RANDOM, - TR_CONFIG_FOLDER, - TR_CONFIG_ARTIST, - TR_CONFIG_ARTIST_LETTER, - TR_CONFIG_TITLE_LETTER, - TR_CONFIG_EDITION, - TR_CONFIG_GENRE, - TR_CONFIG_LANGUAGE, - TR_CONFIG_YEAR, - TR_CONFIG_DECADE - } - - public enum ECoverLoading - { - TR_CONFIG_COVERLOADING_ONDEMAND, - TR_CONFIG_COVERLOADING_ATSTART, - TR_CONFIG_COVERLOADING_DYNAMIC - } - - public enum EGameDifficulty - { - TR_CONFIG_EASY, - TR_CONFIG_NORMAL, - TR_CONFIG_HARD - } - - public enum ETimerMode - { - TR_CONFIG_TIMERMODE_CURRENT, - TR_CONFIG_TIMERMODE_REMAINING, - TR_CONFIG_TIMERMODE_TOTAL - } - - public enum ETimerLook - { - TR_CONFIG_TIMERLOOK_NORMAL, - TR_CONFIG_TIMERLOOK_EXPANDED - } - - public enum EBackgroundMusicSource - { - TR_CONFIG_NO_OWN_MUSIC, - TR_CONFIG_OWN_MUSIC, - TR_CONFIG_ONLY_OWN_MUSIC - } - - public enum EPlayerInfo - { - TR_CONFIG_PLAYERINFO_BOTH, - TR_CONFIG_PLAYERINFO_NAME, - TR_CONFIG_PLAYERINFO_AVATAR, - TR_CONFIG_PLAYERINFO_OFF - } - - public enum EFadePlayerInfo - { - TR_CONFIG_FADEPLAYERINFO_ALL, - TR_CONFIG_FADEPLAYERINFO_INFO, - TR_CONFIG_FADEPLAYERINFO_OFF - } - - public enum ELyricStyle - { - Fill, - Jump, - Slide, - Zoom - } - - #endregion Enums - static class CConfig { private static XmlWriterSettings _settings = new XmlWriterSettings(); diff --git a/Vocaluxe/Base/CFont.cs b/Vocaluxe/Base/CFont.cs index 4e558b9e..20b46154 100644 --- a/Vocaluxe/Base/CFont.cs +++ b/Vocaluxe/Base/CFont.cs @@ -15,29 +15,7 @@ using Vocaluxe.Lib.Draw; using Vocaluxe.Menu; namespace Vocaluxe.Base -{ - public enum EAlignment - { - Left, - Center, - Right - } - - public enum EHAlignment - { - Top, - Center, - Bottom - } - - public enum EStyle - { - Normal, - Italic, - Bold, - BoldItalic - } - +{ class CGlyph { private float _SIZEh = 50f; diff --git a/Vocaluxe/Base/CGame.cs b/Vocaluxe/Base/CGame.cs index a6323536..0f6ffcc3 100644 --- a/Vocaluxe/Base/CGame.cs +++ b/Vocaluxe/Base/CGame.cs @@ -7,6 +7,7 @@ using System.Text; using Vocaluxe.GameModes; using Vocaluxe.Lib.Draw; using Vocaluxe.Lib.Song; +using Vocaluxe.Menu; namespace Vocaluxe.Base { diff --git a/Vocaluxe/Base/CSound.cs b/Vocaluxe/Base/CSound.cs index 7f6414d4..d77c10ad 100644 --- a/Vocaluxe/Base/CSound.cs +++ b/Vocaluxe/Base/CSound.cs @@ -5,6 +5,7 @@ using System.IO; using System.Text; using Vocaluxe.Lib.Sound; +using Vocaluxe.Menu; namespace Vocaluxe.Base { diff --git a/Vocaluxe/Menu/CBackground.cs b/Vocaluxe/Menu/CBackground.cs index 1b6b0b83..1c5a6738 100644 --- a/Vocaluxe/Menu/CBackground.cs +++ b/Vocaluxe/Menu/CBackground.cs @@ -33,6 +33,7 @@ namespace Vocaluxe.Menu public class CBackground : IMenuElement { + private Base _Base; private SThemeBackground _Theme; private bool _ThemeLoaded; @@ -44,8 +45,9 @@ namespace Vocaluxe.Menu } #region Constructors - public CBackground() + public CBackground(Base Base) { + _Base = Base; _ThemeLoaded = false; _Theme = new SThemeBackground(); diff --git a/Vocaluxe/Menu/CButton.cs b/Vocaluxe/Menu/CButton.cs index 2e018ffa..81882c8b 100644 --- a/Vocaluxe/Menu/CButton.cs +++ b/Vocaluxe/Menu/CButton.cs @@ -23,6 +23,7 @@ namespace Vocaluxe.Menu class CButton : IMenuElement { + private Base _Base; private SThemeButton _Theme; private bool _ThemeLoaded; @@ -71,16 +72,17 @@ namespace Vocaluxe.Menu return _Theme.Name; } - public CButton() + public CButton(Base Base) { + _Base = Base; _Theme = new SThemeButton(); Rect = new SRectF(); Color = new SColorF(); SColor = new SColorF(); SelText = false; - Text = new CText(); - SText = new CText(); + Text = new CText(_Base); + SText = new CText(_Base); Selected = false; Visible = true; EditMode = false; diff --git a/Vocaluxe/Menu/CEqualizer.cs b/Vocaluxe/Menu/CEqualizer.cs index 4b8c3997..55f54377 100644 --- a/Vocaluxe/Menu/CEqualizer.cs +++ b/Vocaluxe/Menu/CEqualizer.cs @@ -31,6 +31,7 @@ namespace Vocaluxe.Menu class CEqualizer : IMenuElement { + private Base _Base; private SThemeEqualizer _Theme; private bool _ThemeLoaded; @@ -54,8 +55,9 @@ namespace Vocaluxe.Menu private float[] _Bars; - public CEqualizer() + public CEqualizer(Base Base) { + _Base = Base; _Theme = new SThemeEqualizer(); _ThemeLoaded = false; diff --git a/Vocaluxe/Menu/CLyric.cs b/Vocaluxe/Menu/CLyric.cs index 21929681..59ecd87c 100644 --- a/Vocaluxe/Menu/CLyric.cs +++ b/Vocaluxe/Menu/CLyric.cs @@ -30,6 +30,7 @@ namespace Vocaluxe.Menu class CLyric : IMenuElement { + private Base _Base; private SThemeLyrics _Theme; private bool _ThemeLoaded; @@ -87,8 +88,9 @@ namespace Vocaluxe.Menu set { _Style = value; } } - public CLyric() + public CLyric(Base Base) { + _Base = Base; _Theme = new SThemeLyrics(); _ThemeLoaded = false; Color = new SColorF(); @@ -101,7 +103,7 @@ namespace Vocaluxe.Menu _H = 1f; _width = 1f; _Notes = new List(); - _Text = new CText(); + _Text = new CText(_Base); _Style = ELyricStyle.Fill; } @@ -145,7 +147,7 @@ namespace Vocaluxe.Menu { _Theme.Name = ElementName; LoadTextures(); - _Text = new CText(_X, _Y, _Z, _H, _MaxW, EAlignment.Left, EStyle.Bold, "Normal", Color, String.Empty); + _Text = new CText(_Base, _X, _Y, _Z, _H, _MaxW, EAlignment.Left, EStyle.Bold, "Normal", Color, String.Empty); } return _ThemeLoaded; } diff --git a/Vocaluxe/Menu/CMenu.cs b/Vocaluxe/Menu/CMenu.cs index eaa8a4b3..2ff56816 100644 --- a/Vocaluxe/Menu/CMenu.cs +++ b/Vocaluxe/Menu/CMenu.cs @@ -75,15 +75,7 @@ namespace Vocaluxe.Menu protected string[] _ThemePlaylists; protected SRectF _ScreenArea; - - private IConfig _Config; - private ISettings _Settings; - private ITheme _Theme; - private IHelper _Helper; - private ILog _Log; - private IBackgroundMusic _BackgroundMusic; - private IDrawing _Draw; - private IGraphics _Graphics; + private Base _Base; public SRectF ScreenArea { @@ -106,15 +98,7 @@ namespace Vocaluxe.Menu public void Initialize(IConfig Config, ISettings Settings, ITheme Theme, IHelper Helper, ILog Log, IBackgroundMusic BackgroundMusic, IDrawing Draw, IGraphics Graphics) { - _Config = Config; - _Settings = Settings; - _Theme = Theme; - _Helper = Helper; - _Log = Log; - _BackgroundMusic = BackgroundMusic; - _Draw = Draw; - _Graphics = Graphics; - + _Base = new Base(Config, Settings, Theme, Helper, Log, BackgroundMusic, Draw, Graphics); Init(); } @@ -154,7 +138,7 @@ namespace Vocaluxe.Menu _MouseDY = 0; _Active = false; - _ScreenArea = new SRectF(0f, 0f, _Settings.GetRenderW(), _Settings.GetRenderH(), 0f); + _ScreenArea = new SRectF(0f, 0f, _Base.Settings.GetRenderW(), _Base.Settings.GetRenderH(), 0f); _ThemeName = String.Empty; _ThemeBackgrounds = null; @@ -172,7 +156,7 @@ namespace Vocaluxe.Menu #region ThemeHandler public virtual void LoadTheme() { - string file = Path.Combine(_Theme.GetThemeScreensPath(), _ThemeName + ".xml"); + string file = Path.Combine(_Base.Theme.GetThemeScreensPath(), _ThemeName + ".xml"); XPathDocument xPathDoc = null; XPathNavigator navigator = null; @@ -193,14 +177,14 @@ namespace Vocaluxe.Menu if (xPathDoc != null) xPathDoc = null; - _Log.LogError("Error loading theme file " + file + ": " + e.Message); + _Base.Log.LogError("Error loading theme file " + file + ": " + e.Message); } bool VersionCheck = false; if (loaded) VersionCheck = CheckVersion(_ScreenVersion, navigator); - int SkinIndex = _Theme.GetSkinIndex(); + int SkinIndex = _Base.Theme.GetSkinIndex(); if (loaded && VersionCheck && SkinIndex != -1) { @@ -210,14 +194,14 @@ namespace Vocaluxe.Menu { for (int i = 0; i < _ThemeBackgrounds.Length; i++) { - CBackground background = new CBackground(); + CBackground background = new CBackground(_Base); if (background.LoadTheme("//root/" + _ThemeName, _ThemeBackgrounds[i], navigator, SkinIndex)) { _htBackgrounds.Add(_ThemeBackgrounds[i], AddBackground(background)); } else { - _Log.LogError("Can't load Background \"" + _ThemeBackgrounds[i] + "\" in screen " + _ThemeName); + _Base.Log.LogError("Can't load Background \"" + _ThemeBackgrounds[i] + "\" in screen " + _ThemeName); } } } @@ -226,14 +210,14 @@ namespace Vocaluxe.Menu { for (int i = 0; i < _ThemeStatics.Length; i++) { - CStatic stat = new CStatic(); + CStatic stat = new CStatic(_Base); if (stat.LoadTheme("//root/" + _ThemeName, _ThemeStatics[i], navigator, SkinIndex)) { _htStatics.Add(_ThemeStatics[i], AddStatic(stat)); } else { - _Log.LogError("Can't load Static \"" + _ThemeStatics[i] + "\" in screen " + _ThemeName); + _Base.Log.LogError("Can't load Static \"" + _ThemeStatics[i] + "\" in screen " + _ThemeName); } } } @@ -242,14 +226,14 @@ namespace Vocaluxe.Menu { for (int i = 0; i < _ThemeTexts.Length; i++) { - CText text = new CText(); + CText text = new CText(_Base); if (text.LoadTheme("//root/" + _ThemeName, _ThemeTexts[i], navigator, SkinIndex)) { _htTexts.Add(_ThemeTexts[i], AddText(text)); } else { - _Log.LogError("Can't load Text \"" + _ThemeTexts[i] + "\" in screen " + _ThemeName); + _Base.Log.LogError("Can't load Text \"" + _ThemeTexts[i] + "\" in screen " + _ThemeName); } } } @@ -258,14 +242,14 @@ namespace Vocaluxe.Menu { for (int i = 0; i < _ThemeButtons.Length; i++) { - CButton button = new CButton(); + CButton button = new CButton(_Base); if (button.LoadTheme("//root/" + _ThemeName, _ThemeButtons[i], navigator, SkinIndex)) { _htButtons.Add(_ThemeButtons[i], AddButton(button)); } else { - _Log.LogError("Can't load Button \"" + _ThemeButtons[i] + "\" in screen " + _ThemeName); + _Base.Log.LogError("Can't load Button \"" + _ThemeButtons[i] + "\" in screen " + _ThemeName); } } } @@ -274,14 +258,14 @@ namespace Vocaluxe.Menu { for (int i = 0; i < _ThemeSelectSlides.Length; i++) { - CSelectSlide slide = new CSelectSlide(); + CSelectSlide slide = new CSelectSlide(_Base); if (slide.LoadTheme("//root/" + _ThemeName, _ThemeSelectSlides[i], navigator, SkinIndex)) { _htSelectSlides.Add(_ThemeSelectSlides[i], AddSelectSlide(slide)); } else { - _Log.LogError("Can't load SelectSlide \"" + _ThemeSelectSlides[i] + "\" in screen " + _ThemeName); + _Base.Log.LogError("Can't load SelectSlide \"" + _ThemeSelectSlides[i] + "\" in screen " + _ThemeName); } } } @@ -290,14 +274,14 @@ namespace Vocaluxe.Menu { for (int i = 0; i < _ThemeSongMenus.Length; i++) { - CSongMenu sm = new CSongMenu(); + CSongMenu sm = new CSongMenu(_Base); if (sm.LoadTheme("//root/" + _ThemeName, _ThemeSongMenus[i], navigator, SkinIndex)) { _htSongMenus.Add(_ThemeSongMenus[i], AddSongMenu(sm)); } else { - _Log.LogError("Can't load SongMenu \"" + _ThemeSongMenus[i] + "\" in screen " + _ThemeName); + _Base.Log.LogError("Can't load SongMenu \"" + _ThemeSongMenus[i] + "\" in screen " + _ThemeName); } } } @@ -306,14 +290,14 @@ namespace Vocaluxe.Menu { for (int i = 0; i < _ThemeLyrics.Length; i++) { - CLyric lyric = new CLyric(); + CLyric lyric = new CLyric(_Base); if (lyric.LoadTheme("//root/" + _ThemeName, _ThemeLyrics[i], navigator, SkinIndex)) { _htLyrics.Add(_ThemeLyrics[i], AddLyric(lyric)); } else { - _Log.LogError("Can't load Lyric \"" + _ThemeLyrics[i] + "\" in screen " + _ThemeName); + _Base.Log.LogError("Can't load Lyric \"" + _ThemeLyrics[i] + "\" in screen " + _ThemeName); } } } @@ -322,14 +306,14 @@ namespace Vocaluxe.Menu { for (int i = 0; i < _ThemeSingNotes.Length; i++) { - CSingNotes notes = new CSingNotesClassic(); + CSingNotes notes = new CSingNotesClassic(_Base); if (notes.LoadTheme("//root/" + _ThemeName, _ThemeSingNotes[i], navigator, SkinIndex)) { _htSingNotes.Add(_ThemeSingNotes[i], AddSingNote(notes)); } else { - _Log.LogError("Can't load SingBar \"" + _ThemeSingNotes[i] + "\" in screen " + _ThemeName); + _Base.Log.LogError("Can't load SingBar \"" + _ThemeSingNotes[i] + "\" in screen " + _ThemeName); } } } @@ -338,14 +322,14 @@ namespace Vocaluxe.Menu { for (int i = 0; i < _ThemeNameSelections.Length; i++) { - CNameSelection nsel = new CNameSelection(); + CNameSelection nsel = new CNameSelection(_Base); if (nsel.LoadTheme("//root/" + _ThemeName, _ThemeNameSelections[i], navigator, SkinIndex)) { _htNameSelections.Add(_ThemeNameSelections[i], AddNameSelection(nsel)); } else { - _Log.LogError("Can't load NameSelection \"" + _ThemeNameSelections[i] + "\" in screen " + _ThemeName); + _Base.Log.LogError("Can't load NameSelection \"" + _ThemeNameSelections[i] + "\" in screen " + _ThemeName); } } } @@ -354,14 +338,14 @@ namespace Vocaluxe.Menu { for (int i = 0; i < _ThemeEqualizers.Length; i++) { - CEqualizer eq = new CEqualizer(); + CEqualizer eq = new CEqualizer(_Base); if (eq.LoadTheme("//root/" + _ThemeName, _ThemeEqualizers[i], navigator, SkinIndex)) { _htEqualizers.Add(_ThemeEqualizers[i], AddEqualizer(eq)); } else { - _Log.LogError("Can't load equalizer \"" + _ThemeEqualizers[i] + "\" in screen " + _ThemeName); + _Base.Log.LogError("Can't load equalizer \"" + _ThemeEqualizers[i] + "\" in screen " + _ThemeName); } } } @@ -370,14 +354,14 @@ namespace Vocaluxe.Menu { for (int i = 0; i < _ThemePlaylists.Length; i++) { - CPlaylist pls = new CPlaylist(); + CPlaylist pls = new CPlaylist(_Base); if (pls.LoadTheme("//root/" + _ThemeName, _ThemePlaylists[i], navigator, SkinIndex)) { _htPlaylists.Add(_ThemePlaylists[i], AddPlaylist(pls)); } else { - _Log.LogError("Can't load Playlist \"" + _ThemePlaylists[i] + "\" in screen " + _ThemeName); + _Base.Log.LogError("Can't load Playlist \"" + _ThemePlaylists[i] + "\" in screen " + _ThemeName); } } } @@ -395,7 +379,7 @@ namespace Vocaluxe.Menu settings.Encoding = Encoding.UTF8; settings.ConformanceLevel = ConformanceLevel.Document; - string file = Path.Combine(_Theme.GetThemeScreensPath(), _ThemeName + ".xml"); + string file = Path.Combine(_Base.Theme.GetThemeScreensPath(), _ThemeName + ".xml"); XmlWriter writer = XmlWriter.Create(file, settings); writer.WriteStartDocument(); @@ -660,6 +644,74 @@ namespace Vocaluxe.Menu #endregion GetLists #region ElementHandler + #region Create Elements + public CButton GetNewButton() + { + return new CButton(_Base); + } + + public CText GetNewText() + { + return new CText(_Base); + } + + public CText GetNewText(float x, float y, float z, float h, float mw, EAlignment align, EStyle style, string font, SColorF col, string text) + { + return new CText(_Base, x, y, z, h, mw, align, style, font, col, text); + } + + + public CBackground GetNewBackground() + { + return new CBackground(_Base); + } + + public CStatic GetNewStatic() + { + return new CStatic(_Base); + } + + public CStatic GetNewStatic(STexture Texture, SColorF Color, SRectF Rect) + { + return new CStatic(_Base, Texture, Color, Rect); + } + + public CSelectSlide GetNewSelectSlide() + { + return new CSelectSlide(_Base); + } + + public CSongMenu GetNewSongMenu() + { + return new CSongMenu(_Base); + } + + public CLyric GetNewLyric() + { + return new CLyric(_Base); + } + + public CSingNotes GetNewSingNotes() + { + return new CSingNotesClassic(_Base); + } + + public CNameSelection GetNewNameSelection() + { + return new CNameSelection(_Base); + } + + public CEqualizer GetNewEqualizer() + { + return new CEqualizer(_Base); + } + + public CPlaylist GetNewPlaylist() + { + return new CPlaylist(_Base); + } + #endregion Create Elements + #region Get Arrays public CButton[] Buttons { @@ -759,7 +811,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - _Log.LogError("Can't find Background Element \"" + key + "\" in Screen " + _ThemeName); + _Base.Log.LogError("Can't find Background Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -772,7 +824,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - _Log.LogError("Can't find Statics Element \"" + key + "\" in Screen " + _ThemeName); + _Base.Log.LogError("Can't find Statics Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -785,7 +837,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - _Log.LogError("Can't find Text Element \"" + key + "\" in Screen " + _ThemeName); + _Base.Log.LogError("Can't find Text Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -798,7 +850,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - _Log.LogError("Can't find Button Element \"" + key + "\" in Screen " + _ThemeName); + _Base.Log.LogError("Can't find Button Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -811,7 +863,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - _Log.LogError("Can't find SongMenu Element \"" + key + "\" in Screen " + _ThemeName); + _Base.Log.LogError("Can't find SongMenu Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -824,7 +876,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - _Log.LogError("Can't find Lyric Element \"" + key + "\" in Screen " + _ThemeName); + _Base.Log.LogError("Can't find Lyric Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -837,7 +889,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - _Log.LogError("Can't find SelectSlide Element \"" + key + "\" in Screen " + _ThemeName); + _Base.Log.LogError("Can't find SelectSlide Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -850,7 +902,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - _Log.LogError("Can't find SingBar Element \"" + key + "\" in Screen " + _ThemeName); + _Base.Log.LogError("Can't find SingBar Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -863,7 +915,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - _Log.LogError("Can't find NameSelection Element \"" + key + "\" in Screen " + _ThemeName); + _Base.Log.LogError("Can't find NameSelection Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -876,7 +928,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - _Log.LogError("Can't find Equalizer Element \"" + key + "\" in Screen " + _ThemeName); + _Base.Log.LogError("Can't find Equalizer Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -889,7 +941,7 @@ namespace Vocaluxe.Menu } catch (Exception) { - _Log.LogError("Can't find Playlist Element \"" + key + "\" in Screen " + _ThemeName); + _Base.Log.LogError("Can't find Playlist Element \"" + key + "\" in Screen " + _ThemeName); throw; } } @@ -899,7 +951,7 @@ namespace Vocaluxe.Menu #region MenuHandler public virtual bool HandleInput(KeyEvent KeyEvent) { - if (!_Settings.IsTabNavigation()) + if (!_Base.Settings.IsTabNavigation()) { if (KeyEvent.Key == Keys.Left) { @@ -938,25 +990,25 @@ namespace Vocaluxe.Menu if (KeyEvent.Key == Keys.Right) NextElement(); } - if (_BackgroundMusic.IsDisabled()) + if (_Base.BackgroundMusic.IsDisabled()) { if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Add || KeyEvent.Key == Keys.PageUp)) - _Config.SetBackgroundMusicVolume(_Config.GetBackgroundMusicVolume() + 5); + _Base.Config.SetBackgroundMusicVolume(_Base.Config.GetBackgroundMusicVolume() + 5); else if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Subtract || KeyEvent.Key == Keys.PageDown)) - _Config.SetBackgroundMusicVolume(_Config.GetBackgroundMusicVolume() - 5); + _Base.Config.SetBackgroundMusicVolume(_Base.Config.GetBackgroundMusicVolume() - 5); else if (KeyEvent.Key == Keys.MediaNextTrack) - _BackgroundMusic.Next(); + _Base.BackgroundMusic.Next(); else if (KeyEvent.Key == Keys.MediaPreviousTrack) - _BackgroundMusic.Previous(); + _Base.BackgroundMusic.Previous(); else if (KeyEvent.Key == Keys.MediaPlayPause) { - if (_BackgroundMusic.IsPlaying()) - _BackgroundMusic.Pause(); + if (_Base.BackgroundMusic.IsPlaying()) + _Base.BackgroundMusic.Pause(); else - _BackgroundMusic.Play(); + _Base.BackgroundMusic.Play(); } - _BackgroundMusic.ApplyVolume(); + _Base.BackgroundMusic.ApplyVolume(); } return true; @@ -1367,10 +1419,10 @@ namespace Vocaluxe.Menu public void SelectByMouse(int x, int y) { - float z = _Settings.GetZFar(); + float z = _Base.Settings.GetZFar(); for (int i = 0; i < _Interactions.Count; i++) { - if ((_Settings.GetGameState() == EGameState.EditTheme) || (!_Interactions[i].ThemeEditorOnly && _IsVisible(i))) + if ((_Base.Settings.GetGameState() == EGameState.EditTheme) || (!_Interactions[i].ThemeEditorOnly && _IsVisible(i))) { if (_IsMouseOver(x, y, _Interactions[i])) { @@ -1421,7 +1473,7 @@ namespace Vocaluxe.Menu return true; break; case EType.TText: - RectangleF bounds = _Draw.GetTextBounds(_Texts[interact.Num]); + RectangleF bounds = _Base.Drawing.GetTextBounds(_Texts[interact.Num]); if (CHelper.IsInBounds(new SRectF(_Texts[interact.Num].X, _Texts[interact.Num].Y, bounds.Width, bounds.Height, _Texts[interact.Num].Z), x, y)) return true; break; @@ -1472,7 +1524,7 @@ namespace Vocaluxe.Menu case EType.TPlaylist: return _Playlists[interact.Num].Rect.Z; } - return _Settings.GetZFar(); + return _Base.Settings.GetZFar(); } private float _GetZValue(int interaction) @@ -1507,13 +1559,13 @@ namespace Vocaluxe.Menu return _Playlists[_Interactions[interaction].Num].Rect.Z; } - return _Settings.GetZFar(); + return _Base.Settings.GetZFar(); } private void _NextInteraction() { _UnsetSelected(); - if (_Settings.GetGameState() != EGameState.EditTheme) + if (_Base.Settings.GetGameState() != EGameState.EditTheme) { bool found = false; int start = _Selection; @@ -1540,7 +1592,7 @@ namespace Vocaluxe.Menu private void _PrevInteraction() { _UnsetSelected(); - if (_Settings.GetGameState() != EGameState.EditTheme) + if (_Base.Settings.GetGameState() != EGameState.EditTheme) { bool found = false; int start = _Selection; @@ -1687,13 +1739,13 @@ namespace Vocaluxe.Menu switch (Key.Key) { case Keys.Up: - actualRect = new SRectF(actualRect.X, _Settings.GetRenderH(), 1, 1, actualRect.Z); + actualRect = new SRectF(actualRect.X, _Base.Settings.GetRenderH(), 1, 1, actualRect.Z); break; case Keys.Down: actualRect = new SRectF(actualRect.X, 0, 1, 1, actualRect.Z); break; case Keys.Left: - actualRect = new SRectF(_Settings.GetRenderW(), actualRect.Y, 1, 1, actualRect.Z); + actualRect = new SRectF(_Base.Settings.GetRenderW(), actualRect.Y, 1, 1, actualRect.Z); break; case Keys.Right: actualRect = new SRectF(0, actualRect.Y, 1, 1, actualRect.Z); @@ -2211,7 +2263,7 @@ namespace Vocaluxe.Menu msg += "the file is for newer program versions! "; msg += "Current screen version is " + Version.ToString(); - _Log.LogError(msg); + _Base.Log.LogError(msg); } return false; } @@ -2221,47 +2273,71 @@ namespace Vocaluxe.Menu string value = String.Empty; // Backgrounds - CBackground background = new CBackground(); + CBackground background = new CBackground(_Base); int i = 1; while (background.LoadTheme("//root/" + _ThemeName, "Background" + i.ToString(), navigator, SkinIndex)) { AddBackground(background); - background = new CBackground(); + background = new CBackground(_Base); i++; } // Statics - CStatic stat = new CStatic(); + CStatic stat = new CStatic(_Base); i = 1; while (stat.LoadTheme("//root/" + _ThemeName, "Static" + i.ToString(), navigator, SkinIndex)) { AddStatic(stat); - stat = new CStatic(); + stat = new CStatic(_Base); i++; } // Texts - CText text = new CText(); + CText text = new CText(_Base); i = 1; while (text.LoadTheme("//root/" + _ThemeName, "Text" + i.ToString(), navigator, SkinIndex)) { AddText(text); - text = new CText(); + text = new CText(_Base); i++; } } private void ReloadThemeEditMode() { - _Theme.UnloadSkins(); - _Theme.ListSkins(); - _Theme.LoadSkins(); - _Theme.LoadTheme(); - _Graphics.ReloadTheme(); + _Base.Theme.UnloadSkins(); + _Base.Theme.ListSkins(); + _Base.Theme.LoadSkins(); + _Base.Theme.LoadTheme(); + _Base.Graphics.ReloadTheme(); OnShow(); OnShowFinish(); } #endregion Theme Handling } + + public class Base + { + public IConfig Config; + public ISettings Settings; + public ITheme Theme; + public IHelper Helper; + public ILog Log; + public IBackgroundMusic BackgroundMusic; + public IDrawing Drawing; + public IGraphics Graphics; + + public Base(IConfig Config, ISettings Settings, ITheme Theme, IHelper Helper, ILog Log, IBackgroundMusic BackgroundMusic, IDrawing Draw, IGraphics Graphics) + { + this.Config = Config; + this.Settings = Settings; + this.Theme = Theme; + this.Helper = Helper; + this.Log = Log; + this.BackgroundMusic = BackgroundMusic; + this.Drawing = Draw; + this.Graphics = Graphics; + } + } } diff --git a/Vocaluxe/Menu/CNameSelection.cs b/Vocaluxe/Menu/CNameSelection.cs index 5d426a89..51ae095f 100644 --- a/Vocaluxe/Menu/CNameSelection.cs +++ b/Vocaluxe/Menu/CNameSelection.cs @@ -27,15 +27,16 @@ namespace Vocaluxe.Menu class CNameSelection : IMenuElement { - class CTile { + private Base _Base; public int PlayerNr; public CStatic Avatar; public CText Name; - public CTile() + public CTile(Base Base) { + _Base = Base; } public CTile(CStatic av, CText tex, int pl) @@ -46,6 +47,7 @@ namespace Vocaluxe.Menu } } + private Base _Base; private SThemeNameSelection _Theme; private bool _ThemeLoaded; @@ -85,8 +87,9 @@ namespace Vocaluxe.Menu private CStatic PlayerSelector; - public CNameSelection() + public CNameSelection(Base Base) { + _Base = Base; _Theme = new SThemeNameSelection(); _Tiles = new List(); @@ -97,7 +100,7 @@ namespace Vocaluxe.Menu { PrepareTiles(); - PlayerSelector = new CStatic(); + PlayerSelector = new CStatic(_Base); PlayerSelector.Texture = _TextureTileSelected; PlayerSelector.Rect = new SRectF(0, 0, (_TileW + 6), (_TileH + 6), (Rect.Z - 0.5f)); PlayerSelector.Visible = false; @@ -466,7 +469,7 @@ namespace Vocaluxe.Menu } } - return new CStatic(); + return new CStatic(_Base); } public void UnloadTextures() @@ -501,8 +504,8 @@ namespace Vocaluxe.Menu for (int j = 0; j < _NumW; j++) { SRectF rect = new SRectF(Rect.X + j * (_TileW + _SpaceW), Rect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, Rect.Z); - CStatic tileStatic = new CStatic(_TextureEmptyTile, ColorEmptyTile, rect); - CText tileText = new CText(rect.X + rect.W / 2, rect.Y + rect.H + _Theme.NameSpace, rect.Z, _Theme.NameHeight, rect.W, EAlignment.Center, _Theme.NameStyle, _Theme.NameFont, _Theme.NameColor, ""); + CStatic tileStatic = new CStatic(_Base, _TextureEmptyTile, ColorEmptyTile, rect); + CText tileText = new CText(_Base, rect.X + rect.W / 2, rect.Y + rect.H + _Theme.NameSpace, rect.Z, _Theme.NameHeight, rect.W, EAlignment.Center, _Theme.NameStyle, _Theme.NameFont, _Theme.NameColor, ""); _Tiles.Add(new CTile(tileStatic, tileText, -1)); } } diff --git a/Vocaluxe/Menu/CPlaylist.cs b/Vocaluxe/Menu/CPlaylist.cs index 629ededb..0cad525c 100644 --- a/Vocaluxe/Menu/CPlaylist.cs +++ b/Vocaluxe/Menu/CPlaylist.cs @@ -58,18 +58,21 @@ namespace Vocaluxe.Menu class PlaylistElement { + Base _Base; public CStatic Cover; public CStatic Background; public CText Text1; public CSelectSlide SelectSlide; public int Content; - public PlaylistElement() + public PlaylistElement(Base Base) { + _Base = Base; } public PlaylistElement(PlaylistElement pe) { + _Base = pe._Base; Cover = new CStatic(pe.Cover); Background = new CStatic(pe.Background); Text1 = new CText(pe.Text1); @@ -110,6 +113,7 @@ namespace Vocaluxe.Menu } } + private Base _Base; private SThemePlaylist _Theme; private bool _ThemeLoaded; @@ -158,7 +162,7 @@ namespace Vocaluxe.Menu public int Offset = 0; public int CurrentPlaylistElement = -1; - private PlaylistElement ChangeOrderElement = new PlaylistElement(); + private PlaylistElement ChangeOrderElement; private int ChangeOrderSource = -1; private int OldMousePosX = 0; private int OldMousePosY = 0; @@ -167,19 +171,20 @@ namespace Vocaluxe.Menu //private static - public CPlaylist() + public CPlaylist(Base Base) { + _Base = Base; _Theme = new SThemePlaylist(); - _Theme.Text1 = new CText(); - _Theme.StaticCover = new CStatic(); - _Theme.StaticPlaylistFooter = new CStatic(); - _Theme.StaticPlaylistHeader = new CStatic(); - _Theme.ButtonPlaylistName = new CButton(); - _Theme.ButtonPlaylistClose = new CButton(); - _Theme.ButtonPlaylistDelete = new CButton(); - _Theme.ButtonPlaylistSave = new CButton(); - _Theme.ButtonPlaylistSing = new CButton(); - _Theme.SelectSlideGameMode = new CSelectSlide(); + _Theme.Text1 = new CText(_Base); + _Theme.StaticCover = new CStatic(_Base); + _Theme.StaticPlaylistFooter = new CStatic(_Base); + _Theme.StaticPlaylistHeader = new CStatic(_Base); + _Theme.ButtonPlaylistName = new CButton(_Base); + _Theme.ButtonPlaylistClose = new CButton(_Base); + _Theme.ButtonPlaylistDelete = new CButton(_Base); + _Theme.ButtonPlaylistSave = new CButton(_Base); + _Theme.ButtonPlaylistSing = new CButton(_Base); + _Theme.SelectSlideGameMode = new CSelectSlide(_Base); CompleteRect = new SRectF(); Rect = new SRectF(); @@ -190,6 +195,7 @@ namespace Vocaluxe.Menu PlaylistElementContents = new List(); _Interactions = new CObjectInteractions(); + ChangeOrderElement = new PlaylistElement(_Base); Visible = false; Selected = false; @@ -1093,9 +1099,9 @@ namespace Vocaluxe.Menu for (int i = 0; i < Math.Floor(Rect.H / _Theme.EntryHeight); i++) { - PlaylistElement en = new PlaylistElement(); + PlaylistElement en = new PlaylistElement(_Base); - en.Background = new CStatic(_Theme.TextureBackgroundName, BackgroundColor, new SRectF(Rect.X, Rect.Y + (i * _Theme.EntryHeight), Rect.W, _Theme.EntryHeight, Rect.Z)); + en.Background = new CStatic(_Base, _Theme.TextureBackgroundName, BackgroundColor, new SRectF(Rect.X, Rect.Y + (i * _Theme.EntryHeight), Rect.W, _Theme.EntryHeight, Rect.Z)); en.Cover = new CStatic(_Theme.StaticCover); en.Cover.Rect.Y += Rect.Y + (i * _Theme.EntryHeight); diff --git a/Vocaluxe/Menu/CSelectSlide.cs b/Vocaluxe/Menu/CSelectSlide.cs index 0d51f358..b67aa31e 100644 --- a/Vocaluxe/Menu/CSelectSlide.cs +++ b/Vocaluxe/Menu/CSelectSlide.cs @@ -40,6 +40,7 @@ namespace Vocaluxe.Menu class CSelectSlide : IMenuElement, ICloneable { + private Base _Base; private SThemeSelectSlide _Theme; private bool _ThemeLoaded; @@ -141,8 +142,9 @@ namespace Vocaluxe.Menu } } - public CSelectSlide() + public CSelectSlide(Base Base) { + _Base = Base; _Theme = new SThemeSelectSlide(); _ThemeLoaded = false; @@ -169,6 +171,7 @@ namespace Vocaluxe.Menu public CSelectSlide(CSelectSlide slide) { + _Base = slide._Base; _Theme = new SThemeSelectSlide(); _Theme.TextureArrowLeftName = slide._Theme.TextureArrowLeftName; @@ -763,7 +766,7 @@ namespace Vocaluxe.Menu _ValueBounds.Clear(); for (int i = 0; i < numvis; i++) { - CText Text = new CText(0, 0, 0, TextH, MaxW, EAlignment.Center, _Theme.TextStyle, _Theme.TextFont, TextColor, _ValueNames[i + offset]); + CText Text = new CText(_Base, 0, 0, 0, TextH, MaxW, EAlignment.Center, _Theme.TextStyle, _Theme.TextFont, TextColor, _ValueNames[i + offset]); SColorF Alpha = new SColorF(1f, 1f, 1f, 0.35f); if (i + offset == _Selection) { diff --git a/Vocaluxe/Menu/CStatic.cs b/Vocaluxe/Menu/CStatic.cs index 02c695d4..ef23ed45 100644 --- a/Vocaluxe/Menu/CStatic.cs +++ b/Vocaluxe/Menu/CStatic.cs @@ -5,9 +5,6 @@ using System.Text; using System.Xml; using System.Xml.XPath; -using Vocaluxe.Base; -using Vocaluxe.Lib.Draw; - namespace Vocaluxe.Menu { struct SThemeStatic @@ -19,6 +16,8 @@ namespace Vocaluxe.Menu class CStatic : IMenuElement { + private Base _Base; + private SThemeStatic _Theme; private bool _ThemeLoaded; @@ -35,7 +34,7 @@ namespace Vocaluxe.Menu if (_Texture.index != -1) return _Texture; else - return CTheme.GetSkinTexture(_Theme.TextureName); + return _Base.Theme.GetSkinTexture(_Theme.TextureName); } set { _Texture = value; } @@ -55,8 +54,9 @@ namespace Vocaluxe.Menu public EAspect Aspect = EAspect.Stretch; - public CStatic() + public CStatic(Base Base) { + _Base = Base; _Theme = new SThemeStatic(); _ThemeLoaded = false; @@ -74,6 +74,7 @@ namespace Vocaluxe.Menu public CStatic(CStatic s) { + _Base = s._Base; _Theme = new SThemeStatic(); _ThemeLoaded = false; @@ -89,8 +90,9 @@ namespace Vocaluxe.Menu Visible = s.Visible; } - public CStatic(STexture texture, SColorF color, SRectF rect) + public CStatic(Base Base, STexture texture, SColorF color, SRectF rect) { + _Base = Base; _Theme = new SThemeStatic(); _ThemeLoaded = false; @@ -106,8 +108,9 @@ namespace Vocaluxe.Menu Visible = true; } - public CStatic(string TextureSkinName, SColorF color, SRectF rect) + public CStatic(Base Base, string TextureSkinName, SColorF color, SRectF rect) { + _Base = Base; _Theme = new SThemeStatic(); _Theme.TextureName = TextureSkinName; _ThemeLoaded = false; @@ -139,7 +142,7 @@ namespace Vocaluxe.Menu if (CHelper.GetValueFromXML(item + "/Color", navigator, ref _Theme.ColorName, String.Empty)) { - _ThemeLoaded &= CTheme.GetColor(_Theme.ColorName, SkinIndex, ref Color); + _ThemeLoaded &= _Base.Theme.GetColor(_Theme.ColorName, SkinIndex, ref Color); } else { @@ -239,7 +242,7 @@ namespace Vocaluxe.Menu if (_Texture.index != -1) texture = _Texture; else - texture = CTheme.GetSkinTexture(_Theme.TextureName); + texture = _Base.Theme.GetSkinTexture(_Theme.TextureName); SRectF bounds = new SRectF( Rect.X - Rect.W * (scale - 1f), @@ -263,18 +266,18 @@ namespace Vocaluxe.Menu } SColorF color = new SColorF(Color.R, Color.G, Color.B, Color.A * Alpha); - if (Visible || ForceDraw || (CSettings.GameState == EGameState.EditTheme)) + if (Visible || ForceDraw || (_Base.Settings.GetGameState() == EGameState.EditTheme)) { - CDraw.DrawTexture(texture, rect, color, bounds); + _Base.Drawing.DrawTexture(texture, rect, color, bounds); if (Reflection) { - CDraw.DrawTextureReflection(texture, rect, color, bounds, ReflectionSpace, ReflectionHeight); + _Base.Drawing.DrawTextureReflection(texture, rect, color, bounds, ReflectionSpace, ReflectionHeight); } } - if (Selected && (CSettings.GameState == EGameState.EditTheme)) + if (Selected && (_Base.Settings.GetGameState() == EGameState.EditTheme)) { - CDraw.DrawColor(new SColorF(1f, 1f, 1f, 0.5f), rect); + _Base.Drawing.DrawColor(new SColorF(1f, 1f, 1f, 0.5f), rect); } } @@ -285,7 +288,7 @@ namespace Vocaluxe.Menu public void LoadTextures() { if (_Theme.ColorName != String.Empty) - Color = CTheme.GetColor(_Theme.ColorName); + Color = _Base.Theme.GetColor(_Theme.ColorName); } public void ReloadTextures() diff --git a/Vocaluxe/Menu/CText.cs b/Vocaluxe/Menu/CText.cs index 478dd0c2..ea203c38 100644 --- a/Vocaluxe/Menu/CText.cs +++ b/Vocaluxe/Menu/CText.cs @@ -37,8 +37,9 @@ namespace Vocaluxe.Menu } } - class CText : IMenuElement + public class CText : IMenuElement { + private Base _Base; private SThemeText _Theme; private bool _ThemeLoaded; @@ -221,8 +222,9 @@ namespace Vocaluxe.Menu public float Alpha = 1f; - public CText() + public CText(Base Base) { + _Base = Base; _Theme = new SThemeText(); _ThemeLoaded = false; _ButtonText = false; @@ -252,6 +254,7 @@ namespace Vocaluxe.Menu public CText(CText text) { + _Base = text._Base; _Theme = new SThemeText(); _ThemeLoaded = false; _ButtonText = false; @@ -281,8 +284,9 @@ namespace Vocaluxe.Menu EditMode = text.EditMode; } - public CText(float x, float y, float z, EAlignment align, float h, float mw, float r, float g, float b, float a, EStyle style, string font, string text, float rspace, float rheight) + public CText(Base Base, float x, float y, float z, EAlignment align, float h, float mw, float r, float g, float b, float a, EStyle style, string font, string text, float rspace, float rheight) { + _Base = Base; _Theme = new SThemeText(); _ThemeLoaded = false; _ButtonText = false; @@ -318,8 +322,9 @@ namespace Vocaluxe.Menu ReflectionHeight = rheight; } - public CText(float x, float y, float z, EAlignment align, float h, float mw, float r, float g, float b, float a, EStyle style, string font, string text) + public CText(Base Base, float x, float y, float z, EAlignment align, float h, float mw, float r, float g, float b, float a, EStyle style, string font, string text) { + _Base = Base; _Theme = new SThemeText(); _ThemeLoaded = false; _ButtonText = false; @@ -353,8 +358,9 @@ namespace Vocaluxe.Menu Reflection = false; } - public CText(float x, float y, float z, float h, float mw, EAlignment align, EStyle style, string font, SColorF col, string text, float rspace, float rheight) + public CText(Base Base, float x, float y, float z, float h, float mw, EAlignment align, EStyle style, string font, SColorF col, string text, float rspace, float rheight) { + _Base = Base; _Theme = new SThemeText(); _ThemeLoaded = false; _ButtonText = false; @@ -390,8 +396,9 @@ namespace Vocaluxe.Menu ReflectionHeight = rheight; } - public CText(float x, float y, float z, float h, float mw, EAlignment align, EStyle style, string font, SColorF col, string text) + public CText(Base Base, float x, float y, float z, float h, float mw, EAlignment align, EStyle style, string font, SColorF col, string text) { + _Base = Base; _Theme = new SThemeText(); _ThemeLoaded = false; _ButtonText = false; diff --git a/Vocaluxe/Menu/IMenu.cs b/Vocaluxe/Menu/IMenu.cs index 192a12b5..6538f979 100644 --- a/Vocaluxe/Menu/IMenu.cs +++ b/Vocaluxe/Menu/IMenu.cs @@ -43,13 +43,15 @@ namespace Vocaluxe.Menu void ProcessMouseMove(int x, int y); } - interface IConfig + public interface IConfig { void SetBackgroundMusicVolume(int NewVolume); int GetBackgroundMusicVolume(); + + ESongMenu GetSongMenuType(); } - interface ISettings + public interface ISettings { int GetRenderW(); int GetRenderH(); @@ -61,10 +63,14 @@ namespace Vocaluxe.Menu EGameState GetGameState(); } - interface ITheme + public interface ITheme { string GetThemeScreensPath(); int GetSkinIndex(); + STexture GetSkinTexture(string TextureName); + + SColorF GetColor(string ColorName); + bool GetColor(string ColorName, int SkinIndex, ref SColorF Color); void UnloadSkins(); void ListSkins(); @@ -72,11 +78,11 @@ namespace Vocaluxe.Menu void LoadTheme(); } - interface IHelper + public interface IHelper { } - interface IBackgroundMusic + public interface IBackgroundMusic { bool IsDisabled(); bool IsPlaying(); @@ -89,17 +95,22 @@ namespace Vocaluxe.Menu void ApplyVolume(); } - interface IDrawing + public interface IDrawing { RectangleF GetTextBounds(CText text); + + void DrawTexture(STexture Texture, SRectF Rect, SColorF Color, SRectF Bounds); + void DrawTextureReflection(STexture Texture, SRectF Rect, SColorF Color, SRectF Bounds, float ReflectionSpace, float ReflectionHeight); + + void DrawColor(SColorF Color, SRectF Rect); } - interface IGraphics + public interface IGraphics { void ReloadTheme(); } - interface ILog + public interface ILog { void LogError(string ErrorText); } @@ -347,4 +358,200 @@ namespace Vocaluxe.Menu } } #endregion Structs + + #region EnumsConfig + public enum ERenderer + { +#if WIN + TR_CONFIG_DIRECT3D, +#endif + TR_CONFIG_OPENGL, + TR_CONFIG_SOFTWARE + } + + public enum EAntiAliasingModes + { + x0 = 0, + x2 = 2, + x4 = 4, + x8 = 8, + x16 = 16, + x32 = 32 + } + + public enum EColorDeep + { + Bit8 = 8, + Bit16 = 16, + Bit24 = 24, + Bit32 = 32 + } + + public enum ETextureQuality + { + TR_CONFIG_TEXTURE_LOWEST, + TR_CONFIG_TEXTURE_LOW, + TR_CONFIG_TEXTURE_MEDIUM, + TR_CONFIG_TEXTURE_HIGH, + TR_CONFIG_TEXTURE_HIGHEST + } + + public enum EOffOn + { + TR_CONFIG_OFF, + TR_CONFIG_ON + } + + public enum EDebugLevel + { + // don't change the order! + TR_CONFIG_OFF, //no debug infos + TR_CONFIG_ONLY_FPS, + TR_CONFIG_LEVEL1, + TR_CONFIG_LEVEL2, + TR_CONFIG_LEVEL3, + TR_CONFIG_LEVEL_MAX //all debug infos + } + + public enum EBufferSize + { + b0 = 0, + b512 = 512, + b1024 = 1024, + b1536 = 1536, + b2048 = 2048, + b2560 = 2560, + b3072 = 3072, + b3584 = 3584, + b4096 = 4096 + } + + public enum EPlaybackLib + { + PortAudio, + OpenAL + } + + public enum EWebcamLib + { + OpenCV, + AForgeNet + } + + public enum ERecordLib + { +#if WIN + DirectSound, +#endif + PortAudio + } + + public enum EVideoDecoder + { + FFmpeg + } + + public enum ESongMenu + { + //TR_CONFIG_LIST, //a simple list + //TR_CONFIG_DREIDEL, //as in ultrastar deluxe + TR_CONFIG_TILE_BOARD, //chessboard like + //TR_CONFIG_BOOK //for playlists + } + + public enum ESongSorting + { + TR_CONFIG_NONE, + //TR_CONFIG_RANDOM, + TR_CONFIG_FOLDER, + TR_CONFIG_ARTIST, + TR_CONFIG_ARTIST_LETTER, + TR_CONFIG_TITLE_LETTER, + TR_CONFIG_EDITION, + TR_CONFIG_GENRE, + TR_CONFIG_LANGUAGE, + TR_CONFIG_YEAR, + TR_CONFIG_DECADE + } + + public enum ECoverLoading + { + TR_CONFIG_COVERLOADING_ONDEMAND, + TR_CONFIG_COVERLOADING_ATSTART, + TR_CONFIG_COVERLOADING_DYNAMIC + } + + public enum EGameDifficulty + { + TR_CONFIG_EASY, + TR_CONFIG_NORMAL, + TR_CONFIG_HARD + } + + public enum ETimerMode + { + TR_CONFIG_TIMERMODE_CURRENT, + TR_CONFIG_TIMERMODE_REMAINING, + TR_CONFIG_TIMERMODE_TOTAL + } + + public enum ETimerLook + { + TR_CONFIG_TIMERLOOK_NORMAL, + TR_CONFIG_TIMERLOOK_EXPANDED + } + + public enum EBackgroundMusicSource + { + TR_CONFIG_NO_OWN_MUSIC, + TR_CONFIG_OWN_MUSIC, + TR_CONFIG_ONLY_OWN_MUSIC + } + + public enum EPlayerInfo + { + TR_CONFIG_PLAYERINFO_BOTH, + TR_CONFIG_PLAYERINFO_NAME, + TR_CONFIG_PLAYERINFO_AVATAR, + TR_CONFIG_PLAYERINFO_OFF + } + + public enum EFadePlayerInfo + { + TR_CONFIG_FADEPLAYERINFO_ALL, + TR_CONFIG_FADEPLAYERINFO_INFO, + TR_CONFIG_FADEPLAYERINFO_OFF + } + + public enum ELyricStyle + { + Fill, + Jump, + Slide, + Zoom + } + + #endregion EnumsConfig + + public enum EAlignment + { + Left, + Center, + Right + } + + public enum EHAlignment + { + Top, + Center, + Bottom + } + + public enum EStyle + { + Normal, + Italic, + Bold, + BoldItalic + } } diff --git a/Vocaluxe/Menu/IMenuElement.cs b/Vocaluxe/Menu/IMenuElement.cs index 152e4ec1..f93a5acd 100644 --- a/Vocaluxe/Menu/IMenuElement.cs +++ b/Vocaluxe/Menu/IMenuElement.cs @@ -9,6 +9,7 @@ namespace Vocaluxe.Menu interface IMenuElement { string GetThemeName(); + bool LoadTheme(string XmlPath, string ElementName, XPathNavigator navigator, int SkinIndex); bool SaveTheme(XmlWriter writer); diff --git a/Vocaluxe/Menu/SingNotes/CSingNotes.cs b/Vocaluxe/Menu/SingNotes/CSingNotes.cs index 244d380b..dc442671 100644 --- a/Vocaluxe/Menu/SingNotes/CSingNotes.cs +++ b/Vocaluxe/Menu/SingNotes/CSingNotes.cs @@ -46,6 +46,7 @@ namespace Vocaluxe.Menu.SingNotes abstract class CSingNotes : ISingNotes, IMenuElement { + private Base _Base; private SThemeSingBar _Theme; private bool _ThemeLoaded; @@ -66,8 +67,9 @@ namespace Vocaluxe.Menu.SingNotes set { _BarPos = value; } } - public CSingNotes() + public CSingNotes(Base Base) { + _Base = Base; _Theme = new SThemeSingBar(); _ThemeLoaded = false; diff --git a/Vocaluxe/Menu/SingNotes/CSingNotesClassic.cs b/Vocaluxe/Menu/SingNotes/CSingNotesClassic.cs index 93698740..37827b96 100644 --- a/Vocaluxe/Menu/SingNotes/CSingNotesClassic.cs +++ b/Vocaluxe/Menu/SingNotes/CSingNotesClassic.cs @@ -6,5 +6,12 @@ namespace Vocaluxe.Menu.SingNotes { class CSingNotesClassic : CSingNotes { + private Base _Base; + + public CSingNotesClassic(Base Base) + : base(Base) + { + _Base = Base; + } } } diff --git a/Vocaluxe/Menu/SongMenu/CSongMenu.cs b/Vocaluxe/Menu/SongMenu/CSongMenu.cs index dbb09697..3c24d2f1 100644 --- a/Vocaluxe/Menu/SongMenu/CSongMenu.cs +++ b/Vocaluxe/Menu/SongMenu/CSongMenu.cs @@ -4,25 +4,27 @@ using System.Text; using System.Xml; using System.Xml.XPath; -using Vocaluxe.Base; -using Vocaluxe.Lib.Draw; +using Vocaluxe.Menu; using Vocaluxe.PartyModes; namespace Vocaluxe.Menu.SongMenu { class CSongMenu : ISongMenu { + private Base _Base; + private ISongMenu _SongMenu; private ESongMenu _Type; - public CSongMenu() + public CSongMenu(Base Base) { + _Base = Base; CreateSongMenu(); } public void UpdateSongMenuType() { - if (_Type != CConfig.SongMenu) + if (_Type != _Base.Config.GetSongMenuType()) CreateSongMenu(); } @@ -205,7 +207,7 @@ namespace Vocaluxe.Menu.SongMenu _SongMenu.OnHide(); } - switch (CConfig.SongMenu) + switch (_Base.Config.GetSongMenuType()) { //case ESongMenu.TR_CONFIG_LIST: // _SongMenu = new CSongMenuList(); @@ -216,7 +218,7 @@ namespace Vocaluxe.Menu.SongMenu // break; case ESongMenu.TR_CONFIG_TILE_BOARD: - _SongMenu = new CSongMenuTileBoard(); + _SongMenu = new CSongMenuTileBoard(_Base); break; //case ESongMenu.TR_CONFIG_BOOK: @@ -224,7 +226,7 @@ namespace Vocaluxe.Menu.SongMenu // break; } - _Type = CConfig.SongMenu; + _Type = _Base.Config.GetSongMenuType(); } } } diff --git a/Vocaluxe/Menu/SongMenu/CSongMenuBook.cs b/Vocaluxe/Menu/SongMenu/CSongMenuBook.cs index ed6e433b..ddf6d30d 100644 --- a/Vocaluxe/Menu/SongMenu/CSongMenuBook.cs +++ b/Vocaluxe/Menu/SongMenu/CSongMenuBook.cs @@ -6,5 +6,12 @@ namespace Vocaluxe.Menu.SongMenu { class CSongMenuBook : CSongMenuFramework { + new private Base _Base; + + public CSongMenuBook(Base Base) + : base(Base) + { + _Base = Base; + } } } diff --git a/Vocaluxe/Menu/SongMenu/CSongMenuDreidel.cs b/Vocaluxe/Menu/SongMenu/CSongMenuDreidel.cs index b417d791..cb54d99e 100644 --- a/Vocaluxe/Menu/SongMenu/CSongMenuDreidel.cs +++ b/Vocaluxe/Menu/SongMenu/CSongMenuDreidel.cs @@ -12,6 +12,7 @@ namespace Vocaluxe.Menu.SongMenu { class CSongMenuDreidel : CSongMenuFramework { + new private Base _Base; /* private SRectF _ScrollRect; private CStatic _CoverBig; @@ -31,6 +32,13 @@ namespace Vocaluxe.Menu.SongMenu return _actualSelection; } */ + + public CSongMenuDreidel(Base Base) + : base(Base) + { + _Base = Base; + } + public override void Init() { base.Init(); diff --git a/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs b/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs index deaa6f5c..10de52b5 100644 --- a/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs +++ b/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs @@ -93,6 +93,7 @@ namespace Vocaluxe.Menu.SongMenu abstract class CSongMenuFramework : ISongMenu { + protected Base _Base; protected SThemeSongMenu _Theme; private bool _ThemeLoaded; @@ -234,20 +235,21 @@ namespace Vocaluxe.Menu.SongMenu _Visible = Visible; } - public CSongMenuFramework() + public CSongMenuFramework(Base Base) { + _Base = Base; _Theme = new SThemeSongMenu(); - _Theme.songMenuTileBoard.TextArtist = new CText(); - _Theme.songMenuTileBoard.TextTitle = new CText(); - _Theme.songMenuTileBoard.TextSongLength = new CText(); + _Theme.songMenuTileBoard.TextArtist = new CText(_Base); + _Theme.songMenuTileBoard.TextTitle = new CText(_Base); + _Theme.songMenuTileBoard.TextSongLength = new CText(_Base); - _Theme.songMenuTileBoard.StaticCoverBig = new CStatic(); - _Theme.songMenuTileBoard.StaticTextBG = new CStatic(); - _Theme.songMenuTileBoard.StaticDuetIcon = new CStatic(); - _Theme.songMenuTileBoard.StaticVideoIcon = new CStatic(); - _Theme.songMenuTileBoard.StaticMedleyCalcIcon = new CStatic(); - _Theme.songMenuTileBoard.StaticMedleyTagIcon = new CStatic(); + _Theme.songMenuTileBoard.StaticCoverBig = new CStatic(_Base); + _Theme.songMenuTileBoard.StaticTextBG = new CStatic(_Base); + _Theme.songMenuTileBoard.StaticDuetIcon = new CStatic(_Base); + _Theme.songMenuTileBoard.StaticVideoIcon = new CStatic(_Base); + _Theme.songMenuTileBoard.StaticMedleyCalcIcon = new CStatic(_Base); + _Theme.songMenuTileBoard.StaticMedleyTagIcon = new CStatic(_Base); _ThemeLoaded = false; } @@ -540,7 +542,7 @@ namespace Vocaluxe.Menu.SongMenu public virtual CStatic GetSelectedSongCover() { - return new CStatic(); + return new CStatic(_Base); } public virtual int GetSelectedCategory() diff --git a/Vocaluxe/Menu/SongMenu/CSongMenuList.cs b/Vocaluxe/Menu/SongMenu/CSongMenuList.cs index c7dc8a0f..b6b2ab49 100644 --- a/Vocaluxe/Menu/SongMenu/CSongMenuList.cs +++ b/Vocaluxe/Menu/SongMenu/CSongMenuList.cs @@ -6,5 +6,12 @@ namespace Vocaluxe.Menu.SongMenu { class CSongMenuList : CSongMenuFramework { + new private Base _Base; + + public CSongMenuList(Base Base) + : base(Base) + { + _Base = Base; + } } } diff --git a/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs b/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs index ad0c44b6..0b0880d8 100644 --- a/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs @@ -13,6 +13,7 @@ namespace Vocaluxe.Menu.SongMenu { class CSongMenuTileBoard : CSongMenuFramework { + new private Base _Base; private SRectF _ScrollRect; private List _Tiles; private CStatic _CoverBig; @@ -43,6 +44,12 @@ namespace Vocaluxe.Menu.SongMenu private bool _SmallView = false; + public CSongMenuTileBoard(Base Base) + : base(Base) + { + _Base = Base; + } + public override int GetActualSelection() { return _actualSelection; @@ -74,7 +81,7 @@ namespace Vocaluxe.Menu.SongMenu { SRectF rect = new SRectF(_Theme.songMenuTileBoard.TileRect.X + j * (_TileW + _SpaceW), _Theme.songMenuTileBoard.TileRect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z); - CStatic tile = new CStatic(_CoverTexture, Color, rect); + CStatic tile = new CStatic(_Base, _CoverTexture, Color, rect); _Tiles.Add(tile); } } @@ -518,7 +525,7 @@ namespace Vocaluxe.Menu.SongMenu if (tile.Selected) return new CStatic(tile); } - return new CStatic(); + return new CStatic(_Base); } public override void SetSelectedSong(int VisibleSongNr) @@ -771,7 +778,7 @@ namespace Vocaluxe.Menu.SongMenu { SRectF rect = new SRectF(_Theme.songMenuTileBoard.TileRectSmall.X + j * (_TileW + _SpaceW), _Theme.songMenuTileBoard.TileRectSmall.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z); - CStatic tile = new CStatic(_CoverTexture, Color, rect); + CStatic tile = new CStatic(_Base, _CoverTexture, Color, rect); _Tiles.Add(tile); } } @@ -797,7 +804,7 @@ namespace Vocaluxe.Menu.SongMenu { SRectF rect = new SRectF(_Theme.songMenuTileBoard.TileRect.X + j * (_TileW + _SpaceW), _Theme.songMenuTileBoard.TileRect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z); - CStatic tile = new CStatic(_CoverTexture, Color, rect); + CStatic tile = new CStatic(_Base, _CoverTexture, Color, rect); _Tiles.Add(tile); } } diff --git a/Vocaluxe/Menu/SongMenu/ISongMenu.cs b/Vocaluxe/Menu/SongMenu/ISongMenu.cs index 8a63a8cb..4017ec3a 100644 --- a/Vocaluxe/Menu/SongMenu/ISongMenu.cs +++ b/Vocaluxe/Menu/SongMenu/ISongMenu.cs @@ -2,8 +2,6 @@ using System.Collections.Generic; using System.Text; -using Vocaluxe.Base; -using Vocaluxe.Lib.Draw; using Vocaluxe.PartyModes; namespace Vocaluxe.Menu.SongMenu diff --git a/Vocaluxe/Screens/CScreenCredits.cs b/Vocaluxe/Screens/CScreenCredits.cs index 582a26bc..e8a07386 100644 --- a/Vocaluxe/Screens/CScreenCredits.cs +++ b/Vocaluxe/Screens/CScreenCredits.cs @@ -148,7 +148,7 @@ namespace Vocaluxe.Screens if (paragraphs[i][e] != null) { string newline = line + " " + paragraphs[i][e]; - CText text = new CText(75, lastY, -2, 30, -1, EAlignment.Left, EStyle.Bold, "Outline", new SColorF(1, 1, 1, 1), line); + CText text = GetNewText(75, lastY, -2, 30, -1, EAlignment.Left, EStyle.Bold, "Outline", new SColorF(1, 1, 1, 1), line); if (CDraw.GetTextBounds(text).Width < (CSettings.iRenderW - 220)) { line = line + " " + paragraphs[i][e]; @@ -239,7 +239,7 @@ namespace Vocaluxe.Screens base.OnShow(); //Vocaluxe-Logo - logo = new CStatic(_TexLogo, new SColorF(1, 1, 1, 1), new SRectF((CSettings.iRenderW - _TexLogo.width) / 2, -270, _TexLogo.width, _TexLogo.height, -2)); + logo = GetNewStatic(_TexLogo, new SColorF(1, 1, 1, 1), new SRectF((CSettings.iRenderW - _TexLogo.width) / 2, -270, _TexLogo.width, _TexLogo.height, -2)); //Little stars for logo int numstars = (int)(logo.Rect.W * 0.25f / 2f); @@ -252,7 +252,7 @@ namespace Vocaluxe.Screens //brunzel CCreditName CreditEntryBrunzel = new CCreditName(); - CreditEntryBrunzel.image = new CStatic(_TexNameBrunzel, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 400, 120, -4)); + CreditEntryBrunzel.image = GetNewStatic(_TexNameBrunzel, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 400, 120, -4)); CreditEntryBrunzel.particleRect = new SRectF(CreditEntryBrunzel.image.Rect.X + 342, CreditEntryBrunzel.image.Rect.Y + 4, 30, 30, -5); CreditEntryBrunzel.particle = new CParticleEffect(8, new SColorF(1, 0, 0, 1), CreditEntryBrunzel.particleRect, _TexPerfectNoteStar, 35, EParticeType.Star); CreditEntryBrunzel.active = true; @@ -261,7 +261,7 @@ namespace Vocaluxe.Screens //Darkice CCreditName CreditEntryDarkice = new CCreditName(); - CreditEntryDarkice.image = new CStatic(_TexNameDarkice, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 400, 120, -4)); + CreditEntryDarkice.image = GetNewStatic(_TexNameDarkice, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 400, 120, -4)); CreditEntryDarkice.particleRect = new SRectF(CreditEntryDarkice.image.Rect.X + 242, CreditEntryDarkice.image.Rect.Y + 23, 30, 30, -5); CreditEntryDarkice.particle = new CParticleEffect(8, new SColorF(0.149f, 0.415f, 0.819f, 1), CreditEntryDarkice.particleRect, _TexPerfectNoteStar, 35, EParticeType.Star); CreditEntryDarkice.active = true; @@ -270,7 +270,7 @@ namespace Vocaluxe.Screens //flokuep CCreditName CreditEntryFlokuep = new CCreditName(); - CreditEntryFlokuep.image = new CStatic(_TexNameFlokuep, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 400, 120, -4)); + CreditEntryFlokuep.image = GetNewStatic(_TexNameFlokuep, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 400, 120, -4)); CreditEntryFlokuep.particleRect = new SRectF(CreditEntryFlokuep.image.Rect.X + 141, CreditEntryFlokuep.image.Rect.Y - 2, 30, 30, -5); CreditEntryFlokuep.particle = new CParticleEffect(8, new SColorF(1, 0, 0, 1), CreditEntryFlokuep.particleRect, _TexPerfectNoteStar, 35, EParticeType.Star); CreditEntryFlokuep.active = true; @@ -279,7 +279,7 @@ namespace Vocaluxe.Screens //bohning CCreditName CreditEntryBohning = new CCreditName(); - CreditEntryBohning.image = new CStatic(_TexNameBohning, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 350, 110, -4)); + CreditEntryBohning.image = GetNewStatic(_TexNameBohning, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 350, 110, -4)); CreditEntryBohning.particleRect = new SRectF(CreditEntryBohning.image.Rect.X + 172, CreditEntryBohning.image.Rect.Y + 16, 10, 10, -5); CreditEntryBohning.particle = new CParticleEffect(4, new SColorF(0.149f, 0.415f, 0.819f, 1), CreditEntryBohning.particleRect, _TexPerfectNoteStar, 25, EParticeType.Star); CreditEntryBohning.active = true; @@ -288,7 +288,7 @@ namespace Vocaluxe.Screens //mesand CCreditName CreditEntryMesand = new CCreditName(); - CreditEntryMesand.image = new CStatic(_TexNameMesand, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 350, 110, -4)); + CreditEntryMesand.image = GetNewStatic(_TexNameMesand, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 350, 110, -4)); CreditEntryMesand.particleRect = new SRectF(CreditEntryMesand.image.Rect.X + 240, CreditEntryMesand.image.Rect.Y - 2, 10, 10, -5); CreditEntryMesand.particle = new CParticleEffect(4, new SColorF(1, 0, 0, 1), CreditEntryMesand.particleRect, _TexPerfectNoteStar, 25, EParticeType.Star); CreditEntryMesand.active = true; @@ -297,7 +297,7 @@ namespace Vocaluxe.Screens //babene03 CCreditName CreditEntryBabene03 = new CCreditName(); - CreditEntryBabene03.image = new CStatic(_TexNameBabene03, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 350, 110, -4)); + CreditEntryBabene03.image = GetNewStatic(_TexNameBabene03, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 350, 110, -4)); CreditEntryBabene03.particleRect = new SRectF(CreditEntryBabene03.image.Rect.X + 7, CreditEntryBabene03.image.Rect.Y + 4, 10, 10, -5); CreditEntryBabene03.particle = new CParticleEffect(4, new SColorF(0.149f, 0.415f, 0.819f, 1), CreditEntryBabene03.particleRect, _TexPerfectNoteStar, 25, EParticeType.Star); CreditEntryBabene03.active = true; @@ -306,7 +306,7 @@ namespace Vocaluxe.Screens //pantero CCreditName CreditEntrypantero = new CCreditName(); - CreditEntrypantero.image = new CStatic(_TexNamePantero, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 350, 110, -4)); + CreditEntrypantero.image = GetNewStatic(_TexNamePantero, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 350, 110, -4)); CreditEntrypantero.particleRect = new SRectF(CreditEntrypantero.image.Rect.X + 140, CreditEntrypantero.image.Rect.Y + 15, 10, 10, -5); CreditEntrypantero.particle = new CParticleEffect(4, new SColorF(1, 0, 0, 1), CreditEntrypantero.particleRect, _TexPerfectNoteStar, 25, EParticeType.Star); CreditEntrypantero.active = true; @@ -315,7 +315,7 @@ namespace Vocaluxe.Screens //Pinky007 CCreditName CreditEntryPinky007 = new CCreditName(); - CreditEntryPinky007.image = new CStatic(_TexNamePinky007, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 350, 110, -4)); + CreditEntryPinky007.image = GetNewStatic(_TexNamePinky007, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 350, 110, -4)); CreditEntryPinky007.particleRect = new SRectF(CreditEntryPinky007.image.Rect.X + 42, CreditEntryPinky007.image.Rect.Y + 15, 10, 10, -5); CreditEntryPinky007.particle = new CParticleEffect(4, new SColorF(0.149f, 0.415f, 0.819f, 1), CreditEntryPinky007.particleRect, _TexPerfectNoteStar, 25, EParticeType.Star); CreditEntryPinky007.active = true; diff --git a/Vocaluxe/Screens/CScreenNames.cs b/Vocaluxe/Screens/CScreenNames.cs index 5099dc36..2057049c 100644 --- a/Vocaluxe/Screens/CScreenNames.cs +++ b/Vocaluxe/Screens/CScreenNames.cs @@ -91,7 +91,7 @@ namespace Vocaluxe.Screens texts.AddRange(EqualizerPlayer); _ThemeEqualizers = texts.ToArray(); - chooseAvatarStatic = new CStatic(); + chooseAvatarStatic = GetNewStatic(); chooseAvatarStatic.Visible = false; } diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 2e001911..7599d515 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -1354,7 +1354,7 @@ namespace Vocaluxe.Screens TimeRect trect = new TimeRect(); trect.startBeat = Line[j].FirstNoteBeat; trect.endBeat = Line[j].EndBeat; - trect.rect = new CStatic(new STexture(-1), + trect.rect = GetNewStatic(new STexture(-1), new SColorF(1f, 1f, 1f, 1f), new SRectF(stat.Rect.X + stat.Rect.W * ((CGame.GetTimeFromBeats(trect.startBeat, song.BPM) + song.Gap - song.Start) / TotalTime), stat.Rect.Y, diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 2cee62d6..b6fab24a 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -103,7 +103,7 @@ namespace Vocaluxe.Screens Statics[htStatics(StaticOptionsBG)].Visible = false; Playlists[htPlaylists(Playlist)].Visible = false; - DragAndDropCover = new CStatic(); + DragAndDropCover = GetNewStatic(); Playlists[htPlaylists(Playlist)].Init(); From 075eff5ae75e7415cb6ed01602c816d888ae842d Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Thu, 13 Dec 2012 21:13:32 +0100 Subject: [PATCH 011/110] backgrounds converted --- Vocaluxe/Base/CConfig.cs | 75 +++++++++++++-------------------- Vocaluxe/Menu/CBackground.cs | 47 ++++++++++----------- Vocaluxe/Menu/CEqualizer.cs | 4 +- Vocaluxe/Menu/CNameSelection.cs | 2 +- Vocaluxe/Menu/CSelectSlide.cs | 2 +- Vocaluxe/Menu/CText.cs | 6 +-- Vocaluxe/Menu/IMenu.cs | 12 ++++++ 7 files changed, 71 insertions(+), 77 deletions(-) diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index 03d1e7d8..ed27480a 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -340,7 +340,7 @@ namespace Vocaluxe.Base #region Debug writer.WriteStartElement("Debug"); - writer.WriteComment("DebugLevel: " + ListStrings(Enum.GetNames(typeof(EDebugLevel)))); + writer.WriteComment("DebugLevel: " + CHelper.ListStrings(Enum.GetNames(typeof(EDebugLevel)))); writer.WriteElementString("DebugLevel", Enum.GetName(typeof(EDebugLevel), DebugLevel)); writer.WriteEndElement(); @@ -349,10 +349,10 @@ namespace Vocaluxe.Base #region Graphics writer.WriteStartElement("Graphics"); - writer.WriteComment("Renderer: " + ListStrings(Enum.GetNames(typeof(ERenderer)))); + writer.WriteComment("Renderer: " + CHelper.ListStrings(Enum.GetNames(typeof(ERenderer)))); writer.WriteElementString("Renderer", Enum.GetName(typeof(ERenderer), Renderer)); - writer.WriteComment("TextureQuality: " + ListStrings(Enum.GetNames(typeof(ETextureQuality)))); + writer.WriteComment("TextureQuality: " + CHelper.ListStrings(Enum.GetNames(typeof(ETextureQuality)))); writer.WriteElementString("TextureQuality", Enum.GetName(typeof(ETextureQuality), TextureQuality)); writer.WriteComment("CoverSize (pixels): 32, 64, 128, 256, 512, 1024 (default: 128)"); @@ -362,19 +362,19 @@ namespace Vocaluxe.Base writer.WriteElementString("ScreenW", ScreenW.ToString()); writer.WriteElementString("ScreenH", ScreenH.ToString()); - writer.WriteComment("AAMode: " + ListStrings(Enum.GetNames(typeof(EAntiAliasingModes)))); + writer.WriteComment("AAMode: " + CHelper.ListStrings(Enum.GetNames(typeof(EAntiAliasingModes)))); writer.WriteElementString("AAMode", Enum.GetName(typeof(EAntiAliasingModes), AAMode)); - writer.WriteComment("Colors: " + ListStrings(Enum.GetNames(typeof(EColorDeep)))); + writer.WriteComment("Colors: " + CHelper.ListStrings(Enum.GetNames(typeof(EColorDeep)))); writer.WriteElementString("Colors", Enum.GetName(typeof(EColorDeep), Colors)); writer.WriteComment("MaxFPS should be between 1..200"); writer.WriteElementString("MaxFPS", MaxFPS.ToString("#")); - writer.WriteComment("VSync: " + ListStrings(Enum.GetNames(typeof(EOffOn)))); + writer.WriteComment("VSync: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); writer.WriteElementString("VSync", Enum.GetName(typeof(EOffOn), VSync)); - writer.WriteComment("FullScreen: " + ListStrings(Enum.GetNames(typeof(EOffOn)))); + writer.WriteComment("FullScreen: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); writer.WriteElementString("FullScreen", Enum.GetName(typeof(EOffOn), FullScreen)); writer.WriteComment("FadeTime should be between 0..3 Seconds"); @@ -395,25 +395,25 @@ namespace Vocaluxe.Base writer.WriteComment("Name of cover-theme"); writer.WriteElementString("Cover", CoverTheme); - writer.WriteComment("Draw note-lines:" + ListStrings(Enum.GetNames(typeof(EOffOn)))); + writer.WriteComment("Draw note-lines:" + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); writer.WriteElementString("DrawNoteLines", Enum.GetName(typeof(EOffOn), DrawNoteLines)); - writer.WriteComment("Draw tone-helper:" + ListStrings(Enum.GetNames(typeof(EOffOn)))); + writer.WriteComment("Draw tone-helper:" + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); writer.WriteElementString("DrawToneHelper", Enum.GetName(typeof(EOffOn), DrawToneHelper)); - writer.WriteComment("Look of timer:" + ListStrings(Enum.GetNames(typeof(ETimerLook)))); + writer.WriteComment("Look of timer:" + CHelper.ListStrings(Enum.GetNames(typeof(ETimerLook)))); writer.WriteElementString("TimerLook", Enum.GetName(typeof(ETimerLook), TimerLook)); - writer.WriteComment("Information about players on SingScreen:" + ListStrings(Enum.GetNames(typeof(EPlayerInfo)))); + writer.WriteComment("Information about players on SingScreen:" + CHelper.ListStrings(Enum.GetNames(typeof(EPlayerInfo)))); writer.WriteElementString("PlayerInfo", Enum.GetName(typeof(EPlayerInfo), PlayerInfo)); - writer.WriteComment("Fade player-information with lyrics and notebars:" + ListStrings(Enum.GetNames(typeof(EFadePlayerInfo)))); + writer.WriteComment("Fade player-information with lyrics and notebars:" + CHelper.ListStrings(Enum.GetNames(typeof(EFadePlayerInfo)))); writer.WriteElementString("FadePlayerInfo", Enum.GetName(typeof(EFadePlayerInfo), FadePlayerInfo)); - writer.WriteComment("Cover Loading:" + ListStrings(Enum.GetNames(typeof(ECoverLoading)))); + writer.WriteComment("Cover Loading:" + CHelper.ListStrings(Enum.GetNames(typeof(ECoverLoading)))); writer.WriteElementString("CoverLoading", Enum.GetName(typeof(ECoverLoading), CoverLoading)); - writer.WriteComment("Lyric Style:" + ListStrings(Enum.GetNames(typeof(ELyricStyle)))); + writer.WriteComment("Lyric Style:" + CHelper.ListStrings(Enum.GetNames(typeof(ELyricStyle)))); writer.WriteElementString("LyricStyle", Enum.GetName(typeof(ELyricStyle), LyricStyle)); writer.WriteEndElement(); @@ -422,13 +422,13 @@ namespace Vocaluxe.Base #region Sound writer.WriteStartElement("Sound"); - writer.WriteComment("PlayBackLib: " + ListStrings(Enum.GetNames(typeof(EPlaybackLib)))); + writer.WriteComment("PlayBackLib: " + CHelper.ListStrings(Enum.GetNames(typeof(EPlaybackLib)))); writer.WriteElementString("PlayBackLib", Enum.GetName(typeof(EPlaybackLib), PlayBackLib)); - writer.WriteComment("RecordLib: " + ListStrings(Enum.GetNames(typeof(ERecordLib)))); + writer.WriteComment("RecordLib: " + CHelper.ListStrings(Enum.GetNames(typeof(ERecordLib)))); writer.WriteElementString("RecordLib", Enum.GetName(typeof(ERecordLib), RecordLib)); - writer.WriteComment("AudioBufferSize: " + ListStrings(Enum.GetNames(typeof(EBufferSize)))); + writer.WriteComment("AudioBufferSize: " + CHelper.ListStrings(Enum.GetNames(typeof(EBufferSize)))); writer.WriteElementString("AudioBufferSize", Enum.GetName(typeof(EBufferSize), AudioBufferSize)); writer.WriteComment("AudioLatency from -500 to 500 ms"); @@ -479,28 +479,28 @@ namespace Vocaluxe.Base } } - writer.WriteComment("SongMenu: " + ListStrings(Enum.GetNames(typeof(ESongMenu)))); + writer.WriteComment("SongMenu: " + CHelper.ListStrings(Enum.GetNames(typeof(ESongMenu)))); writer.WriteElementString("SongMenu", Enum.GetName(typeof(ESongMenu), SongMenu)); - writer.WriteComment("SongSorting: " + ListStrings(Enum.GetNames(typeof(ESongSorting)))); + writer.WriteComment("SongSorting: " + CHelper.ListStrings(Enum.GetNames(typeof(ESongSorting)))); writer.WriteElementString("SongSorting", Enum.GetName(typeof(ESongSorting), SongSorting)); - writer.WriteComment("Ignore articles on song-sorting: " + ListStrings(Enum.GetNames(typeof(EOffOn)))); + writer.WriteComment("Ignore articles on song-sorting: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); writer.WriteElementString("IgnoreArticles", Enum.GetName(typeof(EOffOn), IgnoreArticles)); writer.WriteComment("ScoreAnimationTime: Values >= 1 or 0 for no animation. Time is in seconds."); writer.WriteElementString("ScoreAnimationTime", ScoreAnimationTime.ToString()); - writer.WriteComment("TimerMode: " + ListStrings(Enum.GetNames(typeof(ETimerMode)))); + writer.WriteComment("TimerMode: " + CHelper.ListStrings(Enum.GetNames(typeof(ETimerMode)))); writer.WriteElementString("TimerMode", Enum.GetName(typeof(ETimerMode), TimerMode)); writer.WriteComment("NumPlayer: 1.." + CSettings.MaxNumPlayer.ToString()); writer.WriteElementString("NumPlayer", NumPlayer.ToString()); - writer.WriteComment("Order songs in tabs: " + ListStrings(Enum.GetNames(typeof(EOffOn)))); + writer.WriteComment("Order songs in tabs: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); writer.WriteElementString("Tabs", Enum.GetName(typeof(EOffOn), Tabs)); - writer.WriteComment("Lyrics also on Top of screen: " + ListStrings(Enum.GetNames(typeof(EOffOn)))); + writer.WriteComment("Lyrics also on Top of screen: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); writer.WriteElementString("LyricsOnTop", Enum.GetName(typeof(EOffOn), LyricsOnTop)); writer.WriteComment("Default profile for players 1..." + CSettings.MaxNumPlayer.ToString() + ":"); @@ -517,22 +517,22 @@ namespace Vocaluxe.Base #region Video writer.WriteStartElement("Video"); - writer.WriteComment("VideoDecoder: " + ListStrings(Enum.GetNames(typeof(EVideoDecoder)))); + writer.WriteComment("VideoDecoder: " + CHelper.ListStrings(Enum.GetNames(typeof(EVideoDecoder)))); writer.WriteElementString("VideoDecoder", Enum.GetName(typeof(EVideoDecoder), VideoDecoder)); - writer.WriteComment("VideoBackgrounds: " + ListStrings(Enum.GetNames(typeof(EOffOn)))); + writer.WriteComment("VideoBackgrounds: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); writer.WriteElementString("VideoBackgrounds", Enum.GetName(typeof(EOffOn), VideoBackgrounds)); - writer.WriteComment("VideoPreview: " + ListStrings(Enum.GetNames(typeof(EOffOn)))); + writer.WriteComment("VideoPreview: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); writer.WriteElementString("VideoPreview", Enum.GetName(typeof(EOffOn), VideoPreview)); - writer.WriteComment("Show Videos while singing: " + ListStrings(Enum.GetNames(typeof(EOffOn)))); + writer.WriteComment("Show Videos while singing: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); writer.WriteElementString("VideosInSongs", Enum.GetName(typeof(EOffOn), VideosInSongs)); - writer.WriteComment("Show backgroundmusic videos as background: " + ListStrings(Enum.GetNames(typeof(EOffOn)))); + writer.WriteComment("Show backgroundmusic videos as background: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn)))); writer.WriteElementString("VideosToBackground", Enum.GetName(typeof(EOffOn), VideosToBackground)); - writer.WriteComment("WebcamLib: " + ListStrings(Enum.GetNames(typeof(EWebcamLib)))); + writer.WriteComment("WebcamLib: " + CHelper.ListStrings(Enum.GetNames(typeof(EWebcamLib)))); writer.WriteElementString("WebcamLib", Enum.GetName(typeof(EWebcamLib), WebcamLib)); writer.WriteStartElement("WebcamConfig"); @@ -882,23 +882,6 @@ namespace Vocaluxe.Base return true; } - /// - /// Concat strings into one string with ", " as separator. - /// - public static string ListStrings(string[] str) - { - string _Result = string.Empty; - - for (int i = 0; i < str.Length; i++) - { - _Result += str[i]; - if(i < str.Length - 1) - _Result += ", "; - } - - return _Result; - } - /// /// Use saved players from config now for games /// diff --git a/Vocaluxe/Menu/CBackground.cs b/Vocaluxe/Menu/CBackground.cs index 1c5a6738..6254ad34 100644 --- a/Vocaluxe/Menu/CBackground.cs +++ b/Vocaluxe/Menu/CBackground.cs @@ -6,9 +6,6 @@ using System.Text; using System.Xml; using System.Xml.XPath; -using Vocaluxe.Base; -using Vocaluxe.Lib.Draw; - namespace Vocaluxe.Menu { public enum EBackgroundTypes @@ -69,7 +66,7 @@ namespace Vocaluxe.Menu if (CHelper.GetValueFromXML(item + "/Color", navigator, ref _Theme.ColorName, String.Empty)) { - _ThemeLoaded &= CTheme.GetColor(_Theme.ColorName, SkinIndex, ref Color); + _ThemeLoaded &= _Base.Theme.GetColor(_Theme.ColorName, SkinIndex, ref Color); } else { @@ -97,7 +94,7 @@ namespace Vocaluxe.Menu { writer.WriteStartElement(_Theme.Name); - writer.WriteComment(": Background type: " + CConfig.ListStrings(Enum.GetNames(typeof(EBackgroundTypes)))); + writer.WriteComment(": Background type: " + CHelper.ListStrings(Enum.GetNames(typeof(EBackgroundTypes)))); writer.WriteElementString("Type", Enum.GetName(typeof(EBackgroundTypes), _Theme.Type)); writer.WriteComment("