diff --git a/Output/PartyModes/ChallengeMedley.xml b/Output/PartyModes/ChallengeMedley.xml new file mode 100644 index 00000000..618d3000 --- /dev/null +++ b/Output/PartyModes/ChallengeMedley.xml @@ -0,0 +1,19 @@ + + + 1 + + TR_PARTYMODE_NAME + brunzel + TR_PARTYMODE_DESCRIPTION + ChallengeMedley + PartyModeChallenge + 0 + 1 + TR_PARTYMODE_AUDIENCE + + + PartyScreenChallengeMain + PartyScreenChallengeConfig + PartyScreenChallengeNames + + \ No newline at end of file diff --git a/Output/PartyModes/ChallengeMedley/Languages/Deutsch.xml b/Output/PartyModes/ChallengeMedley/Languages/Deutsch.xml new file mode 100644 index 00000000..2bc0d931 --- /dev/null +++ b/Output/PartyModes/ChallengeMedley/Languages/Deutsch.xml @@ -0,0 +1,37 @@ + + + + Deutsch + + + + Challenge Medley Modus + Spiele einen Wettkampfmodus nur mit 5er Medleys + Für alle, die Spaß am Wettkampf und vielen Medleyrunden haben. + Weiter + Zurück + Start + Exit + Ja + Nein + Nächste Runde + + Challenge Medley Modus: Einstellungen + Anzahl der Spieler + Anzahl der Mikrofone + Anzahl der Runden + + Challenge Medley Modus: Spielerwahl + + Challenge Medley Modus: Übersicht + Pos + Name + Runden + Siege + Sing-Punkte + Punkte + Challenge Medley Modus wirklich beenden? + Spieler der nächsten Runde: + Alle Runden wurden gesungen! Und der Gewinner ist... + + diff --git a/Output/PartyModes/ChallengeMedley/Languages/English.xml b/Output/PartyModes/ChallengeMedley/Languages/English.xml new file mode 100644 index 00000000..72bc5586 --- /dev/null +++ b/Output/PartyModes/ChallengeMedley/Languages/English.xml @@ -0,0 +1,37 @@ + + + + English + + + + Challenge Medley Mode + Play some challenge rounds by using 5-some Medleys only. + For all who are interested in duel fights and Medleys. + Next + Back + Start + Exit + Yes + No + Next Round + + Challenge Medley Mode: Configuration + Number of players + Number of mics + Number of rounds + + Challenge Medley Mode: Choose Player + + Challenge Medley Mode: Overview + Pos + Name + Rounds + Wins + Sing Points + Score + Do you really want to exit? + Player of next round: + All rounds were sung! And the winner is... + + diff --git a/Output/PartyModes/ChallengeMedley/Languages/French.xml b/Output/PartyModes/ChallengeMedley/Languages/French.xml new file mode 100644 index 00000000..a5420151 --- /dev/null +++ b/Output/PartyModes/ChallengeMedley/Languages/French.xml @@ -0,0 +1,37 @@ + + + + Français + + + + TODO: Challenge Medley Mode + TODO: Play some challenge rounds by using 5-some Medleys only. + TODO: For all who are interested in duel fights and Medleys. + TODO: Next + Retour + Démarrer + Quitter + Oui + Non + TODO: Next Round + + TODO: Challenge Medley Mode: Configuration + TODO: Number of players + TODO: Number of mics + TODO: Number of rounds + + TODO: Challenge Medley Mode: Choose Player + + TODO: Challenge Medley Mode: Overview + TODO: Pos + TODO: Name + TODO: Rounds + TODO: Wins + TODO: Sing Points + TODO: Score + TODO: Do you really want to exit? + TODO: Player of next round: + TODO: All rounds were sung! And the winner is... + + diff --git a/Output/PartyModes/ChallengeMedley/Languages/Spanish.xml b/Output/PartyModes/ChallengeMedley/Languages/Spanish.xml new file mode 100644 index 00000000..baa8ad8b --- /dev/null +++ b/Output/PartyModes/ChallengeMedley/Languages/Spanish.xml @@ -0,0 +1,36 @@ + + + + Español + + + + TODO: Challenge Medley Mode + TODO: Play some challenge rounds by using 5-some Medleys only. + TODO: For all who are interested in duel fights and Medleys. + TODO: Next + Volver + Comenzar + Salir + Sí + No + TODO: Next Round + + TODO: Challenge Medley Mode: Configuration + TODO: Number of players + TODO: Number of mics + TODO: Number of rounds + + TODO: Challenge Medley Mode: Choose Player + + TODO: Challenge Medley Mode: Overview + TODO: Name + TODO: Rounds + TODO: Wins + TODO: Sing Points + TODO: Score + TODO: Do you really want to exit? + TODO: Player of next round: + TODO: All rounds were sung! And the winner is... + + diff --git a/Output/PartyModes/ChallengeMedley/Screens/PartyScreenChallengeConfig.xml b/Output/PartyModes/ChallengeMedley/Screens/PartyScreenChallengeConfig.xml new file mode 100644 index 00000000..6581aa77 --- /dev/null +++ b/Output/PartyModes/ChallengeMedley/Screens/PartyScreenChallengeConfig.xml @@ -0,0 +1,458 @@ + + + + 1 + + + Video + + + + BG_Default + + + BackgroundColor + + + + Menu + + 40 + 40 + 0,00 + 1200 + 50 + + + StaticColor + + + + + + + 640 + 48 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Center + + Center + + + + Outline + + TR_SCREENCONFIG_TITLE + + + + + + + 75 + 105 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Left + + Center + + + + Outline + + TR_SCREENCONFIG_NUMPLAYERS + + + + + + + 75 + 165 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Left + + Center + + + + Outline + + TR_SCREENCONFIG_NUMMICS + + + + + + + 75 + 225 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Left + + Center + + + + Outline + + TR_SCREENCONFIG_NUMROUNDS + + + + + + + Button + + Button + + 985 + 600 + 0,00 + 150 + 50 + + + ButtonColor + + + ButtonSColor + + + 75 + 10 + + 32 + + 142 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + TR_BUTTON_NEXT + + + + + + 10 + 26 + + + + + + 10 + 26 + + + + + Button + + Button + + 145 + 600 + 0,00 + 150 + 50 + + + ButtonColor + + + ButtonSColor + + + 75 + 10 + + 32 + + 142 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + TR_BUTTON_BACK + + + + + + 10 + 26 + + + + + + 10 + 26 + + + + + Invisible + + SelectSlideArrowLeft + + SelectSlideArrowRight + + SelectSlide + + SelectSlideArrowLeft + + SelectSlideArrowRight + + SelectSlide + + 500 + 100 + 0,00 + 700 + 50 + + 505 + 105 + 0,00 + 40 + 40 + + 1170 + 105 + 0,00 + 40 + 40 + + + SelectSlideColor + + + SelectSlideSColor + + + SelectSlideHColor + + + ArrowColor + + + ArrowSColor + + + TextColor + + + TextSColor + + 32,00 + + 205,33 + + Outline + + Bold + + 9 + + + + Invisible + + SelectSlideArrowLeft + + SelectSlideArrowRight + + SelectSlide + + SelectSlideArrowLeft + + SelectSlideArrowRight + + SelectSlide + + 500 + 160 + 0,00 + 700 + 50 + + 505 + 165 + 0,00 + 40 + 40 + + 1170 + 165 + 0,00 + 40 + 40 + + + SelectSlideColor + + + SelectSlideSColor + + + SelectSlideHColor + + + ArrowColor + + + ArrowSColor + + + TextColor + + + TextSColor + + 32,00 + + 205,33 + + Outline + + Bold + + 2 + + + + Invisible + + SelectSlideArrowLeft + + SelectSlideArrowRight + + SelectSlide + + SelectSlideArrowLeft + + SelectSlideArrowRight + + SelectSlide + + 500 + 220 + 0,00 + 700 + 50 + + 505 + 225 + 0,00 + 40 + 40 + + 1170 + 225 + 0,00 + 40 + 40 + + + SelectSlideColor + + + SelectSlideSColor + + + SelectSlideHColor + + + ArrowColor + + + ArrowSColor + + + TextColor + + + TextSColor + + 32,00 + + 205,33 + + Outline + + Bold + + 10 + + + diff --git a/Output/PartyModes/ChallengeMedley/Screens/PartyScreenChallengeMain.xml b/Output/PartyModes/ChallengeMedley/Screens/PartyScreenChallengeMain.xml new file mode 100644 index 00000000..34733ff1 --- /dev/null +++ b/Output/PartyModes/ChallengeMedley/Screens/PartyScreenChallengeMain.xml @@ -0,0 +1,985 @@ + + + + 1 + + + Video + + + + BG_Default + + + BackgroundColor + + + + Menu + + 40 + 40 + 0,00 + 1200 + 50 + + + StaticColor + + + + + + + PopupBG + + 0 + 0 + -1,00 + 1280 + 720 + + + StaticColor + + + + + + + Invisible + + 0 + 0 + 0,00 + 100 + 100 + + + StaticColor + + + + + + + 640 + 48 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Center + + Center + + + + Outline + + TR_SCREENMAIN_TITLE + + + + + + + 640 + 515 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Center + + Center + + + + Outline + + TR_SCREENMAIN_NEXT_PLAYER + + + + + + + 640 + 520 + + 0,00 + + 50 + + + + StaticColor + + + TextSColor + + Center + + Center + + + + Outline + + TR_SCREENMAIN_FINISH + + + + + + + 640 + 575 + + 0,00 + + 35 + + 770 + + + StaticColor + + + TextSColor + + Center + + Center + + + + Outline + + + + + + + + + 40 + 102 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Right + + Center + + + + Outline + + TR_SCREENMAIN_TABLE_POS + + + + + + + 50 + 102 + + 0,00 + + 32 + + 130 + + + StaticColor + + + TextSColor + + Left + + Center + + + + Outline + + TR_SCREENMAIN_TABLE_PLAYERNAME + + + + + + + 260 + 102 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Right + + Center + + + + Outline + + TR_SCREENMAIN_TABLE_NUMPLAYED + + + + + + + 340 + 102 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Right + + Center + + + + Outline + + TR_SCREENMAIN_TABLE_WON + + + + + + + 490 + 102 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Right + + Center + + + + Outline + + TR_SCREENMAIN_TABLE_SINGPOINTS + + + + + + + 590 + 102 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Right + + Center + + + + Outline + + TR_SCREENMAIN_TABLE_GAMEPOINTS + + + + + + + 0 + 0 + + 0,00 + + 32 + + 100 + + + StaticColor + + + TextSColor + + Center + + Center + + + + Outline + + + + + + + + + 0 + 0 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Center + + Center + + + + Outline + + + + + + + + + 660 + 102 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Right + + Center + + + + Outline + + + + + + + + + 0 + 0 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Center + + Center + + + + Outline + + + + + + + + + 640 + 265 + + -1,01 + + 32 + + 380 + + + StaticColor + + + TextSColor + + Center + + Center + + + + Outline + + TR_SCREENMAIN_POPUP_REALLYEXIT + + + + + + + Button + + Button + + 1030 + 600 + 0,00 + 150 + 50 + + + ButtonColor + + + ButtonSColor + + + 75 + 10 + + 32 + + 142 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + TR_BUTTON_NEXT_ROUND + + + + + + 10 + 26 + + + + + + 10 + 26 + + + + + Button + + Button + + 100 + 600 + 0,00 + 150 + 50 + + + ButtonColor + + + ButtonSColor + + + 75 + 10 + + 32 + + 142 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + TR_BUTTON_BACK + + + + + + 10 + 26 + + + + + + 10 + 26 + + + + + Button + + Button + + 100 + 600 + 0,00 + 150 + 50 + + + ButtonColor + + + ButtonSColor + + + 75 + 10 + + 32 + + 142 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + TR_BUTTON_EXIT + + + + + + 10 + 26 + + + + + + 10 + 26 + + + + + Button + + Button + + 665 + 360 + -1,01 + 150 + 50 + + + ButtonColor + + + ButtonSColor + + + 75 + 10 + + 32 + + 142 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + TR_BUTTON_YES + + + + + + 10 + 26 + + + + + + 10 + 26 + + + + + Button + + Button + + 465 + 360 + -1,01 + 150 + 50 + + + ButtonColor + + + ButtonSColor + + + 75 + 10 + + 32 + + 142 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + TR_BUTTON_NO + + + + + + 10 + 26 + + + + + + 10 + 26 + + + + + ScrollUp + + ScrollUp + + 281 + 94 + -0,01 + 28 + 15 + + + ButtonColor + + + ButtonSColor + + + 75 + 10 + + 32 + + 142 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + + + + + + + + + + + + ScrollDown + + ScrollDown + + 281 + 515 + -0,01 + 28 + 15 + + + ButtonColor + + + ButtonSColor + + + 75 + 10 + + 32 + + 142 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + + + + + + + + + + + + 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/Output/PartyModes/ChallengeMedley/Screens/PartyScreenChallengeNames.xml b/Output/PartyModes/ChallengeMedley/Screens/PartyScreenChallengeNames.xml new file mode 100644 index 00000000..9d033c03 --- /dev/null +++ b/Output/PartyModes/ChallengeMedley/Screens/PartyScreenChallengeNames.xml @@ -0,0 +1,274 @@ + + + + 1 + + + Video + + + + BG_Default + + + BackgroundColor + + + + Menu + + 40 + 40 + 0,00 + 1200 + 50 + + + StaticColor + + + + + + + 640 + 48 + + 0,00 + + 32 + + + + StaticColor + + + TextSColor + + Center + + Center + + + + Outline + + TR_SCREENNAMES_TITLE + + + + + + + Button + + Button + + 985 + 600 + 0,00 + 150 + 50 + + + ButtonColor + + + ButtonSColor + + + 75 + 10 + + 32 + + 142 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + TR_BUTTON_NEXT + + + + + + 10 + 26 + + + + + + 10 + 26 + + + + + Button + + Button + + 145 + 600 + 0,00 + 150 + 50 + + + ButtonColor + + + ButtonSColor + + + 75 + 10 + + 32 + + 142 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + TR_BUTTON_BACK + + + + + + 10 + 26 + + + + + + 10 + 26 + + + + + CoverTile + + CoverTile + + 0 + 0 + 0,00 + 100 + 100 + + + ButtonColor + + + ButtonSColor + + + 50 + 102 + + 20 + + 98 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + + + + + + + + + + + + CoverTile + + CoverTile + + 0 + 0 + 0,00 + 100 + 100 + + + ButtonColor + + + ButtonSColor + + + 50 + 102 + + 20 + + 98 + + + ButtonTextColor + + + ButtonTextSColor + + Center + + Center + + + + Outline + + + + + + + + + + + + diff --git a/PartyModes/PartyModeChallengeMedley/ChallengeRounds.cs b/PartyModes/PartyModeChallengeMedley/ChallengeRounds.cs new file mode 100644 index 00000000..05670e10 --- /dev/null +++ b/PartyModes/PartyModeChallengeMedley/ChallengeRounds.cs @@ -0,0 +1,262 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using Vocaluxe.Menu; + +namespace Vocaluxe.PartyModes +{ + public class ChallengeRounds + { + private Random _Rand; + private int _NumPlayer; + + public List Rounds; + + public ChallengeRounds(int NumRounds, int NumPlayer, int NumPlayerAtOnce) + { + Rounds = new List(); + _Rand = new Random(System.DateTime.Now.Millisecond); + + if (NumPlayerAtOnce < 1 || NumRounds < 1 || NumPlayer == 0) + _NumPlayer = 0; + else + { + _NumPlayer = NumPlayer; + BuildRounds(NumRounds, NumPlayerAtOnce, _Rand); + } + } + + public Combination GetRound(int RoundNr) + { + if (RoundNr >= Rounds.Count || _NumPlayer == 0 || Rounds.Count == 0) + return null; + + return Rounds[RoundNr]; + } + + private void BuildRounds(int NumRounds, int NumPlayerAtOnce, Random Rand) + { + Combinations Combinations = new Combinations(_NumPlayer, NumPlayerAtOnce, Rand); + Rounds.Add(Combinations.GetNextCombination(null)); + + for (int i = 1; i < NumRounds; i++) + { + + Rounds.Add(Combinations.GetNextCombination(GetPlayerDemand(i))); + } + } + + private List GetPlayerDemand(int RoundIndex) + { + List NumPlayed = new List(_NumPlayer); + for (int i = 0; i < _NumPlayer; i++) + { + NumPlayed.Add(0); + } + + for (int i = 0; i < RoundIndex; i++) + { + foreach (int PlayerIndex in Rounds[i].Player) + { + NumPlayed[PlayerIndex]++; + } + } + + int max = 0; + foreach (int p in NumPlayed) + { + if (p > max) + max = p; + } + + int num = Rounds[0].Player.Count; + List result = new List(); + List other = new List(); + List last = new List(); + + for (int i = 0; i < NumPlayed.Count; i++) + { + if (RoundIndex == 0 || NumPlayed[i] < max) + { + if (RoundIndex == 0 || RoundIndex > 0 && NumPlayed[i] < max && !Rounds[RoundIndex - 1].IsAvailable(i)) + result.Add(i); + else if (NumPlayed[i] < max) + other.Add(i); + } + else + { + if (RoundIndex > 0) + { + if (!Rounds[RoundIndex - 1].IsAvailable(i)) + other.Add(i); + else + last.Add(i); + } + else + last.Add(i); + + } + } + + while (result.Count < num && other.Count > 0) + { + int n = other.Count; + int r = _Rand.Next(n); + result.Add(other[r]); + other.RemoveAt(r); + } + + while (result.Count < num) + { + int n = last.Count; + int r = _Rand.Next(n); + result.Add(last[r]); + last.RemoveAt(r); + } + + while (result.Count > num) + { + int n = result.Count; + int r = _Rand.Next(n); + result.RemoveAt(r); + } + + result.Sort(); + return result; + } + } + + class Combinations + { + private List _Combs; + private Random _Rand; + private int _NumPlayer; + private int _NumMics; + + public Combinations(int NumPlayer, int NumMics, Random Rand) + { + _Combs = new List(); + _NumMics = NumMics; + _NumPlayer = NumPlayer; + _Rand = Rand; + } + + public Combination GetNextCombination(List PlayerNrDemand) + { + if (_Combs.Count == 0) + Create(); + + Combination combs = new Combination(); + + if (_NumPlayer == _NumMics) + { + return _Combs[0]; + } + + //filter against PlayerNrDemand + List combsFiltered = new List(); + if (PlayerNrDemand != null) + { + for (int i = 0; i < _Combs.Count; i++) + { + if (_Combs[i].IsAvailableAll(PlayerNrDemand)) + combsFiltered.Add(_Combs[i]); + } + } + + //1st fallback + if (PlayerNrDemand != null && combsFiltered.Count == 0) + { + for (int i = 0; i < _Combs.Count; i++) + { + if (_Combs[i].IsAvailableSomeone(PlayerNrDemand)) + combsFiltered.Add(_Combs[i]); + } + } + + //2nd fallback + if (combsFiltered.Count == 0) + { + for (int i = 0; i < _Combs.Count; i++) + { + combsFiltered.Add(_Combs[i]); + } + } + + int num = combsFiltered.Count; + int rand = _Rand.Next(num); + Combination c = new Combination(); + for (int i = 0; i < combsFiltered[rand].Player.Count; i++) + { + c.Player.Add(combsFiltered[rand].Player[i]); + } + _Combs.Remove(combsFiltered[rand]); + + return combsFiltered[rand]; + } + + private void Create() + { + _Combs.Clear(); + + int num = (int)Math.Pow(2, _NumPlayer); + + for (int i = 1; i <= num; i++) + { + Combination c = new Combination(); + + for (int j = 0; j < _NumPlayer; j++) + { + if ((i & (1 << j)) > 0) + { + c.Player.Add(j); + } + } + + if (c.Player.Count == _NumMics) + _Combs.Add(c); + } + } + } + + public class Combination + { + public List Player; + + public Combination() + { + Player = new List(); + } + + public bool IsAvailable(int PlayerIndex) + { + foreach (int p in Player) + { + if (p == PlayerIndex) + return true; + } + return false; + } + + public bool IsAvailableAll(List PlayerIndices) + { + bool result = true; + foreach (int p in PlayerIndices) + { + result &= IsAvailable(p); + } + return result; + } + + public bool IsAvailableSomeone(List PlayerIndices) + { + bool result = false; + foreach (int p in PlayerIndices) + { + result |= IsAvailable(p); + } + return result; + } + } +} diff --git a/PartyModes/PartyModeChallengeMedley/PartyModeChallenge.cs b/PartyModes/PartyModeChallengeMedley/PartyModeChallenge.cs new file mode 100644 index 00000000..077882cb --- /dev/null +++ b/PartyModes/PartyModeChallengeMedley/PartyModeChallenge.cs @@ -0,0 +1,787 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using Vocaluxe.Menu; +using Vocaluxe.Menu.SongMenu; + +namespace Vocaluxe.PartyModes +{ + #region Communication + #region ToScreen + public struct DataToScreenConfig + { + public int NumPlayer; + public int NumPlayerAtOnce; + public int NumRounds; + } + + public struct DataToScreenNames + { + public int NumPlayer; + public List ProfileIDs; + } + + public struct DataToScreenMain + { + public int CurrentRoundNr; + public int NumPlayerAtOnce; + public List Combs; + public int[,] Results; + public List ResultTable; + public List ProfileIDs; + } + + public class ResultTableRow : IComparable + { + public int Position; + public int PlayerID; + public int NumPlayed; + public int NumRounds; + public int NumWon; + public int NumSingPoints; + public int NumGamePoints; + + public int CompareTo(object obj) + { + if (obj is ResultTableRow) + { + ResultTableRow row = (ResultTableRow)obj; + + int res = row.NumGamePoints.CompareTo(NumGamePoints); + if (res == 0) + { + res = row.NumSingPoints.CompareTo(NumSingPoints); + if (res == 0) + { + res = row.NumWon.CompareTo(NumWon); + } + } + return res; + } + + throw new ArgumentException("object is not a ResultTableRow"); + } + } + + #endregion ToScreen + + #region FromScreen + public struct DataFromScreen + { + public FromScreenConfig ScreenConfig; + public FromScreenNames ScreenNames; + public FromScreenMain ScreenMain; + } + + public struct FromScreenConfig + { + public int NumPlayer; + public int NumPlayerAtOnce; + public int NumRounds; + } + + public struct FromScreenNames + { + public bool FadeToConfig; + public bool FadeToMain; + public List ProfileIDs; + } + + public struct FromScreenMain + { + public bool FadeToSongSelection; + public bool FadeToNameSelection; + } + #endregion FromScreen + #endregion Communication + + public sealed class PartyModeChallenge : CPartyMode + { + private const int MaxPlayer = 12; + private const int MinPlayer = 1; + private const int MaxTeams = 0; + private const int MinTeams = 0; + private const int MaxNumRounds = 100; + private const int NumSongs = 5; + + enum EStage + { + NotStarted, + Config, + Names, + Main, + Singing + } + + struct Data + { + public int NumPlayer; + public int NumPlayerAtOnce; + public int NumRounds; + public List ProfileIDs; + + public ChallengeRounds Rounds; + public List ResultTable; + public int[,] Results; + + public int CurrentRoundNr; + + public int[] CatSongIndices; + } + + struct Stats + { + public int ProfileID; + public int SingPoints; + public int GamePoints; + public int Won; + } + + private DataToScreenConfig ToScreenConfig; + private DataToScreenNames ToScreenNames; + private DataToScreenMain ToScreenMain; + + private Data GameData; + private EStage _Stage; + + public PartyModeChallenge() + { + _ScreenSongOptions.Selection.RandomOnly = false; + _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.SearchActive = false; + _ScreenSongOptions.Sorting.ShowDuetSongs = false; + + _Stage = EStage.NotStarted; + + ToScreenConfig = new DataToScreenConfig(); + ToScreenNames = new DataToScreenNames(); + ToScreenMain = new DataToScreenMain(); + + GameData = new Data(); + GameData.NumPlayer = 4; + GameData.NumPlayerAtOnce = 2; + GameData.NumRounds = 2; + GameData.CurrentRoundNr = 1; + GameData.ProfileIDs = new List(); + GameData.CatSongIndices = null; + GameData.Results = null; + } + + public override bool Init() + { + _Stage = EStage.NotStarted; + + _ScreenSongOptions.Sorting.IgnoreArticles = _Base.Config.GetIgnoreArticles(); + _ScreenSongOptions.Sorting.SongSorting = _Base.Config.GetSongSorting(); + _ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_OFF; + _ScreenSongOptions.Selection.SongIndex = -1; + + if (_Base.Config.GetTabs() == EOffOn.TR_CONFIG_ON && _ScreenSongOptions.Sorting.SongSorting != ESongSorting.TR_CONFIG_NONE) + _ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_ON; + + ToScreenMain.ResultTable = new List(); + GameData.ResultTable = new List(); + + _Base.Songs.SortSongs(ESongSorting.TR_CONFIG_NONE, EOffOn.TR_CONFIG_OFF, EOffOn.TR_CONFIG_OFF, String.Empty, false); + _Base.Songs.SetCategory(0); + + return true; + } + + public override void DataFromScreen(string ScreenName, Object Data) + { + DataFromScreen data = new DataFromScreen(); + switch (ScreenName) + { + case "PartyScreenChallengeConfig": + + try + { + data = (DataFromScreen)Data; + GameData.NumPlayer = data.ScreenConfig.NumPlayer; + GameData.NumPlayerAtOnce = data.ScreenConfig.NumPlayerAtOnce; + GameData.NumRounds = data.ScreenConfig.NumRounds; + + _Stage = EStage.Config; + _Base.Graphics.FadeTo(EScreens.ScreenPartyDummy); + } + catch (Exception e) + { + _Base.Log.LogError("Error in party mode challenge. Can't cast received data from screen " + ScreenName + ". " + e.Message); + } + break; + + case "PartyScreenChallengeNames": + try + { + data = (DataFromScreen)Data; + if (data.ScreenNames.FadeToConfig) + _Stage = EStage.NotStarted; + else + { + GameData.ProfileIDs = data.ScreenNames.ProfileIDs; + _Stage = EStage.Names; + } + + _Base.Graphics.FadeTo(EScreens.ScreenPartyDummy); + } + catch (Exception e) + { + _Base.Log.LogError("Error in party mode challenge. Can't cast received data from screen " + ScreenName + ". " + e.Message); + } + break; + + case "PartyScreenChallengeMain": + try + { + data = (DataFromScreen)Data; + if (data.ScreenMain.FadeToSongSelection) + _Stage = EStage.Singing; + if (data.ScreenMain.FadeToNameSelection) + _Stage = EStage.Config; + } + catch (Exception e) + { + _Base.Log.LogError("Error in party mode challenge. Can't cast received data from screen " + ScreenName + ". " + e.Message); + } + + + if (_Stage == EStage.Singing) + StartNextRound(); + if (_Stage == EStage.Config) + _Base.Graphics.FadeTo(EScreens.ScreenPartyDummy); + break; + + default: + _Base.Log.LogError("Error in party mode challenge. Wrong screen is sending: " + ScreenName); + break; + } + } + + public override void UpdateGame() + { + /* + if (_Base.Songs.GetCurrentCategoryIndex() != -1 || _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF) + _ScreenSongOptions.Selection.RandomOnly = true; + else + _ScreenSongOptions.Selection.RandomOnly = false;*/ + } + + public override CMenuParty GetNextPartyScreen(out EScreens AlternativeScreen) + { + CMenuParty Screen = null; + AlternativeScreen = EScreens.ScreenSong; + + switch (_Stage) + { + case EStage.NotStarted: + _Screens.TryGetValue("PartyScreenChallengeConfig", out Screen); + if (_Screens != null) + { + ToScreenConfig.NumPlayer = GameData.NumPlayer; + ToScreenConfig.NumPlayerAtOnce = GameData.NumPlayerAtOnce; + ToScreenConfig.NumRounds = GameData.NumRounds; + Screen.DataToScreen(ToScreenConfig); + } + break; + case EStage.Config: + _Screens.TryGetValue("PartyScreenChallengeNames", out Screen); + if (_Screens != null) + { + ToScreenNames.NumPlayer = GameData.NumPlayer; + ToScreenNames.ProfileIDs = GameData.ProfileIDs; + Screen.DataToScreen(ToScreenNames); + } + break; + case EStage.Names: + _Screens.TryGetValue("PartyScreenChallengeMain", out Screen); + if (_Screens != null) + { + _Base.Songs.ResetPartySongSung(); + ToScreenMain.ResultTable = new List(); + GameData.ResultTable = new List(); + GameData.Rounds = new ChallengeRounds(GameData.NumRounds, GameData.NumPlayer, GameData.NumPlayerAtOnce); + GameData.CurrentRoundNr = 1; + ToScreenMain.CurrentRoundNr = 1; + ToScreenMain.NumPlayerAtOnce = GameData.NumPlayerAtOnce; + ToScreenMain.Combs = GameData.Rounds.Rounds; + ToScreenMain.ProfileIDs = GameData.ProfileIDs; + UpdateScores(); + ToScreenMain.ResultTable = GameData.ResultTable; + ToScreenMain.Results = GameData.Results; + Screen.DataToScreen(ToScreenMain); + } + break; + case EStage.Main: + //nothing to do + break; + case EStage.Singing: + _Screens.TryGetValue("PartyScreenChallengeMain", out Screen); + if (_Screens != null) + { + UpdateScores(); + ToScreenMain.CurrentRoundNr = GameData.CurrentRoundNr; + ToScreenMain.Combs = GameData.Rounds.Rounds; + ToScreenMain.Results = GameData.Results; + Screen.DataToScreen(ToScreenMain); + } + break; + default: + break; + } + + return Screen; + } + + public override EScreens GetStartScreen() + { + return EScreens.ScreenPartyDummy; + } + + public override EScreens GetMainScreen() + { + return EScreens.ScreenPartyDummy; + } + + public override ScreenSongOptions GetScreenSongOptions() + { + _ScreenSongOptions.Sorting.SongSorting = _Base.Config.GetSongSorting(); + _ScreenSongOptions.Sorting.Tabs = _Base.Config.GetTabs(); + _ScreenSongOptions.Sorting.IgnoreArticles = _Base.Config.GetIgnoreArticles(); + + return _ScreenSongOptions; + } + + public override void OnSongChange(int SongIndex, ref ScreenSongOptions ScreenSongOptions) + { + if (_ScreenSongOptions.Selection.SongIndex != -1) + _ScreenSongOptions.Selection.SongIndex = -1; + + if (_ScreenSongOptions.Selection.SelectNextRandomSong && SongIndex != -1) + { + _ScreenSongOptions.Selection.SelectNextRandomSong = false; + CreateCatSongIndices(); + + if (GameData.CatSongIndices != null) + { + if (GameData.CatSongIndices[_Base.Songs.GetCurrentCategoryIndex()] == -1) + GameData.CatSongIndices[_Base.Songs.GetCurrentCategoryIndex()] = SongIndex; + } + } + + ScreenSongOptions = _ScreenSongOptions; + } + + public override void OnCategoryChange(int CategoryIndex, ref ScreenSongOptions ScreenSongOptions) + { + if (GameData.CatSongIndices != null && CategoryIndex != -1) + { + if (GameData.CatSongIndices[CategoryIndex] == -1) + _ScreenSongOptions.Selection.SelectNextRandomSong = true; + else + _ScreenSongOptions.Selection.SongIndex = GameData.CatSongIndices[CategoryIndex]; + } + + if (GameData.CatSongIndices == null && CategoryIndex != -1) + _ScreenSongOptions.Selection.SelectNextRandomSong = true; + + if (CategoryIndex == -1) + _ScreenSongOptions.Selection.RandomOnly = false; + + if (_ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF || CategoryIndex != -1) + _ScreenSongOptions.Selection.RandomOnly = true; + + ScreenSongOptions = _ScreenSongOptions; + } + + public override void SetSearchString(string SearchString, bool Visible) + { + _ScreenSongOptions.Sorting.SearchString = SearchString; + _ScreenSongOptions.Sorting.SearchActive = Visible; + } + + public override int GetMaxPlayer() + { + return MaxPlayer; + } + + public override int GetMinPlayer() + { + return MinPlayer; + } + + public override int GetMaxTeams() + { + return MaxTeams; + } + + public override int GetMinTeams() + { + return MinTeams; + } + + public override int GetMaxNumRounds() + { + 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; + } + + public override void SongSelected(int SongID) + { + } + + public override void LeavingHighscore() + { + GameData.CurrentRoundNr++; + _Base.Graphics.FadeTo(EScreens.ScreenPartyDummy); + } + + private void StartNextRound() + { + _ScreenSongOptions.Selection.RandomOnly = _ScreenSongOptions.Sorting.Tabs != EOffOn.TR_CONFIG_ON; + _ScreenSongOptions.Selection.CategoryChangeAllowed = _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_ON; + SetNumJokers(); + SetTeamNames(); + GameData.CatSongIndices = null; + + if (RandomizeSongs()) + _Base.Graphics.FadeTo(EScreens.ScreenSing); + } + + private bool RandomizeSongs() + { + _Base.Game.Reset(); + _Base.Game.ClearSongs(); + + #region PlayerNames + _Base.Game.SetNumPlayer(GameData.NumPlayerAtOnce); + SPlayer[] player = _Base.Game.GetPlayer(); + if (player == null) + return false; + + if (player.Length < GameData.NumPlayerAtOnce) + return false; + + SProfile[] profiles = _Base.Profiles.GetProfiles(); + Combination c = GameData.Rounds.GetRound(GameData.CurrentRoundNr - 1); + + for (int i = 0; i < GameData.NumPlayerAtOnce; i++) + { + //default values + player[i].Name = "foobar"; + player[i].Difficulty = EGameDifficulty.TR_CONFIG_EASY; + player[i].ProfileID = -1; + + //try to fill with the right data + if (c != null) + { + if (GameData.ProfileIDs[c.Player[i]] < profiles.Length) + { + player[i].Name = profiles[GameData.ProfileIDs[c.Player[i]]].PlayerName; + player[i].Difficulty = profiles[GameData.ProfileIDs[c.Player[i]]].Difficulty; + player[i].ProfileID = GameData.ProfileIDs[c.Player[i]]; + } + } + } + #endregion PlayerNames + + #region SongQueque + if (_Base.Songs.GetNumVisibleSongs() < NumSongs) + _Base.Songs.ResetPartySongSung(); + + EGameMode gm = EGameMode.TR_GAMEMODE_MEDLEY; + List IDs = new List(); + + CSong[] VisSongs = _Base.Songs.GetSongsNotSung(); + if (VisSongs == null) + { + _Base.Log.LogError("PartyChallengeMedleyMode Error: There are no songs!"); + _Base.Graphics.FadeTo(EScreens.ScreenParty); + return false; + } + + for (int i = 0; i < VisSongs.Length; i++) + { + foreach (EGameMode mode in VisSongs[i].AvailableGameModes) + { + if (mode == EGameMode.TR_GAMEMODE_MEDLEY) + IDs.Add(VisSongs[i].ID); + } + + } + + if (IDs.Count == 0) + { + _Base.Log.LogError("PartyChallengeMedleyMode Error: There are no medley songs!"); + _Base.Graphics.FadeTo(EScreens.ScreenParty); + return false; + } + + int s = 0; + while (s < NumSongs && IDs.Count > 0) + { + int SongID = IDs[_Base.Game.GetRandom(IDs.Count)]; + _Base.Game.AddSong(SongID, gm); + _Base.Songs.AddPartySongSung(SongID); + IDs.Remove(SongID); + s++; + } + return true; + #endregion SongQueque + } + + private void SetNumJokers() + { + switch (GameData.NumPlayerAtOnce) + { + case 1: + _ScreenSongOptions.Selection.NumJokers = new int[] { 10 }; + break; + + case 2: + _ScreenSongOptions.Selection.NumJokers = new int[] { 5, 5 }; + break; + + case 3: + _ScreenSongOptions.Selection.NumJokers = new int[] { 4, 4, 4 }; + break; + + case 4: + _ScreenSongOptions.Selection.NumJokers = new int[] { 3, 3, 3, 3 }; + break; + + case 5: + _ScreenSongOptions.Selection.NumJokers = new int[] { 2, 2, 2, 2, 2 }; + break; + + case 6: + _ScreenSongOptions.Selection.NumJokers = new int[] { 2, 2, 2, 2, 2, 2 }; + break; + default: + _ScreenSongOptions.Selection.NumJokers = new int[] { 5, 5 }; + 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.ProfileIDs.Count < GameData.NumPlayerAtOnce || profiles.Length < GameData.NumPlayerAtOnce) + { + _ScreenSongOptions.Selection.TeamNames = new string[] { "foo", "bar" }; + return; + } + + _ScreenSongOptions.Selection.TeamNames = new string[GameData.NumPlayerAtOnce]; + Combination c = GameData.Rounds.GetRound(GameData.CurrentRoundNr - 1); + + for (int i = 0; i < GameData.NumPlayerAtOnce; i++) + { + if (c != null) + { + if (GameData.ProfileIDs[c.Player[i]] < profiles.Length) + _ScreenSongOptions.Selection.TeamNames[i] = profiles[GameData.ProfileIDs[c.Player[i]]].PlayerName; + else + _ScreenSongOptions.Selection.TeamNames[i] = "foobar"; + } + else + _ScreenSongOptions.Selection.TeamNames[i] = "foobar"; + } + } + + private void UpdateScores() + { + if (GameData.ResultTable.Count == 0) + { + for (int i = 0; i < GameData.NumPlayer; i++) + { + ResultTableRow row = new ResultTableRow(); + row.PlayerID = GameData.ProfileIDs[i]; + row.NumPlayed = 0; + row.NumRounds = 0; + row.NumWon = 0; + row.NumSingPoints = 0; + row.NumGamePoints = 0; + GameData.ResultTable.Add(row); + } + + GameData.Results = new int[GameData.NumRounds, GameData.NumPlayerAtOnce]; + for (int i = 0; i < GameData.NumRounds; i++) + { + for (int j = 0; j < GameData.NumPlayerAtOnce; j++) + { + GameData.Results[i, j] = 0; + } + } + } + else + { + CPoints GamePoints = _Base.Game.GetPoints(); + if (GamePoints == null || GamePoints.NumPlayer < GameData.NumPlayerAtOnce) + return; + + SPlayer[] results = GamePoints.GetPlayer(0, GameData.NumPlayerAtOnce); + if (results == null) + return; + + if (results.Length < GameData.NumPlayerAtOnce) + return; + + if (GamePoints.NumRounds == 0) + return; + + for (int i = 1; i < GamePoints.NumRounds; i++) + { + SPlayer[] temp = GamePoints.GetPlayer(i, GameData.NumPlayerAtOnce); + for (int p = 0; p < GameData.NumPlayerAtOnce; p++) + { + results[p].Points += temp[p].Points; + } + } + + for (int j = 0; j < GameData.NumPlayerAtOnce; j++) + { + results[j].Points = results[j].Points / GamePoints.NumRounds; + GameData.Results[GameData.CurrentRoundNr - 2, j] = (int)Math.Round(results[j].Points); + } + + List points = GetPointsForPlayer(results); + + for (int i = 0; i < GameData.NumPlayerAtOnce; i++) + { + int index = -1; + for (int j = 0; j < GameData.ResultTable.Count; j++) + { + if (points[i].ProfileID == GameData.ResultTable[j].PlayerID) + { + index = j; + break; + } + } + + if (index != -1) + { + ResultTableRow row = GameData.ResultTable[index]; + + row.NumPlayed++; + row.NumWon += points[i].Won; + row.NumRounds += 1; + row.NumSingPoints += points[i].SingPoints; + row.NumGamePoints += points[i].GamePoints; + + GameData.ResultTable[index] = row; + } + } + } + + GameData.ResultTable.Sort(); + + //Update position-number + int pos = 1; + int lastPoints = 0; + int lastSingPoints = 0; + for (int i = 0; i < GameData.ResultTable.Count; i++ ) + { + if (lastPoints > GameData.ResultTable[i].NumGamePoints || lastSingPoints > GameData.ResultTable[i].NumSingPoints) + pos++; + GameData.ResultTable[i].Position = pos; + lastPoints = GameData.ResultTable[i].NumGamePoints; + lastSingPoints = GameData.ResultTable[i].NumSingPoints; + } + } + + private List GetPointsForPlayer(SPlayer[] Results) + { + List result = new List(); + for(int i = 0; i < GameData.NumPlayerAtOnce; i++) + { + Stats stat = new Stats(); + stat.ProfileID = Results[i].ProfileID; + stat.SingPoints = (int)Math.Round(Results[i].Points); + stat.Won = 0; + stat.GamePoints = 0; + result.Add(stat); + } + + result.Sort(delegate(Stats s1, Stats s2) { return s1.SingPoints.CompareTo(s2.SingPoints); }); + + int current = result[result.Count - 1].SingPoints; + int points = result.Count; + bool wonset = false; + + for (int i = result.Count - 1; i >= 0; i--) + { + Stats res = result[i]; + + if (i < result.Count - 1) + { + if (current > res.SingPoints) + { + res.GamePoints = i * 2; + wonset = true; + points = res.GamePoints; + } + else + { + if (!wonset) + res.Won = 1; + res.GamePoints = points; + } + } + else + { + res.GamePoints = i * 2; + res.Won = 1; + } + + current = res.SingPoints; + + result[i] = res; + } + + + + return result; + } + + private void CreateCatSongIndices() + { + if (GameData.CatSongIndices == null && _Base.Songs.GetNumCategories() > 0 && _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_ON) + { + GameData.CatSongIndices = new int[_Base.Songs.GetNumCategories()]; + for (int i = 0; i < GameData.CatSongIndices.Length; i++) + { + GameData.CatSongIndices[i] = -1; + } + } + + if (_Base.Songs.GetNumCategories() == 0 || _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF) + GameData.CatSongIndices = null; + } + } +} \ No newline at end of file diff --git a/PartyModes/PartyModeChallengeMedley/PartyModeChallengeMedley.csproj b/PartyModes/PartyModeChallengeMedley/PartyModeChallengeMedley.csproj new file mode 100644 index 00000000..bace534a --- /dev/null +++ b/PartyModes/PartyModeChallengeMedley/PartyModeChallengeMedley.csproj @@ -0,0 +1,148 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {6F3E1874-F28A-40E9-AFBD-31934D593678} + Library + Properties + PartyModeChallenge + PartyModeChallenge + v2.0 + + + 512 + + + AnyCPU + true + full + false + ..\..\Output\PartyModes\ChallengeMedley\Code + TRACE;DEBUG;WIN + prompt + 4 + Off + + + AnyCPU + none + true + ..\..\Output\PartyModes\ChallengeMedley\Code + prompt + 4 + false + WIN + Off + + + AnyCPU + true + full + false + ..\..\Output\PartyModes\ChallengeMedley\Code + TRACE;DEBUG;WIN + prompt + 4 + Off + + + AnyCPU + none + true + ..\..\Output\PartyModes\ChallengeMedley\Code + prompt + 4 + false + WIN + Off + + + AnyCPU + true + full + false + ..\..\Output\PartyModes\ChallengeMedley\Code + TRACE;DEBUG;LINUX + prompt + 4 + Off + + + AnyCPU + none + true + ..\..\Output\PartyModes\ChallengeMedley\Code + prompt + 4 + false + LINUX + Off + + + AnyCPU + true + full + false + ..\..\Output\PartyModes\ChallengeMedley\Code + TRACE;DEBUG;LINUX + prompt + 4 + Off + + + AnyCPU + none + true + ..\..\Output\PartyModes\ChallengeMedley\Code + prompt + 4 + false + LINUX + Off + + + + + + + Always + + + Always + + + Always + + + Always + + + Always + + + + + {D2B6DDEF-E0E1-4DDF-A73A-E6ACEF5C95EC} + VocaluxeLib + False + + + + + + + + + + + + \ No newline at end of file diff --git a/PartyModes/PartyModeChallengeMedley/PartyScreenChallengeConfig.cs b/PartyModes/PartyModeChallengeMedley/PartyScreenChallengeConfig.cs new file mode 100644 index 00000000..f16799fd --- /dev/null +++ b/PartyModes/PartyModeChallengeMedley/PartyScreenChallengeConfig.cs @@ -0,0 +1,257 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; + +using Vocaluxe.Menu; + +namespace Vocaluxe.PartyModes +{ + public class PartyScreenChallengeConfig : CMenuParty + { + // Version number for theme files. Increment it, if you've changed something on the theme files! + const int ScreenVersion = 1; + + const string SelectSlideNumPlayers = "SelectSlideNumPlayers"; + const string SelectSlideNumMics = "SelectSlideNumMics"; + const string SelectSlideNumRounds = "SelectSlideNumRounds"; + const string ButtonNext = "ButtonNext"; + const string ButtonBack = "ButtonBack"; + + private int _MaxNumMics = 2; + private int _MaxNumRounds = 100; + private int _RoundSteps = 1; + + DataFromScreen Data; + + public PartyScreenChallengeConfig() + { + } + + protected override void Init() + { + base.Init(); + + _ThemeName = "PartyScreenChallengeConfig"; + _ThemeSelectSlides = new string[] { SelectSlideNumPlayers, SelectSlideNumMics, SelectSlideNumRounds }; + _ThemeButtons = new string[] { ButtonNext, ButtonBack }; + _ScreenVersion = ScreenVersion; + + Data = new DataFromScreen(); + FromScreenConfig config = new FromScreenConfig(); + config.NumPlayer = 4; + config.NumPlayerAtOnce = 2; + config.NumRounds = 12; + Data.ScreenConfig = config; + } + + public override void LoadTheme(string XmlPath) + { + base.LoadTheme(XmlPath); + } + + public override void DataToScreen(object ReceivedData) + { + DataToScreenConfig config = new DataToScreenConfig(); + + try + { + config = (DataToScreenConfig)ReceivedData; + Data.ScreenConfig.NumPlayer = config.NumPlayer; + Data.ScreenConfig.NumPlayerAtOnce = config.NumPlayerAtOnce; + Data.ScreenConfig.NumRounds = config.NumRounds; + } + catch (Exception e) + { + _Base.Log.LogError("Error in party mode screen challenge config. Can't cast received data from game mode " + _ThemeName + ". " + e.Message);; + } + + } + + public override bool HandleInput(KeyEvent KeyEvent) + { + base.HandleInput(KeyEvent); + + if (KeyEvent.KeyPressed) + { + + } + else + { + switch (KeyEvent.Key) + { + case Keys.Back: + case Keys.Escape: + Back(); + break; + + case Keys.Enter: + UpdateSlides(); + + if (Buttons[htButtons(ButtonBack)].Selected) + Back(); + + if (Buttons[htButtons(ButtonNext)].Selected) + Next(); + break; + + case Keys.Left: + UpdateSlides(); + break; + + case Keys.Right: + UpdateSlides(); + break; + } + } + return true; + } + + public override bool HandleMouse(MouseEvent MouseEvent) + { + base.HandleMouse(MouseEvent); + + if (MouseEvent.LB && IsMouseOver(MouseEvent)) + { + UpdateSlides(); + if (Buttons[htButtons(ButtonBack)].Selected) + Back(); + + if (Buttons[htButtons(ButtonNext)].Selected) + Next(); + } + + if (MouseEvent.RB) + { + Back(); + } + + return true; + } + + public override void OnShow() + { + base.OnShow(); + + _MaxNumMics = _Base.Config.GetMaxNumMics(); + if (_MaxNumMics > 6) + _MaxNumMics = 6; + + _MaxNumRounds = _PartyMode.GetMaxNumRounds(); + + RebuildSlides(); + } + + public override bool UpdateGame() + { + return true; + } + + public override bool Draw() + { + base.Draw(); + return true; + } + + public override void OnClose() + { + base.OnClose(); + } + + private void RebuildSlides() + { + // build num player slide (min player ... max player); + SelectSlides[htSelectSlides(SelectSlideNumPlayers)].Clear(); + for (int i = _PartyMode.GetMinPlayer(); i <= _PartyMode.GetMaxPlayer(); i++) + { + SelectSlides[htSelectSlides(SelectSlideNumPlayers)].AddValue(i.ToString()); + } + SelectSlides[htSelectSlides(SelectSlideNumPlayers)].Selection = Data.ScreenConfig.NumPlayer - _PartyMode.GetMinPlayer(); + + UpdateMicsAtOnce(); + SetRoundSteps(); + UpdateSlideRounds(); + } + + private void UpdateSlides() + { + int player = Data.ScreenConfig.NumPlayer; + int mics = Data.ScreenConfig.NumPlayerAtOnce; + Data.ScreenConfig.NumPlayer = SelectSlides[htSelectSlides(SelectSlideNumPlayers)].Selection + _PartyMode.GetMinPlayer(); + Data.ScreenConfig.NumPlayerAtOnce = SelectSlides[htSelectSlides(SelectSlideNumMics)].Selection + _PartyMode.GetMinPlayer(); + Data.ScreenConfig.NumRounds = (SelectSlides[htSelectSlides(SelectSlideNumRounds)].Selection + 1) * _RoundSteps; + + UpdateMicsAtOnce(); + SetRoundSteps(); + + if (player != Data.ScreenConfig.NumPlayer || mics != Data.ScreenConfig.NumPlayerAtOnce) + { + int num = CHelper.nCk(Data.ScreenConfig.NumPlayer, Data.ScreenConfig.NumPlayerAtOnce); + while (num > _MaxNumRounds) + { + num -= _RoundSteps; + } + Data.ScreenConfig.NumRounds = num; + } + + UpdateSlideRounds(); + } + + private void UpdateMicsAtOnce() + { + //Data.ScreenConfig.NumPlayerAtOnce + int MaxNum = _MaxNumMics; + if (Data.ScreenConfig.NumPlayer < _MaxNumMics) + MaxNum = Data.ScreenConfig.NumPlayer; + + if (Data.ScreenConfig.NumPlayerAtOnce > MaxNum) + Data.ScreenConfig.NumPlayerAtOnce = MaxNum; + + // build mics at once slide + SelectSlides[htSelectSlides(SelectSlideNumMics)].Clear(); + for (int i = 1; i <= MaxNum; i++) + { + SelectSlides[htSelectSlides(SelectSlideNumMics)].AddValue(i.ToString()); + } + SelectSlides[htSelectSlides(SelectSlideNumMics)].Selection = Data.ScreenConfig.NumPlayerAtOnce - _PartyMode.GetMinPlayer(); + } + + private void UpdateSlideRounds() + { + // build num rounds slide + SelectSlides[htSelectSlides(SelectSlideNumRounds)].Clear(); + for (int i = _RoundSteps; i <= _MaxNumRounds; i += _RoundSteps) + { + SelectSlides[htSelectSlides(SelectSlideNumRounds)].AddValue(i.ToString()); + } + SelectSlides[htSelectSlides(SelectSlideNumRounds)].Selection = Data.ScreenConfig.NumRounds / _RoundSteps - 1; + } + + private void SetRoundSteps() + { + if (Data.ScreenConfig.NumPlayerAtOnce < 1 || Data.ScreenConfig.NumPlayer < 1 || Data.ScreenConfig.NumPlayerAtOnce > Data.ScreenConfig.NumPlayer) + { + _RoundSteps = 1; + return; + } + + int res = Data.ScreenConfig.NumPlayer / Data.ScreenConfig.NumPlayerAtOnce; + int mod = Data.ScreenConfig.NumPlayer % Data.ScreenConfig.NumPlayerAtOnce; + + if (mod == 0) + _RoundSteps = res; + else + _RoundSteps = Data.ScreenConfig.NumPlayer; + } + + private void Back() + { + FadeTo(EScreens.ScreenParty); + } + + private void Next() + { + _PartyMode.DataFromScreen(_ThemeName, Data); + } + } +} diff --git a/PartyModes/PartyModeChallengeMedley/PartyScreenChallengeMain.cs b/PartyModes/PartyModeChallengeMedley/PartyScreenChallengeMain.cs new file mode 100644 index 00000000..072b82a6 --- /dev/null +++ b/PartyModes/PartyModeChallengeMedley/PartyScreenChallengeMain.cs @@ -0,0 +1,659 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; + +using Vocaluxe.Menu; + +namespace Vocaluxe.PartyModes +{ + struct TableRow + { + public CText Pos; + public CText Name; + public CText Rounds; + public CText Won; + public CText SingPoints; + public CText GamePoints; + } + + class RoundsTableRow + { + public CText Number; + public List TextPlayer; + public List TextScores; + } + + + public class PartyScreenChallengeMain : CMenuParty + { + // Version number for theme files. Increment it, if you've changed something on the theme files! + const int ScreenVersion = 1; + + const string TextPosition = "TextPosition"; + const string TextPlayerName = "TextPlayerName"; + const string TextNumPlayed = "TextNumPlayed"; + const string TextWon = "TextWon"; + const string TextSingPoints = "TextSingPoints"; + const string TextGamePoints = "TextGamePoints"; + const string TextNextPlayer = "TextNextPlayer"; + const string TextPopupReallyExit = "TextPopupReallyExit"; + const string TextRoundPlayer = "TextRoundPlayer"; + const string TextRoundScore = "TextRoundScore"; + const string TextRoundNumber = "TextRoundNumber"; + const string TextFinishMessage = "TextFinishMessage"; + const string TextFinishPlayerWin = "TextFinishPlayerWin"; + const string TextNextPlayerMessage = "TextNextPlayerMessage"; + + const string ButtonNextRound = "ButtonNextRound"; + const string ButtonBack = "ButtonBack"; + const string ButtonExit = "ButtonExit"; + const string ButtonPopupYes = "ButtonPopupYes"; + 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"; + + private bool ExitPopupVisible = false; + + private DataFromScreen Data; + private DataToScreenMain GameState; + private List PlayerTable; + private List RoundsTable; + + private List NextPlayerTexts; + private List NextPlayerStatics; + + private SRectF RoundsTableScrollArea; + private SRectF PlayerTableScrollArea; + private int RoundsTableOffset = 0; + private int PlayerTableOffset = 0; + private int NumPlayerVisible = 10; + private int NumRoundsVisible = 3; + + public PartyScreenChallengeMain() + { + Data = new DataFromScreen(); + Data.ScreenMain = new FromScreenMain(); + } + + protected override void Init() + { + base.Init(); + + _ThemeName = "PartyScreenChallengeMain"; + _ThemeTexts = new string[] { TextPosition, TextPlayerName, TextNumPlayed, TextWon, TextSingPoints, TextGamePoints, TextNextPlayer, TextPopupReallyExit, TextRoundNumber, TextRoundPlayer, TextRoundScore, TextFinishMessage, TextFinishPlayerWin, TextNextPlayerMessage }; + _ThemeButtons = new string[] { ButtonNextRound, ButtonBack, ButtonExit, ButtonPopupYes, ButtonPopupNo, ButtonPlayerScrollDown, ButtonPlayerScrollUp, ButtonRoundsScrollDown, ButtonRoundsScrollUp }; + _ThemeStatics = new string[] { StaticPopupBG, StaticNextPlayer }; + _ScreenVersion = ScreenVersion; + } + + public override void LoadTheme(string XmlPath) + { + base.LoadTheme(XmlPath); + + GameState = new DataToScreenMain(); + BuildPlayerTable(); + CreateRoundsTable(); + NextPlayerTexts = new List(); + NextPlayerStatics = new List(); + + for (int i = 0; i < _PartyMode.GetMaxPlayer(); i++) + { + NextPlayerTexts.Add(GetNewText(Texts[htTexts(TextNextPlayer)])); + AddText(NextPlayerTexts[NextPlayerTexts.Count - 1]); + NextPlayerStatics.Add(GetNewStatic(Statics[htStatics(StaticNextPlayer)])); + AddStatic(NextPlayerStatics[NextPlayerStatics.Count - 1]); + } + } + + public override void DataToScreen(object ReceivedData) + { + DataToScreenMain data = new DataToScreenMain(); + + try + { + data = (DataToScreenMain)ReceivedData; + GameState = data; + } + catch (Exception e) + { + _Base.Log.LogError("Error in party mode screen challenge main. Can't cast received data from game mode " + _ThemeName + ". " + e.Message); ; + } + + } + + public override bool HandleInput(KeyEvent KeyEvent) + { + base.HandleInput(KeyEvent); + + if (KeyEvent.KeyPressed) + { + + } + else + { + switch (KeyEvent.Key) + { + case Keys.Back: + case Keys.Escape: + if (!ExitPopupVisible) + if (GameState.CurrentRoundNr == 1) + Back(); + else + ShowPopup(true); + else + ShowPopup(false); + break; + + case Keys.Enter: + if (!ExitPopupVisible) + { + if (Buttons[htButtons(ButtonNextRound)].Selected) + NextRound(); + if (Buttons[htButtons(ButtonBack)].Selected && GameState.CurrentRoundNr == 1) + 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 + { + if (Buttons[htButtons(ButtonPopupYes)].Selected) + EndParty(); + if (Buttons[htButtons(ButtonPopupNo)].Selected) + ShowPopup(false); + } + break; + } + } + return true; + } + + public override bool HandleMouse(MouseEvent MouseEvent) + { + base.HandleMouse(MouseEvent); + + if (MouseEvent.LB && IsMouseOver(MouseEvent)) + { + if (!ExitPopupVisible) + { + if (Buttons[htButtons(ButtonNextRound)].Selected) + NextRound(); + if (Buttons[htButtons(ButtonBack)].Selected && GameState.CurrentRoundNr == 1) + 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 + { + if (Buttons[htButtons(ButtonPopupYes)].Selected) + EndParty(); + if (Buttons[htButtons(ButtonPopupNo)].Selected) + ShowPopup(false); + } + } + + if (MouseEvent.RB) + { + if (!ExitPopupVisible) + if (GameState.CurrentRoundNr == 1) + Back(); + else + ShowPopup(true); + else + ShowPopup(false); + } + + if (MouseEvent.Wheel != 0) + { + if(CHelper.IsInBounds(RoundsTableScrollArea, MouseEvent)) + ScrollRoundsTable(MouseEvent.Wheel); + if(CHelper.IsInBounds(PlayerTableScrollArea, MouseEvent)) + ScrollPlayerTable(MouseEvent.Wheel); + } + + return true; + } + + public override void OnShow() + { + base.OnShow(); + + PlayerTableOffset = 0; + RoundsTableOffset = 0; + + UpdatePlayerTable(); + UpdateNextPlayerPositions(); + UpdateNextPlayerContents(); + if (GameState.CurrentRoundNr == 1) + BuildRoundsTable(); + else + ScrollRoundsTable(GameState.CurrentRoundNr - 2); + UpdateRoundsTable(); + + if (GameState.CurrentRoundNr == 1) + { + Buttons[htButtons(ButtonBack)].Visible = true; + Buttons[htButtons(ButtonExit)].Visible = false; + } + else + { + Buttons[htButtons(ButtonBack)].Visible = false; + Buttons[htButtons(ButtonExit)].Visible = true; + } + + if (GameState.CurrentRoundNr <= GameState.Combs.Count) + { + Buttons[htButtons(ButtonNextRound)].Visible = true; + Texts[htTexts(TextFinishMessage)].Visible = false; + Texts[htTexts(TextFinishPlayerWin)].Visible = false; + SetInteractionToButton(Buttons[htButtons(ButtonNextRound)]); + } + else + { + Buttons[htButtons(ButtonNextRound)].Visible = false; + Texts[htTexts(TextFinishMessage)].Visible = true; + Texts[htTexts(TextFinishPlayerWin)].Visible = true; + Texts[htTexts(TextFinishPlayerWin)].Text = GetPlayerWinString(); + SetInteractionToButton(Buttons[htButtons(ButtonExit)]); + } + + ShowPopup(false); + } + + public override bool UpdateGame() + { + return true; + } + + public override bool Draw() + { + base.Draw(); + return true; + } + + public override void OnClose() + { + base.OnClose(); + } + + private void NextRound() + { + Data.ScreenMain.FadeToNameSelection = false; + Data.ScreenMain.FadeToSongSelection = true; + _PartyMode.DataFromScreen(_ThemeName, Data); + } + + private void EndParty() + { + FadeTo(EScreens.ScreenParty); + } + + private void ShowPopup(bool Visible) + { + ExitPopupVisible = Visible; + + Statics[htStatics(StaticPopupBG)].Visible = ExitPopupVisible; + Texts[htTexts(TextPopupReallyExit)].Visible = ExitPopupVisible; + Buttons[htButtons(ButtonPopupYes)].Visible = ExitPopupVisible; + Buttons[htButtons(ButtonPopupNo)].Visible = ExitPopupVisible; + + if (ExitPopupVisible) + SetInteractionToButton(Buttons[htButtons(ButtonPopupNo)]); + } + + private void Back() + { + Data.ScreenMain.FadeToNameSelection = true; + Data.ScreenMain.FadeToSongSelection = false; + _PartyMode.DataFromScreen(_ThemeName, Data); + } + + private void UpdateNextPlayerPositions() + { + float x = _Base.Settings.GetRenderW()/2 - ((GameState.NumPlayerAtOnce * Statics[htStatics(StaticNextPlayer)].Rect.W) + ((GameState.NumPlayerAtOnce-1) * 15))/2; + float static_y = 590; + float text_y = 550; + for (int i = 0; i < GameState.NumPlayerAtOnce; i++) + { + //static + NextPlayerStatics[i].Rect.X = x; + NextPlayerStatics[i].Rect.Y = static_y; + NextPlayerStatics[i].Visible = true; + //text + NextPlayerTexts[i].X = x + Statics[htStatics(StaticNextPlayer)].Rect.W / 2; + NextPlayerTexts[i].Y = text_y; + NextPlayerTexts[i].Visible = true; + + x += Statics[htStatics(StaticNextPlayer)].Rect.W + 15; + } + for (int i = GameState.NumPlayerAtOnce; i < _PartyMode.GetMaxPlayer(); i++) + { + NextPlayerStatics[i].Visible = false; + NextPlayerTexts[i].Visible = false; + } + } + + private void UpdateNextPlayerContents() + { + if (GameState.CurrentRoundNr <= GameState.Combs.Count) + { + Texts[htTexts(TextNextPlayerMessage)].Visible = true; + SProfile[] profiles = _Base.Profiles.GetProfiles(); + for (int i = 0; i < GameState.NumPlayerAtOnce; i++) + { + int pid = GameState.Combs[GameState.CurrentRoundNr - 1].Player[i]; + NextPlayerStatics[i].Texture = profiles[GameState.ProfileIDs[pid]].Avatar.Texture; + NextPlayerTexts[i].Text = profiles[GameState.ProfileIDs[pid]].PlayerName; + NextPlayerTexts[i].Color = _Base.Theme.GetPlayerColor((i + 1)); + } + } + else + { + Texts[htTexts(TextNextPlayerMessage)].Visible = false; + for (int i = 0; i < GameState.NumPlayerAtOnce; i++) + { + NextPlayerStatics[i].Visible = false; + NextPlayerTexts[i].Visible = false; + } + } + } + + private void CreateRoundsTable() + { + //Create lists + RoundsTable = new List(); + for (int i = 0; i < 5; i++) + { + RoundsTableRow rtr = new RoundsTableRow(); + rtr.TextPlayer = new List(); + rtr.TextScores = new List(); + RoundsTable.Add(rtr); + } + //Create statics and texts for rounds + for (int round = 0; round < RoundsTable.Count; round++) + { + //Round-number + CText text = GetNewText(Texts[htTexts(TextRoundNumber)]); + AddText(text); + RoundsTable[round].Number = text; + 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() + { + RoundsTableScrollArea = new SRectF(); + + int NumPlayerInOneRow = 3; + if (GameState.NumPlayerAtOnce <= NumPlayerInOneRow) + NumRoundsVisible = 5; + else + NumRoundsVisible = 3; + + if (NumRoundsVisible > GameState.Combs.Count) + NumRoundsVisible = GameState.Combs.Count; + + 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 + 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; + int NumPlayerInThisRow = NumPlayerInOneRow; + if (num > GameState.NumPlayerAtOnce) + { + 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; + RoundsTable[round].TextPlayer[column].X = _x; + RoundsTable[round].TextPlayer[column].Y = y; + RoundsTable[round].TextPlayer[column].MaxWidth = maxw; + //Score + 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; + } + RoundsTableScrollArea.H = y - RoundsTableScrollArea.Y; + } + + 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++) + { + if (GameState.Combs.Count > i + RoundsTableOffset && 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 + RoundsTableOffset) + RoundsTable[i].TextScores[p].Text = GameState.Results[i + RoundsTableOffset, p].ToString(); + else + RoundsTable[i].TextScores[p].Text = ""; + } + else + { + RoundsTable[i].TextPlayer[p].Visible = false; + RoundsTable[i].TextScores[p].Visible = false; + } + } + if (GameState.Combs.Count < i + RoundsTableOffset || i + 1 > NumRoundsVisible) + { + RoundsTable[i].Number.Visible = false; + for (int p = 0; p < RoundsTable[i].TextPlayer.Count; p++) + { + RoundsTable[i].TextPlayer[p].Visible = false; + RoundsTable[i].TextScores[p].Visible = false; + } + } + } + + Buttons[htButtons(ButtonRoundsScrollUp)].Visible = RoundsTableOffset > 0; + Buttons[htButtons(ButtonRoundsScrollDown)].Visible = GameState.Combs.Count - NumRoundsVisible - RoundsTableOffset > 0; + } + + 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(); + + row.Pos = GetNewText(Texts[htTexts(TextPosition)]); + row.Name = GetNewText(Texts[htTexts(TextPlayerName)]); + row.Rounds = GetNewText(Texts[htTexts(TextNumPlayed)]); + row.Won = GetNewText(Texts[htTexts(TextWon)]); + row.SingPoints = GetNewText(Texts[htTexts(TextSingPoints)]); + row.GamePoints = GetNewText(Texts[htTexts(TextGamePoints)]); + + row.Pos.Y += delta * (i + 1); + row.Name.Y += delta * (i + 1); + row.Rounds.Y += delta * (i + 1); + row.Won.Y += delta * (i + 1); + row.SingPoints.Y += delta * (i + 1); + row.GamePoints.Y += delta * (i + 1); + + row.Pos.Text = (i + 1).ToString() + "."; + + row.Pos.Visible = false; + row.Name.Visible = false; + row.Rounds.Visible = false; + row.Won.Visible = false; + row.SingPoints.Visible = false; + row.GamePoints.Visible = false; + + AddText(row.Pos); + AddText(row.Name); + AddText(row.Rounds); + AddText(row.Won); + AddText(row.SingPoints); + AddText(row.GamePoints); + + PlayerTable.Add(row); + + h = delta * (i + 1); + } + PlayerTableScrollArea.H = h + delta; + } + + private void UpdatePlayerTable() + { + SProfile[] profiles = _Base.Profiles.GetProfiles(); + + for (int i = 0; i < PlayerTable.Count; i++) + { + TableRow row = PlayerTable[i]; + + if (i+PlayerTableOffset < GameState.ResultTable.Count) + { + row.Pos.Visible = true; + row.Name.Visible = true; + row.Rounds.Visible = true; + row.Won.Visible = true; + row.SingPoints.Visible = true; + row.GamePoints.Visible = true; + + row.Pos.Text = GameState.ResultTable[i + PlayerTableOffset].Position.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].NumSingPoints.ToString(); + row.GamePoints.Text = GameState.ResultTable[i+PlayerTableOffset].NumGamePoints.ToString(); + } + else + { + row.Pos.Visible = false; + row.Name.Visible = false; + row.Rounds.Visible = false; + row.Won.Visible = false; + row.SingPoints.Visible = false; + 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) + { + if (GameState.ProfileIDs.Count <= NumPlayerVisible) + PlayerTableOffset = 0; + else 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 (GameState.Combs.Count <= NumRoundsVisible) + RoundsTableOffset = 0; + else 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(); + } + + private string GetPlayerWinString() + { + string s = ""; + SProfile[] profiles = _Base.Profiles.GetProfiles(); + + for (int i = 0; i < GameState.ResultTable.Count; i++) + { + if (i > 0) + s += ", "; + if (GameState.ResultTable[i].Position == 1) + s += profiles[GameState.ResultTable[i].PlayerID].PlayerName; + else + break; + } + + return s; + } + } +} diff --git a/PartyModes/PartyModeChallengeMedley/PartyScreenChallengeNames.cs b/PartyModes/PartyModeChallengeMedley/PartyScreenChallengeNames.cs new file mode 100644 index 00000000..f1a47548 --- /dev/null +++ b/PartyModes/PartyModeChallengeMedley/PartyScreenChallengeNames.cs @@ -0,0 +1,534 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; + +using Vocaluxe.Menu; + +namespace Vocaluxe.PartyModes +{ + public class PartyScreenChallengeNames : CMenuParty + { + // Version number for theme files. Increment it, if you've changed something on the theme files! + const int ScreenVersion = 1; + + const string ButtonNext = "ButtonNext"; + const string ButtonBack = "ButtonBack"; + const string ButtonPlayerDestination = "ButtonPlayerDestination"; + const string ButtonPlayerChoose = "ButtonPlayerChoose"; + + private List PlayerChooseButtons; + private List PlayerDestinationButtons; + //PlayerDestinationButtons-Option + private const int PlayerDestinationButtonsNumH = 3; + private const int PlayerDestinationButtonsNumW = 4; + private const int PlayerDestinationButtonsFirstX = 900; + private const int PlayerDestinationButtonsFirstY = 105; + private const int PlayerDestinationButtonsSpaceH = 15; + private const int PlayerDestinationButtonsSpaceW = 25; + //PlayerChooseButtons-Option + private List PlayerChooseButtonsVisibleProfiles; + private const int PlayerChooseButtonsNumH = 7; + private const int PlayerChooseButtonsNumW = 4; + private const int PlayerChooseButtonsFirstX = 52; + private const int PlayerChooseButtonsFirstY = 105; + private const int PlayerChooseButtonsSpaceH = 15; + private const int PlayerChooseButtonsSpaceW = 25; + private int PlayerChooseButtonsOffset = 0; + + private CStatic chooseAvatarStatic; + private bool SelectingMouseActive = false; + private int OldMouseX = 0; + private int OldMouseY = 0; + private int SelectedPlayerNr = -1; + private bool ButtonsAdded = false; + + private int NumPlayer = 4; + + private DataFromScreen Data; + + private class CPlayerChooseButton + { + public CButton Button; + public int ProfileID; + } + + public PartyScreenChallengeNames() + { + } + + protected override void Init() + { + base.Init(); + + chooseAvatarStatic = GetNewStatic(); + chooseAvatarStatic.Visible = false; + + PlayerChooseButtonsVisibleProfiles = new List(); + + Data.ScreenNames.ProfileIDs = new List(); + + _ThemeName = "PartyScreenChallengeNames"; + List buttons = new List(); + _ThemeButtons = new string[] { ButtonBack, ButtonNext, ButtonPlayerDestination, ButtonPlayerChoose }; + _ScreenVersion = ScreenVersion; + + Data = new DataFromScreen(); + FromScreenNames names = new FromScreenNames(); + names.FadeToConfig = false; + names.FadeToMain = false; + names.ProfileIDs = new List(); + Data.ScreenNames = names; + } + + public override void LoadTheme(string XmlPath) + { + base.LoadTheme(XmlPath); + } + + public override void DataToScreen(object ReceivedData) + { + DataToScreenNames config = new DataToScreenNames(); + + try + { + config = (DataToScreenNames)ReceivedData; + Data.ScreenNames.ProfileIDs = config.ProfileIDs; + if (Data.ScreenNames.ProfileIDs == null) + Data.ScreenNames.ProfileIDs = new List(); + + NumPlayer = config.NumPlayer; + + while (Data.ScreenNames.ProfileIDs.Count > NumPlayer) + { + Data.ScreenNames.ProfileIDs.RemoveAt(Data.ScreenNames.ProfileIDs.Count - 1); + } + + + } + catch (Exception e) + { + _Base.Log.LogError("Error in party mode screen challenge names. Can't cast received data from game mode " + _ThemeName + ". " + e.Message); ; + } + + } + + public override bool HandleInput(KeyEvent KeyEvent) + { + base.HandleInput(KeyEvent); + + if (KeyEvent.KeyPressed) + { + + } + else + { + switch (KeyEvent.Key) + { + case Keys.Back: + case Keys.Escape: + Back(); + break; + + case Keys.Enter: + if (Buttons[htButtons(ButtonBack)].Selected) + Back(); + + if (Buttons[htButtons(ButtonNext)].Selected) + Next(); + + if (!OnAdd()) + OnRemove(); + break; + + case Keys.Delete: + OnRemove(); + break; + } + } + return true; + } + + public override bool HandleMouse(MouseEvent MouseEvent) + { + base.HandleMouse(MouseEvent); + + /* + //Check if LeftButton is hold and Select-Mode inactive + if (MouseEvent.LBH && !SelectingMouseActive) + { + //Save mouse-coords + OldMouseX = MouseEvent.X; + OldMouseY = MouseEvent.Y; + //Check if mouse if over tile + for (int i = 0; i < PlayerChooseButtons.Count; i++) + { + if (PlayerChooseButtons[i].Button.Selected) + { + SelectedPlayerNr = PlayerChooseButtons[i].ProfileID; + if (SelectedPlayerNr != -1) + { + //Activate mouse-selecting + SelectingMouseActive = true; + //Update of Drag/Drop-Texture + chooseAvatarStatic.Visible = true; + chooseAvatarStatic.Rect = PlayerChooseButtons[i].Button.Rect; + chooseAvatarStatic.Rect.Z = -100; + chooseAvatarStatic.Color = new SColorF(1, 1, 1, 1); + chooseAvatarStatic.Texture = _Base.Profiles.GetProfiles()[SelectedPlayerNr].Avatar.Texture; + } + } + } + }*/ + + //Check if LeftButton is hold and Select-Mode active + if (MouseEvent.LBH && SelectingMouseActive) + { + //Update coords for Drag/Drop-Texture + chooseAvatarStatic.Rect.X += (MouseEvent.X - OldMouseX); + chooseAvatarStatic.Rect.Y += (MouseEvent.Y - OldMouseY); + OldMouseX = MouseEvent.X; + OldMouseY = MouseEvent.Y; + } + // LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar + else if (SelectingMouseActive) + { + //Check if really a player was selected + if (SelectedPlayerNr != -1) + { + //Foreach Drop-Area + for (int i = 0; i < PlayerDestinationButtons.Count; i++) + { + //Check first, if area is "active" + if (PlayerDestinationButtons[i].Visible == true) + { + //Check if Mouse is in area + if (CHelper.IsInBounds(PlayerDestinationButtons[i].Rect, MouseEvent)) + { + int added = -1; + //Add Player-ID to list. + if (Data.ScreenNames.ProfileIDs.Count < (i + 1)) + { + Data.ScreenNames.ProfileIDs.Add(SelectedPlayerNr); + added = Data.ScreenNames.ProfileIDs.Count - 1; + } + else if (Data.ScreenNames.ProfileIDs.Count >= (i + 1)) + { + Data.ScreenNames.ProfileIDs[i] = SelectedPlayerNr; + added = i; + } + UpdateButtonNext(); + //Update texture and name + PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f); + PlayerDestinationButtons[added].SColor = new SColorF(1, 1, 1, 1); + PlayerDestinationButtons[added].Texture = chooseAvatarStatic.Texture; + PlayerDestinationButtons[added].STexture = chooseAvatarStatic.Texture; + PlayerDestinationButtons[added].Text.Text = _Base.Profiles.GetProfiles()[SelectedPlayerNr].PlayerName; + //Update Tiles-List + UpdateButtonPlayerChoose(); + } + } + } + SelectedPlayerNr = -1; + } + //Reset variables + SelectingMouseActive = false; + chooseAvatarStatic.Visible = false; + } + + if (MouseEvent.LB && IsMouseOver(MouseEvent)) + { + if (Buttons[htButtons(ButtonBack)].Selected) + Back(); + + if (Buttons[htButtons(ButtonNext)].Selected) + Next(); + + if (!OnAdd()) + OnRemove(); + } + + if (MouseEvent.RB) + { + Back(); + } + + return true; + } + + public override void OnShow() + { + base.OnShow(); + + if (!ButtonsAdded) + { + AddButtonPlayerDestination(); + AddButtonPlayerChoose(); + ButtonsAdded = true; + } + + UpdateButtonPlayerDestination(); + UpdateButtonPlayerChoose(); + + UpdateButtonNext(); + } + + public override bool UpdateGame() + { + return true; + } + + public override bool Draw() + { + base.Draw(); + if (chooseAvatarStatic.Visible) + chooseAvatarStatic.Draw(); + return true; + } + + public override void OnClose() + { + base.OnClose(); + } + + private void AddButtonPlayerDestination() + { + Buttons[htButtons(ButtonPlayerDestination)].Visible = false; + PlayerDestinationButtons = new List(); + int row = 0; + int column = 0; + for (int i = 1; i <= _PartyMode.GetMaxPlayer(); i++) + { + CButton b = GetNewButton(Buttons[htButtons(ButtonPlayerDestination)]); + b.Rect.X = PlayerDestinationButtonsFirstX + column * (b.Rect.W + PlayerDestinationButtonsSpaceH); + b.Rect.Y = PlayerDestinationButtonsFirstY + row * (b.Rect.H + PlayerDestinationButtonsSpaceW); + PlayerDestinationButtons.Add(b); + column++; + if (column >= PlayerDestinationButtonsNumH) + { + row++; + column = 0; + } + b.Visible = true; + b.Enabled = false; + AddButton(b); + } + } + + private void AddButtonPlayerChoose() + { + Buttons[htButtons(ButtonPlayerChoose)].Visible = false; + PlayerChooseButtons = new List(); + int row = 0; + int column = 0; + for (int i = 1; i <= PlayerChooseButtonsNumH * PlayerChooseButtonsNumW; i++) + { + CButton b = GetNewButton(Buttons[htButtons(ButtonPlayerChoose)]); + b.Rect.X = PlayerChooseButtonsFirstX + column * (b.Rect.W + PlayerChooseButtonsSpaceH); + b.Rect.Y = PlayerChooseButtonsFirstY + row * (b.Rect.H + PlayerChooseButtonsSpaceW); + CPlayerChooseButton pcb = new CPlayerChooseButton(); + pcb.Button = b; + pcb.ProfileID = -1; + PlayerChooseButtons.Add(pcb); + column++; + if (column >= PlayerChooseButtonsNumH) + { + row++; + column = 0; + } + b.Visible = true; + b.Enabled = false; + AddButton(b); + } + } + + private void UpdateButtonPlayerChoose() + { + UpdateVisibleProfiles(); + if ((PlayerChooseButtonsNumW * PlayerChooseButtonsNumH) * (PlayerChooseButtonsOffset + 1) - PlayerChooseButtonsVisibleProfiles.Count >= (PlayerChooseButtonsNumW * PlayerChooseButtonsNumH) * PlayerChooseButtonsOffset) + { + UpdateButtonPlayerChoose(PlayerChooseButtonsOffset - 1); + } + else + { + UpdateButtonPlayerChoose(PlayerChooseButtonsOffset); + } + } + + private void UpdateButtonPlayerChoose(int Offset) + { + int NumButtonPlayerChoose = PlayerChooseButtonsNumW * PlayerChooseButtonsNumH; + if (Offset < 0) + Offset = 0; + + if (NumButtonPlayerChoose * (Offset + 1) - PlayerChooseButtonsVisibleProfiles.Count <= NumButtonPlayerChoose) + { + for (int i = 0; i < NumButtonPlayerChoose; i++) + { + if ((i + Offset * NumButtonPlayerChoose) < PlayerChooseButtonsVisibleProfiles.Count) + { + PlayerChooseButtons[i].ProfileID = PlayerChooseButtonsVisibleProfiles[i + Offset * NumButtonPlayerChoose]; + PlayerChooseButtons[i].Button.Text.Text = _Base.Profiles.GetProfiles()[PlayerChooseButtonsVisibleProfiles[i + Offset * NumButtonPlayerChoose]].PlayerName; + PlayerChooseButtons[i].Button.Texture = _Base.Profiles.GetProfiles()[PlayerChooseButtonsVisibleProfiles[i + Offset * NumButtonPlayerChoose]].Avatar.Texture; + PlayerChooseButtons[i].Button.STexture = _Base.Profiles.GetProfiles()[PlayerChooseButtonsVisibleProfiles[i + Offset * NumButtonPlayerChoose]].Avatar.Texture; + PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f); + PlayerChooseButtons[i].Button.SColor = new SColorF(1, 1, 1, 1); + PlayerChooseButtons[i].Button.Enabled = true; + } + else + { + PlayerChooseButtons[i].ProfileID = -1; + PlayerChooseButtons[i].Button.Text.Text = String.Empty; + PlayerChooseButtons[i].Button.Texture = Buttons[htButtons(ButtonPlayerChoose)].Texture; + PlayerChooseButtons[i].Button.STexture = Buttons[htButtons(ButtonPlayerChoose)].STexture; + PlayerChooseButtons[i].Button.Color = Buttons[htButtons(ButtonPlayerChoose)].Color; + PlayerChooseButtons[i].Button.SColor = Buttons[htButtons(ButtonPlayerChoose)].SColor; + PlayerChooseButtons[i].Button.Enabled = false; + } + } + } + } + + private void UpdateVisibleProfiles() + { + PlayerChooseButtonsVisibleProfiles.Clear(); + for (int i = 0; i < _Base.Profiles.GetProfiles().Length; i++) + { + bool visible = false; + //Show profile only if active + if (_Base.Profiles.GetProfiles()[i].Active == EOffOn.TR_CONFIG_ON) + { + visible = true; + + for (int p = 0; p < Data.ScreenNames.ProfileIDs.Count; p++) + { + //Don't show profile if is selected + if (Data.ScreenNames.ProfileIDs[p] == i) + { + visible = false; + break; + } + } + } + if (visible) + { + PlayerChooseButtonsVisibleProfiles.Add(i); + } + } + } + + private void UpdateButtonPlayerDestination() + { + for (int i = 0; i < PlayerDestinationButtons.Count; i++) + { + if (NumPlayer > i) + { + PlayerDestinationButtons[i].Visible = true; + PlayerDestinationButtons[i].Enabled = true; + } + else + { + PlayerDestinationButtons[i].Visible = false; + PlayerDestinationButtons[i].Enabled = false; + } + } + for (int i = 0; i < NumPlayer; i++) + { + if (i < Data.ScreenNames.ProfileIDs.Count) + { + if (Data.ScreenNames.ProfileIDs[i] != -1) + { + PlayerDestinationButtons[i].Color = new SColorF(1, 1, 1, 0.6f); + PlayerDestinationButtons[i].SColor = new SColorF(1, 1, 1, 1); + PlayerDestinationButtons[i].Texture = _Base.Profiles.GetProfiles()[Data.ScreenNames.ProfileIDs[i]].Avatar.Texture; + PlayerDestinationButtons[i].STexture = _Base.Profiles.GetProfiles()[Data.ScreenNames.ProfileIDs[i]].Avatar.Texture; + PlayerDestinationButtons[i].Text.Text = _Base.Profiles.GetProfiles()[Data.ScreenNames.ProfileIDs[i]].PlayerName; + PlayerDestinationButtons[i].Enabled = true; + } + } + else + { + PlayerDestinationButtons[i].Color = Buttons[htButtons(ButtonPlayerDestination)].Color; + PlayerDestinationButtons[i].SColor = Buttons[htButtons(ButtonPlayerDestination)].SColor; + PlayerDestinationButtons[i].Texture = Buttons[htButtons(ButtonPlayerDestination)].Texture; + PlayerDestinationButtons[i].STexture = Buttons[htButtons(ButtonPlayerDestination)].STexture; + PlayerDestinationButtons[i].Text.Text = String.Empty; + PlayerDestinationButtons[i].Enabled = false; + } + } + } + + private void UpdateButtonNext() + { + if (Data.ScreenNames.ProfileIDs.Count == NumPlayer) + { + Buttons[htButtons(ButtonNext)].Visible = true; + SetInteractionToButton(Buttons[htButtons(ButtonNext)]); + } + else + Buttons[htButtons(ButtonNext)].Visible = false; + } + + private bool OnAdd() + { + for (int i = 0; i < PlayerChooseButtons.Count; i++) + { + if (PlayerChooseButtons[i].Button.Selected && PlayerChooseButtons[i].ProfileID != -1) + { + if (Data.ScreenNames.ProfileIDs.Count < NumPlayer) + { + Data.ScreenNames.ProfileIDs.Add(PlayerChooseButtons[i].ProfileID); + int added = Data.ScreenNames.ProfileIDs.Count - 1; + UpdateButtonNext(); + //Update texture and name + PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f); + PlayerDestinationButtons[added].SColor = new SColorF(1, 1, 1, 1); + PlayerDestinationButtons[added].Texture = _Base.Profiles.GetProfiles()[PlayerChooseButtons[i].ProfileID].Avatar.Texture; + PlayerDestinationButtons[added].STexture = _Base.Profiles.GetProfiles()[PlayerChooseButtons[i].ProfileID].Avatar.Texture; + PlayerDestinationButtons[added].Text.Text = _Base.Profiles.GetProfiles()[PlayerChooseButtons[i].ProfileID].PlayerName; + PlayerDestinationButtons[added].Enabled = true; + //Update Tiles-List + UpdateButtonPlayerChoose(); + CheckInteraction(); + return true; + } + } + } + return false; + } + + private bool OnRemove() + { + for (int i = 0; i < PlayerDestinationButtons.Count; i++) + { + if (PlayerDestinationButtons[i].Selected) + { + if ((i + 1) <= Data.ScreenNames.ProfileIDs.Count) + { + Data.ScreenNames.ProfileIDs.RemoveAt(i); + UpdateButtonNext(); + UpdateButtonPlayerDestination(); + UpdateButtonPlayerChoose(); + CheckInteraction(); + return true; + } + } + } + return false; + } + + private void Back() + { + Data.ScreenNames.FadeToConfig = true; + Data.ScreenNames.FadeToMain = false; + _PartyMode.DataFromScreen(_ThemeName, Data); + } + + private void Next() + { + Data.ScreenNames.FadeToConfig = false; + Data.ScreenNames.FadeToMain = true; + _PartyMode.DataFromScreen(_ThemeName, Data); + } + } +} diff --git a/Vocaluxe.sln b/Vocaluxe.sln index e8b0335b..3714a400 100644 --- a/Vocaluxe.sln +++ b/Vocaluxe.sln @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PartyModeTicTacToe", "Party EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PartyModeChallenge", "PartyModes\PartyModeChallenge\PartyModeChallenge.csproj", "{5A4053F1-5AD5-441F-B254-D97A088127B6}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PartyModeChallengeMedley", "PartyModes\PartyModeChallengeMedley\PartyModeChallengeMedley.csproj", "{6F3E1874-F28A-40E9-AFBD-31934D593678}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution DebugLinux|x64 = DebugLinux|x64 @@ -89,6 +91,22 @@ Global {5A4053F1-5AD5-441F-B254-D97A088127B6}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 {5A4053F1-5AD5-441F-B254-D97A088127B6}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 {5A4053F1-5AD5-441F-B254-D97A088127B6}.ReleaseWin|x86.Build.0 = ReleaseWin|x86 + {6F3E1874-F28A-40E9-AFBD-31934D593678}.DebugLinux|x64.ActiveCfg = DebugLinux|x64 + {6F3E1874-F28A-40E9-AFBD-31934D593678}.DebugLinux|x64.Build.0 = DebugLinux|x64 + {6F3E1874-F28A-40E9-AFBD-31934D593678}.DebugLinux|x86.ActiveCfg = DebugLinux|x86 + {6F3E1874-F28A-40E9-AFBD-31934D593678}.DebugLinux|x86.Build.0 = DebugLinux|x86 + {6F3E1874-F28A-40E9-AFBD-31934D593678}.DebugWin|x64.ActiveCfg = DebugWin|x64 + {6F3E1874-F28A-40E9-AFBD-31934D593678}.DebugWin|x64.Build.0 = DebugWin|x64 + {6F3E1874-F28A-40E9-AFBD-31934D593678}.DebugWin|x86.ActiveCfg = DebugWin|x86 + {6F3E1874-F28A-40E9-AFBD-31934D593678}.DebugWin|x86.Build.0 = DebugWin|x86 + {6F3E1874-F28A-40E9-AFBD-31934D593678}.ReleaseLinux|x64.ActiveCfg = ReleaseLinux|x64 + {6F3E1874-F28A-40E9-AFBD-31934D593678}.ReleaseLinux|x64.Build.0 = ReleaseLinux|x64 + {6F3E1874-F28A-40E9-AFBD-31934D593678}.ReleaseLinux|x86.ActiveCfg = ReleaseLinux|x86 + {6F3E1874-F28A-40E9-AFBD-31934D593678}.ReleaseLinux|x86.Build.0 = ReleaseLinux|x86 + {6F3E1874-F28A-40E9-AFBD-31934D593678}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 + {6F3E1874-F28A-40E9-AFBD-31934D593678}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 + {6F3E1874-F28A-40E9-AFBD-31934D593678}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 + {6F3E1874-F28A-40E9-AFBD-31934D593678}.ReleaseWin|x86.Build.0 = ReleaseWin|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index fd63e4d3..816ccb83 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -483,6 +483,11 @@ namespace Vocaluxe.Base return CGame.Player; } + public CPoints GetPoints() + { + return CGame.GetPoints(); + } + public float GetMidBeatD() { return CGame.MidBeatD; @@ -547,6 +552,11 @@ namespace Vocaluxe.Base class BSongs : ISongs { + public int GetNumSongs() + { + return CSongs.NumAllSongs; + } + public int GetNumVisibleSongs() { return CSongs.NumVisibleSongs; @@ -604,6 +614,16 @@ namespace Vocaluxe.Base return new CSong(CSongs.GetSong(SongID)); } + public CSong[] GetSongs() + { + return CSongs.AllSongs; + } + + public CSong[] GetSongsNotSung() + { + return CSongs.SongsNotSung; + } + public CCategory GetCategory(int Index) { if (Index >= CSongs.NumCategories) @@ -627,6 +647,11 @@ namespace Vocaluxe.Base CSongs.ResetPartySongSung(CatIndex); } + public void SortSongs(ESongSorting Sorting, EOffOn Tabs, EOffOn IgnoreArticles, String SearchString, bool ShowDuetSongs) + { + CSongs.Sort(Sorting, Tabs, IgnoreArticles, SearchString, ShowDuetSongs); + } + public void NextCategory() { CSongs.NextCategory(); @@ -746,21 +771,16 @@ namespace Vocaluxe.Base class BPlaylist : IPlaylist { - public string[] GetPlaylistNames() - { - List Names = new List(); - for (int i = 0; i < CPlaylists.Playlists.Length; i++) - { - Names.Add(CPlaylists.Playlists[i].PlaylistName); - } - return Names.ToArray(); - } - public void SetPlaylistName(int PlaylistID, string Name) { CPlaylists.SetPlaylistName(PlaylistID, Name); } + public string[] GetPlaylistNames() + { + return CPlaylists.GetPlaylistNames(); + } + public string GetPlaylistName(int PlaylistID) { return CPlaylists.GetPlaylistName(PlaylistID); diff --git a/Vocaluxe/Base/CPlaylists.cs b/Vocaluxe/Base/CPlaylists.cs index d4aed0db..4a7fb088 100644 --- a/Vocaluxe/Base/CPlaylists.cs +++ b/Vocaluxe/Base/CPlaylists.cs @@ -84,6 +84,18 @@ namespace Vocaluxe.Base return _Playlists[PlaylistID].PlaylistName; } + public static string[] GetPlaylistNames() + { + List result = new List(); + + foreach (CPlaylistFile playlist in _Playlists) + { + result.Add(playlist.PlaylistName); + } + + return result.ToArray(); + } + public static void SetPlaylistName(int PlaylistID, string Name) { if (PlaylistID >= _Playlists.Count || PlaylistID < 0) diff --git a/Vocaluxe/Base/CSongs.cs b/Vocaluxe/Base/CSongs.cs index a265098b..4bb2e2ed 100644 --- a/Vocaluxe/Base/CSongs.cs +++ b/Vocaluxe/Base/CSongs.cs @@ -348,6 +348,20 @@ namespace Vocaluxe.Base get { return _Songs.ToArray(); } } + public static CSong[] SongsNotSung + { + get + { + List songs = new List(); + foreach (SongPointer sp in _SongsSortList) + { + if (sp.Visible) + songs.Add(_Songs[sp.SongID]); + } + return songs.ToArray(); + } + } + public static CSong[] VisibleSongs { get diff --git a/Vocaluxe/GameModes/CGameMode.cs b/Vocaluxe/GameModes/CGameMode.cs index bac7fb6e..a69065ae 100644 --- a/Vocaluxe/GameModes/CGameMode.cs +++ b/Vocaluxe/GameModes/CGameMode.cs @@ -20,89 +20,6 @@ namespace Vocaluxe.GameModes } } - class CPoints - { - private SPlayer[,] _Rounds; - - public CPoints(int NumRounds, SPlayer[] Player) - { - _Rounds = new SPlayer[NumRounds, Player.Length]; - - for (int round = 0; round < NumRounds; round++) - { - for (int player = 0; player < Player.Length; player++) - { - _Rounds[round, player].ProfileID = Player[player].ProfileID; - _Rounds[round, player].Name = Player[player].Name; - _Rounds[round, player].Difficulty = Player[player].Difficulty; - _Rounds[round, player].Points = 0f; - _Rounds[round, player].PointsGoldenNotes = 0f; - _Rounds[round, player].PointsLineBonus = 0f; - _Rounds[round, player].Medley = false; - _Rounds[round, player].Duet = false; - _Rounds[round, player].ShortSong = false; - _Rounds[round, player].SongFinished = false; - } - } - } - - public void SetPoints(int Round, int SongID, SPlayer[] Player, bool Medley, bool Duet, bool ShortSong) - { - long DateTicks = DateTime.Now.Ticks; - for (int player = 0; player < Player.Length; player++) - { - _Rounds[Round, player].SongID = SongID; - _Rounds[Round, player].LineNr = Player[player].LineNr; - _Rounds[Round, player].Points = Player[player].Points; - _Rounds[Round, player].PointsGoldenNotes = Player[player].PointsGoldenNotes; - _Rounds[Round, player].PointsLineBonus = Player[player].PointsLineBonus; - _Rounds[Round, player].Medley = Medley; - _Rounds[Round, player].Duet = Duet; - _Rounds[Round, player].ShortSong = ShortSong; - _Rounds[Round, player].DateTicks = DateTicks; - _Rounds[Round, player].SongFinished = Player[player].SongFinished; - } - } - - public int NumRounds - { - get { return _Rounds.GetLength(0); } - } - - public int NumPlayer - { - get { return _Rounds.GetLength(1); } - } - - public SPlayer[] GetPlayer(int Round, int numPlayer) - { - if (NumPlayer == 0) - return new SPlayer[1]; - if (Round >= NumRounds) - return new SPlayer[1]; - - SPlayer[] player = new SPlayer[numPlayer]; - - for (int p = 0; p < player.Length; p++) - { - player[p].Name = _Rounds[Round, p].Name; - player[p].Points = _Rounds[Round, p].Points; - player[p].PointsGoldenNotes = _Rounds[Round, p].PointsGoldenNotes; - player[p].PointsLineBonus = _Rounds[Round, p].PointsLineBonus; - player[p].SongID = _Rounds[Round, p].SongID; - player[p].LineNr = _Rounds[Round, p].LineNr; - player[p].Difficulty = _Rounds[Round, p].Difficulty; - player[p].Medley = _Rounds[Round, p].Medley; - player[p].Duet = _Rounds[Round, p].Duet; - player[p].ShortSong = _Rounds[Round, p].ShortSong; - player[p].DateTicks = _Rounds[Round, p].DateTicks; - player[p].SongFinished = _Rounds[Round, p].SongFinished; - player[p].ProfileID = _Rounds[Round, p].ProfileID; - } - return player; - } - } - abstract class CGameMode : IGameMode { protected bool _Initialized = false; diff --git a/Vocaluxe/Screens/CScreenScore.cs b/Vocaluxe/Screens/CScreenScore.cs index 7f73ead5..3e8abc60 100644 --- a/Vocaluxe/Screens/CScreenScore.cs +++ b/Vocaluxe/Screens/CScreenScore.cs @@ -311,7 +311,7 @@ namespace Vocaluxe.Screens } for (int p = 0; p < player.Length; p++) { - player[p].Points = (int)(player[p].Points / CGame.NumRounds); + player[p].Points = (int)Math.Round((player[p].Points / CGame.NumRounds)); } } diff --git a/VocaluxeLib/Menu/IMenu.cs b/VocaluxeLib/Menu/IMenu.cs index 1336872f..609a2361 100644 --- a/VocaluxeLib/Menu/IMenu.cs +++ b/VocaluxeLib/Menu/IMenu.cs @@ -198,6 +198,7 @@ namespace Vocaluxe.Menu int GetNumPlayer(); void SetNumPlayer(int NumPlayer); SPlayer[] GetPlayer(); + CPoints GetPoints(); float GetMidBeatD(); int GetCurrentBeatD(); @@ -224,6 +225,7 @@ namespace Vocaluxe.Menu public interface ISongs { + int GetNumSongs(); int GetNumVisibleSongs(); int GetNumCategories(); int NumSongsInCategory(int CategoryIndex); @@ -237,12 +239,16 @@ namespace Vocaluxe.Menu CSong GetVisibleSong(int VisibleIndex); CSong GetSongByID(int SongID); + CSong[] GetSongs(); + CSong[] GetSongsNotSung(); CCategory GetCategory(int Index); void AddPartySongSung(int SongID); void ResetPartySongSung(); void ResetPartySongSung(int CatIndex); + void SortSongs(ESongSorting Sorting, EOffOn Tabs, EOffOn IgnoreArticles, String SearchString, bool ShowDuetSongs); + void NextCategory(); void PrevCategory(); } @@ -289,14 +295,14 @@ namespace Vocaluxe.Menu public interface IPlaylist { + string GetPlaylistName(int PlaylistID); string[] GetPlaylistNames(); - string GetPlaylistName(int PlaylistID); void SetPlaylistName(int PlaylistID, string Name); void DeletePlaylist(int PlaylistID); void SavePlaylist(int PlaylistID); int GetNumPlaylists(); - + void AddPlaylistSong(int PlaylistID, int SongID); void AddPlaylistSong(int PlaylistID, int SongID, EGameMode GameMode); void InsertPlaylistSong(int PlaylistID, int PositionIndex, int SongID, EGameMode GameMode); @@ -808,6 +814,89 @@ namespace Vocaluxe.Menu public bool SongFinished; } + public class CPoints + { + private SPlayer[,] _Rounds; + + public CPoints(int NumRounds, SPlayer[] Player) + { + _Rounds = new SPlayer[NumRounds, Player.Length]; + + for (int round = 0; round < NumRounds; round++) + { + for (int player = 0; player < Player.Length; player++) + { + _Rounds[round, player].ProfileID = Player[player].ProfileID; + _Rounds[round, player].Name = Player[player].Name; + _Rounds[round, player].Difficulty = Player[player].Difficulty; + _Rounds[round, player].Points = 0f; + _Rounds[round, player].PointsGoldenNotes = 0f; + _Rounds[round, player].PointsLineBonus = 0f; + _Rounds[round, player].Medley = false; + _Rounds[round, player].Duet = false; + _Rounds[round, player].ShortSong = false; + _Rounds[round, player].SongFinished = false; + } + } + } + + public void SetPoints(int Round, int SongID, SPlayer[] Player, bool Medley, bool Duet, bool ShortSong) + { + long DateTicks = DateTime.Now.Ticks; + for (int player = 0; player < Player.Length; player++) + { + _Rounds[Round, player].SongID = SongID; + _Rounds[Round, player].LineNr = Player[player].LineNr; + _Rounds[Round, player].Points = Player[player].Points; + _Rounds[Round, player].PointsGoldenNotes = Player[player].PointsGoldenNotes; + _Rounds[Round, player].PointsLineBonus = Player[player].PointsLineBonus; + _Rounds[Round, player].Medley = Medley; + _Rounds[Round, player].Duet = Duet; + _Rounds[Round, player].ShortSong = ShortSong; + _Rounds[Round, player].DateTicks = DateTicks; + _Rounds[Round, player].SongFinished = Player[player].SongFinished; + } + } + + public int NumRounds + { + get { return _Rounds.GetLength(0); } + } + + public int NumPlayer + { + get { return _Rounds.GetLength(1); } + } + + public SPlayer[] GetPlayer(int Round, int numPlayer) + { + if (NumPlayer == 0) + return new SPlayer[1]; + if (Round >= NumRounds) + return new SPlayer[1]; + + SPlayer[] player = new SPlayer[numPlayer]; + + for (int p = 0; p < player.Length; p++) + { + player[p].Name = _Rounds[Round, p].Name; + player[p].Points = _Rounds[Round, p].Points; + player[p].PointsGoldenNotes = _Rounds[Round, p].PointsGoldenNotes; + player[p].PointsLineBonus = _Rounds[Round, p].PointsLineBonus; + player[p].SongID = _Rounds[Round, p].SongID; + player[p].LineNr = _Rounds[Round, p].LineNr; + player[p].Difficulty = _Rounds[Round, p].Difficulty; + player[p].Medley = _Rounds[Round, p].Medley; + player[p].Duet = _Rounds[Round, p].Duet; + player[p].ShortSong = _Rounds[Round, p].ShortSong; + player[p].DateTicks = _Rounds[Round, p].DateTicks; + player[p].SongFinished = _Rounds[Round, p].SongFinished; + player[p].ProfileID = _Rounds[Round, p].ProfileID; + } + return player; + } + } + public struct SScores { public string Name;