From 2dfbecdb20415730696a94514e93aa5cf522a584 Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Mon, 17 Dec 2012 20:35:28 +0100 Subject: [PATCH] added drawing team names, fixed joker handling --- .../Challenge/Code/PartyModeChallenge.cs | 63 ++++++++++++++++++- PartyModeChallenge/PartyModeChallenge.cs | 63 ++++++++++++++++++- Vocaluxe/Base/CGraphics.cs | 1 + Vocaluxe/Base/CParty.cs | 5 ++ Vocaluxe/Screens/CScreenSong.cs | 31 ++++++++- VocaluxeLib/PartyModes/CPartyMode.cs | 4 ++ VocaluxeLib/PartyModes/CPartyModeNone.cs | 1 + VocaluxeLib/PartyModes/IPartyMode.cs | 7 +++ 8 files changed, 168 insertions(+), 7 deletions(-) diff --git a/Output/PartyModes/Challenge/Code/PartyModeChallenge.cs b/Output/PartyModes/Challenge/Code/PartyModeChallenge.cs index fd270716..232411a3 100644 --- a/Output/PartyModes/Challenge/Code/PartyModeChallenge.cs +++ b/Output/PartyModes/Challenge/Code/PartyModeChallenge.cs @@ -97,10 +97,11 @@ namespace Vocaluxe.PartyModes _ScreenSongOptions.Selection.PartyMode = true; _ScreenSongOptions.Selection.CategoryChangeAllowed = true; _ScreenSongOptions.Selection.NumJokers = new int[] { 5, 5 }; + _ScreenSongOptions.Selection.TeamNames = new string[] { "foo", "bar" }; _ScreenSongOptions.Sorting.SearchString = String.Empty; _ScreenSongOptions.Sorting.SearchStringVisible = false; - + _Stage = EStage.NotStarted; ToScreenConfig = new DataToScreenConfig(); @@ -118,6 +119,11 @@ namespace Vocaluxe.PartyModes public override bool Init() { _Stage = EStage.NotStarted; + + _ScreenSongOptions.Sorting.IgnoreArticles = _Base.Config.GetIgnoreArticles(); + _ScreenSongOptions.Sorting.SongSorting = ESongSorting.TR_CONFIG_FOLDER; + _ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_ON; + return true; } @@ -187,6 +193,14 @@ namespace Vocaluxe.PartyModes } } + public override void UpdateGame() + { + if (_Base.Songs.GetCurrentCategoryIndex() != -1) + _ScreenSongOptions.Selection.RandomOnly = true; + else + _ScreenSongOptions.Selection.RandomOnly = false; + } + public override CMenuParty GetNextPartyScreen(out EScreens AlternativeScreen) { CMenuParty Screen = null; @@ -283,9 +297,27 @@ namespace Vocaluxe.PartyModes return MaxNumRounds; } + public override void JokerUsed(int TeamNr) + { + if (_ScreenSongOptions.Selection.NumJokers == null) + return; + + if (TeamNr >= _ScreenSongOptions.Selection.NumJokers.Length) + return; + + _ScreenSongOptions.Selection.NumJokers[TeamNr]--; + _ScreenSongOptions.Selection.RandomOnly = true; + _ScreenSongOptions.Selection.CategoryChangeAllowed = false; + + + } + private void StartNextRound() { - + _ScreenSongOptions.Selection.RandomOnly = false; + _ScreenSongOptions.Selection.CategoryChangeAllowed = true; + SetNumJokers(); + SetTeamNames(); _Base.Graphics.FadeTo(EScreens.ScreenSong); } @@ -321,5 +353,32 @@ namespace Vocaluxe.PartyModes break; } } + + private void SetTeamNames() + { + SProfile[] profiles = _Base.Profiles.GetProfiles(); + + if (profiles == null) + { + _ScreenSongOptions.Selection.TeamNames = new string[] { "foo", "bar" }; + return; + } + + if (GameData.NumPlayerAtOnce < 1 || GameData.NumPlayerAtOnce > 6 || GameData.ProfileIDs.Count < GameData.NumPlayerAtOnce || profiles.Length < GameData.NumPlayerAtOnce) + { + _ScreenSongOptions.Selection.TeamNames = new string[] { "foo", "bar" }; + return; + } + + _ScreenSongOptions.Selection.TeamNames = new string[GameData.NumPlayerAtOnce]; + + for (int i = 0; i < GameData.NumPlayerAtOnce; i++) + { + if (GameData.ProfileIDs[i] < profiles.Length) + _ScreenSongOptions.Selection.TeamNames[i] = profiles[GameData.ProfileIDs[i]].PlayerName; + else + _ScreenSongOptions.Selection.TeamNames[i] = "foobar"; + } + } } } \ No newline at end of file diff --git a/PartyModeChallenge/PartyModeChallenge.cs b/PartyModeChallenge/PartyModeChallenge.cs index fd270716..232411a3 100644 --- a/PartyModeChallenge/PartyModeChallenge.cs +++ b/PartyModeChallenge/PartyModeChallenge.cs @@ -97,10 +97,11 @@ namespace Vocaluxe.PartyModes _ScreenSongOptions.Selection.PartyMode = true; _ScreenSongOptions.Selection.CategoryChangeAllowed = true; _ScreenSongOptions.Selection.NumJokers = new int[] { 5, 5 }; + _ScreenSongOptions.Selection.TeamNames = new string[] { "foo", "bar" }; _ScreenSongOptions.Sorting.SearchString = String.Empty; _ScreenSongOptions.Sorting.SearchStringVisible = false; - + _Stage = EStage.NotStarted; ToScreenConfig = new DataToScreenConfig(); @@ -118,6 +119,11 @@ namespace Vocaluxe.PartyModes public override bool Init() { _Stage = EStage.NotStarted; + + _ScreenSongOptions.Sorting.IgnoreArticles = _Base.Config.GetIgnoreArticles(); + _ScreenSongOptions.Sorting.SongSorting = ESongSorting.TR_CONFIG_FOLDER; + _ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_ON; + return true; } @@ -187,6 +193,14 @@ namespace Vocaluxe.PartyModes } } + public override void UpdateGame() + { + if (_Base.Songs.GetCurrentCategoryIndex() != -1) + _ScreenSongOptions.Selection.RandomOnly = true; + else + _ScreenSongOptions.Selection.RandomOnly = false; + } + public override CMenuParty GetNextPartyScreen(out EScreens AlternativeScreen) { CMenuParty Screen = null; @@ -283,9 +297,27 @@ namespace Vocaluxe.PartyModes return MaxNumRounds; } + public override void JokerUsed(int TeamNr) + { + if (_ScreenSongOptions.Selection.NumJokers == null) + return; + + if (TeamNr >= _ScreenSongOptions.Selection.NumJokers.Length) + return; + + _ScreenSongOptions.Selection.NumJokers[TeamNr]--; + _ScreenSongOptions.Selection.RandomOnly = true; + _ScreenSongOptions.Selection.CategoryChangeAllowed = false; + + + } + private void StartNextRound() { - + _ScreenSongOptions.Selection.RandomOnly = false; + _ScreenSongOptions.Selection.CategoryChangeAllowed = true; + SetNumJokers(); + SetTeamNames(); _Base.Graphics.FadeTo(EScreens.ScreenSong); } @@ -321,5 +353,32 @@ namespace Vocaluxe.PartyModes break; } } + + private void SetTeamNames() + { + SProfile[] profiles = _Base.Profiles.GetProfiles(); + + if (profiles == null) + { + _ScreenSongOptions.Selection.TeamNames = new string[] { "foo", "bar" }; + return; + } + + if (GameData.NumPlayerAtOnce < 1 || GameData.NumPlayerAtOnce > 6 || GameData.ProfileIDs.Count < GameData.NumPlayerAtOnce || profiles.Length < GameData.NumPlayerAtOnce) + { + _ScreenSongOptions.Selection.TeamNames = new string[] { "foo", "bar" }; + return; + } + + _ScreenSongOptions.Selection.TeamNames = new string[GameData.NumPlayerAtOnce]; + + for (int i = 0; i < GameData.NumPlayerAtOnce; i++) + { + if (GameData.ProfileIDs[i] < profiles.Length) + _ScreenSongOptions.Selection.TeamNames[i] = profiles[GameData.ProfileIDs[i]].PlayerName; + else + _ScreenSongOptions.Selection.TeamNames[i] = "foobar"; + } + } } } \ No newline at end of file diff --git a/Vocaluxe/Base/CGraphics.cs b/Vocaluxe/Base/CGraphics.cs index 68f6633d..68048f00 100644 --- a/Vocaluxe/Base/CGraphics.cs +++ b/Vocaluxe/Base/CGraphics.cs @@ -336,6 +336,7 @@ namespace Vocaluxe.Base { _Run &= HandleInputs(Keys, Mouse); _Run &= Update(); + CParty.UpdateGame(); } else { diff --git a/Vocaluxe/Base/CParty.cs b/Vocaluxe/Base/CParty.cs index 35753bbc..9d14f34f 100644 --- a/Vocaluxe/Base/CParty.cs +++ b/Vocaluxe/Base/CParty.cs @@ -142,6 +142,11 @@ namespace Vocaluxe.Base #endregion public stuff #region Interface + public static void UpdateGame() + { + _CurrentPartyMode.PartyMode.UpdateGame(); + } + public static EScreens GetStartScreen() { return _CurrentPartyMode.PartyMode.GetStartScreen(); diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 97470b97..559a2cf6 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -647,6 +647,17 @@ namespace Vocaluxe.Screens public override bool UpdateGame() { + _sso = CParty.GetSongSelectionOptions(); + CSongs.Sort(_sso.Sorting.SongSorting, _sso.Sorting.Tabs, _sso.Sorting.IgnoreArticles, _sso.Sorting.SearchString); + _SearchActive = _sso.Sorting.SearchStringVisible; + _SearchText = _sso.Sorting.SearchString; + + if (_sso.Selection.PartyMode) + _PlaylistActive = false; + + if (_sso.Selection.PartyMode) + ToggleSongOptions(ESongOptionsView.None); + SongMenus[htSongMenus(SongMenu)].Update(); if (SongMenus[htSongMenus(SongMenu)].IsSmallView()) @@ -698,8 +709,19 @@ namespace Vocaluxe.Screens Buttons[htButtons(ButtonsJoker[i])].Visible = true; Buttons[htButtons(ButtonsJoker[i])].Text.Text = _sso.Selection.NumJokers[i].ToString(); Texts[htTexts(TextsPlayer[i])].Visible = true; - //TODO: Set text to player-name. - Texts[htTexts(TextsPlayer[i])].Text = i.ToString(); + + bool NameExists = false; + if (_sso.Selection.TeamNames != null) + { + if (_sso.Selection.TeamNames.Length > i) + { + Texts[htTexts(TextsPlayer[i])].Text = _sso.Selection.TeamNames[i]; + NameExists = true; + } + } + + if (!NameExists) + Texts[htTexts(TextsPlayer[i])].Text = i.ToString(); } else { @@ -887,7 +909,10 @@ namespace Vocaluxe.Screens return result; } - return SelectNextRandomSong(TeamNr) || SelectNextRandomCategory(); + if (TeamNr == -1) + return SelectNextRandomSong(TeamNr) || SelectNextRandomCategory(); + + return false; } private bool SelectNextRandomSong(int TeamNr) diff --git a/VocaluxeLib/PartyModes/CPartyMode.cs b/VocaluxeLib/PartyModes/CPartyMode.cs index e9cc5659..80797cfe 100644 --- a/VocaluxeLib/PartyModes/CPartyMode.cs +++ b/VocaluxeLib/PartyModes/CPartyMode.cs @@ -42,6 +42,10 @@ namespace Vocaluxe.PartyModes { } + public virtual void UpdateGame() + { + } + public virtual CMenuParty GetNextPartyScreen(out EScreens AlternativeScreen) { AlternativeScreen = EScreens.ScreenMain; diff --git a/VocaluxeLib/PartyModes/CPartyModeNone.cs b/VocaluxeLib/PartyModes/CPartyModeNone.cs index 37c1c2a1..3a9ca0dc 100644 --- a/VocaluxeLib/PartyModes/CPartyModeNone.cs +++ b/VocaluxeLib/PartyModes/CPartyModeNone.cs @@ -15,6 +15,7 @@ namespace Vocaluxe.PartyModes _ScreenSongOptions.Selection.PartyMode = false; _ScreenSongOptions.Selection.CategoryChangeAllowed = true; _ScreenSongOptions.Selection.NumJokers = null; + _ScreenSongOptions.Selection.TeamNames = null; _ScreenSongOptions.Sorting.SearchString = String.Empty; _ScreenSongOptions.Sorting.SearchStringVisible = false; diff --git a/VocaluxeLib/PartyModes/IPartyMode.cs b/VocaluxeLib/PartyModes/IPartyMode.cs index dd42ec41..7dc4719d 100644 --- a/VocaluxeLib/PartyModes/IPartyMode.cs +++ b/VocaluxeLib/PartyModes/IPartyMode.cs @@ -46,6 +46,11 @@ namespace Vocaluxe.PartyModes /// The number of jokers left for each team /// public int[] NumJokers; + + /// + /// The Team Name of the teams (:>) + /// + public string[] TeamNames; } #endregion Structs @@ -56,6 +61,8 @@ namespace Vocaluxe.PartyModes void AddScreen(CMenuParty Screen, string ScreenName); void DataFromScreen(string ScreenName, Object Data); + void UpdateGame(); + CMenuParty GetNextPartyScreen(out EScreens AlternativeScreen); EScreens GetStartScreen(); EScreens GetMainScreen();