Improved handling of next round in challenge-mode, also some documentation
This commit is contained in:
1 parent
c3bbe85c1f
commit
b1225a1a97
1 file changed
+61
-32
@@ -109,6 +109,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
Songs,
|
||||
Names,
|
||||
Main,
|
||||
SongSelection,
|
||||
Singing,
|
||||
MedleySinging
|
||||
}
|
||||
@@ -231,8 +232,9 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
return _Screens["CPartyScreenChallengeNames"];
|
||||
case EStage.Main:
|
||||
return _Screens["CPartyScreenChallengeMain"];
|
||||
case EStage.Singing:
|
||||
case EStage.SongSelection:
|
||||
return CBase.Graphics.GetScreen(EScreen.Song);
|
||||
case EStage.Singing:
|
||||
case EStage.MedleySinging:
|
||||
return CBase.Graphics.GetScreen(EScreen.Sing);
|
||||
default:
|
||||
@@ -265,10 +267,18 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
break;
|
||||
case EStage.Main:
|
||||
if (GameData.GameMode == EGameMode.TR_GAMEMODE_MEDLEY)
|
||||
{
|
||||
_Stage = EStage.MedleySinging;
|
||||
_PrepareMedleyRound();
|
||||
}
|
||||
else
|
||||
_Stage = EStage.Singing;
|
||||
_StartNextRound();
|
||||
{
|
||||
_Stage = EStage.SongSelection;
|
||||
_PrepareSongSelection();
|
||||
}
|
||||
break;
|
||||
case EStage.SongSelection:
|
||||
_Stage = EStage.Singing;
|
||||
break;
|
||||
case EStage.MedleySinging:
|
||||
case EStage.Singing:
|
||||
@@ -418,63 +428,76 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
|
||||
public override void SongSelected(int songID)
|
||||
{
|
||||
_PrepareGame(new int[] { songID });
|
||||
_PrepareRound(new int[] { songID });
|
||||
|
||||
CBase.Graphics.FadeTo(EScreen.Sing);
|
||||
Next();
|
||||
}
|
||||
|
||||
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++;
|
||||
|
||||
Next();
|
||||
}
|
||||
|
||||
private void _StartNextRound()
|
||||
/// <summary>
|
||||
/// Start a new medley round based on song configuration
|
||||
/// </summary>
|
||||
private void _PrepareMedleyRound()
|
||||
{
|
||||
if (GameData.GameMode == EGameMode.TR_GAMEMODE_MEDLEY)
|
||||
//Select songs for medley
|
||||
int[] songIDs = new int[GameData.NumMedleySongs];
|
||||
for (int i = 0; i < GameData.NumMedleySongs; i++)
|
||||
{
|
||||
int[] songIDs = new int[GameData.NumMedleySongs];
|
||||
for (int i = 0; i < GameData.NumMedleySongs; i++)
|
||||
{
|
||||
if (GameData.Songs.Count == 0)
|
||||
_UpdateSongList();
|
||||
if (GameData.Songs.Count == 0)
|
||||
_UpdateSongList();
|
||||
|
||||
songIDs[i] = GameData.Songs[0];
|
||||
GameData.Songs.RemoveAt(0);
|
||||
}
|
||||
songIDs[i] = GameData.Songs[0];
|
||||
GameData.Songs.RemoveAt(0);
|
||||
}
|
||||
|
||||
_PrepareGame(songIDs);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ScreenSongOptions.Selection.RandomOnly = _ScreenSongOptions.Sorting.Tabs != EOffOn.TR_CONFIG_ON;
|
||||
_ScreenSongOptions.Selection.CategoryChangeAllowed = false;
|
||||
_SetNumJokers();
|
||||
_SetTeamNames();
|
||||
GameData.CatSongIndices = null;
|
||||
}
|
||||
_PrepareRound(songIDs);
|
||||
}
|
||||
|
||||
private bool _PrepareGame(int[] songIDs)
|
||||
/// <summary>
|
||||
/// Setup options for song selection
|
||||
/// </summary>
|
||||
private void _PrepareSongSelection()
|
||||
{
|
||||
_ScreenSongOptions.Selection.RandomOnly = _ScreenSongOptions.Sorting.Tabs != EOffOn.TR_CONFIG_ON;
|
||||
_ScreenSongOptions.Selection.CategoryChangeAllowed = false;
|
||||
_SetNumJokers();
|
||||
_SetTeamNames();
|
||||
GameData.CatSongIndices = null;
|
||||
}
|
||||
|
||||
/// <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.ClearSongs();
|
||||
|
||||
#region PlayerNames
|
||||
CBase.Game.SetNumPlayer(GameData.NumPlayerAtOnce);
|
||||
SPlayer[] players = CBase.Game.GetPlayers();
|
||||
if (players == null)
|
||||
return false;
|
||||
|
||||
if (players.Length < GameData.NumPlayerAtOnce)
|
||||
if (players == null || players.Length < GameData.NumPlayerAtOnce)
|
||||
return false;
|
||||
|
||||
//Get current round
|
||||
CRound c = GameData.Rounds[GameData.CurrentRoundNr - 1];
|
||||
|
||||
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)
|
||||
players[i].ProfileID = GameData.ProfileIDs[c.Players[i]];
|
||||
else
|
||||
@@ -483,6 +506,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
#endregion PlayerNames
|
||||
|
||||
#region SongQueue
|
||||
//Add all songs with configure game mode to song queue
|
||||
for (int i = 0; i < songIDs.Length; i++)
|
||||
CBase.Game.AddSong(songIDs[i], GameData.GameMode);
|
||||
#endregion SongQueue
|
||||
@@ -533,6 +557,10 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
_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()
|
||||
{
|
||||
if (GameData.Songs.Count > 0)
|
||||
@@ -555,6 +583,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
break;
|
||||
|
||||
case ESongSource.TR_SONGSOURCE_CATEGORY:
|
||||
//Save old sorting to roll it back after getting songs for configured category
|
||||
ESongSorting oldSorting = CBase.Config.GetSongSorting();
|
||||
CBase.Songs.SortSongs(GameData.Sorting, EOffOn.TR_CONFIG_ON, CBase.Config.GetIgnoreArticles() ,String.Empty, EDuetOptions.NoDuets, -1);
|
||||
|
||||
|
||||
Reference in new issue
Block a user