Fix some bugs where round was actually roundNr
Now round (0 based) is always used
This commit is contained in:
1 parent
e6d8cf3ad9
commit
271772301d
7 files changed
+92
-75
No files matched your search
@@ -131,7 +131,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static void NextRound()
|
||||
{
|
||||
_SongQueue.NextRound(Players);
|
||||
_SongQueue.StartNextRound(Players);
|
||||
}
|
||||
|
||||
public static bool IsFinished()
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
_IsDuet = false;
|
||||
CPoints points = CGame.GetPoints();
|
||||
CSong song = CGame.GetSong(_Round + 1);
|
||||
CSong song = CGame.GetSong(_Round);
|
||||
if (song == null)
|
||||
return;
|
||||
|
||||
@@ -250,7 +250,7 @@ namespace Vocaluxe.Screens
|
||||
if (points.NumRounds > 1)
|
||||
_Texts[_TextSongName].Text += " (" + (_Round + 1) + "/" + points.NumRounds + ")";
|
||||
|
||||
switch (CGame.GetGameMode(_Round + 1))
|
||||
switch (CGame.GetGameMode(_Round))
|
||||
{
|
||||
case EGameMode.TR_GAMEMODE_NORMAL:
|
||||
_Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL";
|
||||
@@ -279,28 +279,15 @@ namespace Vocaluxe.Screens
|
||||
|
||||
private void _ChangePos(int num)
|
||||
{
|
||||
if (num > 0)
|
||||
{
|
||||
if (_Pos + num + _NumEntrys < _Scores[_Round].Count)
|
||||
_Pos += num;
|
||||
}
|
||||
if (num < 0)
|
||||
{
|
||||
_Pos += num;
|
||||
if (_Pos < 0)
|
||||
_Pos = 0;
|
||||
}
|
||||
_Pos += num;
|
||||
_Pos = _Pos.Clamp(0, _Scores[_Round].Count - 1);
|
||||
}
|
||||
|
||||
private void _ChangeRound(int num)
|
||||
{
|
||||
CPoints points = CGame.GetPoints();
|
||||
if (_Round + num < points.NumRounds && _Round + num > -1)
|
||||
_Round += num;
|
||||
else if (_Round + num >= points.NumRounds)
|
||||
_Round = points.NumRounds - 1;
|
||||
else if (_Round + num < 0)
|
||||
_Round = 0;
|
||||
_Round += num;
|
||||
_Round = _Round.Clamp(0, points.NumRounds - 1);
|
||||
_UpdateRound();
|
||||
}
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ namespace Vocaluxe.Screens
|
||||
break;
|
||||
|
||||
case Keys.F10:
|
||||
if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet)
|
||||
if (CGame.GetNumSongs() == 1 && CGame.GetSong(0).IsDuet)
|
||||
{
|
||||
CSelectSlide selectSlideDuetPart = _SelectSlides[_SelectSlideDuetPlayer[_SelectingFastPlayerNr - 1]];
|
||||
selectSlideDuetPart.Selection = (selectSlideDuetPart.Selection + 1) % 2;
|
||||
@@ -603,12 +603,12 @@ namespace Vocaluxe.Screens
|
||||
CProfiles.GetAvatarTextureFromProfile(CGame.Players[i].ProfileID) :
|
||||
_OriginalPlayerAvatarTextures[i];
|
||||
_Texts[_TextPlayer[i]].Text = CProfiles.GetPlayerName(CGame.Players[i].ProfileID, i + 1);
|
||||
if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet)
|
||||
if (CGame.GetNumSongs() == 1 && CGame.GetSong(0).IsDuet)
|
||||
{
|
||||
_SelectSlides[_SelectSlideDuetPlayer[i]].Clear();
|
||||
_SelectSlides[_SelectSlideDuetPlayer[i]].Visible = i + 1 <= CGame.NumPlayer;
|
||||
_SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(CGame.GetSong(1).DuetPart1);
|
||||
_SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(CGame.GetSong(1).DuetPart2);
|
||||
_SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(CGame.GetSong(0).DuetPart1);
|
||||
_SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(CGame.GetSong(0).DuetPart2);
|
||||
_SelectSlides[_SelectSlideDuetPlayer[i]].Selection = i % 2;
|
||||
}
|
||||
else
|
||||
@@ -623,7 +623,7 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
for (int i = 0; i < CGame.NumPlayer; i++)
|
||||
{
|
||||
if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet)
|
||||
if (CGame.GetNumSongs() == 1 && CGame.GetSong(0).IsDuet)
|
||||
CGame.Players[i].VoiceNr = _SelectSlides[_SelectSlideDuetPlayer[i]].Selection;
|
||||
}
|
||||
|
||||
@@ -652,7 +652,7 @@ namespace Vocaluxe.Screens
|
||||
if (_Texts["TextPlayer" + i].Text == "")
|
||||
_Texts["TextPlayer" + i].Text = CProfiles.GetPlayerName(-1, i);
|
||||
_Equalizers["EqualizerPlayer" + i].Visible = true;
|
||||
if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet)
|
||||
if (CGame.GetNumSongs() == 1 && CGame.GetSong(0).IsDuet)
|
||||
_SelectSlides["SelectSlideDuetPlayer" + i].Visible = true;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -118,7 +118,8 @@ namespace Vocaluxe.Screens
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
_Round = CGame.NumRounds > 1 ? 0 : 1;
|
||||
//-1 --> Show average
|
||||
_Round = CGame.NumRounds > 1 ? -1 : 0;
|
||||
_Points = CGame.GetPoints();
|
||||
|
||||
_SavePlayedSongs();
|
||||
@@ -130,8 +131,8 @@ namespace Vocaluxe.Screens
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
var players = new SPlayer[CGame.NumPlayer];
|
||||
if (_Round != 0)
|
||||
players = _Points.GetPlayer(_Round - 1, CGame.NumPlayer);
|
||||
if (_Round >= 0)
|
||||
players = _Points.GetPlayer(_Round, CGame.NumPlayer);
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < CGame.NumRounds; i++)
|
||||
@@ -263,7 +264,7 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
CSong song = null;
|
||||
var players = new SPlayer[CGame.NumPlayer];
|
||||
if (_Round != 0)
|
||||
if (_Round >= 0)
|
||||
{
|
||||
song = CGame.GetSong(_Round);
|
||||
if (song == null)
|
||||
@@ -271,8 +272,8 @@ namespace Vocaluxe.Screens
|
||||
|
||||
_Texts[_TextSong].Text = song.Artist + " - " + song.Title;
|
||||
if (_Points.NumRounds > 1)
|
||||
_Texts[_TextSong].Text += " (" + _Round + "/" + _Points.NumRounds + ")";
|
||||
players = _Points.GetPlayer(_Round - 1, CGame.NumPlayer);
|
||||
_Texts[_TextSong].Text += " (" + (_Round + 1) + "/" + _Points.NumRounds + ")";
|
||||
players = _Points.GetPlayer(_Round, CGame.NumPlayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -386,16 +387,14 @@ namespace Vocaluxe.Screens
|
||||
|
||||
private void _ChangeRound(int num)
|
||||
{
|
||||
if ((_Round + num) <= _Points.NumRounds && (_Round + num > 0))
|
||||
{
|
||||
_Round += num;
|
||||
_UpdateRatings();
|
||||
}
|
||||
else if (num < 0 && _Round == 1 && CGame.NumRounds > 1)
|
||||
{
|
||||
_Round = 0;
|
||||
_UpdateRatings();
|
||||
}
|
||||
if (_Points.NumRounds < 1)
|
||||
return;
|
||||
_Round += num;
|
||||
_Round = _Round.Clamp(-1, _Points.NumRounds - 1);
|
||||
if (_Round >= _Points.NumRounds)
|
||||
_Round = _Points.NumRounds - 1;
|
||||
|
||||
_UpdateRatings();
|
||||
}
|
||||
|
||||
private void _SavePlayedSongs()
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Vocaluxe.SongQueue
|
||||
class CSongQueue : ISongQueue
|
||||
{
|
||||
private List<SSongQueueEntry> _SongQueue;
|
||||
private int _CurrentSong;
|
||||
private int _CurrentRound;
|
||||
private CPoints _Points;
|
||||
|
||||
#region Implementation
|
||||
@@ -52,9 +52,7 @@ namespace Vocaluxe.SongQueue
|
||||
|
||||
public EGameMode GetCurrentGameMode()
|
||||
{
|
||||
if (_CurrentSong >= 0 && _CurrentSong < _SongQueue.Count)
|
||||
return _SongQueue[_CurrentSong].GameMode;
|
||||
return EGameMode.TR_GAMEMODE_NORMAL;
|
||||
return GetGameMode(_CurrentRound);
|
||||
}
|
||||
|
||||
public bool AddVisibleSong(int visibleIndex, EGameMode gameMode)
|
||||
@@ -105,7 +103,7 @@ namespace Vocaluxe.SongQueue
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_CurrentSong = -1;
|
||||
_CurrentRound = -1;
|
||||
}
|
||||
|
||||
public void Start(SPlayer[] players)
|
||||
@@ -113,37 +111,51 @@ namespace Vocaluxe.SongQueue
|
||||
_Points = new CPoints(_SongQueue.Count, players);
|
||||
}
|
||||
|
||||
public void NextRound(SPlayer[] players)
|
||||
public void StartNextRound(SPlayer[] players)
|
||||
{
|
||||
if (_CurrentSong < _SongQueue.Count && _SongQueue.Count > 0)
|
||||
if (IsFinished())
|
||||
return;
|
||||
if (_CurrentRound > -1)
|
||||
{
|
||||
if (_CurrentSong > -1)
|
||||
{
|
||||
_Points.SetPoints(
|
||||
_CurrentSong,
|
||||
_SongQueue[_CurrentSong].SongID,
|
||||
players,
|
||||
_SongQueue[_CurrentSong].GameMode);
|
||||
}
|
||||
_CurrentSong++;
|
||||
_Points.SetPoints(
|
||||
_CurrentRound,
|
||||
_SongQueue[_CurrentRound].SongID,
|
||||
players,
|
||||
_SongQueue[_CurrentRound].GameMode);
|
||||
}
|
||||
_CurrentRound++;
|
||||
}
|
||||
|
||||
public bool IsFinished()
|
||||
{
|
||||
return _CurrentSong == _SongQueue.Count || _SongQueue.Count == 0;
|
||||
return _CurrentRound >= _SongQueue.Count || _SongQueue.Count == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get current round nr (1 ~ n)
|
||||
/// </summary>
|
||||
/// <returns>current round nr (1 ~ n)</returns>
|
||||
public int GetCurrentRoundNr()
|
||||
{
|
||||
return _CurrentSong + 1;
|
||||
return _CurrentRound + 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns current round
|
||||
/// </summary>
|
||||
/// <returns>Current round (0 based)</returns>
|
||||
public int GetCurrentRound()
|
||||
{
|
||||
return _CurrentRound;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get current song
|
||||
/// </summary>
|
||||
/// <returns>Song of current round or null if there is none/game finished</returns>
|
||||
public CSong GetSong()
|
||||
{
|
||||
if (_CurrentSong >= 0 && _CurrentSong < _SongQueue.Count)
|
||||
return CGameModes.Get(_SongQueue[_CurrentSong].GameMode).GetSong(_SongQueue[_CurrentSong].SongID);
|
||||
return null;
|
||||
return GetSong(_CurrentRound);
|
||||
}
|
||||
|
||||
public int GetNumSongs()
|
||||
@@ -151,18 +163,28 @@ namespace Vocaluxe.SongQueue
|
||||
return _SongQueue.Count;
|
||||
}
|
||||
|
||||
public CSong GetSong(int num)
|
||||
/// <summary>
|
||||
/// Get song of specified round
|
||||
/// </summary>
|
||||
/// <param name="round">Round (0 based)</param>
|
||||
/// <returns>Current song or null if out of bounds</returns>
|
||||
public CSong GetSong(int round)
|
||||
{
|
||||
if (num - 1 < _SongQueue.Count && num > 0)
|
||||
return CSongs.GetSong(_SongQueue[num - 1].SongID);
|
||||
if (round < _SongQueue.Count && round >= 0)
|
||||
return CSongs.GetSong(_SongQueue[round].SongID);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public EGameMode GetGameMode(int num)
|
||||
/// <summary>
|
||||
/// Get gameMode of specified round
|
||||
/// </summary>
|
||||
/// <param name="round">Round (0 based)</param>
|
||||
/// <returns>Current song or null if out of bounds</returns>
|
||||
public EGameMode GetGameMode(int round)
|
||||
{
|
||||
if (num - 1 < _SongQueue.Count && num > 0)
|
||||
return _SongQueue[num - 1].GameMode;
|
||||
if (round < _SongQueue.Count && round >= 0)
|
||||
return _SongQueue[round].GameMode;
|
||||
|
||||
return EGameMode.TR_GAMEMODE_NORMAL;
|
||||
}
|
||||
|
||||
@@ -25,8 +25,6 @@ namespace Vocaluxe.SongQueue
|
||||
{
|
||||
void Init();
|
||||
|
||||
EGameMode GetCurrentGameMode();
|
||||
|
||||
bool AddVisibleSong(int visibleIndex, EGameMode gameMode);
|
||||
bool AddSong(int absoluteIndex, EGameMode gameMode);
|
||||
bool RemoveVisibleSong(int visibleIndex);
|
||||
@@ -35,15 +33,17 @@ namespace Vocaluxe.SongQueue
|
||||
|
||||
void Reset();
|
||||
void Start(SPlayer[] players);
|
||||
void NextRound(SPlayer[] players);
|
||||
void StartNextRound(SPlayer[] players);
|
||||
bool IsFinished();
|
||||
int GetCurrentRoundNr();
|
||||
|
||||
CPoints GetPoints();
|
||||
|
||||
int GetNumSongs();
|
||||
int GetCurrentRoundNr();
|
||||
|
||||
CSong GetSong();
|
||||
CSong GetSong(int num);
|
||||
EGameMode GetGameMode(int num);
|
||||
CSong GetSong(int round);
|
||||
EGameMode GetCurrentGameMode();
|
||||
EGameMode GetGameMode(int round);
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,15 @@ namespace VocaluxeLib
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
public static T Clamp<T>(this T val, T min, T max) where T : IComparable<T>
|
||||
{
|
||||
if (val.CompareTo(min) < 0)
|
||||
return min;
|
||||
if (val.CompareTo(max) > 0)
|
||||
return max;
|
||||
return val;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Concat strings into one string with ", " as separator.
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user