diff --git a/Output/Languages/English.xml b/Output/Languages/English.xml
index a847b5d2..2ad11503 100644
--- a/Output/Languages/English.xml
+++ b/Output/Languages/English.xml
@@ -101,6 +101,7 @@
Version
Can\'t load this party-mode.
There are no mics configured!
+ %d mics are required for this party-mode!
Target audience
No teams
Number of teams
diff --git a/Output/Languages/German.xml b/Output/Languages/German.xml
index 968b2f79..82924766 100644
--- a/Output/Languages/German.xml
+++ b/Output/Languages/German.xml
@@ -101,6 +101,7 @@
Version
Dieser Party-Modus konnte nicht geladen werden.
Es sind keine Mikros konfiguriert!
+ Für diesen Party-Modus werden %d Mikros benötigt!
Zielgruppe
Keine Teams
Anzahl der Teams
diff --git a/PartyModes/PartyModeChallenge/CChallengeRounds.cs b/PartyModes/PartyModeChallenge/CChallengeRounds.cs
index 7627c636..5ec9f331 100644
--- a/PartyModes/PartyModeChallenge/CChallengeRounds.cs
+++ b/PartyModes/PartyModeChallenge/CChallengeRounds.cs
@@ -92,7 +92,7 @@ namespace VocaluxeLib.PartyModes.Challenge
{
if (roundIndex == 0 || numPlayed[i] < max)
{
- if (roundIndex == 0 || roundIndex > 0 && numPlayed[i] < max && !Rounds[roundIndex - 1].IsAvailable(i))
+ if (roundIndex == 0 || roundIndex > 0 && numPlayed[i] < max && !Rounds[roundIndex - 1].Contains(i))
result.Add(i);
else if (numPlayed[i] < max)
other.Add(i);
@@ -101,7 +101,7 @@ namespace VocaluxeLib.PartyModes.Challenge
{
if (roundIndex > 0)
{
- if (!Rounds[roundIndex - 1].IsAvailable(i))
+ if (!Rounds[roundIndex - 1].Contains(i))
other.Add(i);
else
last.Add(i);
@@ -165,11 +165,11 @@ namespace VocaluxeLib.PartyModes.Challenge
//filter against PlayerNrDemand
List combsFiltered = new List();
if (playerNrDemand != null)
- combsFiltered.AddRange(_Combs.Where(t => t.IsAvailableAll(playerNrDemand)));
+ combsFiltered.AddRange(_Combs.Where(t => t.ContainsAll(playerNrDemand)));
//1st fallback
if (playerNrDemand != null && combsFiltered.Count == 0)
- combsFiltered.AddRange(_Combs.Where(t => t.IsAvailableSomeone(playerNrDemand)));
+ combsFiltered.AddRange(_Combs.Where(t => t.ContainsAny(playerNrDemand)));
//2nd fallback
if (combsFiltered.Count == 0)
@@ -191,7 +191,7 @@ namespace VocaluxeLib.PartyModes.Challenge
int num = (int)Math.Pow(2, _NumPlayer);
- for (int i = 1; i <= num; i++)
+ for (int i = 1; i < num; i++)
{
CCombination c = new CCombination();
@@ -216,19 +216,19 @@ namespace VocaluxeLib.PartyModes.Challenge
Player = new List();
}
- public bool IsAvailable(int playerIndex)
+ public bool Contains(int playerIndex)
{
return Player.Any(p => p == playerIndex);
}
- public bool IsAvailableAll(IEnumerable playerIndices)
+ public bool ContainsAll(IEnumerable playerIndices)
{
- return playerIndices.All(IsAvailable);
+ return playerIndices.All(Contains);
}
- public bool IsAvailableSomeone(IEnumerable playerIndices)
+ public bool ContainsAny(IEnumerable playerIndices)
{
- return playerIndices.Any(IsAvailable);
+ return playerIndices.Any(Contains);
}
}
}
\ No newline at end of file
diff --git a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs
index db882cd4..4abd7de8 100644
--- a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs
+++ b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs
@@ -67,11 +67,38 @@ namespace VocaluxeLib.PartyModes.Challenge
public sealed class CPartyModeChallenge : CPartyMode
// ReSharper restore ClassNeverInstantiated.Global
{
- private const int _MaxPlayer = 12;
- private const int _MinPlayer = 1;
- private const int _MaxTeams = 0;
- private const int _MinTeams = 0;
- private const int _MaxNumRounds = 100;
+ public override int MinMics
+ {
+ get { return 1; }
+ }
+ public override int MaxMics
+ {
+ get { return CBase.Config.GetMaxNumMics(); }
+ }
+ public override int MinPlayers
+ {
+ get { return 1; }
+ }
+ public override int MaxPlayers
+ {
+ get { return 12; }
+ }
+ public override int MinTeams
+ {
+ get { return 1; }
+ }
+ public override int MaxTeams
+ {
+ get { return 1; }
+ }
+ public override int MinPlayersPerTeam
+ {
+ get { return MinPlayers; }
+ }
+ public override int MaxPlayersPerTeam
+ {
+ get { return MaxPlayers; }
+ }
private enum EStage
{
@@ -108,7 +135,7 @@ namespace VocaluxeLib.PartyModes.Challenge
public SData GameData;
private EStage _Stage;
- public CPartyModeChallenge(int id, string folder) : base(id, folder)
+ public CPartyModeChallenge(int id) : base(id)
{
_ScreenSongOptions.Selection.RandomOnly = false;
_ScreenSongOptions.Selection.PartyMode = true;
@@ -125,6 +152,8 @@ namespace VocaluxeLib.PartyModes.Challenge
public override bool Init()
{
+ if (!base.Init())
+ return false;
_Stage = EStage.Config;
_ScreenSongOptions.Sorting.IgnoreArticles = CBase.Config.GetIgnoreArticles();
@@ -283,31 +312,6 @@ namespace VocaluxeLib.PartyModes.Challenge
_ScreenSongOptions.Sorting.SearchActive = visible;
}
- public override int GetMaxPlayer()
- {
- return _MaxPlayer;
- }
-
- public override int GetMinPlayer()
- {
- return _MinPlayer;
- }
-
- public override int GetMaxTeams()
- {
- return _MaxTeams;
- }
-
- public override int GetMinTeams()
- {
- return _MinTeams;
- }
-
- public override int GetMaxNumRounds()
- {
- return _MaxNumRounds;
- }
-
public override void JokerUsed(int teamNr)
{
if (_ScreenSongOptions.Selection.NumJokers == null)
diff --git a/PartyModes/PartyModeChallenge/CPartyScreenChallengeConfig.cs b/PartyModes/PartyModeChallenge/CPartyScreenChallengeConfig.cs
index b9095b50..d1a4747b 100644
--- a/PartyModes/PartyModeChallenge/CPartyScreenChallengeConfig.cs
+++ b/PartyModes/PartyModeChallenge/CPartyScreenChallengeConfig.cs
@@ -15,6 +15,7 @@
// along with Vocaluxe. If not, see .
#endregion
+using System;
using System.Windows.Forms;
namespace VocaluxeLib.PartyModes.Challenge
@@ -35,8 +36,7 @@ namespace VocaluxeLib.PartyModes.Challenge
private const string _ButtonNext = "ButtonNext";
private const string _ButtonBack = "ButtonBack";
- private int _MaxNumMics = 2;
- private int _MaxNumRounds = 100;
+ private const int _MaxNumRounds = 100;
private int _RoundSteps = 1;
public override void Init()
@@ -107,12 +107,6 @@ namespace VocaluxeLib.PartyModes.Challenge
{
base.OnShow();
- _MaxNumMics = CBase.Config.GetMaxNumMics();
- if (_MaxNumMics > 6)
- _MaxNumMics = 6;
-
- _MaxNumRounds = _PartyMode.GetMaxNumRounds();
-
_RebuildSlides();
}
@@ -125,7 +119,7 @@ namespace VocaluxeLib.PartyModes.Challenge
{
// build num player slide (min player ... max player);
_SelectSlides[_SelectSlideNumPlayers].Clear();
- for (int i = _PartyMode.GetMinPlayer(); i <= _PartyMode.GetMaxPlayer(); i++)
+ for (int i = _PartyMode.MinPlayers; i <= _PartyMode.MaxPlayers; i++)
_SelectSlides[_SelectSlideNumPlayers].AddValue(i.ToString());
_SelectSlides[_SelectSlideNumPlayers].SelectedValue = _PartyMode.GameData.NumPlayer.ToString();
@@ -138,8 +132,8 @@ namespace VocaluxeLib.PartyModes.Challenge
{
int player = _PartyMode.GameData.NumPlayer;
int mics = _PartyMode.GameData.NumPlayerAtOnce;
- _PartyMode.GameData.NumPlayer = _SelectSlides[_SelectSlideNumPlayers].Selection + _PartyMode.GetMinPlayer();
- _PartyMode.GameData.NumPlayerAtOnce = _SelectSlides[_SelectSlideNumMics].Selection + _PartyMode.GetMinPlayer();
+ _PartyMode.GameData.NumPlayer = _SelectSlides[_SelectSlideNumPlayers].Selection + _PartyMode.MinPlayers;
+ _PartyMode.GameData.NumPlayerAtOnce = _SelectSlides[_SelectSlideNumMics].Selection + _PartyMode.MinPlayers;
_PartyMode.GameData.NumRounds = (_SelectSlides[_SelectSlideNumRounds].Selection + 1) * _RoundSteps;
_UpdateMicsAtOnce();
@@ -158,9 +152,7 @@ namespace VocaluxeLib.PartyModes.Challenge
private void _UpdateMicsAtOnce()
{
- int maxNum = _MaxNumMics;
- if (_PartyMode.GameData.NumPlayer < _MaxNumMics)
- maxNum = _PartyMode.GameData.NumPlayer;
+ int maxNum = Math.Min(_PartyMode.MaxMics, _PartyMode.GameData.NumPlayer);
if (_PartyMode.GameData.NumPlayerAtOnce > maxNum)
_PartyMode.GameData.NumPlayerAtOnce = maxNum;
@@ -169,7 +161,7 @@ namespace VocaluxeLib.PartyModes.Challenge
_SelectSlides[_SelectSlideNumMics].Clear();
for (int i = 1; i <= maxNum; i++)
_SelectSlides[_SelectSlideNumMics].AddValue(i.ToString());
- _SelectSlides[_SelectSlideNumMics].Selection = _PartyMode.GameData.NumPlayerAtOnce - _PartyMode.GetMinPlayer();
+ _SelectSlides[_SelectSlideNumMics].Selection = _PartyMode.GameData.NumPlayerAtOnce - _PartyMode.MinPlayers;
}
private void _UpdateSlideRounds()
diff --git a/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs b/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs
index 41805118..0c06f9b7 100644
--- a/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs
+++ b/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs
@@ -119,7 +119,7 @@ namespace VocaluxeLib.PartyModes.Challenge
_NextPlayerTexts = new List();
_NextPlayerStatics = new List();
- for (int i = 0; i < _PartyMode.GetMaxPlayer(); i++)
+ for (int i = 0; i < _PartyMode.MaxPlayers; i++)
{
_NextPlayerTexts.Add(GetNewText(_Texts[_TextNextPlayer]));
_AddText(_NextPlayerTexts[_NextPlayerTexts.Count - 1]);
@@ -326,7 +326,7 @@ namespace VocaluxeLib.PartyModes.Challenge
x += _Statics[_StaticNextPlayer].Rect.W + 15;
}
- for (int i = _PartyMode.GameData.NumPlayerAtOnce; i < _PartyMode.GetMaxPlayer(); i++)
+ for (int i = _PartyMode.GameData.NumPlayerAtOnce; i < _PartyMode.MaxPlayers; i++)
{
_NextPlayerStatics[i].Visible = false;
_NextPlayerTexts[i].Visible = false;
diff --git a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs
index ec9429f9..e3b4c45f 100644
--- a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs
+++ b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs
@@ -72,13 +72,41 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public sealed class CPartyModeChallengeMedley : CPartyMode
// ReSharper restore ClassNeverInstantiated.Global
{
- private const int _MaxPlayer = 12;
- private const int _MinPlayer = 1;
- private const int _MaxTeams = 0;
- private const int _MinTeams = 0;
- private const int _MaxNumRounds = 100;
private const int _NumSongs = 5;
+ public override int MinMics
+ {
+ get { return 1; }
+ }
+ public override int MaxMics
+ {
+ get { return CBase.Config.GetMaxNumMics(); }
+ }
+ public override int MinPlayers
+ {
+ get { return 1; }
+ }
+ public override int MaxPlayers
+ {
+ get { return 12; }
+ }
+ public override int MinTeams
+ {
+ get { return 1; }
+ }
+ public override int MaxTeams
+ {
+ get { return 1; }
+ }
+ public override int MinPlayersPerTeam
+ {
+ get { return MinPlayers; }
+ }
+ public override int MaxPlayersPerTeam
+ {
+ get { return MaxPlayers; }
+ }
+
private enum EStage
{
Config,
@@ -114,7 +142,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public SData GameData;
private EStage _Stage;
- public CPartyModeChallengeMedley(int id, string folder) : base(id, folder)
+ public CPartyModeChallengeMedley(int id) : base(id)
{
_ScreenSongOptions.Selection.RandomOnly = false;
_ScreenSongOptions.Selection.PartyMode = true;
@@ -131,6 +159,8 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public override bool Init()
{
+ if (!base.Init())
+ return false;
_Stage = EStage.Config;
_ScreenSongOptions.Sorting.IgnoreArticles = EOffOn.TR_CONFIG_OFF;
@@ -290,31 +320,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_ScreenSongOptions.Sorting.SearchActive = visible;
}
- public override int GetMaxPlayer()
- {
- return _MaxPlayer;
- }
-
- public override int GetMinPlayer()
- {
- return _MinPlayer;
- }
-
- public override int GetMaxTeams()
- {
- return _MaxTeams;
- }
-
- public override int GetMinTeams()
- {
- return _MinTeams;
- }
-
- public override int GetMaxNumRounds()
- {
- return _MaxNumRounds;
- }
-
public override void JokerUsed(int teamNr)
{
if (_ScreenSongOptions.Selection.NumJokers == null)
diff --git a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs
index 2174939b..dbb80bb6 100644
--- a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs
+++ b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs
@@ -15,6 +15,7 @@
// along with Vocaluxe. If not, see .
#endregion
+using System;
using System.Windows.Forms;
namespace VocaluxeLib.PartyModes.ChallengeMedley
@@ -35,8 +36,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private const string _ButtonNext = "ButtonNext";
private const string _ButtonBack = "ButtonBack";
- private int _MaxNumMics = 2;
- private int _MaxNumRounds = 100;
+ private const int _MaxNumRounds = 100;
private int _RoundSteps = 1;
public override void Init()
@@ -107,12 +107,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{
base.OnShow();
- _MaxNumMics = CBase.Config.GetMaxNumMics();
- if (_MaxNumMics > 6)
- _MaxNumMics = 6;
-
- _MaxNumRounds = _PartyMode.GetMaxNumRounds();
-
_RebuildSlides();
}
@@ -125,9 +119,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{
// build num player slide (min player ... max player);
_SelectSlides[_SelectSlideNumPlayers].Clear();
- for (int i = _PartyMode.GetMinPlayer(); i <= _PartyMode.GetMaxPlayer(); i++)
+ for (int i = _PartyMode.MinPlayers; i <= _PartyMode.MaxPlayers; i++)
_SelectSlides[_SelectSlideNumPlayers].AddValue(i.ToString());
- _SelectSlides[_SelectSlideNumPlayers].Selection = _PartyMode.GameData.NumPlayer - _PartyMode.GetMinPlayer();
+ _SelectSlides[_SelectSlideNumPlayers].Selection = _PartyMode.GameData.NumPlayer - _PartyMode.MinPlayers;
_UpdateMicsAtOnce();
_SetRoundSteps();
@@ -138,8 +132,8 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{
int player = _PartyMode.GameData.NumPlayer;
int mics = _PartyMode.GameData.NumPlayerAtOnce;
- _PartyMode.GameData.NumPlayer = _SelectSlides[_SelectSlideNumPlayers].Selection + _PartyMode.GetMinPlayer();
- _PartyMode.GameData.NumPlayerAtOnce = _SelectSlides[_SelectSlideNumMics].Selection + _PartyMode.GetMinPlayer();
+ _PartyMode.GameData.NumPlayer = _SelectSlides[_SelectSlideNumPlayers].Selection + _PartyMode.MinPlayers;
+ _PartyMode.GameData.NumPlayerAtOnce = _SelectSlides[_SelectSlideNumMics].Selection + _PartyMode.MinPlayers;
_PartyMode.GameData.NumRounds = (_SelectSlides[_SelectSlideNumRounds].Selection + 1) * _RoundSteps;
_UpdateMicsAtOnce();
@@ -158,9 +152,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _UpdateMicsAtOnce()
{
- int maxNum = _MaxNumMics;
- if (_PartyMode.GameData.NumPlayer < _MaxNumMics)
- maxNum = _PartyMode.GameData.NumPlayer;
+ int maxNum = Math.Min(_PartyMode.MaxMics, _PartyMode.GameData.NumPlayer);
if (_PartyMode.GameData.NumPlayerAtOnce > maxNum)
_PartyMode.GameData.NumPlayerAtOnce = maxNum;
@@ -169,7 +161,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_SelectSlides[_SelectSlideNumMics].Clear();
for (int i = 1; i <= maxNum; i++)
_SelectSlides[_SelectSlideNumMics].AddValue(i.ToString());
- _SelectSlides[_SelectSlideNumMics].Selection = _PartyMode.GameData.NumPlayerAtOnce - _PartyMode.GetMinPlayer();
+ _SelectSlides[_SelectSlideNumMics].Selection = _PartyMode.GameData.NumPlayerAtOnce - _PartyMode.MinPlayers;
}
private void _UpdateSlideRounds()
diff --git a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs
index 84831c23..f3e5723d 100644
--- a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs
+++ b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs
@@ -119,7 +119,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_NextPlayerTexts = new List();
_NextPlayerStatics = new List();
- for (int i = 0; i < _PartyMode.GetMaxPlayer(); i++)
+ for (int i = 0; i < _PartyMode.MaxPlayers; i++)
{
_NextPlayerTexts.Add(GetNewText(_Texts[_TextNextPlayer]));
_AddText(_NextPlayerTexts[_NextPlayerTexts.Count - 1]);
@@ -326,7 +326,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
x += _Statics[_StaticNextPlayer].Rect.W + 15;
}
- for (int i = _PartyMode.GameData.NumPlayerAtOnce; i < _PartyMode.GetMaxPlayer(); i++)
+ for (int i = _PartyMode.GameData.NumPlayerAtOnce; i < _PartyMode.MaxPlayers; i++)
{
_NextPlayerStatics[i].Visible = false;
_NextPlayerTexts[i].Visible = false;
diff --git a/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs b/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs
index 1dadbaea..62c281ba 100644
--- a/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs
+++ b/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs
@@ -36,15 +36,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe
// ReSharper restore InconsistentNaming
}
- public enum EPartyGameMode
- {
- // ReSharper disable InconsistentNaming
- TR_GAMEMODE_NORMAL,
- TR_GAMEMODE_SHORTSONG,
- TR_GAMEMODE_DUET
- // ReSharper restore InconsistentNaming
- }
-
public class CRound
{
public int SongID;
@@ -71,13 +62,39 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public sealed class CPartyModeTicTacToe : CPartyMode
// ReSharper restore ClassNeverInstantiated.Global
{
- private const int _MaxPlayer = 20;
- private const int _MinPlayer = 2;
- private const int _MaxTeams = 2;
- private const int _MinTeams = 2;
- private const int _MinPlayerPerTeam = 1;
- private const int _MaxPlayerPerTeam = 10;
- private const int _NumFields = 9;
+ public override int MinMics
+ {
+ get { return 2; }
+ }
+ public override int MaxMics
+ {
+ get { return 2; }
+ }
+ public override int MinPlayers
+ {
+ get { return 2; }
+ }
+ public override int MaxPlayers
+ {
+ get { return 20; }
+ }
+ public override int MinTeams
+ {
+ get { return 2; }
+ }
+ public override int MaxTeams
+ {
+ get { return 2; }
+ }
+
+ public override int MinPlayersPerTeam
+ {
+ get { return 1; }
+ }
+ public override int MaxPlayersPerTeam
+ {
+ get { return 10; }
+ }
private enum EStage
{
@@ -99,10 +116,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public List PlayerTeam2;
public ESongSource SongSource;
- public int CategoryID;
+ public int CategoryIndex;
public int PlaylistID;
- public EPartyGameMode GameMode;
+ public EGameMode GameMode;
public List Rounds;
public List Songs;
@@ -117,7 +134,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public SData GameData;
private EStage _Stage;
- public CPartyModeTicTacToe(int id, string folder) : base(id, folder)
+ public CPartyModeTicTacToe(int id) : base(id)
{
_ScreenSongOptions.Selection.RandomOnly = false;
_ScreenSongOptions.Selection.PartyMode = true;
@@ -142,8 +159,8 @@ namespace VocaluxeLib.PartyModes.TicTacToe
FieldNr = 0,
SongSource = ESongSource.TR_ALLSONGS,
PlaylistID = 0,
- CategoryID = 0,
- GameMode = EPartyGameMode.TR_GAMEMODE_NORMAL,
+ CategoryIndex = 0,
+ GameMode = EGameMode.TR_GAMEMODE_NORMAL,
Rounds = new List(),
Songs = new List(),
NumJokerRandom = new int[2],
@@ -153,6 +170,8 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public override bool Init()
{
+ if (!base.Init())
+ return false;
_Stage = EStage.Config;
_ScreenSongOptions.Sorting.IgnoreArticles = CBase.Config.GetIgnoreArticles();
@@ -277,41 +296,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe
throw new ArgumentException("Not required!");
}
- public override int GetMaxPlayer()
- {
- return _MaxPlayer;
- }
-
- public override int GetMinPlayer()
- {
- return _MinPlayer;
- }
-
- public override int GetMaxTeams()
- {
- return _MaxTeams;
- }
-
- public override int GetMinTeams()
- {
- return _MinTeams;
- }
-
- public override int GetMinPlayerPerTeam()
- {
- return _MinPlayerPerTeam;
- }
-
- public override int GetMaxPlayerPerTeam()
- {
- return _MaxPlayerPerTeam;
- }
-
- public override int GetMaxNumRounds()
- {
- return _NumFields;
- }
-
public override void JokerUsed(int teamNr) {}
public override void SongSelected(int songID)
@@ -447,46 +431,26 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (GameData.Songs.Count > 0)
return;
- EGameMode gm;
- switch (GameData.GameMode)
- {
- case EPartyGameMode.TR_GAMEMODE_NORMAL:
- gm = EGameMode.TR_GAMEMODE_NORMAL;
- break;
-
- case EPartyGameMode.TR_GAMEMODE_DUET:
- gm = EGameMode.TR_GAMEMODE_DUET;
- break;
-
- case EPartyGameMode.TR_GAMEMODE_SHORTSONG:
- gm = EGameMode.TR_GAMEMODE_SHORTSONG;
- break;
-
- default:
- gm = EGameMode.TR_GAMEMODE_NORMAL;
- break;
- }
-
switch (GameData.SongSource)
{
case ESongSource.TR_PLAYLIST:
for (int i = 0; i < CBase.Playlist.GetSongCount(GameData.PlaylistID); i++)
{
int id = CBase.Playlist.GetSong(GameData.PlaylistID, i).SongID;
- if (CBase.Songs.GetSongByID(id).AvailableGameModes.Contains(gm))
+ if (CBase.Songs.GetSongByID(id).AvailableGameModes.Contains(GameData.GameMode))
GameData.Songs.Add(id);
}
break;
case ESongSource.TR_ALLSONGS:
ReadOnlyCollection avSongs = CBase.Songs.GetSongs();
- GameData.Songs.AddRange(avSongs.Where(song => song.AvailableGameModes.Contains(gm)).Select(song => song.ID));
+ GameData.Songs.AddRange(avSongs.Where(song => song.AvailableGameModes.Contains(GameData.GameMode)).Select(song => song.ID));
break;
case ESongSource.TR_CATEGORY:
- CBase.Songs.SetCategory(GameData.CategoryID);
+ CBase.Songs.SetCategory(GameData.CategoryIndex);
avSongs = CBase.Songs.GetVisibleSongs();
- GameData.Songs.AddRange(avSongs.Where(song => song.AvailableGameModes.Contains(gm)).Select(song => song.ID));
+ GameData.Songs.AddRange(avSongs.Where(song => song.AvailableGameModes.Contains(GameData.GameMode)).Select(song => song.ID));
CBase.Songs.SetCategory(-1);
break;
@@ -534,23 +498,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (isDuet)
players[1].VoiceNr = 1;
- var gm = EGameMode.TR_GAMEMODE_NORMAL;
-
- switch (GameData.GameMode)
- {
- case EPartyGameMode.TR_GAMEMODE_NORMAL:
- gm = EGameMode.TR_GAMEMODE_NORMAL;
- break;
-
- case EPartyGameMode.TR_GAMEMODE_DUET:
- gm = EGameMode.TR_GAMEMODE_DUET;
- break;
-
- case EPartyGameMode.TR_GAMEMODE_SHORTSONG:
- gm = EGameMode.TR_GAMEMODE_SHORTSONG;
- break;
- }
- CBase.Game.AddSong(round.SongID, gm);
+ CBase.Game.AddSong(round.SongID, GameData.GameMode);
}
private void _SetNumJokers()
diff --git a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeConfig.cs b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeConfig.cs
index 2986c303..c75cd880 100644
--- a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeConfig.cs
+++ b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeConfig.cs
@@ -16,6 +16,7 @@
#endregion
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Windows.Forms;
using VocaluxeLib.Songs;
@@ -113,8 +114,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
base.OnShow();
- if (CBase.Config.GetMaxNumMics() >= 2)
- _ConfigOk = true;
+ Debug.Assert(CBase.Config.GetMaxNumMics() >= 2);
_FillSlides();
_UpdateSlides();
@@ -129,15 +129,11 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _FillSlides()
{
_SelectSlides[_SelectSlideNumFields].Clear();
- _SelectSlides[_SelectSlideNumFields].AddValue("9");
- _SelectSlides[_SelectSlideNumFields].AddValue("16");
- _SelectSlides[_SelectSlideNumFields].AddValue("25");
- if (_PartyMode.GameData.NumFields == 9)
- _SelectSlides[_SelectSlideNumFields].Selection = 0;
- else if (_PartyMode.GameData.NumFields == 16)
- _SelectSlides[_SelectSlideNumFields].Selection = 1;
- else if (_PartyMode.GameData.NumFields == 25)
- _SelectSlides[_SelectSlideNumFields].Selection = 2;
+ _SelectSlides[_SelectSlideNumFields].AddValue(9);
+ _SelectSlides[_SelectSlideNumFields].AddValue(16);
+ _SelectSlides[_SelectSlideNumFields].AddValue(25);
+
+ _SelectSlides[_SelectSlideNumFields].SelectedTag = _PartyMode.GameData.NumFields;
_SelectSlides[_SelectSlideSongSource].Clear();
_SelectSlides[_SelectSlideSongSource].SetValues((int)_PartyMode.GameData.SongSource);
@@ -152,52 +148,32 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_SelectSlides[_SelectSlidePlaylist].Selection = _PartyMode.GameData.PlaylistID;
_SelectSlides[_SelectSlidePlaylist].Visible = _PartyMode.GameData.SongSource == ESongSource.TR_PLAYLIST;
- var categories = new string[CBase.Songs.GetNumCategories()];
- for (int i = 0; i < CBase.Songs.GetNumCategories(); i++)
- categories[i] = CBase.Songs.GetCategory(i).Name;
_SelectSlides[_SelectSlideCategory].Clear();
- for (int i = 0; i < categories.Length; i++)
+ for (int i = 0; i < CBase.Songs.GetNumCategories(); i++)
{
- string value = categories[i] + " (" + CBase.Songs.GetNumSongsNotSungInCategory(i) + " " + CBase.Language.Translate("TR_SONGS", PartyModeID) + ")";
+ CCategory cat = CBase.Songs.GetCategory(i);
+ string value = cat.Name + " (" + cat.GetNumSongsNotSung() + " " + CBase.Language.Translate("TR_SONGS", PartyModeID) + ")";
_SelectSlides[_SelectSlideCategory].AddValue(value);
}
- _SelectSlides[_SelectSlideCategory].Selection = _PartyMode.GameData.CategoryID;
+ _SelectSlides[_SelectSlideCategory].Selection = _PartyMode.GameData.CategoryIndex;
_SelectSlides[_SelectSlideCategory].Visible = _PartyMode.GameData.SongSource == ESongSource.TR_CATEGORY;
_SelectSlides[_SelectSlideGameMode].Visible = true;
- _SelectSlides[_SelectSlideGameMode].SetValues((int)_PartyMode.GameData.GameMode);
+ _SelectSlides[_SelectSlideGameMode].Clear();
+ _SelectSlides[_SelectSlideGameMode].SetValues((int)_PartyMode.GameData.GameMode);
+ _SelectSlides[_SelectSlideGameMode].RemoveValue(EGameMode.TR_GAMEMODE_MEDLEY.ToString());
}
private void _UpdateSlides()
{
- if (_SelectSlides[_SelectSlideNumFields].Selection == 0)
- _PartyMode.GameData.NumFields = 9;
- else if (_SelectSlides[_SelectSlideNumFields].Selection == 1)
- _PartyMode.GameData.NumFields = 16;
- else if (_SelectSlides[_SelectSlideNumFields].Selection == 2)
- _PartyMode.GameData.NumFields = 25;
+ _PartyMode.GameData.NumFields = _SelectSlides[_SelectSlideNumFields].SelectedTag;
_PartyMode.GameData.SongSource = (ESongSource)_SelectSlides[_SelectSlideSongSource].Selection;
_PartyMode.GameData.PlaylistID = _SelectSlides[_SelectSlidePlaylist].Selection;
- _PartyMode.GameData.CategoryID = _SelectSlides[_SelectSlideCategory].Selection;
- _PartyMode.GameData.GameMode = (EPartyGameMode)_SelectSlides[_SelectSlideGameMode].Selection;
+ _PartyMode.GameData.CategoryIndex = _SelectSlides[_SelectSlideCategory].Selection;
+ _PartyMode.GameData.GameMode = (EGameMode)_SelectSlides[_SelectSlideGameMode].Selection;
- var gm = EGameMode.TR_GAMEMODE_NORMAL;
-
- switch (_PartyMode.GameData.GameMode)
- {
- case EPartyGameMode.TR_GAMEMODE_NORMAL:
- gm = EGameMode.TR_GAMEMODE_NORMAL;
- break;
-
- case EPartyGameMode.TR_GAMEMODE_DUET:
- gm = EGameMode.TR_GAMEMODE_DUET;
- break;
-
- case EPartyGameMode.TR_GAMEMODE_SHORTSONG:
- gm = EGameMode.TR_GAMEMODE_SHORTSONG;
- break;
- }
+ EGameMode gm = _PartyMode.GameData.GameMode;
if (_PartyMode.GameData.SongSource == ESongSource.TR_PLAYLIST)
{
@@ -224,11 +200,11 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
if (CBase.Songs.GetNumCategories() == 0)
_ConfigOk = false;
- else if (CBase.Songs.GetNumSongsNotSungInCategory(_PartyMode.GameData.CategoryID) <= 0)
+ else if (CBase.Songs.GetNumSongsNotSungInCategory(_PartyMode.GameData.CategoryIndex) <= 0)
_ConfigOk = false;
else
{
- CBase.Songs.SetCategory(_PartyMode.GameData.CategoryID);
+ CBase.Songs.SetCategory(_PartyMode.GameData.CategoryIndex);
_ConfigOk = false;
foreach (CSong song in CBase.Songs.GetVisibleSongs())
{
diff --git a/Vocaluxe/Base/CParty.cs b/Vocaluxe/Base/CParty.cs
index 6408281b..28847a28 100644
--- a/Vocaluxe/Base/CParty.cs
+++ b/Vocaluxe/Base/CParty.cs
@@ -18,6 +18,7 @@
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
+using System.Diagnostics;
using System.IO;
using System.Reflection;
using Vocaluxe.Base.ThemeSystem;
@@ -32,40 +33,52 @@ namespace Vocaluxe.Base
{
private const int _PartyModeSystemVersion = 1;
- private static Dictionary _PartyModes;
+ private static readonly Dictionary _PartyModes = new Dictionary();
private static int _NextID;
-
- private static int _NormalGameModeID;
- private static SPartyMode _CurrentPartyMode;
+ private static IPartyMode _CurrentPartyMode;
#region public stuff
- public static void Init()
+ public static bool Init()
{
- _PartyModes = new Dictionary();
- _NextID = 0;
-
- //add dummy normal game mode and set it as default
- var pm = new SPartyMode {ScreenFiles = new List(), PartyMode = new CPartyModeNone(_NextID++, null)};
- _NormalGameModeID = pm.PartyMode.ID;
- _PartyModes.Add(pm.PartyMode.ID, pm);
- _CurrentPartyMode = pm;
+ if (_PartyModes.Count > 0)
+ return false; //Already initialized
+ SPartyMode pm = new SPartyMode
+ {
+ Info = new SPartyModeInfos {Author = "Vocaluxe Team", Description = "Normal game", Name = "Normal", TargetAudience = "Just a normal game for everyone"},
+ PartyMode = new CPartyModeNormal(-1),
+ PartyModeSystemVersion = _PartyModeSystemVersion,
+ ScreenFiles = new List()
+ };
+ _PartyModes.Add(-1, pm);
+ _CurrentPartyMode = pm.PartyMode;
+ Debug.Assert(_CurrentPartyMode != null && _CurrentPartyMode.ID == -1);
//load other party modes
_LoadPartyModes();
+ return _CurrentPartyMode.Init();
}
public static int CurrentPartyModeID
{
- get
+ get { return _CurrentPartyMode.ID; }
+ set
{
- if (_CurrentPartyMode.PartyMode.ID != _NormalGameModeID)
- return _CurrentPartyMode.PartyMode.ID;
-
- return -1;
+ if (_CurrentPartyMode.ID == value)
+ return;
+ if (value != -1 && !_PartyModes.ContainsKey(value))
+ throw new ArgumentException("Partymode with ID=" + value + " does not exist!");
+ IPartyMode pm = _PartyModes[value].PartyMode;
+ if (pm.Init())
+ _CurrentPartyMode = pm;
+ else
+ {
+ CLog.LogError("Could not init PartyMode \"" + _PartyModes[value].Info.Name + "\"! Removing...", true);
+ _PartyModes.Remove(value);
+ }
}
}
- public static int NumModes
+ public static int Count
{
get { return _PartyModes.Count; }
}
@@ -90,85 +103,81 @@ namespace Vocaluxe.Base
public static List GetPartyModeInfos()
{
- var infos = new List();
-
- foreach (KeyValuePair kvp in _PartyModes)
+ List list = new List();
+ foreach (SPartyMode pm in _PartyModes.Values)
{
- if (kvp.Key != _NormalGameModeID)
- infos.Add(kvp.Value.Info);
+ if (pm.PartyMode.ID >= 0)
+ list.Add(pm.Info);
}
- return infos;
+ return list;
}
public static void SetNormalGameMode()
{
CSongs.ResetPartySongSung();
- SetPartyMode(_NormalGameModeID);
+ CurrentPartyModeID = -1;
}
public static void SetPartyMode(int partyModeID)
{
- if (!_PartyModes.TryGetValue(partyModeID, out _CurrentPartyMode))
- CLog.LogError("CParty: Can't find party mode ID: " + partyModeID);
-
- _CurrentPartyMode.PartyMode.Init();
+ CurrentPartyModeID = partyModeID;
}
#endregion public stuff
#region Interface
public static void UpdateGame()
{
- _CurrentPartyMode.PartyMode.UpdateGame();
+ _CurrentPartyMode.UpdateGame();
}
public static IMenu GetStartScreen()
{
- return _CurrentPartyMode.PartyMode.GetStartScreen();
+ return _CurrentPartyMode.GetStartScreen();
}
public static SScreenSongOptions GetSongSelectionOptions()
{
- return _CurrentPartyMode.PartyMode.GetScreenSongOptions();
+ return _CurrentPartyMode.GetScreenSongOptions();
}
public static void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions)
{
- _CurrentPartyMode.PartyMode.OnSongChange(songIndex, ref screenSongOptions);
+ _CurrentPartyMode.OnSongChange(songIndex, ref screenSongOptions);
}
public static void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions)
{
- _CurrentPartyMode.PartyMode.OnCategoryChange(categoryIndex, ref screenSongOptions);
+ _CurrentPartyMode.OnCategoryChange(categoryIndex, ref screenSongOptions);
}
public static void SetSearchString(string searchString, bool visible)
{
- _CurrentPartyMode.PartyMode.SetSearchString(searchString, visible);
+ _CurrentPartyMode.SetSearchString(searchString, visible);
}
public static void JokerUsed(int teamNr)
{
- _CurrentPartyMode.PartyMode.JokerUsed(teamNr);
+ _CurrentPartyMode.JokerUsed(teamNr);
}
public static void SongSelected(int songID)
{
- _CurrentPartyMode.PartyMode.SongSelected(songID);
+ _CurrentPartyMode.SongSelected(songID);
}
public static void FinishedSinging()
{
- _CurrentPartyMode.PartyMode.FinishedSinging();
+ _CurrentPartyMode.FinishedSinging();
}
public static void LeavingScore()
{
- _CurrentPartyMode.PartyMode.LeavingScore();
+ _CurrentPartyMode.LeavingScore();
}
public static void LeavingHighscore()
{
- _CurrentPartyMode.PartyMode.LeavingHighscore();
+ _CurrentPartyMode.LeavingHighscore();
}
#endregion Interface
@@ -216,7 +225,7 @@ namespace Vocaluxe.Base
return false;
object instance = output.CreateInstance(typeof(IPartyMode).Namespace + "." + pm.Info.Folder + "." + pm.Info.PartyModeFile, false,
- BindingFlags.Public | BindingFlags.Instance, null, new object[] {_NextID++, pathToPm}, null, null);
+ BindingFlags.Public | BindingFlags.Instance, null, new object[] {_NextID++}, null, null);
if (instance == null)
{
CLog.LogError("Error creating Instance of PartyMode file: " + filePath);
@@ -258,7 +267,7 @@ namespace Vocaluxe.Base
return false;
}
pm.PartyMode.LoadTheme();
- pm.Info.LoadData(pm.PartyMode);
+ pm.Info.ExtInfo = pm.PartyMode;
return true;
}
@@ -269,6 +278,7 @@ namespace Vocaluxe.Base
var compilerParams = new CompilerParameters();
compilerParams.ReferencedAssemblies.Add("System.Windows.Forms.dll");
+ compilerParams.ReferencedAssemblies.Add("System.dll");
compilerParams.ReferencedAssemblies.Add("System.Core.dll");
compilerParams.ReferencedAssemblies.Add("VocaluxeLib.dll");
compilerParams.GenerateInMemory = true;
diff --git a/Vocaluxe/Base/XmlStructs.cs b/Vocaluxe/Base/XmlStructs.cs
index e9ee97d2..12046975 100644
--- a/Vocaluxe/Base/XmlStructs.cs
+++ b/Vocaluxe/Base/XmlStructs.cs
@@ -17,6 +17,7 @@
using System.Collections.Generic;
using System.ComponentModel;
+using System.Diagnostics;
using System.Xml.Serialization;
using Vocaluxe.Base.Fonts;
using VocaluxeLib;
@@ -121,17 +122,7 @@ namespace Vocaluxe.Base
[XmlAltName("PartyModeVersionMajor")] public int VersionMajor;
[XmlAltName("PartyModeVersionMinor")] public int VersionMinor;
public string TargetAudience;
- [XmlIgnore] public int MaxPlayers, MinPlayers, MaxTeams, MinTeams;
- [XmlIgnore] public int PartyModeID;
-
- public void LoadData(IPartyMode pm)
- {
- MaxPlayers = pm.GetMaxPlayer();
- MinPlayers = pm.GetMinPlayer();
- MaxTeams = pm.GetMaxTeams();
- MinTeams = pm.GetMinTeams();
- PartyModeID = pm.ID;
- }
+ [XmlIgnore] public IPartyModeInfo ExtInfo;
}
struct SPartyMode
diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs
index 24873361..73b5a737 100644
--- a/Vocaluxe/Program.cs
+++ b/Vocaluxe/Program.cs
@@ -238,7 +238,8 @@ namespace Vocaluxe
// Init Party Modes;
CLog.StartBenchmark("Init Party Modes");
- CParty.Init();
+ if (!CParty.Init())
+ throw new CLoadingException("Party Modes");
CLog.StopBenchmark("Init Party Modes");
Application.DoEvents();
diff --git a/Vocaluxe/Screens/CScreenParty.cs b/Vocaluxe/Screens/CScreenParty.cs
index 3f6d801f..7b11c376 100644
--- a/Vocaluxe/Screens/CScreenParty.cs
+++ b/Vocaluxe/Screens/CScreenParty.cs
@@ -20,6 +20,7 @@ using System.Windows.Forms;
using Vocaluxe.Base;
using VocaluxeLib;
using VocaluxeLib.Menu;
+using VocaluxeLib.PartyModes;
namespace Vocaluxe.Screens
{
@@ -115,7 +116,7 @@ namespace Vocaluxe.Screens
_SelectSlides[_SelectSlideModes].Clear();
foreach (SPartyModeInfos info in _PartyModeInfos)
- _SelectSlides[_SelectSlideModes].AddValue(info.Name, info.PartyModeID);
+ _SelectSlides[_SelectSlideModes].AddValue(info.Name, info.ExtInfo.ID);
_SelectSlides[_SelectSlideModes].Selection = 0;
_UpdateSelection();
@@ -134,42 +135,48 @@ namespace Vocaluxe.Screens
int index = _SelectSlides[_SelectSlideModes].Selection;
if (index >= _PartyModeInfos.Count)
- return;
+ {
+ index = 0;
+ _SelectSlides[_SelectSlideModes].Selection = 0;
+ }
//Description
- _Texts[_TextDescription].Text = _PartyModeInfos[index].Description;
- _Texts[_TextDescription].TranslationID = _PartyModeInfos[index].PartyModeID;
+ SPartyModeInfos infos = _PartyModeInfos[index];
+ IPartyModeInfo extInfo = infos.ExtInfo;
+ _Texts[_TextDescription].Text = infos.Description;
+ _Texts[_TextDescription].TranslationID = extInfo.ID;
//TargetAudience
- _Texts[_TextTargetAudience].TranslationID = _PartyModeInfos[index].PartyModeID;
- _Texts[_TextTargetAudience].Text = _PartyModeInfos[index].TargetAudience;
+ _Texts[_TextTargetAudience].TranslationID = extInfo.ID;
+ _Texts[_TextTargetAudience].Text = infos.TargetAudience;
//NumTeams
- if (_PartyModeInfos[index].MaxTeams == 0)
+ if (extInfo.MaxTeams == 1)
_Texts[_TextNumTeams].Text = "TR_SCREENPARTY_NOTEAMS";
- else if (_PartyModeInfos[index].MaxTeams == _PartyModeInfos[index].MinTeams)
- _Texts[_TextNumTeams].Text = _PartyModeInfos[index].MaxTeams.ToString();
- else if (_PartyModeInfos[index].MaxTeams > _PartyModeInfos[index].MinTeams)
- _Texts[_TextNumTeams].Text = _PartyModeInfos[index].MinTeams + " - " + _PartyModeInfos[index].MaxTeams;
+ else if (extInfo.MaxTeams == extInfo.MinTeams)
+ _Texts[_TextNumTeams].Text = extInfo.MaxTeams.ToString();
+ else
+ _Texts[_TextNumTeams].Text = extInfo.MinTeams + " - " + extInfo.MaxTeams;
//NumPlayers
- if (_PartyModeInfos[index].MaxPlayers == _PartyModeInfos[index].MinPlayers)
- _Texts[_TextNumPlayers].Text = _PartyModeInfos[index].MaxTeams.ToString();
- else if (_PartyModeInfos[index].MaxPlayers > _PartyModeInfos[index].MinPlayers)
- _Texts[_TextNumPlayers].Text = _PartyModeInfos[index].MinPlayers + " - " + _PartyModeInfos[index].MaxPlayers;
+ if (extInfo.MaxPlayers == extInfo.MinPlayers)
+ _Texts[_TextNumPlayers].Text = extInfo.MaxTeams.ToString();
+ else
+ _Texts[_TextNumPlayers].Text = extInfo.MinPlayers + " - " + extInfo.MaxPlayers;
//Author
- _Texts[_TextAuthor].Text = _PartyModeInfos[index].Author;
- _Texts[_TextAuthor].TranslationID = _PartyModeInfos[index].PartyModeID;
+ _Texts[_TextAuthor].Text = infos.Author;
+ _Texts[_TextAuthor].TranslationID = extInfo.ID;
//Version
- _Texts[_TextVersion].Text = _PartyModeInfos[index].VersionMajor + "." + _PartyModeInfos[index].VersionMinor;
- _Texts[_TextVersion].TranslationID = _PartyModeInfos[index].PartyModeID;
+ _Texts[_TextVersion].Text = infos.VersionMajor + "." + infos.VersionMinor;
+ _Texts[_TextVersion].TranslationID = extInfo.ID;
- if (CConfig.GetMaxNumMics() == 0)
+ if (CConfig.GetMaxNumMics() < extInfo.MinMics)
{
_Buttons[_ButtonStart].Visible = false;
- _Texts[_TextError].Text = "TR_SCREENPARTY_ERROR_MICS";
+ _Texts[_TextError].Text = CConfig.GetMaxNumMics() == 0
+ ? "TR_SCREENPARTY_ERROR_MICS" : CLanguage.Translate("TR_SCREENPARTY_ERROR_MIC_NUM").Replace("%d", extInfo.MinMics.ToString());
_Texts[_TextError].Visible = true;
}
else
@@ -193,7 +200,7 @@ namespace Vocaluxe.Screens
return;
}
- CParty.SetPartyMode(_PartyModeInfos[index].PartyModeID);
+ CParty.SetPartyMode(_PartyModeInfos[index].ExtInfo.ID);
CGraphics.FadeTo(CParty.GetStartScreen());
}
}
diff --git a/Vocaluxe/Screens/CScreenScore.cs b/Vocaluxe/Screens/CScreenScore.cs
index 4f8a7aff..adce6bf6 100644
--- a/Vocaluxe/Screens/CScreenScore.cs
+++ b/Vocaluxe/Screens/CScreenScore.cs
@@ -187,26 +187,23 @@ namespace Vocaluxe.Screens
private static string _GetRating(double points)
{
- string rating = String.Empty;
+ string rating;
if (points >= 9800)
- {
- //in case of the game names so:
rating = "TR_RATING_VOCAL_HERO";
- }
- else if (points < 9800 && points >= 8400)
+ else if (points >= 8400)
rating = "TR_RATING_SUPERSTAR";
- else if (points < 8400 && points >= 7000)
+ else if (points >= 7000)
rating = "TR_RATING_LEAD_SINGER";
- else if (points < 7000 && points >= 5600)
+ else if (points >= 5600)
rating = "TR_RATING_RISING_STAR";
- else if (points < 5600 && points >= 4200)
+ else if (points >= 4200)
rating = "TR_RATING_HOPEFUL";
- else if (points < 4200 && points >= 2800)
+ else if (points >= 2800)
rating = "TR_RATING_WANNABE";
- else if (points < 2800 && points >= 1400)
+ else if (points >= 1400)
rating = "TR_RATING_AMATEUR";
- else if (points < 1400)
+ else
rating = "TR_RATING_TONE_DEAF";
return rating;
diff --git a/VocaluxeLib/Menu/CMenuPartyNameSelection.cs b/VocaluxeLib/Menu/CMenuPartyNameSelection.cs
index e5b4da12..423d89e8 100644
--- a/VocaluxeLib/Menu/CMenuPartyNameSelection.cs
+++ b/VocaluxeLib/Menu/CMenuPartyNameSelection.cs
@@ -149,7 +149,7 @@ namespace VocaluxeLib.Menu
{
if (!_ChangePlayerNumDynamic && _TeamList[_CurrentTeam].Count == _NumPlayerTeams[_CurrentTeam])
resetSelection = true;
- else if (_TeamList[_CurrentTeam].Count == _PartyMode.GetMaxPlayerPerTeam())
+ else if (_TeamList[_CurrentTeam].Count == _PartyMode.MaxPlayersPerTeam)
resetSelection = true;
}
else if (!_SelectingFast)
@@ -346,9 +346,9 @@ namespace VocaluxeLib.Menu
if (numPressed > 0)
{
- if (_ChangeTeamNumDynamic && numPressed < _PartyMode.GetMaxTeams() && numPressed > _SelectSlides[_SelectSlideTeams].NumValues)
+ if (_ChangeTeamNumDynamic && numPressed < _PartyMode.MaxTeams && numPressed > _SelectSlides[_SelectSlideTeams].NumValues)
{
- while (numPressed < _PartyMode.GetMaxTeams())
+ while (numPressed < _PartyMode.MaxTeams)
IncreaseTeamNum();
}
if (numPressed <= _SelectSlides[_SelectSlideTeams].NumValues)
@@ -435,7 +435,7 @@ namespace VocaluxeLib.Menu
if (!_ChangePlayerNumDynamic && _TeamList[_CurrentTeam].Count == _NumPlayerTeams[_CurrentTeam])
stopSelectingFast = true;
- else if (_TeamList[_CurrentTeam].Count == _PartyMode.GetMaxPlayerPerTeam())
+ else if (_TeamList[_CurrentTeam].Count == _PartyMode.MaxPlayersPerTeam)
stopSelectingFast = true;
}
else
@@ -507,7 +507,7 @@ namespace VocaluxeLib.Menu
{
if (!_ChangePlayerNumDynamic && _TeamList[_CurrentTeam].Count == _NumPlayerTeams[_CurrentTeam])
stopSelectingFast = true;
- else if (_TeamList[_CurrentTeam].Count == _PartyMode.GetMaxPlayerPerTeam())
+ else if (_TeamList[_CurrentTeam].Count == _PartyMode.MaxPlayersPerTeam)
stopSelectingFast = true;
}
else if (mouseEvent.MB)
@@ -573,7 +573,7 @@ namespace VocaluxeLib.Menu
if (!_AllowChangeTeamNum)
return;
- if (_NumTeams + 1 <= _PartyMode.GetMaxTeams())
+ if (_NumTeams + 1 <= _PartyMode.MaxTeams)
{
_NumTeams++;
int[] numPlayerTeams = _NumPlayerTeams;
@@ -602,7 +602,7 @@ namespace VocaluxeLib.Menu
if (!_AllowChangeTeamNum)
return;
- if (_NumTeams - 1 >= _PartyMode.GetMinTeams())
+ if (_NumTeams - 1 >= _PartyMode.MinTeams)
_NumTeams--;
_UpdateButtonState();
}
@@ -613,7 +613,7 @@ namespace VocaluxeLib.Menu
return;
if (_NumPlayerTeams.Length > team)
{
- if (_NumPlayerTeams[team] + 1 <= _PartyMode.GetMaxPlayerPerTeam())
+ if (_NumPlayerTeams[team] + 1 <= _PartyMode.MaxPlayersPerTeam)
_NumPlayerTeams[team]++;
_UpdatePlayerSlide();
}
@@ -626,7 +626,7 @@ namespace VocaluxeLib.Menu
return;
if (_NumPlayerTeams.Length > team)
{
- if (_NumPlayerTeams[team] - 1 >= _PartyMode.GetMinPlayerPerTeam())
+ if (_NumPlayerTeams[team] - 1 >= _PartyMode.MinPlayersPerTeam)
_NumPlayerTeams[team]--;
if (_TeamList[team].Count > _NumPlayerTeams[team])
_RemovePlayerByIndex(team, _NumPlayerTeams[team] - 1);
@@ -699,20 +699,20 @@ namespace VocaluxeLib.Menu
private void _UpdateButtonVisibility()
{
- _Buttons[_ButtonIncreaseTeams].Visible = _AllowChangePlayerNum && _Teams && _PartyMode.GetMinTeams() != _PartyMode.GetMaxTeams();
- _Buttons[_ButtonDecreaseTeams].Visible = _AllowChangePlayerNum && _Teams && _PartyMode.GetMinTeams() != _PartyMode.GetMaxTeams();
+ _Buttons[_ButtonIncreaseTeams].Visible = _AllowChangePlayerNum && _Teams && _PartyMode.MinTeams != _PartyMode.MaxTeams;
+ _Buttons[_ButtonDecreaseTeams].Visible = _AllowChangePlayerNum && _Teams && _PartyMode.MinTeams != _PartyMode.MaxTeams;
_Buttons[_ButtonIncreasePlayer].Visible = _AllowChangePlayerNum;
_Buttons[_ButtonDecreasePlayer].Visible = _AllowChangePlayerNum;
}
private void _UpdateButtonState()
{
- _Buttons[_ButtonIncreaseTeams].Selectable = _NumTeams < _PartyMode.GetMaxTeams();
- _Buttons[_ButtonDecreaseTeams].Selectable = _NumTeams > _PartyMode.GetMinTeams();
+ _Buttons[_ButtonIncreaseTeams].Selectable = _NumTeams < _PartyMode.MaxTeams;
+ _Buttons[_ButtonDecreaseTeams].Selectable = _NumTeams > _PartyMode.MinTeams;
if (_NumPlayerTeams != null && _NumPlayerTeams.Length > _CurrentTeam)
{
- _Buttons[_ButtonIncreasePlayer].Selectable = _NumPlayerTeams[_CurrentTeam] < _PartyMode.GetMaxPlayerPerTeam();
- _Buttons[_ButtonDecreasePlayer].Selectable = _NumPlayerTeams[_CurrentTeam] > _PartyMode.GetMinPlayerPerTeam();
+ _Buttons[_ButtonIncreasePlayer].Selectable = _NumPlayerTeams[_CurrentTeam] < _PartyMode.MaxPlayersPerTeam;
+ _Buttons[_ButtonDecreasePlayer].Selectable = _NumPlayerTeams[_CurrentTeam] > _PartyMode.MinPlayersPerTeam;
}
else
{
@@ -725,7 +725,7 @@ namespace VocaluxeLib.Menu
{
if (_NumPlayerTeams[team] == _TeamList[team].Count && !_ChangePlayerNumDynamic)
return;
- if (_NumPlayerTeams[team] == _PartyMode.GetMaxPlayerPerTeam())
+ if (_NumPlayerTeams[team] == _PartyMode.MaxPlayersPerTeam)
return;
_NameSelections[_NameSelection].UseProfile(profileID);
diff --git a/VocaluxeLib/Menu/CSelectSlide.cs b/VocaluxeLib/Menu/CSelectSlide.cs
index 9c381208..be8a8ad9 100644
--- a/VocaluxeLib/Menu/CSelectSlide.cs
+++ b/VocaluxeLib/Menu/CSelectSlide.cs
@@ -390,6 +390,15 @@ namespace VocaluxeLib.Menu
_NeedsRevalidate = true;
}
+ ///
+ /// Adds an integer to the slide setting its tag to the value and its text to the text representation of the tag
+ ///
+ /// Value to add
+ public void AddValue(int tag)
+ {
+ AddValue(tag.ToString(), null, tag);
+ }
+
///
/// Adds an entry to the slide.
///
@@ -434,6 +443,17 @@ namespace VocaluxeLib.Menu
AddValue(values[i], textures[i]);
}
+ public void RemoveValue(string text)
+ {
+ int idx = _Values.FindIndex(val => val.Text == text);
+ if (idx < 0)
+ return;
+ _Values.RemoveAt(idx);
+ if (Selection >= idx)
+ Selection--;
+ _Invalidate();
+ }
+
public void SetValues(int selection)
{
AddValues(Enum.GetNames(typeof(T)));
diff --git a/VocaluxeLib/PartyModes/CPartyMode.cs b/VocaluxeLib/PartyModes/CPartyMode.cs
index 14192af7..5a4d2b14 100644
--- a/VocaluxeLib/PartyModes/CPartyMode.cs
+++ b/VocaluxeLib/PartyModes/CPartyMode.cs
@@ -16,21 +16,20 @@
#endregion
using System.Collections.Generic;
+using System.Diagnostics;
using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes
{
public abstract class CPartyMode : IPartyMode
{
- private readonly string _Folder;
private readonly int _ID;
protected SScreenSongOptions _ScreenSongOptions = new SScreenSongOptions {Selection = new SSelectionOptions(), Sorting = new SSortingOptions()};
protected readonly Dictionary _Screens = new Dictionary();
- protected CPartyMode(int id, string folder)
+ protected CPartyMode(int id)
{
_ID = id;
- _Folder = folder;
}
#region Implementation
@@ -39,7 +38,15 @@ namespace VocaluxeLib.PartyModes
get { return _ID; }
}
- public abstract bool Init();
+ public int NumPlayers { get; set; }
+ public int NumTeams { get; set; }
+
+ public virtual bool Init()
+ {
+ Debug.Assert(MinPlayers > 0 && MinPlayers <= MaxPlayers);
+ Debug.Assert(MinTeams > 0 && MinTeams <= MaxTeams);
+ return true;
+ }
public void LoadTheme()
{
@@ -75,61 +82,6 @@ namespace VocaluxeLib.PartyModes
entry.Value.SaveTheme();
}
- public virtual void UpdateGame() {}
-
- public abstract IMenu GetStartScreen();
-
- public virtual SScreenSongOptions GetScreenSongOptions()
- {
- return new SScreenSongOptions();
- }
-
- public virtual void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions) {}
-
- public virtual void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions) {}
-
- public virtual int GetMaxPlayer()
- {
- return 6;
- }
-
- public virtual int GetMinPlayer()
- {
- return 1;
- }
-
- public virtual int GetMaxTeams()
- {
- return 0;
- }
-
- public virtual int GetMinTeams()
- {
- return 0;
- }
-
- public virtual int GetMinPlayerPerTeam()
- {
- return GetMinPlayer();
- }
-
- public virtual int GetMaxPlayerPerTeam()
- {
- return GetMaxPlayer();
- }
-
- public virtual int GetMaxNumRounds()
- {
- return 1;
- }
-
- public string GetFolder()
- {
- return _Folder;
- }
-
- public virtual void SetSearchString(string searchString, bool visible) {}
-
public virtual void JokerUsed(int teamNr)
{
if (_ScreenSongOptions.Selection.NumJokers == null)
@@ -142,8 +94,6 @@ namespace VocaluxeLib.PartyModes
_ScreenSongOptions.Selection.NumJokers[teamNr]--;
}
- public abstract void SongSelected(int songID);
-
public virtual void FinishedSinging()
{
CBase.Graphics.FadeTo(EScreen.Score);
@@ -159,5 +109,25 @@ namespace VocaluxeLib.PartyModes
CBase.Graphics.FadeTo(EScreen.Song);
}
#endregion Implementation
+
+ #region Abstract members
+ public abstract int MinMics { get; }
+ public abstract int MaxMics { get; }
+ public abstract int MinPlayers { get; }
+ public abstract int MaxPlayers { get; }
+ public abstract int MinTeams { get; }
+ public abstract int MaxTeams { get; }
+ public abstract int MinPlayersPerTeam { get; }
+ public abstract int MaxPlayersPerTeam { get; }
+
+ public abstract void UpdateGame();
+ public abstract IMenu GetStartScreen();
+ public abstract SScreenSongOptions GetScreenSongOptions();
+ public abstract void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions);
+ public abstract void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions);
+ public abstract void SetSearchString(string searchString, bool visible);
+
+ public abstract void SongSelected(int songID);
+ #endregion Abstract members
}
}
\ No newline at end of file
diff --git a/VocaluxeLib/PartyModes/CPartyModeNone.cs b/VocaluxeLib/PartyModes/CPartyModeNormal.cs
similarity index 68%
rename from VocaluxeLib/PartyModes/CPartyModeNone.cs
rename to VocaluxeLib/PartyModes/CPartyModeNormal.cs
index c3e3ea6a..a84ecb73 100644
--- a/VocaluxeLib/PartyModes/CPartyModeNone.cs
+++ b/VocaluxeLib/PartyModes/CPartyModeNormal.cs
@@ -20,10 +20,42 @@ using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes
{
- public class CPartyModeNone : CPartyMode
+ public class CPartyModeNormal : CPartyMode
{
- //just a dummy for normal game mode
- public CPartyModeNone(int id, string folder) : base(id, folder)
+ public override int MinMics
+ {
+ get { return 1; }
+ }
+ public override int MaxMics
+ {
+ get { return CBase.Config.GetMaxNumMics(); }
+ }
+ public override int MinPlayers
+ {
+ get { return 1; }
+ }
+ public override int MaxPlayers
+ {
+ get { return CBase.Settings.GetMaxNumPlayer(); }
+ }
+ public override int MinTeams
+ {
+ get { return 1; }
+ }
+ public override int MaxTeams
+ {
+ get { return 1; }
+ }
+ public override int MinPlayersPerTeam
+ {
+ get { return MinPlayers; }
+ }
+ public override int MaxPlayersPerTeam
+ {
+ get { return MaxPlayers; }
+ }
+
+ public CPartyModeNormal(int id) : base(id)
{
_ScreenSongOptions.Selection.RandomOnly = false;
_ScreenSongOptions.Selection.PartyMode = false;
@@ -42,6 +74,8 @@ namespace VocaluxeLib.PartyModes
return true;
}
+ public override void UpdateGame() {}
+
public override IMenu GetStartScreen()
{
return CBase.Graphics.GetScreen(EScreen.Names);
@@ -60,6 +94,10 @@ namespace VocaluxeLib.PartyModes
return _ScreenSongOptions;
}
+ public override void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions) {}
+
+ public override void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions) {}
+
public override void SetSearchString(string searchString, bool visible)
{
_ScreenSongOptions.Sorting.SearchString = searchString;
diff --git a/VocaluxeLib/PartyModes/IPartyMode.cs b/VocaluxeLib/PartyModes/IPartyMode.cs
index d432e368..d1aa7e1f 100644
--- a/VocaluxeLib/PartyModes/IPartyMode.cs
+++ b/VocaluxeLib/PartyModes/IPartyMode.cs
@@ -79,9 +79,24 @@ namespace VocaluxeLib.PartyModes
}
#endregion Structs
- public interface IPartyMode
+ public interface IPartyModeInfo
{
int ID { get; }
+ int MinMics { get; }
+ int MaxMics { get; }
+ int MinPlayers { get; }
+ int MaxPlayers { get; }
+ int MinTeams { get; }
+ int MaxTeams { get; }
+ int MinPlayersPerTeam { get; }
+ int MaxPlayersPerTeam { get; }
+ }
+
+ public interface IPartyMode : IPartyModeInfo
+ {
+ int NumPlayers { get; set; }
+ int NumTeams { get; set; }
+
bool Init();
void LoadTheme();
@@ -99,14 +114,6 @@ namespace VocaluxeLib.PartyModes
void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions);
void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions);
- int GetMaxPlayer();
- int GetMinPlayer();
- int GetMaxTeams();
- int GetMinTeams();
- int GetMinPlayerPerTeam();
- int GetMaxPlayerPerTeam();
- int GetMaxNumRounds();
-
void SetSearchString(string searchString, bool visible);
void JokerUsed(int teamNr);
diff --git a/VocaluxeLib/VocaluxeLib.csproj b/VocaluxeLib/VocaluxeLib.csproj
index cd947ae2..e1faa2d8 100644
--- a/VocaluxeLib/VocaluxeLib.csproj
+++ b/VocaluxeLib/VocaluxeLib.csproj
@@ -139,7 +139,7 @@
-
+