Fix wrong song played in TicTacToe

This commit is contained in:
Flamefire committed 2014-12-07 23:05:06 +01:00
1 parent 3402c7b4c4
commit 5f96ac77b5
2 files changed
+65 -77

No files matched your search

@@ -17,6 +17,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -105,7 +106,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public List<int> Songs; public List<int> Songs;
public int CurrentRoundNr; public int CurrentRoundNr;
public int SingRoundNr; public int FieldNr;
public int[] NumJokerRandom; public int[] NumJokerRandom;
public int[] NumJokerRetry; public int[] NumJokerRetry;
@@ -136,7 +137,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
PlayerTeam1 = new List<int>(), PlayerTeam1 = new List<int>(),
PlayerTeam2 = new List<int>(), PlayerTeam2 = new List<int>(),
CurrentRoundNr = 0, CurrentRoundNr = 0,
SingRoundNr = 0, FieldNr = 0,
SongSource = ESongSource.TR_ALLSONGS, SongSource = ESongSource.TR_ALLSONGS,
PlaylistID = 0, PlaylistID = 0,
CategoryID = 0, CategoryID = 0,
@@ -195,7 +196,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _FadeToScreen() private void _FadeToScreen()
{ {
if(CBase.Graphics.GetNextScreen() != _GetNextScreen()) if (CBase.Graphics.GetNextScreen() != _GetNextScreen())
CBase.Graphics.FadeTo(_GetNextScreen()); CBase.Graphics.FadeTo(_GetNextScreen());
} }
@@ -218,7 +219,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
break; break;
case EStage.Main: case EStage.Main:
_Stage = EStage.Singing; _Stage = EStage.Singing;
_StartRound(GameData.SingRoundNr); _StartRound(GameData.FieldNr);
break; break;
case EStage.Singing: case EStage.Singing:
_Stage = EStage.Main; _Stage = EStage.Main;
@@ -258,31 +259,22 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public override SScreenSongOptions GetScreenSongOptions() public override SScreenSongOptions GetScreenSongOptions()
{ {
_ScreenSongOptions.Sorting.SongSorting = CBase.Config.GetSongSorting(); throw new ArgumentException("Not required!");
_ScreenSongOptions.Sorting.Tabs = CBase.Config.GetTabs();
_ScreenSongOptions.Sorting.IgnoreArticles = CBase.Config.GetIgnoreArticles();
return _ScreenSongOptions;
} }
// ReSharper disable RedundantAssignment
public override void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions) public override void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions)
// ReSharper restore RedundantAssignment
{ {
screenSongOptions = _ScreenSongOptions; throw new ArgumentException("Not required!");
} }
// ReSharper disable RedundantAssignment
public override void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions) public override void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions)
// ReSharper restore RedundantAssignment
{ {
screenSongOptions = _ScreenSongOptions; throw new ArgumentException("Not required!");
} }
public override void SetSearchString(string searchString, bool visible) public override void SetSearchString(string searchString, bool visible)
{ {
_ScreenSongOptions.Sorting.SearchString = searchString; throw new ArgumentException("Not required!");
_ScreenSongOptions.Sorting.SearchActive = visible;
} }
public override int GetMaxPlayer() public override int GetMaxPlayer()
@@ -324,25 +316,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public override void SongSelected(int songID) public override void SongSelected(int songID)
{ {
var gm = EGameMode.TR_GAMEMODE_NORMAL; throw new ArgumentException("Not required!");
switch (GameData.GameMode)
{
case EPartyGameMode.TR_GAMEMODE_NORMAL:
gm = EGameMode.TR_GAMEMODE_NORMAL;
break;
case EPartyGameMode.TR_GAMEMODE_DUET:
gm = EGameMode.TR_GAMEMODE_DUET;
break;
case EPartyGameMode.TR_GAMEMODE_SHORTSONG:
gm = EGameMode.TR_GAMEMODE_SHORTSONG;
break;
}
CBase.Game.AddSong(songID, gm);
CBase.Graphics.FadeTo(EScreen.Sing);
} }
public override void LeavingHighscore() public override void LeavingHighscore()
@@ -559,8 +533,8 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (players.Length < 2) if (players.Length < 2)
return; return;
CRound r = GameData.Rounds[roundNr]; CRound round = GameData.Rounds[roundNr];
bool isDuet = CBase.Songs.GetSongByID(r.SongID).IsDuet; bool isDuet = CBase.Songs.GetSongByID(round.SongID).IsDuet;
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
@@ -569,18 +543,31 @@ namespace VocaluxeLib.PartyModes.TicTacToe
} }
//try to fill with the right data //try to fill with the right data
if (r != null) players[0].ProfileID = GameData.ProfileIDsTeam1[round.SingerTeam1];
if (isDuet)
players[0].VoiceNr = 0;
players[1].ProfileID = GameData.ProfileIDsTeam2[round.SingerTeam2];
if (isDuet)
players[1].VoiceNr = 1;
var gm = EGameMode.TR_GAMEMODE_NORMAL;
switch (GameData.GameMode)
{ {
players[0].ProfileID = GameData.ProfileIDsTeam1[r.SingerTeam1]; case EPartyGameMode.TR_GAMEMODE_NORMAL:
if (isDuet) gm = EGameMode.TR_GAMEMODE_NORMAL;
players[0].VoiceNr = 0; break;
players[1].ProfileID = GameData.ProfileIDsTeam2[r.SingerTeam2]; case EPartyGameMode.TR_GAMEMODE_DUET:
if (isDuet) gm = EGameMode.TR_GAMEMODE_DUET;
players[1].VoiceNr = 1; break;
SongSelected(r.SongID); case EPartyGameMode.TR_GAMEMODE_SHORTSONG:
gm = EGameMode.TR_GAMEMODE_SHORTSONG;
break;
} }
CBase.Game.AddSong(round.SongID, gm);
} }
private void _SetNumJokers() private void _SetNumJokers()
@@ -612,7 +599,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _UpdateScores() private void _UpdateScores()
{ {
if (!GameData.Rounds[GameData.SingRoundNr].Finished) if (!GameData.Rounds[GameData.FieldNr].Finished)
GameData.CurrentRoundNr++; GameData.CurrentRoundNr++;
SPlayer[] results = CBase.Game.GetPlayers(); SPlayer[] results = CBase.Game.GetPlayers();
@@ -622,16 +609,16 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (results.Length < 2) if (results.Length < 2)
return; return;
GameData.Rounds[GameData.SingRoundNr].PointsTeam1 = (int)Math.Round(results[0].Points); GameData.Rounds[GameData.FieldNr].PointsTeam1 = (int)Math.Round(results[0].Points);
GameData.Rounds[GameData.SingRoundNr].PointsTeam2 = (int)Math.Round(results[1].Points); GameData.Rounds[GameData.FieldNr].PointsTeam2 = (int)Math.Round(results[1].Points);
GameData.Rounds[GameData.SingRoundNr].Finished = true; GameData.Rounds[GameData.FieldNr].Finished = true;
if (GameData.Rounds[GameData.SingRoundNr].PointsTeam1 < GameData.Rounds[GameData.SingRoundNr].PointsTeam2) if (GameData.Rounds[GameData.FieldNr].PointsTeam1 < GameData.Rounds[GameData.FieldNr].PointsTeam2)
GameData.Rounds[GameData.SingRoundNr].Winner = 2; GameData.Rounds[GameData.FieldNr].Winner = 2;
else if (GameData.Rounds[GameData.SingRoundNr].PointsTeam1 > GameData.Rounds[GameData.SingRoundNr].PointsTeam2) else if (GameData.Rounds[GameData.FieldNr].PointsTeam1 > GameData.Rounds[GameData.FieldNr].PointsTeam2)
GameData.Rounds[GameData.SingRoundNr].Winner = 1; GameData.Rounds[GameData.FieldNr].Winner = 1;
else else
{ {
GameData.Rounds[GameData.SingRoundNr].Finished = false; GameData.Rounds[GameData.FieldNr].Finished = false;
GameData.CurrentRoundNr--; GameData.CurrentRoundNr--;
} }
} }
@@ -80,7 +80,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private float _FieldSize = 100; private float _FieldSize = 100;
private int _PreviewStream = -1; private int _PreviewStream = -1;
private int _SelectedField = -1;
private int _OldSelectedField = -1; private int _OldSelectedField = -1;
private int[,] _Possibilities; private int[,] _Possibilities;
@@ -152,7 +151,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
case EStatus.FieldChoosing: case EStatus.FieldChoosing:
if (_Fields[i].Button.Selected) if (_Fields[i].Button.Selected)
{ {
_SelectedField = i; _PartyMode.GameData.FieldNr = i;
_FieldSelected(); _FieldSelected();
} }
break; break;
@@ -160,7 +159,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
case EStatus.JokerRetry: case EStatus.JokerRetry:
if (_Fields[i].Button.Selected) if (_Fields[i].Button.Selected)
{ {
_SelectedField = i; _PartyMode.GameData.FieldNr = i;
_FieldSelectedAgain(); _FieldSelectedAgain();
} }
break; break;
@@ -217,7 +216,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
case EStatus.FieldChoosing: case EStatus.FieldChoosing:
if (_Fields[i].Button.Selected) if (_Fields[i].Button.Selected)
{ {
_SelectedField = i; _PartyMode.GameData.FieldNr = i;
_FieldSelected(); _FieldSelected();
} }
break; break;
@@ -225,7 +224,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
case EStatus.JokerRetry: case EStatus.JokerRetry:
if (_Fields[i].Button.Selected) if (_Fields[i].Button.Selected)
{ {
_SelectedField = i; _PartyMode.GameData.FieldNr = i;
_FieldSelectedAgain(); _FieldSelectedAgain();
} }
break; break;
@@ -281,7 +280,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (_PartyMode.GameData.CurrentRoundNr == 1) if (_PartyMode.GameData.CurrentRoundNr == 1)
{ {
_BuildWinnerPossibilities(); _BuildWinnerPossibilities();
_SelectedField = -1; _PartyMode.GameData.FieldNr = -1;
_Buttons[_ButtonBack].Visible = true; _Buttons[_ButtonBack].Visible = true;
_Buttons[_ButtonExit].Visible = false; _Buttons[_ButtonExit].Visible = false;
_SelectElement(_Buttons[_ButtonBack]); _SelectElement(_Buttons[_ButtonBack]);
@@ -419,7 +418,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Fields[i].Button.Color = CBase.Themes.GetPlayerColor(_Fields[i].Content.Winner); _Fields[i].Button.Color = CBase.Themes.GetPlayerColor(_Fields[i].Content.Winner);
_Fields[i].Button.SelColor = CBase.Themes.GetPlayerColor(_Fields[i].Content.Winner); _Fields[i].Button.SelColor = CBase.Themes.GetPlayerColor(_Fields[i].Content.Winner);
} }
if (_Status == EStatus.FieldSelected && _SelectedField == i) if (_Status == EStatus.FieldSelected && _PartyMode.GameData.FieldNr == i)
{ {
_Fields[i].Button.Texture = CBase.Songs.GetSongByID(_Fields[i].Content.SongID).CoverTextureBig; _Fields[i].Button.Texture = CBase.Songs.GetSongByID(_Fields[i].Content.SongID).CoverTextureBig;
_Fields[i].Button.Color = new SColorF(1, 1, 1, 1); _Fields[i].Button.Color = new SColorF(1, 1, 1, 1);
@@ -456,8 +455,8 @@ namespace VocaluxeLib.PartyModes.TicTacToe
singerTeam2 = _PartyMode.GameData.PlayerTeam2[0]; singerTeam2 = _PartyMode.GameData.PlayerTeam2[0];
_PartyMode.GameData.PlayerTeam2.RemoveAt(0); _PartyMode.GameData.PlayerTeam2.RemoveAt(0);
} }
_PartyMode.GameData.Rounds[_SelectedField].SingerTeam1 = singerTeam1; _PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam1 = singerTeam1;
_PartyMode.GameData.Rounds[_SelectedField].SingerTeam2 = singerTeam2; _PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam2 = singerTeam2;
_UpdatePlayerInformation(); _UpdatePlayerInformation();
} }
@@ -470,8 +469,8 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_StartPreview(songID); _StartPreview(songID);
_Status = EStatus.FieldSelected; _Status = EStatus.FieldSelected;
_Fields[_SelectedField].Content.SongID = songID; _Fields[_PartyMode.GameData.FieldNr].Content.SongID = songID;
_PartyMode.GameData.Rounds[_SelectedField].SongID = songID; _PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SongID = songID;
_UpdateFieldContents(); _UpdateFieldContents();
_UpdateJokerButtons(); _UpdateJokerButtons();
@@ -484,13 +483,13 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _FieldSelectedAgain() private void _FieldSelectedAgain()
{ {
int songID = _Fields[_SelectedField].Content.SongID; int songID = _Fields[_PartyMode.GameData.FieldNr].Content.SongID;
_StartPreview(songID); _StartPreview(songID);
_Status = EStatus.FieldSelected; _Status = EStatus.FieldSelected;
_Fields[_SelectedField].Content.SongID = songID; _Fields[_PartyMode.GameData.FieldNr].Content.SongID = songID;
_PartyMode.GameData.Rounds[_SelectedField].SongID = songID; _PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SongID = songID;
_PartyMode.GameData.Rounds[_SelectedField].SingerTeam1 = _PartyMode.GameData.Rounds[_OldSelectedField].SingerTeam1; _PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam1 = _PartyMode.GameData.Rounds[_OldSelectedField].SingerTeam1;
_PartyMode.GameData.Rounds[_SelectedField].SingerTeam2 = _PartyMode.GameData.Rounds[_OldSelectedField].SingerTeam2; _PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam2 = _PartyMode.GameData.Rounds[_OldSelectedField].SingerTeam2;
_UpdateFieldContents(); _UpdateFieldContents();
_UpdatePlayerInformation(); _UpdatePlayerInformation();
@@ -522,12 +521,14 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Texts[_TextNextPlayerT2].Visible = true; _Texts[_TextNextPlayerT2].Visible = true;
_Texts[_TextNextPlayerNameT1].Visible = true; _Texts[_TextNextPlayerNameT1].Visible = true;
_Texts[_TextNextPlayerNameT2].Visible = true; _Texts[_TextNextPlayerNameT2].Visible = true;
_Texts[_TextNextPlayerNameT1].Text = CBase.Profiles.GetPlayerName(_PartyMode.GameData.ProfileIDsTeam1[_PartyMode.GameData.Rounds[_SelectedField].SingerTeam1]); _Texts[_TextNextPlayerNameT1].Text =
_Texts[_TextNextPlayerNameT2].Text = CBase.Profiles.GetPlayerName(_PartyMode.GameData.ProfileIDsTeam2[_PartyMode.GameData.Rounds[_SelectedField].SingerTeam2]); CBase.Profiles.GetPlayerName(_PartyMode.GameData.ProfileIDsTeam1[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam1]);
_Texts[_TextNextPlayerNameT2].Text =
CBase.Profiles.GetPlayerName(_PartyMode.GameData.ProfileIDsTeam2[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam2]);
_Statics[_StaticAvatarT1].Visible = true; _Statics[_StaticAvatarT1].Visible = true;
_Statics[_StaticAvatarT2].Visible = true; _Statics[_StaticAvatarT2].Visible = true;
_Statics[_StaticAvatarT1].Texture = CBase.Profiles.GetAvatar(_PartyMode.GameData.ProfileIDsTeam1[_PartyMode.GameData.Rounds[_SelectedField].SingerTeam1]); _Statics[_StaticAvatarT1].Texture = CBase.Profiles.GetAvatar(_PartyMode.GameData.ProfileIDsTeam1[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam1]);
_Statics[_StaticAvatarT2].Texture = CBase.Profiles.GetAvatar(_PartyMode.GameData.ProfileIDsTeam2[_PartyMode.GameData.Rounds[_SelectedField].SingerTeam2]); _Statics[_StaticAvatarT2].Texture = CBase.Profiles.GetAvatar(_PartyMode.GameData.ProfileIDsTeam2[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam2]);
} }
private void _UseJoker(int teamNr, int jokerNum) private void _UseJoker(int teamNr, int jokerNum)
@@ -554,8 +555,8 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (!CBase.Sound.IsFinished(_PreviewStream)) if (!CBase.Sound.IsFinished(_PreviewStream))
CBase.Sound.Fade(_PreviewStream, 0, 1, EStreamAction.Close); CBase.Sound.Fade(_PreviewStream, 0, 1, EStreamAction.Close);
_Status = EStatus.JokerRetry; _Status = EStatus.JokerRetry;
_OldSelectedField = _SelectedField; _OldSelectedField = _PartyMode.GameData.FieldNr;
_SelectedField = -1; _PartyMode.GameData.FieldNr = -1;
_UpdateFieldContents(); _UpdateFieldContents();
_Buttons[_ButtonNextRound].Visible = false; _Buttons[_ButtonNextRound].Visible = false;
} }