From 2fabc379d1ab7a061f51f53243bf45155c0bffe5 Mon Sep 17 00:00:00 2001 From: Florian Kuepper Date: Mon, 24 Dec 2012 01:13:49 +0100 Subject: [PATCH 1/5] Fixed scrolling. Added rounds-table-scrolling. --- .../Screens/PartyScreenChallengeMain.xml | 98 +++++++++ .../PartyScreenChallengeMain.cs | 194 +++++++++++++----- 2 files changed, 235 insertions(+), 57 deletions(-) diff --git a/Output/PartyModes/Challenge/Screens/PartyScreenChallengeMain.xml b/Output/PartyModes/Challenge/Screens/PartyScreenChallengeMain.xml index 350446da..cbc7ee69 100644 --- a/Output/PartyModes/Challenge/Screens/PartyScreenChallengeMain.xml +++ b/Output/PartyModes/Challenge/Screens/PartyScreenChallengeMain.xml @@ -824,5 +824,103 @@ + + + ScrollUp + + ScrollUp + + 954 + 94 + -0,01 + 28 + 15 + + + ButtonColor + + + ButtonSColor + + + 75 + 10 + + 32 + + 142 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + + + + + + + + + + + + ScrollDown + + ScrollDown + + 954 + 515 + -0,01 + 28 + 15 + + + ButtonColor + + + ButtonSColor + + + 75 + 10 + + 32 + + 142 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + + + + + + + + + diff --git a/PartyModeChallenge/PartyScreenChallengeMain.cs b/PartyModeChallenge/PartyScreenChallengeMain.cs index ac068d31..b88d06b5 100644 --- a/PartyModeChallenge/PartyScreenChallengeMain.cs +++ b/PartyModeChallenge/PartyScreenChallengeMain.cs @@ -49,7 +49,8 @@ namespace Vocaluxe.PartyModes const string ButtonPopupNo = "ButtonPopupNo"; const string ButtonPlayerScrollUp = "ButtonPlayerScrollUp"; const string ButtonPlayerScrollDown = "ButtonPlayerScrollDown"; - + const string ButtonRoundsScrollUp = "ButtonRoundsScrollUp"; + const string ButtonRoundsScrollDown = "ButtonRoundsScrollDown"; const string StaticPopupBG = "StaticPopupBG"; const string StaticNextPlayer = "StaticNextPlayer"; @@ -68,6 +69,8 @@ namespace Vocaluxe.PartyModes private SRectF PlayerTableScrollArea; private int RoundsTableOffset = 0; private int PlayerTableOffset = 0; + private int NumPlayerVisible = 10; + private int NumRoundsVisible = 3; public PartyScreenChallengeMain() { @@ -81,7 +84,7 @@ namespace Vocaluxe.PartyModes _ThemeName = "PartyScreenChallengeMain"; _ThemeTexts = new string[] { TextPosition, TextPlayerName, TextNumPlayed, TextWon, TextSingPoints, TextGamePoints, TextNextPlayer, TextPopupReallyExit, TextRoundNumber, TextRoundPlayer, TextRoundScore }; - _ThemeButtons = new string[] { ButtonNextRound, ButtonBack, ButtonExit, ButtonPopupYes, ButtonPopupNo, ButtonPlayerScrollDown, ButtonPlayerScrollUp }; + _ThemeButtons = new string[] { ButtonNextRound, ButtonBack, ButtonExit, ButtonPopupYes, ButtonPopupNo, ButtonPlayerScrollDown, ButtonPlayerScrollUp, ButtonRoundsScrollDown, ButtonRoundsScrollUp }; _ThemeStatics = new string[] { StaticPopupBG, StaticNextPlayer }; _ScreenVersion = ScreenVersion; } @@ -92,7 +95,7 @@ namespace Vocaluxe.PartyModes GameState = new DataToScreenMain(); BuildPlayerTable(); - + CreateRoundsTable(); NextPlayerTexts = new List(); NextPlayerStatics = new List(); @@ -153,6 +156,14 @@ namespace Vocaluxe.PartyModes Back(); if (Buttons[htButtons(ButtonExit)].Selected && GameState.CurrentRoundNr > 1) ShowPopup(true); + if (Buttons[htButtons(ButtonPlayerScrollUp)].Selected) + ScrollPlayerTable(-1); + if (Buttons[htButtons(ButtonPlayerScrollDown)].Selected) + ScrollPlayerTable(1); + if (Buttons[htButtons(ButtonRoundsScrollUp)].Selected) + ScrollRoundsTable(-1); + if (Buttons[htButtons(ButtonRoundsScrollDown)].Selected) + ScrollRoundsTable(1); } else { @@ -181,6 +192,14 @@ namespace Vocaluxe.PartyModes Back(); if (Buttons[htButtons(ButtonExit)].Selected && GameState.CurrentRoundNr > 1) ShowPopup(true); + if (Buttons[htButtons(ButtonPlayerScrollUp)].Selected) + ScrollPlayerTable(-1); + if (Buttons[htButtons(ButtonPlayerScrollDown)].Selected) + ScrollPlayerTable(1); + if (Buttons[htButtons(ButtonRoundsScrollUp)].Selected) + ScrollRoundsTable(-1); + if (Buttons[htButtons(ButtonRoundsScrollDown)].Selected) + ScrollRoundsTable(1); } else { @@ -209,12 +228,15 @@ namespace Vocaluxe.PartyModes { base.OnShow(); - UpdatePlayerTable(PlayerTableOffset); + PlayerTableOffset = 0; + RoundsTableOffset = 0; + + UpdatePlayerTable(); UpdateNextPlayerPositions(); UpdateNextPlayerContents(); - if(GameState.CurrentRoundNr == 1 || RoundsTable == null) - BuildRoundsTable(); - UpdateRoundsTable(RoundsTableOffset); + if (GameState.CurrentRoundNr == 1) + BuildRoundsTable(); + UpdateRoundsTable(); if (GameState.CurrentRoundNr == 1) { @@ -328,23 +350,11 @@ namespace Vocaluxe.PartyModes } } - private void BuildRoundsTable() + private void CreateRoundsTable() { - int NumRoundsVisible = 3; - int NumPlayerInOneRow = 3; - if (GameState.NumPlayerAtOnce <= NumPlayerInOneRow) - NumRoundsVisible = 5; - if (NumRoundsVisible > GameState.Combs.Count) - NumRoundsVisible = GameState.Combs.Count; - - float x = Texts[htTexts(TextRoundNumber)].X; - float y = Texts[htTexts(TextRoundNumber)].Y; - - float delta = Texts[htTexts(TextRoundNumber)].Height; - //Create lists RoundsTable = new List(); - for (int i = 0; i < NumRoundsVisible; i++) + for (int i = 0; i < 5; i++) { RoundsTableRow rtr = new RoundsTableRow(); rtr.TextPlayer = new List(); @@ -356,12 +366,45 @@ namespace Vocaluxe.PartyModes { //Round-number CText text = GetNewText(Texts[htTexts(TextRoundNumber)]); - text.X = x; - text.Y = y; - text.Text = (round + 1) + ")"; AddText(text); RoundsTable[round].Number = text; - int NumInnerRows = (int) Math.Ceiling(GameState.NumPlayerAtOnce / ((double)NumPlayerInOneRow)); + for (int row = 0; row < 2; row++) + { + for (int column = 0; column < 3; column++) + { + //Player + text = GetNewText(Texts[htTexts(TextRoundPlayer)]); + AddText(text); + RoundsTable[round].TextPlayer.Add(text); + //Score + text = GetNewText(Texts[htTexts(TextRoundScore)]); + AddText(text); + RoundsTable[round].TextScores.Add(text); + } + } + } + } + + private void BuildRoundsTable() + { + int NumPlayerInOneRow = 3; + if (GameState.NumPlayerAtOnce <= NumPlayerInOneRow) + NumRoundsVisible = 5; + if (NumRoundsVisible > GameState.Combs.Count) + NumRoundsVisible = GameState.Combs.Count; + + float x = Texts[htTexts(TextRoundNumber)].X; + float y = Texts[htTexts(TextRoundNumber)].Y; + + float delta = Texts[htTexts(TextRoundNumber)].Height; + + //Update statics and texts for rounds + for (int round = 0; round < RoundsTable.Count; round++) + { + //Round-number + RoundsTable[round].Number.X = x; + RoundsTable[round].Number.Y = y; + int NumInnerRows = (int)Math.Ceiling(GameState.NumPlayerAtOnce / ((double)NumPlayerInOneRow)); for (int row = 0; row < NumInnerRows; row++) { int num = (row + 1) * NumPlayerInOneRow; @@ -371,58 +414,66 @@ namespace Vocaluxe.PartyModes num = GameState.NumPlayerAtOnce; NumPlayerInThisRow = GameState.NumPlayerAtOnce - (row * NumPlayerInOneRow); } - for (int column = row * NumPlayerInOneRow; column < num; column++) { //Player float _x = x + 15 + (_Base.Settings.GetRenderW() - Texts[htTexts(TextRoundNumber)].X - 20) / NumPlayerInThisRow * (column - row * NumPlayerInOneRow) + ((_Base.Settings.GetRenderW() - Texts[htTexts(TextRoundNumber)].X - 20) / NumPlayerInThisRow) / 2; - float maxw = ((_Base.Settings.GetRenderW() - Texts[htTexts(TextRoundNumber)].X - 20) / NumPlayerInThisRow)/2 - 5; - text = GetNewText(Texts[htTexts(TextRoundNumber)]); - text.X = _x; - text.Y = y; - text.MaxWidth = maxw; - AddText(text); - RoundsTable[round].TextPlayer.Add(text); + float maxw = ((_Base.Settings.GetRenderW() - Texts[htTexts(TextRoundNumber)].X - 20) / NumPlayerInThisRow) / 2 - 5; + RoundsTable[round].TextPlayer[column].X = _x; + RoundsTable[round].TextPlayer[column].Y = y; + RoundsTable[round].TextPlayer[column].MaxWidth = maxw; //Score - text = GetNewText(Texts[htTexts(TextRoundNumber)]); - text.X = _x; - text.Y = y + delta; - text.MaxWidth = maxw; - AddText(text); - RoundsTable[round].TextScores.Add(text); + RoundsTable[round].TextScores[column] = RoundsTable[round].TextScores[column]; + RoundsTable[round].TextScores[column].X = _x; + RoundsTable[round].TextScores[column].Y = y + delta; + RoundsTable[round].TextScores[column].MaxWidth = maxw; } y = y + delta + delta; } - y = y + delta/2; + y = y + delta / 2; } } - private void UpdateRoundsTable(int Offset) + private void UpdateRoundsTable() { SProfile[] profile = _Base.Profiles.GetProfiles(); for (int i = 0; i < RoundsTable.Count; i++) { for(int p = 0; p < RoundsTable[i].TextPlayer.Count; p++) { - RoundsTable[i].Number.Text = (i + 1 + Offset).ToString(); - int pID = GameState.ProfileIDs[GameState.Combs[i + Offset].Player[p]]; - RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName+""; - if ((GameState.CurrentRoundNr - 1) > i) - RoundsTable[i].TextScores[p].Text = GameState.Results[i + Offset, p].ToString(); + if (GameState.Combs[i + RoundsTableOffset].Player.Count > p) + { + RoundsTable[i].Number.Visible = true; + RoundsTable[i].TextPlayer[p].Visible = true; + RoundsTable[i].TextScores[p].Visible = true; + RoundsTable[i].Number.Text = (i + 1 + RoundsTableOffset).ToString() + ")"; + int pID = GameState.ProfileIDs[GameState.Combs[i + RoundsTableOffset].Player[p]]; + RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName; + if ((GameState.CurrentRoundNr - 1) > i) + RoundsTable[i].TextScores[p].Text = GameState.Results[i + RoundsTableOffset, p].ToString(); + else + RoundsTable[i].TextScores[p].Text = ""; + } else - RoundsTable[i].TextScores[p].Text = ""; + { + RoundsTable[i].TextPlayer[p].Visible = false; + RoundsTable[i].TextScores[p].Visible = false; + } + } + if (GameState.Combs.Count < i + RoundsTableOffset) + { + RoundsTable[i].Number.Visible = false; } } } private void BuildPlayerTable() { - int NumPlayerVisible = 10; PlayerTable = new List(); float delta = Texts[htTexts(TextPosition)].Height * 1.2f; - for (int i = 0; i < NumPlayerVisible; i++) + for (int i = 0; i < 10; i++) { TableRow row = new TableRow(); @@ -460,15 +511,15 @@ namespace Vocaluxe.PartyModes } } - private void UpdatePlayerTable(int Offset) + private void UpdatePlayerTable() { SProfile[] profiles = _Base.Profiles.GetProfiles(); for (int i = 0; i < PlayerTable.Count; i++) { - TableRow row = PlayerTable[i+Offset]; + TableRow row = PlayerTable[i]; - if (i+Offset < GameState.ResultTable.Count) + if (i+PlayerTableOffset < GameState.ResultTable.Count) { row.Pos.Visible = true; row.Name.Visible = true; @@ -477,11 +528,12 @@ namespace Vocaluxe.PartyModes row.SingPoints.Visible = true; row.GamePoints.Visible = true; - row.Name.Text = profiles[GameState.ResultTable[i+Offset].PlayerID].PlayerName; - row.Rounds.Text = GameState.ResultTable[i+Offset].NumRounds.ToString(); - row.Won.Text = GameState.ResultTable[i+Offset].NumWon.ToString(); - row.SingPoints.Text = GameState.ResultTable[i+Offset].SumSingPoints.ToString(); - row.GamePoints.Text = GameState.ResultTable[i+Offset].NumGamePoints.ToString(); + row.Pos.Text = (i + 1 + PlayerTableOffset).ToString(); + row.Name.Text = profiles[GameState.ResultTable[i+PlayerTableOffset].PlayerID].PlayerName; + row.Rounds.Text = GameState.ResultTable[i+PlayerTableOffset].NumRounds.ToString(); + row.Won.Text = GameState.ResultTable[i+PlayerTableOffset].NumWon.ToString(); + row.SingPoints.Text = GameState.ResultTable[i+PlayerTableOffset].SumSingPoints.ToString(); + row.GamePoints.Text = GameState.ResultTable[i+PlayerTableOffset].NumGamePoints.ToString(); } else { @@ -494,5 +546,33 @@ namespace Vocaluxe.PartyModes } } } + + private void ScrollPlayerTable(int Offset) + { + if (Offset < 0 && PlayerTableOffset + Offset >= 0) + PlayerTableOffset += Offset; + else if (Offset < 0 && PlayerTableOffset + Offset < 0) + PlayerTableOffset = 0; + else if (Offset > 0 && PlayerTableOffset + Offset <= GameState.ProfileIDs.Count - NumPlayerVisible) + PlayerTableOffset += Offset; + else if (Offset > 0 && PlayerTableOffset + Offset > GameState.ProfileIDs.Count - NumPlayerVisible) + PlayerTableOffset = GameState.ProfileIDs.Count - NumPlayerVisible; + + UpdatePlayerTable(); + } + + private void ScrollRoundsTable(int Offset) + { + if (Offset < 0 && RoundsTableOffset + Offset >= 0) + RoundsTableOffset += Offset; + else if (Offset < 0 && RoundsTableOffset + Offset < 0) + RoundsTableOffset = 0; + else if (Offset > 0 && RoundsTableOffset + Offset <= GameState.Combs.Count - NumRoundsVisible) + RoundsTableOffset += Offset; + else if (Offset > 0 && RoundsTableOffset + Offset > GameState.Combs.Count - NumRoundsVisible) + RoundsTableOffset = GameState.Combs.Count - NumRoundsVisible; + + UpdateRoundsTable(); + } } } From 11f626187de1a52fd1695283ac1b37c625ba075f Mon Sep 17 00:00:00 2001 From: Florian Kuepper Date: Mon, 24 Dec 2012 01:37:34 +0100 Subject: [PATCH 2/5] Added possibility to scroll with mouse through rounds and players. --- .../PartyScreenChallengeMain.cs | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/PartyModeChallenge/PartyScreenChallengeMain.cs b/PartyModeChallenge/PartyScreenChallengeMain.cs index b88d06b5..21d270ac 100644 --- a/PartyModeChallenge/PartyScreenChallengeMain.cs +++ b/PartyModeChallenge/PartyScreenChallengeMain.cs @@ -221,6 +221,14 @@ namespace Vocaluxe.PartyModes ShowPopup(false); } + if (MouseEvent.Wheel != 0) + { + if(CHelper.IsInBounds(RoundsTableScrollArea, MouseEvent)) + ScrollRoundsTable(MouseEvent.Wheel); + if(CHelper.IsInBounds(PlayerTableScrollArea, MouseEvent)) + ScrollPlayerTable(MouseEvent.Wheel); + } + return true; } @@ -387,6 +395,8 @@ namespace Vocaluxe.PartyModes private void BuildRoundsTable() { + RoundsTableScrollArea = new SRectF(); + int NumPlayerInOneRow = 3; if (GameState.NumPlayerAtOnce <= NumPlayerInOneRow) NumRoundsVisible = 5; @@ -396,6 +406,10 @@ namespace Vocaluxe.PartyModes float x = Texts[htTexts(TextRoundNumber)].X; float y = Texts[htTexts(TextRoundNumber)].Y; + RoundsTableScrollArea.X = x; + RoundsTableScrollArea.Y = y; + RoundsTableScrollArea.W = _Base.Settings.GetRenderW() - Texts[htTexts(TextRoundNumber)].X - 20; + float delta = Texts[htTexts(TextRoundNumber)].Height; //Update statics and texts for rounds @@ -432,6 +446,7 @@ namespace Vocaluxe.PartyModes } y = y + delta / 2; } + RoundsTableScrollArea.H = y - RoundsTableScrollArea.Y; } private void UpdateRoundsTable() @@ -441,7 +456,7 @@ namespace Vocaluxe.PartyModes { for(int p = 0; p < RoundsTable[i].TextPlayer.Count; p++) { - if (GameState.Combs[i + RoundsTableOffset].Player.Count > p) + if (GameState.Combs.Count > i + RoundsTableOffset && GameState.Combs[i + RoundsTableOffset].Player.Count > p) { RoundsTable[i].Number.Visible = true; RoundsTable[i].TextPlayer[p].Visible = true; @@ -469,10 +484,16 @@ namespace Vocaluxe.PartyModes private void BuildPlayerTable() { + PlayerTableScrollArea = new SRectF(); + PlayerTableScrollArea.X = Texts[htTexts(TextPosition)].X; + PlayerTableScrollArea.Y = Texts[htTexts(TextPosition)].Y; + PlayerTableScrollArea.W = Texts[htTexts(TextGamePoints)].X - Texts[htTexts(TextPosition)].X; PlayerTable = new List(); float delta = Texts[htTexts(TextPosition)].Height * 1.2f; + float h = 0; + for (int i = 0; i < 10; i++) { TableRow row = new TableRow(); @@ -508,7 +529,10 @@ namespace Vocaluxe.PartyModes AddText(row.GamePoints); PlayerTable.Add(row); + + h = delta * (i + 1); } + PlayerTableScrollArea.H = h + delta; } private void UpdatePlayerTable() From 259876405c03dcbbe6a7a5b2d7851a1447139b1b Mon Sep 17 00:00:00 2001 From: Florian Kuepper Date: Mon, 24 Dec 2012 01:44:40 +0100 Subject: [PATCH 3/5] Don't show scroll-buttons if there is nothing to scroll. --- PartyModeChallenge/PartyScreenChallengeMain.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/PartyModeChallenge/PartyScreenChallengeMain.cs b/PartyModeChallenge/PartyScreenChallengeMain.cs index 21d270ac..e701186e 100644 --- a/PartyModeChallenge/PartyScreenChallengeMain.cs +++ b/PartyModeChallenge/PartyScreenChallengeMain.cs @@ -480,6 +480,9 @@ namespace Vocaluxe.PartyModes RoundsTable[i].Number.Visible = false; } } + + Buttons[htButtons(ButtonRoundsScrollUp)].Visible = RoundsTableOffset > 0; + Buttons[htButtons(ButtonRoundsScrollDown)].Visible = GameState.Combs.Count - NumRoundsVisible - RoundsTableOffset > 0; } private void BuildPlayerTable() @@ -569,6 +572,9 @@ namespace Vocaluxe.PartyModes row.GamePoints.Visible = false; } } + + Buttons[htButtons(ButtonPlayerScrollUp)].Visible = PlayerTableOffset > 0; + Buttons[htButtons(ButtonPlayerScrollDown)].Visible = GameState.ProfileIDs.Count - NumPlayerVisible - PlayerTableOffset > 0; } private void ScrollPlayerTable(int Offset) From 643e68ee1a2b3735ad2d5ab3d62a50ccc518856f Mon Sep 17 00:00:00 2001 From: Florian Kuepper Date: Mon, 24 Dec 2012 01:54:14 +0100 Subject: [PATCH 4/5] Scroll automatically to even played round. --- PartyModeChallenge/PartyScreenChallengeMain.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PartyModeChallenge/PartyScreenChallengeMain.cs b/PartyModeChallenge/PartyScreenChallengeMain.cs index e701186e..1a1ccb00 100644 --- a/PartyModeChallenge/PartyScreenChallengeMain.cs +++ b/PartyModeChallenge/PartyScreenChallengeMain.cs @@ -244,6 +244,8 @@ namespace Vocaluxe.PartyModes UpdateNextPlayerContents(); if (GameState.CurrentRoundNr == 1) BuildRoundsTable(); + else + ScrollRoundsTable(GameState.CurrentRoundNr - 2); UpdateRoundsTable(); if (GameState.CurrentRoundNr == 1) @@ -464,7 +466,7 @@ namespace Vocaluxe.PartyModes RoundsTable[i].Number.Text = (i + 1 + RoundsTableOffset).ToString() + ")"; int pID = GameState.ProfileIDs[GameState.Combs[i + RoundsTableOffset].Player[p]]; RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName; - if ((GameState.CurrentRoundNr - 1) > i) + if ((GameState.CurrentRoundNr - 1) > i + RoundsTableOffset) RoundsTable[i].TextScores[p].Text = GameState.Results[i + RoundsTableOffset, p].ToString(); else RoundsTable[i].TextScores[p].Text = ""; From c53dea851ac2dd5f4bc4901694631e2f10f44c69 Mon Sep 17 00:00:00 2001 From: Florian Kuepper Date: Mon, 24 Dec 2012 01:56:55 +0100 Subject: [PATCH 5/5] Set interaction to next-button when all player are selected. --- PartyModeChallenge/PartyScreenChallengeNames.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PartyModeChallenge/PartyScreenChallengeNames.cs b/PartyModeChallenge/PartyScreenChallengeNames.cs index 4532e91a..f1a47548 100644 --- a/PartyModeChallenge/PartyScreenChallengeNames.cs +++ b/PartyModeChallenge/PartyScreenChallengeNames.cs @@ -461,7 +461,10 @@ namespace Vocaluxe.PartyModes private void UpdateButtonNext() { if (Data.ScreenNames.ProfileIDs.Count == NumPlayer) + { Buttons[htButtons(ButtonNext)].Visible = true; + SetInteractionToButton(Buttons[htButtons(ButtonNext)]); + } else Buttons[htButtons(ButtonNext)].Visible = false; }