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()
|
public static void NextRound()
|
||||||
{
|
{
|
||||||
_SongQueue.NextRound(Players);
|
_SongQueue.StartNextRound(Players);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsFinished()
|
public static bool IsFinished()
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ namespace Vocaluxe.Screens
|
|||||||
{
|
{
|
||||||
_IsDuet = false;
|
_IsDuet = false;
|
||||||
CPoints points = CGame.GetPoints();
|
CPoints points = CGame.GetPoints();
|
||||||
CSong song = CGame.GetSong(_Round + 1);
|
CSong song = CGame.GetSong(_Round);
|
||||||
if (song == null)
|
if (song == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -250,7 +250,7 @@ namespace Vocaluxe.Screens
|
|||||||
if (points.NumRounds > 1)
|
if (points.NumRounds > 1)
|
||||||
_Texts[_TextSongName].Text += " (" + (_Round + 1) + "/" + points.NumRounds + ")";
|
_Texts[_TextSongName].Text += " (" + (_Round + 1) + "/" + points.NumRounds + ")";
|
||||||
|
|
||||||
switch (CGame.GetGameMode(_Round + 1))
|
switch (CGame.GetGameMode(_Round))
|
||||||
{
|
{
|
||||||
case EGameMode.TR_GAMEMODE_NORMAL:
|
case EGameMode.TR_GAMEMODE_NORMAL:
|
||||||
_Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL";
|
_Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL";
|
||||||
@@ -279,28 +279,15 @@ namespace Vocaluxe.Screens
|
|||||||
|
|
||||||
private void _ChangePos(int num)
|
private void _ChangePos(int num)
|
||||||
{
|
{
|
||||||
if (num > 0)
|
_Pos += num;
|
||||||
{
|
_Pos = _Pos.Clamp(0, _Scores[_Round].Count - 1);
|
||||||
if (_Pos + num + _NumEntrys < _Scores[_Round].Count)
|
|
||||||
_Pos += num;
|
|
||||||
}
|
|
||||||
if (num < 0)
|
|
||||||
{
|
|
||||||
_Pos += num;
|
|
||||||
if (_Pos < 0)
|
|
||||||
_Pos = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _ChangeRound(int num)
|
private void _ChangeRound(int num)
|
||||||
{
|
{
|
||||||
CPoints points = CGame.GetPoints();
|
CPoints points = CGame.GetPoints();
|
||||||
if (_Round + num < points.NumRounds && _Round + num > -1)
|
_Round += num;
|
||||||
_Round += num;
|
_Round = _Round.Clamp(0, points.NumRounds - 1);
|
||||||
else if (_Round + num >= points.NumRounds)
|
|
||||||
_Round = points.NumRounds - 1;
|
|
||||||
else if (_Round + num < 0)
|
|
||||||
_Round = 0;
|
|
||||||
_UpdateRound();
|
_UpdateRound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ namespace Vocaluxe.Screens
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Keys.F10:
|
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]];
|
CSelectSlide selectSlideDuetPart = _SelectSlides[_SelectSlideDuetPlayer[_SelectingFastPlayerNr - 1]];
|
||||||
selectSlideDuetPart.Selection = (selectSlideDuetPart.Selection + 1) % 2;
|
selectSlideDuetPart.Selection = (selectSlideDuetPart.Selection + 1) % 2;
|
||||||
@@ -603,12 +603,12 @@ namespace Vocaluxe.Screens
|
|||||||
CProfiles.GetAvatarTextureFromProfile(CGame.Players[i].ProfileID) :
|
CProfiles.GetAvatarTextureFromProfile(CGame.Players[i].ProfileID) :
|
||||||
_OriginalPlayerAvatarTextures[i];
|
_OriginalPlayerAvatarTextures[i];
|
||||||
_Texts[_TextPlayer[i]].Text = CProfiles.GetPlayerName(CGame.Players[i].ProfileID, i + 1);
|
_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]].Clear();
|
||||||
_SelectSlides[_SelectSlideDuetPlayer[i]].Visible = i + 1 <= CGame.NumPlayer;
|
_SelectSlides[_SelectSlideDuetPlayer[i]].Visible = i + 1 <= CGame.NumPlayer;
|
||||||
_SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(CGame.GetSong(1).DuetPart1);
|
_SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(CGame.GetSong(0).DuetPart1);
|
||||||
_SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(CGame.GetSong(1).DuetPart2);
|
_SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(CGame.GetSong(0).DuetPart2);
|
||||||
_SelectSlides[_SelectSlideDuetPlayer[i]].Selection = i % 2;
|
_SelectSlides[_SelectSlideDuetPlayer[i]].Selection = i % 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -623,7 +623,7 @@ namespace Vocaluxe.Screens
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < CGame.NumPlayer; i++)
|
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;
|
CGame.Players[i].VoiceNr = _SelectSlides[_SelectSlideDuetPlayer[i]].Selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -652,7 +652,7 @@ namespace Vocaluxe.Screens
|
|||||||
if (_Texts["TextPlayer" + i].Text == "")
|
if (_Texts["TextPlayer" + i].Text == "")
|
||||||
_Texts["TextPlayer" + i].Text = CProfiles.GetPlayerName(-1, i);
|
_Texts["TextPlayer" + i].Text = CProfiles.GetPlayerName(-1, i);
|
||||||
_Equalizers["EqualizerPlayer" + i].Visible = true;
|
_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;
|
_SelectSlides["SelectSlideDuetPlayer" + i].Visible = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -118,7 +118,8 @@ namespace Vocaluxe.Screens
|
|||||||
public override void OnShow()
|
public override void OnShow()
|
||||||
{
|
{
|
||||||
base.OnShow();
|
base.OnShow();
|
||||||
_Round = CGame.NumRounds > 1 ? 0 : 1;
|
//-1 --> Show average
|
||||||
|
_Round = CGame.NumRounds > 1 ? -1 : 0;
|
||||||
_Points = CGame.GetPoints();
|
_Points = CGame.GetPoints();
|
||||||
|
|
||||||
_SavePlayedSongs();
|
_SavePlayedSongs();
|
||||||
@@ -130,8 +131,8 @@ namespace Vocaluxe.Screens
|
|||||||
public override bool UpdateGame()
|
public override bool UpdateGame()
|
||||||
{
|
{
|
||||||
var players = new SPlayer[CGame.NumPlayer];
|
var players = new SPlayer[CGame.NumPlayer];
|
||||||
if (_Round != 0)
|
if (_Round >= 0)
|
||||||
players = _Points.GetPlayer(_Round - 1, CGame.NumPlayer);
|
players = _Points.GetPlayer(_Round, CGame.NumPlayer);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i = 0; i < CGame.NumRounds; i++)
|
for (int i = 0; i < CGame.NumRounds; i++)
|
||||||
@@ -263,7 +264,7 @@ namespace Vocaluxe.Screens
|
|||||||
{
|
{
|
||||||
CSong song = null;
|
CSong song = null;
|
||||||
var players = new SPlayer[CGame.NumPlayer];
|
var players = new SPlayer[CGame.NumPlayer];
|
||||||
if (_Round != 0)
|
if (_Round >= 0)
|
||||||
{
|
{
|
||||||
song = CGame.GetSong(_Round);
|
song = CGame.GetSong(_Round);
|
||||||
if (song == null)
|
if (song == null)
|
||||||
@@ -271,8 +272,8 @@ namespace Vocaluxe.Screens
|
|||||||
|
|
||||||
_Texts[_TextSong].Text = song.Artist + " - " + song.Title;
|
_Texts[_TextSong].Text = song.Artist + " - " + song.Title;
|
||||||
if (_Points.NumRounds > 1)
|
if (_Points.NumRounds > 1)
|
||||||
_Texts[_TextSong].Text += " (" + _Round + "/" + _Points.NumRounds + ")";
|
_Texts[_TextSong].Text += " (" + (_Round + 1) + "/" + _Points.NumRounds + ")";
|
||||||
players = _Points.GetPlayer(_Round - 1, CGame.NumPlayer);
|
players = _Points.GetPlayer(_Round, CGame.NumPlayer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -386,16 +387,14 @@ namespace Vocaluxe.Screens
|
|||||||
|
|
||||||
private void _ChangeRound(int num)
|
private void _ChangeRound(int num)
|
||||||
{
|
{
|
||||||
if ((_Round + num) <= _Points.NumRounds && (_Round + num > 0))
|
if (_Points.NumRounds < 1)
|
||||||
{
|
return;
|
||||||
_Round += num;
|
_Round += num;
|
||||||
_UpdateRatings();
|
_Round = _Round.Clamp(-1, _Points.NumRounds - 1);
|
||||||
}
|
if (_Round >= _Points.NumRounds)
|
||||||
else if (num < 0 && _Round == 1 && CGame.NumRounds > 1)
|
_Round = _Points.NumRounds - 1;
|
||||||
{
|
|
||||||
_Round = 0;
|
_UpdateRatings();
|
||||||
_UpdateRatings();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _SavePlayedSongs()
|
private void _SavePlayedSongs()
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace Vocaluxe.SongQueue
|
|||||||
class CSongQueue : ISongQueue
|
class CSongQueue : ISongQueue
|
||||||
{
|
{
|
||||||
private List<SSongQueueEntry> _SongQueue;
|
private List<SSongQueueEntry> _SongQueue;
|
||||||
private int _CurrentSong;
|
private int _CurrentRound;
|
||||||
private CPoints _Points;
|
private CPoints _Points;
|
||||||
|
|
||||||
#region Implementation
|
#region Implementation
|
||||||
@@ -52,9 +52,7 @@ namespace Vocaluxe.SongQueue
|
|||||||
|
|
||||||
public EGameMode GetCurrentGameMode()
|
public EGameMode GetCurrentGameMode()
|
||||||
{
|
{
|
||||||
if (_CurrentSong >= 0 && _CurrentSong < _SongQueue.Count)
|
return GetGameMode(_CurrentRound);
|
||||||
return _SongQueue[_CurrentSong].GameMode;
|
|
||||||
return EGameMode.TR_GAMEMODE_NORMAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AddVisibleSong(int visibleIndex, EGameMode gameMode)
|
public bool AddVisibleSong(int visibleIndex, EGameMode gameMode)
|
||||||
@@ -105,7 +103,7 @@ namespace Vocaluxe.SongQueue
|
|||||||
|
|
||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
_CurrentSong = -1;
|
_CurrentRound = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start(SPlayer[] players)
|
public void Start(SPlayer[] players)
|
||||||
@@ -113,37 +111,51 @@ namespace Vocaluxe.SongQueue
|
|||||||
_Points = new CPoints(_SongQueue.Count, players);
|
_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(
|
||||||
{
|
_CurrentRound,
|
||||||
_Points.SetPoints(
|
_SongQueue[_CurrentRound].SongID,
|
||||||
_CurrentSong,
|
players,
|
||||||
_SongQueue[_CurrentSong].SongID,
|
_SongQueue[_CurrentRound].GameMode);
|
||||||
players,
|
|
||||||
_SongQueue[_CurrentSong].GameMode);
|
|
||||||
}
|
|
||||||
_CurrentSong++;
|
|
||||||
}
|
}
|
||||||
|
_CurrentRound++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsFinished()
|
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()
|
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()
|
public CSong GetSong()
|
||||||
{
|
{
|
||||||
if (_CurrentSong >= 0 && _CurrentSong < _SongQueue.Count)
|
return GetSong(_CurrentRound);
|
||||||
return CGameModes.Get(_SongQueue[_CurrentSong].GameMode).GetSong(_SongQueue[_CurrentSong].SongID);
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetNumSongs()
|
public int GetNumSongs()
|
||||||
@@ -151,18 +163,28 @@ namespace Vocaluxe.SongQueue
|
|||||||
return _SongQueue.Count;
|
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)
|
if (round < _SongQueue.Count && round >= 0)
|
||||||
return CSongs.GetSong(_SongQueue[num - 1].SongID);
|
return CSongs.GetSong(_SongQueue[round].SongID);
|
||||||
|
|
||||||
return null;
|
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)
|
if (round < _SongQueue.Count && round >= 0)
|
||||||
return _SongQueue[num - 1].GameMode;
|
return _SongQueue[round].GameMode;
|
||||||
|
|
||||||
return EGameMode.TR_GAMEMODE_NORMAL;
|
return EGameMode.TR_GAMEMODE_NORMAL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ namespace Vocaluxe.SongQueue
|
|||||||
{
|
{
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
EGameMode GetCurrentGameMode();
|
|
||||||
|
|
||||||
bool AddVisibleSong(int visibleIndex, EGameMode gameMode);
|
bool AddVisibleSong(int visibleIndex, EGameMode gameMode);
|
||||||
bool AddSong(int absoluteIndex, EGameMode gameMode);
|
bool AddSong(int absoluteIndex, EGameMode gameMode);
|
||||||
bool RemoveVisibleSong(int visibleIndex);
|
bool RemoveVisibleSong(int visibleIndex);
|
||||||
@@ -35,15 +33,17 @@ namespace Vocaluxe.SongQueue
|
|||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
void Start(SPlayer[] players);
|
void Start(SPlayer[] players);
|
||||||
void NextRound(SPlayer[] players);
|
void StartNextRound(SPlayer[] players);
|
||||||
bool IsFinished();
|
bool IsFinished();
|
||||||
int GetCurrentRoundNr();
|
|
||||||
|
|
||||||
CPoints GetPoints();
|
CPoints GetPoints();
|
||||||
|
|
||||||
int GetNumSongs();
|
int GetNumSongs();
|
||||||
|
int GetCurrentRoundNr();
|
||||||
|
|
||||||
CSong GetSong();
|
CSong GetSong();
|
||||||
CSong GetSong(int num);
|
CSong GetSong(int round);
|
||||||
EGameMode GetGameMode(int num);
|
EGameMode GetCurrentGameMode();
|
||||||
|
EGameMode GetGameMode(int round);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,6 +47,15 @@ namespace VocaluxeLib
|
|||||||
return (int)result;
|
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>
|
/// <summary>
|
||||||
/// Concat strings into one string with ", " as separator.
|
/// Concat strings into one string with ", " as separator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in new issue
Block a user