Improved handling of next round in challenge-mode, also some documentation
This commit is contained in:
1 parent
c3bbe85c1f
commit
b1225a1a97
1 file changed
+46
-17
@@ -109,6 +109,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
|||||||
Songs,
|
Songs,
|
||||||
Names,
|
Names,
|
||||||
Main,
|
Main,
|
||||||
|
SongSelection,
|
||||||
Singing,
|
Singing,
|
||||||
MedleySinging
|
MedleySinging
|
||||||
}
|
}
|
||||||
@@ -231,8 +232,9 @@ namespace VocaluxeLib.PartyModes.Challenge
|
|||||||
return _Screens["CPartyScreenChallengeNames"];
|
return _Screens["CPartyScreenChallengeNames"];
|
||||||
case EStage.Main:
|
case EStage.Main:
|
||||||
return _Screens["CPartyScreenChallengeMain"];
|
return _Screens["CPartyScreenChallengeMain"];
|
||||||
case EStage.Singing:
|
case EStage.SongSelection:
|
||||||
return CBase.Graphics.GetScreen(EScreen.Song);
|
return CBase.Graphics.GetScreen(EScreen.Song);
|
||||||
|
case EStage.Singing:
|
||||||
case EStage.MedleySinging:
|
case EStage.MedleySinging:
|
||||||
return CBase.Graphics.GetScreen(EScreen.Sing);
|
return CBase.Graphics.GetScreen(EScreen.Sing);
|
||||||
default:
|
default:
|
||||||
@@ -265,10 +267,18 @@ namespace VocaluxeLib.PartyModes.Challenge
|
|||||||
break;
|
break;
|
||||||
case EStage.Main:
|
case EStage.Main:
|
||||||
if (GameData.GameMode == EGameMode.TR_GAMEMODE_MEDLEY)
|
if (GameData.GameMode == EGameMode.TR_GAMEMODE_MEDLEY)
|
||||||
|
{
|
||||||
_Stage = EStage.MedleySinging;
|
_Stage = EStage.MedleySinging;
|
||||||
|
_PrepareMedleyRound();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
_Stage = EStage.SongSelection;
|
||||||
|
_PrepareSongSelection();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EStage.SongSelection:
|
||||||
_Stage = EStage.Singing;
|
_Stage = EStage.Singing;
|
||||||
_StartNextRound();
|
|
||||||
break;
|
break;
|
||||||
case EStage.MedleySinging:
|
case EStage.MedleySinging:
|
||||||
case EStage.Singing:
|
case EStage.Singing:
|
||||||
@@ -418,22 +428,28 @@ namespace VocaluxeLib.PartyModes.Challenge
|
|||||||
|
|
||||||
public override void SongSelected(int songID)
|
public override void SongSelected(int songID)
|
||||||
{
|
{
|
||||||
_PrepareGame(new int[] { songID });
|
_PrepareRound(new int[] { songID });
|
||||||
|
|
||||||
CBase.Graphics.FadeTo(EScreen.Sing);
|
Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void LeavingHighscore()
|
public override void LeavingHighscore()
|
||||||
{
|
{
|
||||||
CBase.Songs.AddPartySongSung(CBase.Game.GetSong(0).ID);
|
//Remember sung songs, so they don't will be selected a second time
|
||||||
|
for(int i = 0; i < CBase.Game.GetNumSongs(); i++)
|
||||||
|
CBase.Songs.AddPartySongSung(CBase.Game.GetSong(i).ID);
|
||||||
|
|
||||||
GameData.CurrentRoundNr++;
|
GameData.CurrentRoundNr++;
|
||||||
|
|
||||||
Next();
|
Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _StartNextRound()
|
/// <summary>
|
||||||
{
|
/// Start a new medley round based on song configuration
|
||||||
if (GameData.GameMode == EGameMode.TR_GAMEMODE_MEDLEY)
|
/// </summary>
|
||||||
|
private void _PrepareMedleyRound()
|
||||||
{
|
{
|
||||||
|
//Select songs for medley
|
||||||
int[] songIDs = new int[GameData.NumMedleySongs];
|
int[] songIDs = new int[GameData.NumMedleySongs];
|
||||||
for (int i = 0; i < GameData.NumMedleySongs; i++)
|
for (int i = 0; i < GameData.NumMedleySongs; i++)
|
||||||
{
|
{
|
||||||
@@ -444,9 +460,13 @@ namespace VocaluxeLib.PartyModes.Challenge
|
|||||||
GameData.Songs.RemoveAt(0);
|
GameData.Songs.RemoveAt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
_PrepareGame(songIDs);
|
_PrepareRound(songIDs);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
/// <summary>
|
||||||
|
/// Setup options for song selection
|
||||||
|
/// </summary>
|
||||||
|
private void _PrepareSongSelection()
|
||||||
{
|
{
|
||||||
_ScreenSongOptions.Selection.RandomOnly = _ScreenSongOptions.Sorting.Tabs != EOffOn.TR_CONFIG_ON;
|
_ScreenSongOptions.Selection.RandomOnly = _ScreenSongOptions.Sorting.Tabs != EOffOn.TR_CONFIG_ON;
|
||||||
_ScreenSongOptions.Selection.CategoryChangeAllowed = false;
|
_ScreenSongOptions.Selection.CategoryChangeAllowed = false;
|
||||||
@@ -454,27 +474,30 @@ namespace VocaluxeLib.PartyModes.Challenge
|
|||||||
_SetTeamNames();
|
_SetTeamNames();
|
||||||
GameData.CatSongIndices = null;
|
GameData.CatSongIndices = null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private bool _PrepareGame(int[] songIDs)
|
/// <summary>
|
||||||
|
/// Prepare next game and fill song queue based on configuration and given songs.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="songIDs">Array of SongIDs that are selected</param>
|
||||||
|
/// <returns>false, if something can't setup correctly</returns>
|
||||||
|
private bool _PrepareRound(int[] songIDs)
|
||||||
{
|
{
|
||||||
|
//Reset game
|
||||||
CBase.Game.Reset();
|
CBase.Game.Reset();
|
||||||
CBase.Game.ClearSongs();
|
CBase.Game.ClearSongs();
|
||||||
|
|
||||||
#region PlayerNames
|
#region PlayerNames
|
||||||
CBase.Game.SetNumPlayer(GameData.NumPlayerAtOnce);
|
CBase.Game.SetNumPlayer(GameData.NumPlayerAtOnce);
|
||||||
SPlayer[] players = CBase.Game.GetPlayers();
|
SPlayer[] players = CBase.Game.GetPlayers();
|
||||||
if (players == null)
|
if (players == null || players.Length < GameData.NumPlayerAtOnce)
|
||||||
return false;
|
|
||||||
|
|
||||||
if (players.Length < GameData.NumPlayerAtOnce)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
//Get current round
|
||||||
CRound c = GameData.Rounds[GameData.CurrentRoundNr - 1];
|
CRound c = GameData.Rounds[GameData.CurrentRoundNr - 1];
|
||||||
|
|
||||||
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||||
{
|
{
|
||||||
//try to fill with the right data
|
//try to fill with correct player data
|
||||||
if (c != null)
|
if (c != null)
|
||||||
players[i].ProfileID = GameData.ProfileIDs[c.Players[i]];
|
players[i].ProfileID = GameData.ProfileIDs[c.Players[i]];
|
||||||
else
|
else
|
||||||
@@ -483,6 +506,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
|||||||
#endregion PlayerNames
|
#endregion PlayerNames
|
||||||
|
|
||||||
#region SongQueue
|
#region SongQueue
|
||||||
|
//Add all songs with configure game mode to song queue
|
||||||
for (int i = 0; i < songIDs.Length; i++)
|
for (int i = 0; i < songIDs.Length; i++)
|
||||||
CBase.Game.AddSong(songIDs[i], GameData.GameMode);
|
CBase.Game.AddSong(songIDs[i], GameData.GameMode);
|
||||||
#endregion SongQueue
|
#endregion SongQueue
|
||||||
@@ -533,6 +557,10 @@ namespace VocaluxeLib.PartyModes.Challenge
|
|||||||
_ScreenSongOptions.Selection.TeamNames[i] = CBase.Profiles.GetPlayerName(GameData.ProfileIDs[c.Players[i]]);
|
_ScreenSongOptions.Selection.TeamNames[i] = CBase.Profiles.GetPlayerName(GameData.ProfileIDs[c.Players[i]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fill song list based on song configuration. This is basically needed for singing medleys,
|
||||||
|
/// because we don't show song selection screen for these games.
|
||||||
|
/// </summary>
|
||||||
private void _UpdateSongList()
|
private void _UpdateSongList()
|
||||||
{
|
{
|
||||||
if (GameData.Songs.Count > 0)
|
if (GameData.Songs.Count > 0)
|
||||||
@@ -555,6 +583,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ESongSource.TR_SONGSOURCE_CATEGORY:
|
case ESongSource.TR_SONGSOURCE_CATEGORY:
|
||||||
|
//Save old sorting to roll it back after getting songs for configured category
|
||||||
ESongSorting oldSorting = CBase.Config.GetSongSorting();
|
ESongSorting oldSorting = CBase.Config.GetSongSorting();
|
||||||
CBase.Songs.SortSongs(GameData.Sorting, EOffOn.TR_CONFIG_ON, CBase.Config.GetIgnoreArticles() ,String.Empty, EDuetOptions.NoDuets, -1);
|
CBase.Songs.SortSongs(GameData.Sorting, EOffOn.TR_CONFIG_ON, CBase.Config.GetIgnoreArticles() ,String.Empty, EDuetOptions.NoDuets, -1);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user