diff --git a/Output/PartyModes/ChallengeMedley.xml b/Output/PartyModes/ChallengeMedley.xml
index 3f1063dc..8b3d8155 100644
--- a/Output/PartyModes/ChallengeMedley.xml
+++ b/Output/PartyModes/ChallengeMedley.xml
@@ -8,7 +8,7 @@
ChallengeMedley
CPartyModeChallengeMedley
0
- 1
+ 2
TR_PARTYMODE_AUDIENCE
@@ -16,4 +16,4 @@
CPartyScreenChallengeMedleyConfig
CPartyScreenChallengeMedleyNames
-
\ No newline at end of file
+
diff --git a/Output/PartyModes/ChallengeMedley/Languages/English.xml b/Output/PartyModes/ChallengeMedley/Languages/English.xml
index 4ce10c84..51c783a4 100644
--- a/Output/PartyModes/ChallengeMedley/Languages/English.xml
+++ b/Output/PartyModes/ChallengeMedley/Languages/English.xml
@@ -2,7 +2,7 @@
English
Challenge Medley Mode
- Play some challenge rounds by using 5-some Medleys only.
+ Play some challenge rounds by using Medleys only.
For all who are interested in duel fights and Medleys.
Next
Back
@@ -11,10 +11,16 @@
Yes
No
Next Round
+ Playlist
+ Category
+ All songs
+ Songs
Challenge Medley Mode: Configuration
Number of players
Number of mics
Number of rounds
+ Number of songs per round
+ Song source
Challenge Medley Mode: Choose Player
Select random
Challenge Medley Mode: Overview
diff --git a/Output/PartyModes/ChallengeMedley/Themes/Default/Screens/PartyScreenChallengeMedleyConfig.xml b/Output/PartyModes/ChallengeMedley/Themes/Default/Screens/PartyScreenChallengeMedleyConfig.xml
index dbc62be5..021cff22 100644
--- a/Output/PartyModes/ChallengeMedley/Themes/Default/Screens/PartyScreenChallengeMedleyConfig.xml
+++ b/Output/PartyModes/ChallengeMedley/Themes/Default/Screens/PartyScreenChallengeMedleyConfig.xml
@@ -2,7 +2,7 @@
PartyScreenChallengeMedleyConfig
- 1
+ 2
@@ -83,6 +83,34 @@
Outline
TR_SCREENCONFIG_NUMROUNDS
+
+ 75
+ 285
+ 0
+ 27
+ 0
+
+
+ Left
+ Center
+
+ Outline
+ TR_SCREENCONFIG_NUMSONGS
+
+
+ 75
+ 345
+ 0
+ 27
+ 0
+
+
+ Left
+ Center
+
+ Outline
+ TR_SCREENCONFIG_SONGSOURCE
+
\ No newline at end of file
+
diff --git a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs
index 5f2d6a1b..38c49aa8 100644
--- a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs
+++ b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs
@@ -29,6 +29,13 @@ using VocaluxeLib.Songs;
namespace VocaluxeLib.PartyModes.ChallengeMedley
{
+ public enum ESongSource
+ {
+ TR_ALLSONGS,
+ TR_CATEGORY,
+ TR_PLAYLIST
+ }
+
public class CResultTableRow : IComparable
{
public int Position;
@@ -72,8 +79,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public sealed class CPartyModeChallengeMedley : CPartyMode
// ReSharper restore ClassNeverInstantiated.Global
{
- private const int _NumSongs = 5;
-
public override int MinMics
{
get { return 1; }
@@ -107,6 +112,16 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
get { return MaxPlayers; }
}
+ public int MinSongs
+ {
+ get { return 1; }
+ }
+
+ public int MaxSongs
+ {
+ get { return 10; }
+ }
+
private enum EStage
{
Config,
@@ -121,6 +136,8 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public int NumPlayerAtOnce;
public int NumRounds;
public List ProfileIDs;
+ public int NumSongs;
+ public List Songs;
public CChallengeRounds Rounds;
public List ResultTable;
@@ -129,6 +146,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public int CurrentRoundNr;
public int[] CatSongIndices;
+
+ public ESongSource SongSource;
+ public int CategoryIndex;
+ public int PlaylistID;
}
private struct SStats
@@ -144,17 +165,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public CPartyModeChallengeMedley(int id) : base(id)
{
- _ScreenSongOptions.Selection.RandomOnly = false;
- _ScreenSongOptions.Selection.PartyMode = true;
- _ScreenSongOptions.Selection.CategoryChangeAllowed = true;
- _ScreenSongOptions.Selection.NumJokers = new int[] {5, 5};
- _ScreenSongOptions.Selection.TeamNames = new string[] {"foo", "bar"};
-
- _ScreenSongOptions.Sorting.SearchString = String.Empty;
- _ScreenSongOptions.Sorting.SearchActive = false;
- _ScreenSongOptions.Sorting.DuetOptions = EDuetOptions.NoDuets;
-
- GameData = new SData {NumPlayer = 4, NumPlayerAtOnce = 2, NumRounds = 12, CurrentRoundNr = 1, ProfileIDs = new List(), CatSongIndices = null, Results = null};
+ GameData = new SData {NumPlayer = 4, NumPlayerAtOnce = 2, NumRounds = 12, CurrentRoundNr = 1, ProfileIDs = new List(), NumSongs = 5, Songs = new List(), SongSource = ESongSource.TR_ALLSONGS, CatSongIndices = null, Results = null};
}
public override bool Init()
@@ -163,14 +174,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
return false;
_Stage = EStage.Config;
- _ScreenSongOptions.Sorting.IgnoreArticles = EOffOn.TR_CONFIG_OFF;
- _ScreenSongOptions.Sorting.SongSorting = ESongSorting.TR_CONFIG_NONE;
- _ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_OFF;
- _ScreenSongOptions.Selection.SongIndex = -1;
-
- CBase.Songs.SortSongs(ESongSorting.TR_CONFIG_NONE, EOffOn.TR_CONFIG_OFF, EOffOn.TR_CONFIG_OFF, String.Empty, EDuetOptions.NoDuets);
- CBase.Songs.SetCategory(0);
-
GameData.ResultTable = new List();
return true;
@@ -259,79 +262,27 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{
return _Screens["CPartyScreenChallengeMedleyConfig"];
}
-
public override SScreenSongOptions GetScreenSongOptions()
{
- _ScreenSongOptions.Sorting.SongSorting = CBase.Config.GetSongSorting();
- _ScreenSongOptions.Sorting.Tabs = CBase.Config.GetTabs();
- _ScreenSongOptions.Sorting.IgnoreArticles = CBase.Config.GetIgnoreArticles();
-
- return _ScreenSongOptions;
+ throw new ArgumentException("Not required!");
}
- // ReSharper disable RedundantAssignment
public override void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions)
- // ReSharper restore RedundantAssignment
{
- _ScreenSongOptions.Selection.SongIndex = -1;
-
- if (_ScreenSongOptions.Selection.SelectNextRandomSong && songIndex != -1)
- {
- _ScreenSongOptions.Selection.SelectNextRandomSong = false;
- _CreateCatSongIndices();
-
- if (GameData.CatSongIndices != null)
- {
- if (GameData.CatSongIndices[CBase.Songs.GetCurrentCategoryIndex()] == -1)
- GameData.CatSongIndices[CBase.Songs.GetCurrentCategoryIndex()] = songIndex;
- }
- }
-
- screenSongOptions = _ScreenSongOptions;
+ throw new ArgumentException("Not required!");
}
- // ReSharper disable RedundantAssignment
public override void OnCategoryChange(int categoryIndex, ref SScreenSongOptions screenSongOptions)
- // ReSharper restore RedundantAssignment
{
- if (GameData.CatSongIndices != null && categoryIndex != -1)
- {
- if (GameData.CatSongIndices[categoryIndex] == -1)
- _ScreenSongOptions.Selection.SelectNextRandomSong = true;
- else
- _ScreenSongOptions.Selection.SongIndex = GameData.CatSongIndices[categoryIndex];
- }
-
- if (GameData.CatSongIndices == null && categoryIndex != -1)
- _ScreenSongOptions.Selection.SelectNextRandomSong = true;
-
- if (categoryIndex == -1)
- _ScreenSongOptions.Selection.RandomOnly = false;
-
- if (_ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF || categoryIndex != -1)
- _ScreenSongOptions.Selection.RandomOnly = true;
-
- screenSongOptions = _ScreenSongOptions;
+ throw new ArgumentException("Not required!");
}
public override void SetSearchString(string searchString, bool visible)
{
- _ScreenSongOptions.Sorting.SearchString = searchString;
- _ScreenSongOptions.Sorting.SearchActive = visible;
+ throw new ArgumentException("Not required!");
}
- public override void JokerUsed(int teamNr)
- {
- if (_ScreenSongOptions.Selection.NumJokers == null)
- return;
-
- if (teamNr >= _ScreenSongOptions.Selection.NumJokers.Length)
- return;
-
- _ScreenSongOptions.Selection.NumJokers[teamNr]--;
- _ScreenSongOptions.Selection.RandomOnly = true;
- _ScreenSongOptions.Selection.CategoryChangeAllowed = false;
- }
+ public override void JokerUsed(int teamNr) { }
public override void SongSelected(int songID) {}
@@ -343,16 +294,13 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private bool _StartNextRound()
{
- _ScreenSongOptions.Selection.RandomOnly = _ScreenSongOptions.Sorting.Tabs != EOffOn.TR_CONFIG_ON;
- _ScreenSongOptions.Selection.CategoryChangeAllowed = _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_ON;
- _SetNumJokers();
_SetTeamNames();
GameData.CatSongIndices = null;
- return _RandomizeSongs();
+ return _PrepareGame();
}
- private bool _RandomizeSongs()
+ private bool _PrepareGame()
{
CBase.Game.Reset();
CBase.Game.ClearSongs();
@@ -379,85 +327,50 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
#endregion PlayerNames
#region SongQueue
- if (CBase.Songs.GetNumSongsVisible() < _NumSongs)
- CBase.Songs.ResetSongSung();
-
- List ids = new List();
-
- ReadOnlyCollection visibleSongs = CBase.Songs.GetVisibleSongs();
- if (visibleSongs.Count == 0)
+ for (int i = 0; i < GameData.NumSongs; i++)
{
- CBase.Log.LogError("CPartyChallengeMedleyMode Error: There are no songs!");
- return false;
- }
-
- //Calc avarage sing-count
- int totalCounts = visibleSongs.Sum(song => song.NumPlayedSession);
- int averageCount = totalCounts / visibleSongs.Count;
-
- // ReSharper disable LoopCanBeConvertedToQuery
- foreach (CSong song in visibleSongs)
- {
- foreach (EGameMode mode in song.AvailableGameModes)
- {
- if (mode == EGameMode.TR_GAMEMODE_MEDLEY && song.NumPlayedSession <= averageCount)
- ids.Add(song.ID);
- }
- }
- // ReSharper restore LoopCanBeConvertedToQuery
-
- if (ids.Count == 0)
- {
- CBase.Log.LogError("CPartyChallengeMedleyMode Error: There are no medley songs!");
- return false;
- }
-
- int s = 0;
- while (s < _NumSongs && ids.Count > 0)
- {
- int songID = ids[CBase.Game.GetRandom(ids.Count)];
- CBase.Game.AddSong(songID, EGameMode.TR_GAMEMODE_MEDLEY);
- CBase.Songs.AddPartySongSung(songID);
- ids.Remove(songID);
- s++;
+ if (GameData.Songs.Count == 0)
+ _UpdateSongList();
+ CBase.Game.AddSong(GameData.Songs[0], EGameMode.TR_GAMEMODE_MEDLEY);
+ GameData.Songs.RemoveAt(0);
}
return true;
#endregion SongQueue
}
- private void _SetNumJokers()
+ private void _UpdateSongList()
{
- switch (GameData.NumPlayerAtOnce)
+ if (GameData.Songs.Count > 0)
+ return;
+
+ switch (GameData.SongSource)
{
- case 1:
- _ScreenSongOptions.Selection.NumJokers = new int[] {10};
+ 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(EGameMode.TR_GAMEMODE_MEDLEY))
+ GameData.Songs.Add(id);
+ }
break;
- case 2:
- _ScreenSongOptions.Selection.NumJokers = new int[] {5, 5};
+ case ESongSource.TR_ALLSONGS:
+ ReadOnlyCollection avSongs = CBase.Songs.GetSongs();
+ GameData.Songs.AddRange(avSongs.Where(song => song.AvailableGameModes.Contains(EGameMode.TR_GAMEMODE_MEDLEY)).Select(song => song.ID));
break;
- case 3:
- _ScreenSongOptions.Selection.NumJokers = new int[] {4, 4, 4};
- break;
+ case ESongSource.TR_CATEGORY:
+ CBase.Songs.SetCategory(GameData.CategoryIndex);
+ avSongs = CBase.Songs.GetVisibleSongs();
+ GameData.Songs.AddRange(avSongs.Where(song => song.AvailableGameModes.Contains(EGameMode.TR_GAMEMODE_MEDLEY)).Select(song => song.ID));
- case 4:
- _ScreenSongOptions.Selection.NumJokers = new int[] {3, 3, 3, 3};
- break;
-
- case 5:
- _ScreenSongOptions.Selection.NumJokers = new int[] {2, 2, 2, 2, 2};
- break;
-
- case 6:
- _ScreenSongOptions.Selection.NumJokers = new int[] {2, 2, 2, 2, 2, 2};
- break;
- default:
- _ScreenSongOptions.Selection.NumJokers = new int[] {5, 5};
+ CBase.Songs.SetCategory(-1);
break;
}
+ GameData.Songs.Shuffle();
}
+
private void _SetTeamNames()
{
CProfile[] profiles = CBase.Profiles.GetProfiles();
diff --git a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs
index dbb80bb6..88c5e688 100644
--- a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs
+++ b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs
@@ -16,7 +16,10 @@
#endregion
using System;
+using System.Linq;
+using System.Collections.Generic;
using System.Windows.Forms;
+using VocaluxeLib.Songs;
namespace VocaluxeLib.PartyModes.ChallengeMedley
{
@@ -27,23 +30,28 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
// Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion
{
- get { return 1; }
+ get { return 2; }
}
private const string _SelectSlideNumPlayers = "SelectSlideNumPlayers";
private const string _SelectSlideNumMics = "SelectSlideNumMics";
private const string _SelectSlideNumRounds = "SelectSlideNumRounds";
+ private const string _SelectSlideNumSongs = "SelectSlideNumSongs";
+ private const string _SelectSlideSongSource = "SelectSlideSongSource";
+ private const string _SelectSlidePlaylist = "SelectSlidePlaylist";
+ private const string _SelectSlideCategory = "SelectSlideCategory";
private const string _ButtonNext = "ButtonNext";
private const string _ButtonBack = "ButtonBack";
private const int _MaxNumRounds = 100;
private int _RoundSteps = 1;
+ private bool _ConfigOk;
public override void Init()
{
base.Init();
- _ThemeSelectSlides = new string[] {_SelectSlideNumPlayers, _SelectSlideNumMics, _SelectSlideNumRounds};
+ _ThemeSelectSlides = new string[] {_SelectSlideNumPlayers, _SelectSlideNumMics, _SelectSlideNumRounds, _SelectSlideNumSongs, _SelectSlideSongSource, _SelectSlidePlaylist, _SelectSlideCategory};
_ThemeButtons = new string[] {_ButtonNext, _ButtonBack};
}
@@ -108,10 +116,12 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
base.OnShow();
_RebuildSlides();
+ _UpdateSlides();
}
public override bool UpdateGame()
{
+ _Buttons[_ButtonNext].Visible = _ConfigOk;
return true;
}
@@ -123,7 +133,35 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_SelectSlides[_SelectSlideNumPlayers].AddValue(i.ToString());
_SelectSlides[_SelectSlideNumPlayers].Selection = _PartyMode.GameData.NumPlayer - _PartyMode.MinPlayers;
- _UpdateMicsAtOnce();
+ _SelectSlides[_SelectSlideNumSongs].Clear();
+ for (int i = _PartyMode.MinSongs; i <= _PartyMode.MaxSongs; i++)
+ _SelectSlides[_SelectSlideNumSongs].AddValue(i.ToString());
+ _SelectSlides[_SelectSlideNumSongs].Selection = _PartyMode.GameData.NumSongs - _PartyMode.MinSongs;
+
+ _SelectSlides[_SelectSlideSongSource].Clear();
+ _SelectSlides[_SelectSlideSongSource].SetValues((int)_PartyMode.GameData.SongSource);
+
+ List playlists = CBase.Playlist.GetNames();
+ _SelectSlides[_SelectSlidePlaylist].Clear();
+ for (int i = 0; i < playlists.Count; i++)
+ {
+ string value = playlists[i] + " (" + CBase.Playlist.GetSongCount(i) + " " + CBase.Language.Translate("TR_SONGS", PartyModeID) + ")";
+ _SelectSlides[_SelectSlidePlaylist].AddValue(value);
+ }
+ _SelectSlides[_SelectSlidePlaylist].Selection = _PartyMode.GameData.PlaylistID;
+ _SelectSlides[_SelectSlidePlaylist].Visible = _PartyMode.GameData.SongSource == ESongSource.TR_PLAYLIST;
+
+ _SelectSlides[_SelectSlideCategory].Clear();
+ for (int i = 0; i < CBase.Songs.GetNumCategories(); i++)
+ {
+ 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.CategoryIndex;
+ _SelectSlides[_SelectSlideCategory].Visible = _PartyMode.GameData.SongSource == ESongSource.TR_CATEGORY;
+
+ _UpdateMicsAtOnce();
_SetRoundSteps();
_UpdateSlideRounds();
}
@@ -135,6 +173,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_PartyMode.GameData.NumPlayer = _SelectSlides[_SelectSlideNumPlayers].Selection + _PartyMode.MinPlayers;
_PartyMode.GameData.NumPlayerAtOnce = _SelectSlides[_SelectSlideNumMics].Selection + _PartyMode.MinPlayers;
_PartyMode.GameData.NumRounds = (_SelectSlides[_SelectSlideNumRounds].Selection + 1) * _RoundSteps;
+ _PartyMode.GameData.NumSongs = _SelectSlides[_SelectSlideNumSongs].Selection + _PartyMode.MinSongs;
+ _PartyMode.GameData.SongSource = (ESongSource)_SelectSlides[_SelectSlideSongSource].Selection;
+ _PartyMode.GameData.PlaylistID = _SelectSlides[_SelectSlidePlaylist].Selection;
+ _PartyMode.GameData.CategoryIndex = _SelectSlides[_SelectSlideCategory].Selection;
_UpdateMicsAtOnce();
_SetRoundSteps();
@@ -147,6 +189,64 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_PartyMode.GameData.NumRounds = num;
}
+ if (_PartyMode.GameData.SongSource == ESongSource.TR_PLAYLIST)
+ {
+ if (CBase.Playlist.GetNumPlaylists() > 0)
+ {
+ if (CBase.Playlist.GetSongCount(_PartyMode.GameData.PlaylistID) > 0)
+ {
+ _ConfigOk = false;
+ for (int i = 0; i < CBase.Playlist.GetSongCount(_PartyMode.GameData.PlaylistID); i++)
+ {
+ int id = CBase.Playlist.GetSong(_PartyMode.GameData.PlaylistID, i).SongID;
+ _ConfigOk = CBase.Songs.GetSongByID(id).AvailableGameModes.Any(mode => mode == EGameMode.TR_GAMEMODE_MEDLEY);
+ if (_ConfigOk)
+ break;
+ }
+ }
+ else
+ _ConfigOk = false;
+ }
+ else
+ _ConfigOk = false;
+ }
+ if (_PartyMode.GameData.SongSource == ESongSource.TR_CATEGORY)
+ {
+ if (CBase.Songs.GetNumCategories() == 0)
+ _ConfigOk = false;
+ else if (CBase.Songs.GetNumSongsNotSungInCategory(_PartyMode.GameData.CategoryIndex) <= 0)
+ _ConfigOk = false;
+ else
+ {
+ CBase.Songs.SetCategory(_PartyMode.GameData.CategoryIndex);
+ _ConfigOk = false;
+ foreach (CSong song in CBase.Songs.GetVisibleSongs())
+ {
+ _ConfigOk = song.AvailableGameModes.Any(mode => mode == EGameMode.TR_GAMEMODE_MEDLEY);
+ if (_ConfigOk)
+ break;
+ }
+ CBase.Songs.SetCategory(-1);
+ }
+ }
+ if (_PartyMode.GameData.SongSource == ESongSource.TR_ALLSONGS)
+ {
+ if (CBase.Songs.GetNumSongs() > 0)
+ {
+ for (int i = 0; i < CBase.Songs.GetNumSongs(); i++)
+ {
+ _ConfigOk = CBase.Songs.GetSongByID(i).AvailableGameModes.Any(mode => mode == EGameMode.TR_GAMEMODE_MEDLEY);
+ if (_ConfigOk)
+ break;
+ }
+ }
+ else
+ _ConfigOk = false;
+ }
+
+ _SelectSlides[_SelectSlideCategory].Visible = _PartyMode.GameData.SongSource == ESongSource.TR_CATEGORY;
+ _SelectSlides[_SelectSlidePlaylist].Visible = _PartyMode.GameData.SongSource == ESongSource.TR_PLAYLIST;
+
_UpdateSlideRounds();
}