Merge remote-tracking branch 'upstream/develop' into medley

This commit is contained in:
Florian Kuepper committed 2012-06-17 17:52:24 +02:00
commit 5f00a432e1
10 files changed
+117 -107

No files matched your search

+8 -24
View File
@@ -108,41 +108,25 @@ namespace Vocaluxe.Base
CConfig.UsePlayers(); CConfig.UsePlayers();
} }
public static void SetGameMode(EGameMode Mode) public static void EnterNomalGame()
{ {
switch (Mode) _GameMode = new CGameModeNormal();
{
case EGameMode.TR_GAMEMODE_NORMAL:
_GameMode = new CGameModeNormal();
break;
case EGameMode.TR_GAMEMODE_MEDLEY:
_GameMode = new CGameModeMedley();
break;
case EGameMode.TR_GAMEMODE_DUET:
_GameMode = new CGameModeDuet();
break;
case EGameMode.TR_GAMEMODE_SHORTSONG:
_GameMode = new CGameModeShortSong();
break;
default:
break;
}
_GameMode.Init(); _GameMode.Init();
} }
public static EGameMode GameMode public static EGameMode GameMode
{ {
get { return _GameMode.GetGameMode(); } get { return _GameMode.GetCurrentGameMode(); }
} }
public static bool AddVisibleSong(int VisibleIndex) public static bool AddVisibleSong(int VisibleIndex, EGameMode GameMode)
{ {
return _GameMode.AddVisibleSong(VisibleIndex); return _GameMode.AddVisibleSong(VisibleIndex, GameMode);
} }
public static bool AddSong(int AbsoluteIndex) public static bool AddSong(int AbsoluteIndex, EGameMode GameMode)
{ {
return _GameMode.AddSong(AbsoluteIndex); return _GameMode.AddSong(AbsoluteIndex, GameMode);
} }
public static bool RemoveVisibleSong(int VisibleIndex) public static bool RemoveVisibleSong(int VisibleIndex)
@@ -182,7 +166,7 @@ namespace Vocaluxe.Base
public static int RoundNr public static int RoundNr
{ {
get { return _GameMode.GetActualRoundNr(); } get { return _GameMode.GetCurrentRoundNr(); }
} }
public static CSong GetSong() public static CSong GetSong()
+68 -47
View File
@@ -7,6 +7,18 @@ using Vocaluxe.Lib.Song;
namespace Vocaluxe.GameModes namespace Vocaluxe.GameModes
{ {
struct SongQueque
{
public int SongID;
public EGameMode GameMode;
public SongQueque(int songID, EGameMode gameMode)
{
SongID = songID;
GameMode = gameMode;
}
}
class CPoints class CPoints
{ {
private SPlayer[,] _Rounds; private SPlayer[,] _Rounds;
@@ -90,40 +102,49 @@ namespace Vocaluxe.GameModes
abstract class CGameMode : IGameMode abstract class CGameMode : IGameMode
{ {
protected bool _Initialized = false; protected bool _Initialized = false;
protected EGameMode _GameMode; protected List<SongQueque> _SongQueque;
protected List<CSong> _Songs; protected int _CurrentSong;
protected int _ActualSong;
protected CPoints _Points; protected CPoints _Points;
#region Implementation #region Implementation
public virtual void Init() public virtual void Init()
{ {
_Songs = new List<CSong>(); _SongQueque = new List<SongQueque>();
Reset(); Reset();
} }
public virtual EGameMode GetGameMode() public virtual EGameMode GetCurrentGameMode()
{ {
return _GameMode; if (_CurrentSong >= 0 && _CurrentSong < _SongQueque.Count)
{
return _SongQueque[_CurrentSong].GameMode;
}
return EGameMode.TR_GAMEMODE_NORMAL;
} }
public virtual bool AddVisibleSong(int VisibleIndex) public virtual bool AddVisibleSong(int VisibleIndex, EGameMode GameMode)
{ {
if (CSongs.VisibleSongs.Length > VisibleIndex) if (CSongs.VisibleSongs.Length > VisibleIndex)
{ {
_Songs.Add(new CSong(CSongs.VisibleSongs[VisibleIndex])); int SongID = CSongs.VisibleSongs[VisibleIndex].ID;
SongManipulation(_Songs.Count - 1); if (GameMode == EGameMode.TR_GAMEMODE_DUET && !CSongs.GetSong(SongID).IsDuet)
return false;
_SongQueque.Add(new SongQueque(SongID, GameMode));
return true; return true;
} }
return false; return false;
} }
public virtual bool AddSong(int AbsoluteIndex) public virtual bool AddSong(int AbsoluteIndex, EGameMode GameMode)
{ {
if (CSongs.AllSongs.Length > AbsoluteIndex) if (CSongs.AllSongs.Length > AbsoluteIndex)
{ {
_Songs.Add(CSongs.AllSongs[AbsoluteIndex]); int SongID = CSongs.AllSongs[AbsoluteIndex].ID;
SongManipulation(_Songs.Count - 1); if (GameMode == EGameMode.TR_GAMEMODE_DUET && !CSongs.GetSong(SongID).IsDuet)
return false;
_SongQueque.Add(new SongQueque(SongID, GameMode));
return true; return true;
} }
return false; return false;
@@ -133,24 +154,22 @@ namespace Vocaluxe.GameModes
{ {
if (CSongs.VisibleSongs.Length > VisibleIndex) if (CSongs.VisibleSongs.Length > VisibleIndex)
{ {
int ID = CSongs.VisibleSongs[VisibleIndex].ID;
int index = -1; int index = -1;
int SongID = CSongs.VisibleSongs[VisibleIndex].ID;
for (int i = 0; i < _Songs.Count; i++) for (int i = 0; i < _SongQueque.Count; i++)
{ {
if (_Songs[i].ID == ID) if (_SongQueque[i].SongID == SongID)
{ {
index = i; index = i;
break; break;
} }
} }
if (index > -1) if (index == -1)
{ return false;
_Songs.RemoveAt(index);
return true; _SongQueque.RemoveAt(index);
} return true;
return false;
} }
return false; return false;
} }
@@ -159,83 +178,85 @@ namespace Vocaluxe.GameModes
{ {
if (CSongs.AllSongs.Length > AbsoluteIndex) if (CSongs.AllSongs.Length > AbsoluteIndex)
{ {
int ID = CSongs.AllSongs[AbsoluteIndex].ID;
int index = -1; int index = -1;
int SongID = CSongs.AllSongs[AbsoluteIndex].ID;
for (int i = 0; i < _Songs.Count; i++) for (int i = 0; i < _SongQueque.Count; i++)
{ {
if (_Songs[i].ID == ID) if (_SongQueque[i].SongID == SongID)
{ {
index = i; index = i;
break; break;
} }
} }
if (index == -1)
return false;
if (index > -1) _SongQueque.RemoveAt(index);
{ return true;
_Songs.RemoveAt(index);
return true;
}
return false;
} }
return false; return false;
} }
public virtual void ClearSongs() public virtual void ClearSongs()
{ {
_Songs.Clear(); _SongQueque.Clear();
} }
public virtual void Reset() public virtual void Reset()
{ {
_ActualSong = -1; _CurrentSong = -1;
} }
public virtual void Start(SPlayer[] Player) public virtual void Start(SPlayer[] Player)
{ {
_Points = new CPoints(_Songs.Count, Player); _Points = new CPoints(_SongQueque.Count, Player);
} }
public virtual void NextRound(SPlayer[] Player) public virtual void NextRound(SPlayer[] Player)
{ {
if (_ActualSong < _Songs.Count && _Songs.Count > 0) if (_CurrentSong < _SongQueque.Count && _SongQueque.Count > 0)
{ {
if (_ActualSong > -1) if (_CurrentSong > -1)
{ {
_Points.SetPoints(_ActualSong, _Songs[_ActualSong].ID, Player, _GameMode == EGameMode.TR_GAMEMODE_MEDLEY, _GameMode == EGameMode.TR_GAMEMODE_DUET); _Points.SetPoints(
_CurrentSong,
_SongQueque[_CurrentSong].SongID,
Player,
_SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_MEDLEY,
_SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_DUET);
} }
_ActualSong++; _CurrentSong++;
} }
} }
public virtual bool IsFinished() public virtual bool IsFinished()
{ {
return (_ActualSong == _Songs.Count || _Songs.Count == 0); return (_CurrentSong == _SongQueque.Count || _SongQueque.Count == 0);
} }
public virtual int GetActualRoundNr() public virtual int GetCurrentRoundNr()
{ {
return _ActualSong + 1; return _CurrentSong + 1;
} }
public virtual CSong GetSong() public virtual CSong GetSong()
{ {
if (_ActualSong >= 0 && _ActualSong < _Songs.Count) if (_CurrentSong >= 0 && _CurrentSong < _SongQueque.Count)
{ {
return _Songs[_ActualSong]; return CSongs.GetSong(_SongQueque[_CurrentSong].SongID);
} }
return null; return null;
} }
public virtual int GetNumSongs() public virtual int GetNumSongs()
{ {
return _Songs.Count; return _SongQueque.Count;
} }
public virtual CSong GetSong(int Num) public virtual CSong GetSong(int Num)
{ {
if (Num - 1 < _Songs.Count) if (Num - 1 < _SongQueque.Count)
return _Songs[Num - 1]; return CSongs.GetSong(_SongQueque[Num - 1].SongID);
return null; return null;
} }
-1
View File
@@ -10,7 +10,6 @@ namespace Vocaluxe.GameModes
{ {
base.Init(); base.Init();
_GameMode = EGameMode.TR_GAMEMODE_DUET;
_Initialized = true; _Initialized = true;
} }
} }
+1 -2
View File
@@ -13,13 +13,12 @@ namespace Vocaluxe.GameModes
{ {
base.Init(); base.Init();
_GameMode = EGameMode.TR_GAMEMODE_MEDLEY;
_Initialized = true; _Initialized = true;
} }
protected override void SongManipulation(int SongIndex) protected override void SongManipulation(int SongIndex)
{ {
CSong song = _Songs[SongIndex]; CSong song = CSongs.AllSongs[_SongQueque[SongIndex].SongID];
// set medley mode timings // set medley mode timings
song.Start = CGame.GetTimeFromBeats(song.Medley.StartBeat, song.BPM) - song.Medley.FadeInTime + song.Gap; song.Start = CGame.GetTimeFromBeats(song.Medley.StartBeat, song.BPM) - song.Medley.FadeInTime + song.Gap;
+1 -1
View File
@@ -4,13 +4,13 @@ using System.Text;
namespace Vocaluxe.GameModes namespace Vocaluxe.GameModes
{ {
// Nomal singing
class CGameModeNormal : CGameMode class CGameModeNormal : CGameMode
{ {
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
_GameMode = EGameMode.TR_GAMEMODE_NORMAL;
_Initialized = true; _Initialized = true;
} }
} }
+1 -2
View File
@@ -13,13 +13,12 @@ namespace Vocaluxe.GameModes
{ {
base.Init(); base.Init();
_GameMode = EGameMode.TR_GAMEMODE_SHORTSONG;
_Initialized = true; _Initialized = true;
} }
protected override void SongManipulation(int SongIndex) protected override void SongManipulation(int SongIndex)
{ {
CSong song = _Songs[SongIndex]; CSong song = CSongs.AllSongs[_SongQueque[SongIndex].SongID];
song.Finish = CGame.GetTimeFromBeats(song.ShortEnd, song.BPM) + CSettings.DefaultMedleyFadeOutTime + song.Gap; song.Finish = CGame.GetTimeFromBeats(song.ShortEnd, song.BPM) + CSettings.DefaultMedleyFadeOutTime + song.Gap;
+6 -5
View File
@@ -19,10 +19,10 @@ namespace Vocaluxe.GameModes
{ {
void Init(); void Init();
EGameMode GetGameMode(); EGameMode GetCurrentGameMode();
bool AddVisibleSong(int VisibleIndex); bool AddVisibleSong(int VisibleIndex, EGameMode GameMode);
bool AddSong(int AbsoluteIndex); bool AddSong(int AbsoluteIndex, EGameMode GameMode);
bool RemoveVisibleSong(int VisibleIndex); bool RemoveVisibleSong(int VisibleIndex);
bool RemoveSong(int AbsoluteIndex); bool RemoveSong(int AbsoluteIndex);
void ClearSongs(); void ClearSongs();
@@ -31,11 +31,12 @@ namespace Vocaluxe.GameModes
void Start(SPlayer[] Player); void Start(SPlayer[] Player);
void NextRound(SPlayer[] Player); void NextRound(SPlayer[] Player);
bool IsFinished(); bool IsFinished();
int GetActualRoundNr(); int GetCurrentRoundNr();
CSong GetSong();
CPoints GetPoints(); CPoints GetPoints();
int GetNumSongs(); int GetNumSongs();
CSong GetSong();
CSong GetSong(int Num); CSong GetSong(int Num);
} }
} }
@@ -5,6 +5,7 @@ using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using Vocaluxe.GameModes;
using Vocaluxe.Lib.Draw; using Vocaluxe.Lib.Draw;
using Vocaluxe.Menu; using Vocaluxe.Menu;
using Vocaluxe.Lib.Song; using Vocaluxe.Lib.Song;
@@ -213,14 +214,14 @@ namespace Vocaluxe.Screens
{ {
if (SongNr >= 0 && CSongs.SongsLoaded) if (SongNr >= 0 && CSongs.SongsLoaded)
{ {
if (Duet)
CGame.SetGameMode(GameModes.EGameMode.TR_GAMEMODE_DUET);
else
CGame.SetGameMode(GameModes.EGameMode.TR_GAMEMODE_NORMAL);
CGame.Reset(); CGame.Reset();
CGame.ClearSongs(); CGame.ClearSongs();
CGame.AddSong(SongNr);
EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
if (CSongs.VisibleSongs[SongNr].IsDuet)
gm = EGameMode.TR_GAMEMODE_DUET;
CGame.AddSong(SongNr, gm);
CGraphics.FadeTo(EScreens.ScreenNames); CGraphics.FadeTo(EScreens.ScreenNames);
} }
+22 -18
View File
@@ -7,6 +7,7 @@ using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using Vocaluxe.Base; using Vocaluxe.Base;
using Vocaluxe.GameModes;
using Vocaluxe.Lib.Draw; using Vocaluxe.Lib.Draw;
using Vocaluxe.Lib.Song; using Vocaluxe.Lib.Song;
using Vocaluxe.Menu; using Vocaluxe.Menu;
@@ -265,7 +266,7 @@ namespace Vocaluxe.Screens
public override void OnShow() public override void OnShow()
{ {
base.OnShow(); base.OnShow();
CGame.EnterNomalGame();
SongMenus[htSongMenus(SongMenu)].OnShow(); SongMenus[htSongMenus(SongMenu)].OnShow();
} }
@@ -327,22 +328,23 @@ namespace Vocaluxe.Screens
{ {
if ((CSongs.Category >= 0) && (SongNr >= 0)) if ((CSongs.Category >= 0) && (SongNr >= 0))
{ {
EGameMode gm;
if (_AvailableGameModes.Count >= SelectSlides[htSelectSlides(SelectSlideOptionsMode)].Selection) if (_AvailableGameModes.Count >= SelectSlides[htSelectSlides(SelectSlideOptionsMode)].Selection)
{ {
CGame.SetGameMode(_AvailableGameModes[SelectSlides[htSelectSlides(SelectSlideOptionsMode)].Selection]); gm = _AvailableGameModes[SelectSlides[htSelectSlides(SelectSlideOptionsMode)].Selection];
} }
else else
{ {
if (CSongs.VisibleSongs[SongNr].IsDuet) if (CSongs.VisibleSongs[SongNr].IsDuet)
CGame.SetGameMode(GameModes.EGameMode.TR_GAMEMODE_DUET); gm = GameModes.EGameMode.TR_GAMEMODE_DUET;
else else
CGame.SetGameMode(GameModes.EGameMode.TR_GAMEMODE_NORMAL); gm = GameModes.EGameMode.TR_GAMEMODE_NORMAL;
} }
CGame.Reset(); CGame.Reset();
CGame.ClearSongs(); CGame.ClearSongs();
CGame.AddVisibleSong(SongNr);
//CGame.AddSong(SongNr+1); CGame.AddVisibleSong(SongNr, gm);
CGraphics.FadeTo(EScreens.ScreenNames); CGraphics.FadeTo(EScreens.ScreenNames);
} }
@@ -352,14 +354,15 @@ namespace Vocaluxe.Screens
{ {
if ((CSongs.Category >= 0) && (SongNr >= 0)) if ((CSongs.Category >= 0) && (SongNr >= 0))
{ {
EGameMode gm;
if (CSongs.VisibleSongs[SongNr].Medley.Source != EMedleySource.None) if (CSongs.VisibleSongs[SongNr].Medley.Source != EMedleySource.None)
CGame.SetGameMode(GameModes.EGameMode.TR_GAMEMODE_MEDLEY); gm = GameModes.EGameMode.TR_GAMEMODE_MEDLEY;
else else
return; return;
CGame.Reset(); CGame.Reset();
CGame.ClearSongs(); CGame.ClearSongs();
CGame.AddVisibleSong(SongNr); CGame.AddVisibleSong(SongNr, gm);
CGraphics.FadeTo(EScreens.ScreenNames); CGraphics.FadeTo(EScreens.ScreenNames);
} }
@@ -369,7 +372,6 @@ namespace Vocaluxe.Screens
{ {
CGame.Reset(); CGame.Reset();
CGame.ClearSongs(); CGame.ClearSongs();
CGame.SetGameMode(GameModes.EGameMode.TR_GAMEMODE_NORMAL);
List<int> IDs = new List<int>(); List<int> IDs = new List<int>();
for (int i = 0; i < CSongs.AllSongs.Length; i++) for (int i = 0; i < CSongs.AllSongs.Length; i++)
@@ -381,10 +383,11 @@ namespace Vocaluxe.Screens
{ {
int SongNr = IDs[CGame.Rand.Next(IDs.Count)]; int SongNr = IDs[CGame.Rand.Next(IDs.Count)];
if (!CSongs.AllSongs[SongNr].IsDuet) EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
{ if (CSongs.VisibleSongs[SongNr].IsDuet)
CGame.AddSong(SongNr); gm = EGameMode.TR_GAMEMODE_DUET;
} CGame.AddSong(SongNr, gm);
IDs.Remove(SongNr); IDs.Remove(SongNr);
} }
@@ -396,7 +399,6 @@ namespace Vocaluxe.Screens
{ {
CGame.Reset(); CGame.Reset();
CGame.ClearSongs(); CGame.ClearSongs();
CGame.SetGameMode(GameModes.EGameMode.TR_GAMEMODE_NORMAL);
List<int> IDs = new List<int>(); List<int> IDs = new List<int>();
for (int i = 0; i < CSongs.VisibleSongs.Length; i++) for (int i = 0; i < CSongs.VisibleSongs.Length; i++)
@@ -408,10 +410,12 @@ namespace Vocaluxe.Screens
{ {
int SongNr = IDs[CGame.Rand.Next(IDs.Count)]; int SongNr = IDs[CGame.Rand.Next(IDs.Count)];
if (!CSongs.AllSongs[SongNr].IsDuet) EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL;
{ if (CSongs.VisibleSongs[SongNr].IsDuet)
CGame.AddSong(SongNr); gm = EGameMode.TR_GAMEMODE_DUET;
}
CGame.AddSong(SongNr, gm);
IDs.Remove(SongNr); IDs.Remove(SongNr);
} }
+3 -1
View File
@@ -134,7 +134,9 @@
<Compile Include="GameModes\CGameMode.cs" /> <Compile Include="GameModes\CGameMode.cs" />
<Compile Include="GameModes\CGameModeDuet.cs" /> <Compile Include="GameModes\CGameModeDuet.cs" />
<Compile Include="GameModes\CGameModeMedley.cs" /> <Compile Include="GameModes\CGameModeMedley.cs" />
<Compile Include="GameModes\CGameModeNormal.cs" /> <Compile Include="GameModes\CGameModeNormal.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="GameModes\CGameModeShortSong.cs" /> <Compile Include="GameModes\CGameModeShortSong.cs" />
<Compile Include="GameModes\IGameMode.cs" /> <Compile Include="GameModes\IGameMode.cs" />
<Compile Include="Lib\Draw\CDirect3D.cs"> <Compile Include="Lib\Draw\CDirect3D.cs">