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
+118 -108

No files matched your search

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