Added Gamemode-Classes

This commit is contained in:
Flamefire committed 2013-04-26 18:56:33 +02:00
1 parent 124ed1c3d3
commit 780a179fcb
16 files changed
+258 -224

No files matched your search

@@ -459,11 +459,11 @@ namespace VocaluxeLib.PartyModes.Challenge
CBase.Game.AddSong(songID, gm); CBase.Game.AddSong(songID, gm);
CBase.Game.SetNumPlayer(_GameData.NumPlayerAtOnce); CBase.Game.SetNumPlayer(_GameData.NumPlayerAtOnce);
SPlayer[] player = CBase.Game.GetPlayers(); SPlayer[] players = CBase.Game.GetPlayers();
if (player == null) if (players == null)
return; return;
if (player.Length < _GameData.NumPlayerAtOnce) if (players.Length < _GameData.NumPlayerAtOnce)
return; return;
CCombination c = _GameData.Rounds.GetRound(_GameData.CurrentRoundNr - 1); CCombination c = _GameData.Rounds.GetRound(_GameData.CurrentRoundNr - 1);
@@ -472,9 +472,9 @@ namespace VocaluxeLib.PartyModes.Challenge
{ {
//try to fill with the right data //try to fill with the right data
if (c != null) if (c != null)
player[i].ProfileID = _GameData.ProfileIDs[c.Player[i]]; players[i].ProfileID = _GameData.ProfileIDs[c.Player[i]];
else else
player[i].ProfileID = -1; players[i].ProfileID = -1;
} }
CBase.Songs.AddPartySongSung(songID); CBase.Songs.AddPartySongSung(songID);
@@ -482,11 +482,11 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
#region PlayerNames #region PlayerNames
CBase.Game.SetNumPlayer(_GameData.NumPlayerAtOnce); CBase.Game.SetNumPlayer(_GameData.NumPlayerAtOnce);
SPlayer[] player = CBase.Game.GetPlayers(); SPlayer[] players = CBase.Game.GetPlayers();
if (player == null) if (players == null)
return false; return false;
if (player.Length < _GameData.NumPlayerAtOnce) if (players.Length < _GameData.NumPlayerAtOnce)
return false; return false;
CCombination c = _GameData.Rounds.GetRound(_GameData.CurrentRoundNr - 1); CCombination c = _GameData.Rounds.GetRound(_GameData.CurrentRoundNr - 1);
@@ -495,9 +495,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
//try to fill with the right data //try to fill with the right data
if (c != null) if (c != null)
player[i].ProfileID = _GameData.ProfileIDs[c.Player[i]]; players[i].ProfileID = _GameData.ProfileIDs[c.Player[i]];
else else
player[i].ProfileID = -1; players[i].ProfileID = -1;
} }
#endregion PlayerNames #endregion PlayerNames
@@ -718,11 +718,11 @@ namespace VocaluxeLib.PartyModes.TicTacToe
CBase.Game.SetNumPlayer(2); CBase.Game.SetNumPlayer(2);
SPlayer[] player = CBase.Game.GetPlayers(); SPlayer[] players = CBase.Game.GetPlayers();
if (player == null) if (players == null)
return; return;
if (player.Length < 2) if (players.Length < 2)
return; return;
SProfile[] profiles = CBase.Profiles.GetProfiles(); SProfile[] profiles = CBase.Profiles.GetProfiles();
@@ -732,7 +732,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
//default values //default values
player[i].ProfileID = -1; players[i].ProfileID = -1;
} }
//try to fill with the right data //try to fill with the right data
@@ -740,15 +740,15 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{ {
if (_GameData.ProfileIDsTeam1[r.SingerTeam1] < profiles.Length) if (_GameData.ProfileIDsTeam1[r.SingerTeam1] < profiles.Length)
{ {
player[0].ProfileID = _GameData.ProfileIDsTeam1[r.SingerTeam1]; players[0].ProfileID = _GameData.ProfileIDsTeam1[r.SingerTeam1];
if (isDuet) if (isDuet)
player[0].LineNr = 0; players[0].LineNr = 0;
} }
if (_GameData.ProfileIDsTeam2[r.SingerTeam2] < profiles.Length) if (_GameData.ProfileIDsTeam2[r.SingerTeam2] < profiles.Length)
{ {
player[1].ProfileID = _GameData.ProfileIDsTeam2[r.SingerTeam2]; players[1].ProfileID = _GameData.ProfileIDsTeam2[r.SingerTeam2];
if (isDuet) if (isDuet)
player[1].LineNr = 1; players[1].LineNr = 1;
} }
SongSelected(r.SongID); SongSelected(r.SongID);
} }
+3 -9
View File
@@ -246,15 +246,9 @@ namespace Vocaluxe.Base
Players[p].SingLine.Add(new CLine()); Players[p].SingLine.Add(new CLine());
CNote[] notes = lines[line].Notes; CNote[] notes = lines[line].Notes;
int note = -1; int note = lines[line].FindPreviousNote(beat);
for (int j = 0; j < notes.Length; j++) if (notes[note].EndBeat < beat)
{ note = -1;
if (beat >= notes[j].StartBeat && beat <= notes[j].EndBeat)
{
note = j;
break;
}
}
if (note >= 0) if (note >= 0)
{ {
+11 -16
View File
@@ -52,7 +52,6 @@ namespace Vocaluxe.Base
private static bool _SongsLoaded; private static bool _SongsLoaded;
private static bool _CoverLoaded; private static bool _CoverLoaded;
private static int _CoverLoadIndex;
private static int _CatIndex = -1; private static int _CatIndex = -1;
private static readonly List<CCategory> _CategoriesForRandom = new List<CCategory>(); private static readonly List<CCategory> _CategoriesForRandom = new List<CCategory>();
@@ -157,20 +156,17 @@ namespace Vocaluxe.Base
if (!SongsLoaded) if (!SongsLoaded)
return -1; return -1;
if (_CoverLoadIndex < _Songs.Count) if (NumSongsWithCoverLoaded < _Songs.Count)
{ {
song = _Songs[_CoverLoadIndex]; song = _Songs[NumSongsWithCoverLoaded];
_CoverLoadIndex++; NumSongsWithCoverLoaded++;
return _CoverLoadIndex; return NumSongsWithCoverLoaded;
} }
return -2; return -2;
} }
public static int NumSongsWithCoverLoaded public static int NumSongsWithCoverLoaded { get; private set; }
{
get { return _CoverLoadIndex; }
}
public static void SetCoverSmall(int songIndex, STexture texture) public static void SetCoverSmall(int songIndex, STexture texture)
{ {
@@ -392,12 +388,11 @@ namespace Vocaluxe.Base
foreach (string file in files) foreach (string file in files)
{ {
CSong song = CSong.LoadSong(file); CSong song = CSong.LoadSong(file);
if (song != null) if (song == null)
{ continue;
song.ID = _Songs.Count; song.ID = _Songs.Count;
if (song.ReadNotes()) if (song.ReadNotes())
_Songs.Add(song); _Songs.Add(song);
}
} }
CLog.StopBenchmark(2, "Read TXTs"); CLog.StopBenchmark(2, "Read TXTs");
@@ -460,7 +455,7 @@ namespace Vocaluxe.Base
foreach (CSong song in _Songs) foreach (CSong song in _Songs)
{ {
song.LoadSmallCover(); song.LoadSmallCover();
_CoverLoadIndex++; NumSongsWithCoverLoaded++;
} }
GC.Collect(); GC.Collect();
_CoverLoaded = true; _CoverLoaded = true;
+24
View File
@@ -0,0 +1,24 @@
using Vocaluxe.Base;
using VocaluxeLib.Menu.SongMenu;
namespace Vocaluxe.GameModes
{
abstract class CGameMode : IGameMode
{
private CSong _LastSong;
private int _LastSongID;
public CSong GetSong(int songID)
{
if (songID != _LastSongID)
{
CSong song = CSongs.GetSong(songID);
_LastSong = _PrepareSong(song);
_LastSongID = songID;
}
return _LastSong;
}
protected abstract CSong _PrepareSong(CSong song);
}
}
+81
View File
@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Vocaluxe.Base;
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu;
namespace Vocaluxe.GameModes
{
static class CGameModes
{
private static Dictionary<EGameMode, IGameMode> _GameModes;
public static void Init()
{
_GameModes = new Dictionary<EGameMode, IGameMode>
{
{EGameMode.TR_GAMEMODE_NORMAL, new CGameModeNormal()},
{EGameMode.TR_GAMEMODE_DUET, new CGameModeDuet()},
{EGameMode.TR_GAMEMODE_SHORTSONG, new CGameModeShort()},
{EGameMode.TR_GAMEMODE_MEDLEY, new CGameModeMedley()}
};
}
public static IGameMode Get(EGameMode gameMode)
{
if (_GameModes == null)
return null;
IGameMode result;
if (!_GameModes.TryGetValue(gameMode, out result))
result = _GameModes[EGameMode.TR_GAMEMODE_NORMAL];
return result;
}
}
class CGameModeNormal : CGameMode
{
protected override CSong _PrepareSong(CSong song)
{
return song;
}
}
class CGameModeDuet : CGameMode
{
protected override CSong _PrepareSong(CSong song)
{
return (song.IsDuet) ? song : null;
}
}
class CGameModeShort : CGameMode
{
protected override CSong _PrepareSong(CSong song)
{
CSong newSong = new CSong(song) {Finish = CGame.GetTimeFromBeats(song.ShortEnd, song.BPM) + CSettings.DefaultMedleyFadeOutTime + song.Gap};
// set lines to short mode
newSong.Notes.SetMedley(song.Notes.GetVoice(0).Lines[0].FirstNoteBeat, song.ShortEnd);
return newSong;
}
}
class CGameModeMedley : CGameMode
{
protected override CSong _PrepareSong(CSong song)
{
CSong newSong = new CSong(song) {Start = CGame.GetTimeFromBeats(song.Medley.StartBeat, song.BPM) - song.Medley.FadeInTime + song.Gap};
if (newSong.Start < 0f)
newSong.Start = 0f;
newSong.Finish = CGame.GetTimeFromBeats(song.Medley.EndBeat, song.BPM) + song.Medley.FadeOutTime + song.Gap;
// set lines to medley mode
newSong.Notes.SetMedley(song.Medley.StartBeat, song.Medley.EndBeat);
return newSong;
}
}
}
+9
View File
@@ -0,0 +1,9 @@
using VocaluxeLib.Menu.SongMenu;
namespace Vocaluxe.GameModes
{
interface IGameMode
{
CSong GetSong(int songID);
}
}
+4 -4
View File
@@ -219,12 +219,12 @@ namespace Vocaluxe.Screens
for (int round = 0; round < points.NumRounds; round++) for (int round = 0; round < points.NumRounds; round++)
{ {
SPlayer[] player = points.GetPlayer(round, CGame.NumPlayer); SPlayer[] players = points.GetPlayer(round, CGame.NumPlayer);
for (int p = 0; p < player.Length; p++) for (int p = 0; p < players.Length; p++)
{ {
if (player[p].Points > CSettings.MinScoreForDB && player[p].SongFinished && !CProfiles.IsGuestProfile(player[p].ProfileID)) if (players[p].Points > CSettings.MinScoreForDB && players[p].SongFinished && !CProfiles.IsGuestProfile(players[p].ProfileID))
_NewEntryIDs.Add(CDataBase.AddScore(player[p])); _NewEntryIDs.Add(CDataBase.AddScore(players[p]));
} }
} }
} }
+31 -31
View File
@@ -127,31 +127,31 @@ namespace Vocaluxe.Screens
public override bool UpdateGame() public override bool UpdateGame()
{ {
SPlayer[] player = new SPlayer[CGame.NumPlayer]; SPlayer[] players = new SPlayer[CGame.NumPlayer];
if (_Round != 0) if (_Round != 0)
player = _Points.GetPlayer(_Round - 1, CGame.NumPlayer); players = _Points.GetPlayer(_Round - 1, CGame.NumPlayer);
else else
{ {
for (int i = 0; i < CGame.NumRounds; i++) for (int i = 0; i < CGame.NumRounds; i++)
{ {
SPlayer[] points = _Points.GetPlayer(i, CGame.NumPlayer); SPlayer[] points = _Points.GetPlayer(i, CGame.NumPlayer);
for (int p = 0; p < player.Length; p++) for (int p = 0; p < players.Length; p++)
player[p].Points += points[p].Points; players[p].Points += points[p].Points;
} }
for (int p = 0; p < player.Length; p++) for (int p = 0; p < players.Length; p++)
player[p].Points = (int)(player[p].Points / CGame.NumRounds); players[p].Points = (int)(players[p].Points / CGame.NumRounds);
} }
for (int p = 0; p < player.Length; p++) for (int p = 0; p < players.Length; p++)
{ {
if (_StaticPointsBarDrawnPoints[p] < player[p].Points) if (_StaticPointsBarDrawnPoints[p] < players[p].Points)
{ {
if (CConfig.ScoreAnimationTime >= 1) if (CConfig.ScoreAnimationTime >= 1)
{ {
_StaticPointsBarDrawnPoints[p] = (_Timer.ElapsedMilliseconds / 1000f) / CConfig.ScoreAnimationTime * 10000; _StaticPointsBarDrawnPoints[p] = (_Timer.ElapsedMilliseconds / 1000f) / CConfig.ScoreAnimationTime * 10000;
if (_StaticPointsBarDrawnPoints[p] > player[p].Points) if (_StaticPointsBarDrawnPoints[p] > players[p].Points)
_StaticPointsBarDrawnPoints[p] = player[p].Points; _StaticPointsBarDrawnPoints[p] = players[p].Points;
string direction = (string)_ScreenSettings[_ScreenSettingAnimationDirection].GetValue(); string direction = (string)_ScreenSettings[_ScreenSettingAnimationDirection].GetValue();
if (direction.ToLower() == "vertical") if (direction.ToLower() == "vertical")
{ {
@@ -260,7 +260,7 @@ namespace Vocaluxe.Screens
private void _UpdateRatings() private void _UpdateRatings()
{ {
CSong song = null; CSong song = null;
SPlayer[] player = new SPlayer[CGame.NumPlayer]; SPlayer[] players = new SPlayer[CGame.NumPlayer];
if (_Round != 0) if (_Round != 0)
{ {
song = CGame.GetSong(_Round); song = CGame.GetSong(_Round);
@@ -270,7 +270,7 @@ 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 + "/" + _Points.NumRounds + ")";
player = _Points.GetPlayer(_Round - 1, CGame.NumPlayer); players = _Points.GetPlayer(_Round - 1, CGame.NumPlayer);
} }
else else
{ {
@@ -278,47 +278,47 @@ namespace Vocaluxe.Screens
for (int i = 0; i < CGame.NumRounds; i++) for (int i = 0; i < CGame.NumRounds; i++)
{ {
SPlayer[] points = _Points.GetPlayer(i, CGame.NumPlayer); SPlayer[] points = _Points.GetPlayer(i, CGame.NumPlayer);
for (int p = 0; p < player.Length; p++) for (int p = 0; p < players.Length; p++)
{ {
if (i < 1) if (i < 1)
player[p].ProfileID = points[p].ProfileID; players[p].ProfileID = points[p].ProfileID;
player[p].Points += points[p].Points; players[p].Points += points[p].Points;
} }
} }
for (int p = 0; p < player.Length; p++) for (int p = 0; p < players.Length; p++)
player[p].Points = (int)Math.Round(player[p].Points / CGame.NumRounds); players[p].Points = (int)Math.Round(players[p].Points / CGame.NumRounds);
} }
for (int p = 0; p < player.Length; p++) for (int p = 0; p < players.Length; p++)
{ {
string name = CProfiles.GetPlayerName(player[p].ProfileID, p); string name = CProfiles.GetPlayerName(players[p].ProfileID, p);
if (song != null && song.IsDuet) if (song != null && song.IsDuet)
{ {
if (player[p].LineNr == 0 && song.DuetPart1 != "Part 1") if (players[p].LineNr == 0 && song.DuetPart1 != "Part 1")
name += " (" + song.DuetPart1 + ")"; name += " (" + song.DuetPart1 + ")";
else if (player[p].LineNr == 1 && song.DuetPart2 != "Part 2") else if (players[p].LineNr == 1 && song.DuetPart2 != "Part 2")
name += " (" + song.DuetPart2 + ")"; name += " (" + song.DuetPart2 + ")";
} }
_Texts[_TextNames[p, CGame.NumPlayer - 1]].Text = name; _Texts[_TextNames[p, CGame.NumPlayer - 1]].Text = name;
if (CGame.NumPlayer < (int)_ScreenSettings[_ScreenSettingShortScore].GetValue()) if (CGame.NumPlayer < (int)_ScreenSettings[_ScreenSettingShortScore].GetValue())
_Texts[_TextScores[p, CGame.NumPlayer - 1]].Text = ((int)Math.Round(player[p].Points)).ToString("0000") + " " + CLanguage.Translate("TR_SCREENSCORE_POINTS"); _Texts[_TextScores[p, CGame.NumPlayer - 1]].Text = ((int)Math.Round(players[p].Points)).ToString("0000") + " " + CLanguage.Translate("TR_SCREENSCORE_POINTS");
else else
_Texts[_TextScores[p, CGame.NumPlayer - 1]].Text = ((int)Math.Round(player[p].Points)).ToString("0000"); _Texts[_TextScores[p, CGame.NumPlayer - 1]].Text = ((int)Math.Round(players[p].Points)).ToString("0000");
if (CGame.NumPlayer < (int)_ScreenSettings[_ScreenSettingShortDifficulty].GetValue()) if (CGame.NumPlayer < (int)_ScreenSettings[_ScreenSettingShortDifficulty].GetValue())
{ {
_Texts[_TextDifficulty[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate("TR_SCREENSCORE_GAMEDIFFICULTY") + ": " + _Texts[_TextDifficulty[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate("TR_SCREENSCORE_GAMEDIFFICULTY") + ": " +
CLanguage.Translate(CProfiles.GetDifficulty(player[p].ProfileID).ToString()); CLanguage.Translate(CProfiles.GetDifficulty(players[p].ProfileID).ToString());
} }
else else
_Texts[_TextDifficulty[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate(CProfiles.GetDifficulty(player[p].ProfileID).ToString()); _Texts[_TextDifficulty[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate(CProfiles.GetDifficulty(players[p].ProfileID).ToString());
if (CGame.NumPlayer < (int)_ScreenSettings[_ScreenSettingShortRating].GetValue()) if (CGame.NumPlayer < (int)_ScreenSettings[_ScreenSettingShortRating].GetValue())
{ {
_Texts[_TextRatings[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate("TR_SCREENSCORE_RATING") + ": " + _Texts[_TextRatings[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate("TR_SCREENSCORE_RATING") + ": " +
CLanguage.Translate(_GetRating((int)Math.Round(player[p].Points))); CLanguage.Translate(_GetRating((int)Math.Round(players[p].Points)));
} }
else else
_Texts[_TextRatings[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate(_GetRating((int)Math.Round(player[p].Points))); _Texts[_TextRatings[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate(_GetRating((int)Math.Round(players[p].Points)));
_StaticPointsBarDrawnPoints[p] = 0.0; _StaticPointsBarDrawnPoints[p] = 0.0;
string direction = (string)_ScreenSettings[_ScreenSettingAnimationDirection].GetValue(); string direction = (string)_ScreenSettings[_ScreenSettingAnimationDirection].GetValue();
@@ -331,19 +331,19 @@ namespace Vocaluxe.Screens
_Statics[_StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.Y - _Statics[_StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.Y -
_Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H; _Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H;
} }
if (CProfiles.IsProfileIDValid(player[p].ProfileID)) if (CProfiles.IsProfileIDValid(players[p].ProfileID))
_Statics[_StaticAvatar[p, CGame.NumPlayer - 1]].Texture = CProfiles.Profiles[player[p].ProfileID].Avatar.Texture; _Statics[_StaticAvatar[p, CGame.NumPlayer - 1]].Texture = CProfiles.Profiles[players[p].ProfileID].Avatar.Texture;
} }
if (CConfig.ScoreAnimationTime < 1) if (CConfig.ScoreAnimationTime < 1)
{ {
for (int p = 0; p < CGame.NumPlayer; p++) for (int p = 0; p < CGame.NumPlayer; p++)
{ {
_Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H = ((float)player[p].Points) * (_Statics[_StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.H / 10000); _Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H = ((float)players[p].Points) * (_Statics[_StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.H / 10000);
_Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.Y = _Statics[_StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.H + _Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.Y = _Statics[_StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.H +
_Statics[_StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.Y - _Statics[_StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.Y -
_Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H; _Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H;
_StaticPointsBarDrawnPoints[p] = player[p].Points; _StaticPointsBarDrawnPoints[p] = players[p].Points;
} }
} }
+52 -111
View File
@@ -19,6 +19,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Vocaluxe.Base; using Vocaluxe.Base;
using Vocaluxe.GameModes;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu; using VocaluxeLib.Menu.SongMenu;
@@ -43,110 +44,77 @@ namespace Vocaluxe.SongQueue
private CPoints _Points; private CPoints _Points;
#region Implementation #region Implementation
public virtual void Init() public void Init()
{ {
_SongQueque = new List<SSongQueueEntry>(); _SongQueque = new List<SSongQueueEntry>();
Reset(); Reset();
CGameModes.Init();
} }
public virtual EGameMode GetCurrentGameMode() public EGameMode GetCurrentGameMode()
{ {
if (_CurrentSong >= 0 && _CurrentSong < _SongQueque.Count) if (_CurrentSong >= 0 && _CurrentSong < _SongQueque.Count)
return _SongQueque[_CurrentSong].GameMode; return _SongQueque[_CurrentSong].GameMode;
return EGameMode.TR_GAMEMODE_NORMAL; return EGameMode.TR_GAMEMODE_NORMAL;
} }
public virtual bool AddVisibleSong(int visibleIndex, EGameMode gameMode) public bool AddVisibleSong(int visibleIndex, EGameMode gameMode)
{ {
if (CSongs.VisibleSongs.Length > visibleIndex) return CSongs.VisibleSongs.Length > visibleIndex && _AddSong(CSongs.VisibleSongs[visibleIndex].ID, gameMode);
{ }
int songID = CSongs.VisibleSongs[visibleIndex].ID;
if (gameMode == EGameMode.TR_GAMEMODE_DUET && !CSongs.GetSong(songID).IsDuet)
return false;
_SongQueque.Add(new SSongQueueEntry(songID, gameMode)); public bool AddSong(int absoluteIndex, EGameMode gameMode)
{
return CSongs.AllSongs.Length > absoluteIndex && _AddSong(CSongs.AllSongs[absoluteIndex].ID, gameMode);
}
private bool _AddSong(int songID, EGameMode gameMode)
{
if (gameMode == EGameMode.TR_GAMEMODE_DUET && !CSongs.GetSong(songID).IsDuet)
return false;
_SongQueque.Add(new SSongQueueEntry(songID, gameMode));
return true;
}
public bool RemoveVisibleSong(int visibleIndex)
{
return CSongs.VisibleSongs.Length > visibleIndex && _RemoveSong(CSongs.VisibleSongs[visibleIndex].ID);
}
public bool RemoveSong(int absoluteIndex)
{
return CSongs.AllSongs.Length > absoluteIndex && _RemoveSong(CSongs.AllSongs[absoluteIndex].ID);
}
private bool _RemoveSong(int songID)
{
for (int i = 0; i < _SongQueque.Count; i++)
{
if (_SongQueque[i].SongID != songID)
continue;
_SongQueque.RemoveAt(i);
return true; return true;
} }
return false; return false;
} }
public virtual bool AddSong(int absoluteIndex, EGameMode gameMode) public void ClearSongs()
{
if (CSongs.AllSongs.Length > absoluteIndex)
{
int songID = CSongs.AllSongs[absoluteIndex].ID;
if (gameMode == EGameMode.TR_GAMEMODE_DUET && !CSongs.GetSong(songID).IsDuet)
return false;
_SongQueque.Add(new SSongQueueEntry(songID, gameMode));
return true;
}
return false;
}
public virtual bool RemoveVisibleSong(int visibleIndex)
{
if (CSongs.VisibleSongs.Length > visibleIndex)
{
int index = -1;
int songID = CSongs.VisibleSongs[visibleIndex].ID;
for (int i = 0; i < _SongQueque.Count; i++)
{
if (_SongQueque[i].SongID == songID)
{
index = i;
break;
}
}
if (index == -1)
return false;
_SongQueque.RemoveAt(index);
return true;
}
return false;
}
public virtual bool RemoveSong(int absoluteIndex)
{
if (CSongs.AllSongs.Length > absoluteIndex)
{
int index = -1;
int songID = CSongs.AllSongs[absoluteIndex].ID;
for (int i = 0; i < _SongQueque.Count; i++)
{
if (_SongQueque[i].SongID == songID)
{
index = i;
break;
}
}
if (index == -1)
return false;
_SongQueque.RemoveAt(index);
return true;
}
return false;
}
public virtual void ClearSongs()
{ {
_SongQueque.Clear(); _SongQueque.Clear();
} }
public virtual void Reset() public void Reset()
{ {
_CurrentSong = -1; _CurrentSong = -1;
} }
public virtual void Start(SPlayer[] player) public void Start(SPlayer[] players)
{ {
_Points = new CPoints(_SongQueque.Count, player); _Points = new CPoints(_SongQueque.Count, players);
} }
public virtual void NextRound(SPlayer[] player) public void NextRound(SPlayer[] players)
{ {
if (_CurrentSong < _SongQueque.Count && _SongQueque.Count > 0) if (_CurrentSong < _SongQueque.Count && _SongQueque.Count > 0)
{ {
@@ -155,7 +123,7 @@ namespace Vocaluxe.SongQueue
_Points.SetPoints( _Points.SetPoints(
_CurrentSong, _CurrentSong,
_SongQueque[_CurrentSong].SongID, _SongQueque[_CurrentSong].SongID,
player, players,
_SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_MEDLEY, _SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_MEDLEY,
_SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_DUET, _SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_DUET,
_SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_SHORTSONG); _SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_SHORTSONG);
@@ -164,56 +132,29 @@ namespace Vocaluxe.SongQueue
} }
} }
public virtual bool IsFinished() public bool IsFinished()
{ {
return _CurrentSong == _SongQueque.Count || _SongQueque.Count == 0; return _CurrentSong == _SongQueque.Count || _SongQueque.Count == 0;
} }
public virtual int GetCurrentRoundNr() public int GetCurrentRoundNr()
{ {
return _CurrentSong + 1; return _CurrentSong + 1;
} }
public virtual CSong GetSong() public CSong GetSong()
{ {
if (_CurrentSong >= 0 && _CurrentSong < _SongQueque.Count) if (_CurrentSong >= 0 && _CurrentSong < _SongQueque.Count)
{ CGameModes.Get(GetCurrentGameMode()).GetSong(_SongQueque[_CurrentSong].SongID);
CSong song = CSongs.GetSong(_SongQueque[_CurrentSong].SongID);
song = new CSong(song);
switch (GetCurrentGameMode())
{
case EGameMode.TR_GAMEMODE_MEDLEY:
// set medley mode timings
song.Start = CGame.GetTimeFromBeats(song.Medley.StartBeat, song.BPM) - song.Medley.FadeInTime + song.Gap;
if (song.Start < 0f)
song.Start = 0f;
song.Finish = CGame.GetTimeFromBeats(song.Medley.EndBeat, song.BPM) + song.Medley.FadeOutTime + song.Gap;
// set lines to medley mode
song.Notes.SetMedley(song.Medley.StartBeat, song.Medley.EndBeat);
break;
case EGameMode.TR_GAMEMODE_SHORTSONG:
song.Finish = CGame.GetTimeFromBeats(song.ShortEnd, song.BPM) + CSettings.DefaultMedleyFadeOutTime + song.Gap;
// set lines to medley mode
song.Notes.SetMedley(song.Notes.GetVoice(0).Lines[0].FirstNoteBeat, song.ShortEnd);
break;
}
return song;
}
return null; return null;
} }
public virtual int GetNumSongs() public int GetNumSongs()
{ {
return _SongQueque.Count; return _SongQueque.Count;
} }
public virtual CSong GetSong(int num) public CSong GetSong(int num)
{ {
if (num - 1 < _SongQueque.Count && num > 0) if (num - 1 < _SongQueque.Count && num > 0)
return CSongs.GetSong(_SongQueque[num - 1].SongID); return CSongs.GetSong(_SongQueque[num - 1].SongID);
@@ -221,7 +162,7 @@ namespace Vocaluxe.SongQueue
return null; return null;
} }
public virtual EGameMode GetGameMode(int num) public EGameMode GetGameMode(int num)
{ {
if (num - 1 < _SongQueque.Count && num > 0) if (num - 1 < _SongQueque.Count && num > 0)
return _SongQueque[num - 1].GameMode; return _SongQueque[num - 1].GameMode;
@@ -229,7 +170,7 @@ namespace Vocaluxe.SongQueue
return EGameMode.TR_GAMEMODE_NORMAL; return EGameMode.TR_GAMEMODE_NORMAL;
} }
public virtual CPoints GetPoints() public CPoints GetPoints()
{ {
return _Points; return _Points;
} }
+2 -2
View File
@@ -35,8 +35,8 @@ namespace Vocaluxe.SongQueue
void ClearSongs(); void ClearSongs();
void Reset(); void Reset();
void Start(SPlayer[] player); void Start(SPlayer[] players);
void NextRound(SPlayer[] player); void NextRound(SPlayer[] players);
bool IsFinished(); bool IsFinished();
int GetCurrentRoundNr(); int GetCurrentRoundNr();
+3
View File
@@ -198,7 +198,10 @@
<Compile Include="CSplashScreen.cs"> <Compile Include="CSplashScreen.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="GameModes\CGameMode.cs" />
<Compile Include="GameModes\CGameModes.cs" />
<Compile Include="SongQueue\CSongQueue.cs" /> <Compile Include="SongQueue\CSongQueue.cs" />
<Compile Include="GameModes\IGameMode.cs" />
<Compile Include="SongQueue\ISongQueue.cs" /> <Compile Include="SongQueue\ISongQueue.cs" />
<Compile Include="GlobalSuppressions.cs" /> <Compile Include="GlobalSuppressions.cs" />
<Compile Include="Lib\Draw\CDirect3D.cs"> <Compile Include="Lib\Draw\CDirect3D.cs">
+14 -14
View File
@@ -80,23 +80,23 @@ namespace VocaluxeLib.Menu
if (round >= NumRounds) if (round >= NumRounds)
return new SPlayer[1]; return new SPlayer[1];
SPlayer[] player = new SPlayer[numPlayer]; SPlayer[] players = new SPlayer[numPlayer];
for (int p = 0; p < player.Length; p++) for (int p = 0; p < players.Length; p++)
{ {
player[p].Points = _Rounds[round, p].Points; players[p].Points = _Rounds[round, p].Points;
player[p].PointsGoldenNotes = _Rounds[round, p].PointsGoldenNotes; players[p].PointsGoldenNotes = _Rounds[round, p].PointsGoldenNotes;
player[p].PointsLineBonus = _Rounds[round, p].PointsLineBonus; players[p].PointsLineBonus = _Rounds[round, p].PointsLineBonus;
player[p].SongID = _Rounds[round, p].SongID; players[p].SongID = _Rounds[round, p].SongID;
player[p].LineNr = _Rounds[round, p].LineNr; players[p].LineNr = _Rounds[round, p].LineNr;
player[p].Medley = _Rounds[round, p].Medley; players[p].Medley = _Rounds[round, p].Medley;
player[p].Duet = _Rounds[round, p].Duet; players[p].Duet = _Rounds[round, p].Duet;
player[p].ShortSong = _Rounds[round, p].ShortSong; players[p].ShortSong = _Rounds[round, p].ShortSong;
player[p].DateTicks = _Rounds[round, p].DateTicks; players[p].DateTicks = _Rounds[round, p].DateTicks;
player[p].SongFinished = _Rounds[round, p].SongFinished; players[p].SongFinished = _Rounds[round, p].SongFinished;
player[p].ProfileID = _Rounds[round, p].ProfileID; players[p].ProfileID = _Rounds[round, p].ProfileID;
} }
return player; return players;
} }
} }
} }
+1
View File
@@ -423,6 +423,7 @@ namespace VocaluxeLib.Menu.SingNotes
return _PerfectLine; return _PerfectLine;
} }
//Find last note with StartBeat<=Beat
public int FindPreviousNote(int beat) public int FindPreviousNote(int beat)
{ {
//If no notes -> No previous note //If no notes -> No previous note
+5 -19
View File
@@ -116,7 +116,6 @@ namespace VocaluxeLib.Menu.SongMenu
{ {
private bool _CoverSmallLoaded; private bool _CoverSmallLoaded;
private bool _CoverBigLoaded; private bool _CoverBigLoaded;
private bool _NotesLoaded;
private STexture _CoverTextureSmall = new STexture(-1); private STexture _CoverTextureSmall = new STexture(-1);
private STexture _CoverTextureBig = new STexture(-1); private STexture _CoverTextureBig = new STexture(-1);
@@ -140,18 +139,7 @@ namespace VocaluxeLib.Menu.SongMenu
public EAspect VideoAspect = EAspect.Crop; public EAspect VideoAspect = EAspect.Crop;
public bool CoverSmallLoaded public bool NotesLoaded { get; private set; }
{
get { return _CoverSmallLoaded; }
}
public bool CoverBigLoaded
{
get { return _CoverBigLoaded; }
}
public bool NotesLoaded
{
get { return _NotesLoaded; }
}
public STexture CoverTextureSmall public STexture CoverTextureSmall
{ {
@@ -173,9 +161,7 @@ namespace VocaluxeLib.Menu.SongMenu
{ {
get get
{ {
if (_CoverBigLoaded) return _CoverBigLoaded ? _CoverTextureBig : _CoverTextureSmall;
return _CoverTextureBig;
return _CoverTextureSmall;
} }
set set
{ {
@@ -278,7 +264,7 @@ namespace VocaluxeLib.Menu.SongMenu
VideoAspect = song.VideoAspect; VideoAspect = song.VideoAspect;
_CoverSmallLoaded = song._CoverSmallLoaded; _CoverSmallLoaded = song._CoverSmallLoaded;
_CoverBigLoaded = song._CoverBigLoaded; _CoverBigLoaded = song._CoverBigLoaded;
_NotesLoaded = song._NotesLoaded; NotesLoaded = song.NotesLoaded;
Artist = song.Artist; Artist = song.Artist;
Title = song.Title; Title = song.Title;
@@ -619,7 +605,7 @@ namespace VocaluxeLib.Menu.SongMenu
private bool _ReadNotes(string filePath, bool forceReload = false) private bool _ReadNotes(string filePath, bool forceReload = false)
{ {
//Skip loading if already done and no reload is forced //Skip loading if already done and no reload is forced
if (_NotesLoaded && !forceReload) if (NotesLoaded && !forceReload)
return true; return true;
if (!File.Exists(filePath)) if (!File.Exists(filePath))
@@ -784,7 +770,7 @@ namespace VocaluxeLib.Menu.SongMenu
{ {
_FindRefrain(); _FindRefrain();
_FindShortEnd(); _FindShortEnd();
_NotesLoaded = true; NotesLoaded = true;
if (IsDuet) if (IsDuet)
_CheckDuet(); _CheckDuet();
} }