Apply R# clean-up for reliability (#877)
* Apply R# clean-up for reliability - Migrate to NUnit4 Assert.That - Update dependencise versions - Fix LangVersion to 9.0 (until net core migration) - Reformat code - Apply 'var' style (easier for refactoring) - Remove redundant parentheses - Add braces on every condition blocks (1 line) - Uses new null checking patterns - Uses AutoProperties when possible - Uses string scalar type instead of class - Clean usings - Add .orig files in git ignore - Rename some properties to respect defined conventions and US format definition - ID -> Id - BPM -> Bpm - Finish -> End * Update R# settings according to the clean-up made
This commit is contained in:
1 parent
b9b0f7c8df
commit
6ffa63b923
236 files changed
+14194
-7278
No files matched your search
@@ -40,16 +40,20 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
public CChallengeRounds(int numRounds, int numPlayer, int playersPerRound)
|
||||
{
|
||||
if (numRounds < 1 || numPlayer < 1 || playersPerRound < 1)
|
||||
{
|
||||
throw new ArgumentException("Invalid paramters for the rounds");
|
||||
}
|
||||
|
||||
if (playersPerRound > numPlayer)
|
||||
{
|
||||
playersPerRound = numPlayer;
|
||||
}
|
||||
|
||||
_BuildRounds(numRounds, numPlayer, playersPerRound);
|
||||
if (Count > numRounds)
|
||||
{
|
||||
//Try again and take the better one
|
||||
List<CRound> old = new List<CRound>(_Rounds);
|
||||
var old = new List<CRound>(_Rounds);
|
||||
_Rounds.Clear();
|
||||
_BuildRounds(numRounds, numPlayer, playersPerRound);
|
||||
if (Count > old.Count)
|
||||
@@ -66,50 +70,60 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
/// <param name="numSung">List matching the playerIndex to the number of songs sung</param>
|
||||
private static List<int> _GetPlayersForRound(IList<int> numSung)
|
||||
{
|
||||
List<int> mustSing = new List<int>();
|
||||
int max = numSung.Max();
|
||||
for (int i = 0; i < numSung.Count; i++)
|
||||
var mustSing = new List<int>();
|
||||
var max = numSung.Max();
|
||||
for (var i = 0; i < numSung.Count; i++)
|
||||
{
|
||||
if (numSung[i] < max)
|
||||
{
|
||||
mustSing.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
return mustSing;
|
||||
}
|
||||
|
||||
private static void _AddCombinations(int numPlayer, int playersPerRound, List<CRound> combinations)
|
||||
{
|
||||
List<int> input = new List<int>(numPlayer);
|
||||
for (int i = 0; i < numPlayer; i++)
|
||||
var input = new List<int>(numPlayer);
|
||||
for (var i = 0; i < numPlayer; i++)
|
||||
{
|
||||
input.Add(i);
|
||||
CCombinations<int> combs = new CCombinations<int>(input, playersPerRound);
|
||||
}
|
||||
|
||||
var combs = new CCombinations<int>(input, playersPerRound);
|
||||
combinations.AddRange(combs.Select(combination => new CRound(combination)));
|
||||
combinations.Shuffle();
|
||||
}
|
||||
|
||||
private static CRound _GetMatchingCombination(List<int> playersInRound, List<int> numSung, List<CRound> combinations)
|
||||
{
|
||||
foreach (CRound round in combinations)
|
||||
foreach (var round in combinations)
|
||||
{
|
||||
int matching = round.Players.Count(playersInRound.Contains);
|
||||
var matching = round.Players.Count(playersInRound.Contains);
|
||||
// A valid round contains only players from playersInRound or all players from playersInRound (and some others)
|
||||
if (matching == round.Players.Count || matching == playersInRound.Count)
|
||||
{
|
||||
return round;
|
||||
}
|
||||
}
|
||||
|
||||
// It may happen, that there are only players that already sung against each other. So create a 2nd best option with the most number of players that should sing in it
|
||||
int maxMatching = combinations.Max(c => c.Players.Count(playersInRound.Contains));
|
||||
List<CRound> nextOptions = combinations.Where(c => c.Players.Count(playersInRound.Contains) == maxMatching).ToList();
|
||||
var maxMatching = combinations.Max(c => c.Players.Count(playersInRound.Contains));
|
||||
var nextOptions = combinations.Where(c => c.Players.Count(playersInRound.Contains) == maxMatching).ToList();
|
||||
// And select the combination that minimizes the sum of the number of songs sung (--> favor rounds with players that sung less than others)
|
||||
CRound result = null;
|
||||
int minSung = int.MaxValue;
|
||||
foreach (CRound round in nextOptions)
|
||||
var minSung = int.MaxValue;
|
||||
foreach (var round in nextOptions)
|
||||
{
|
||||
int curNumSung = round.Players.Sum(pl => numSung[pl]);
|
||||
var curNumSung = round.Players.Sum(pl => numSung[pl]);
|
||||
if (curNumSung < minSung)
|
||||
{
|
||||
minSung = curNumSung;
|
||||
result = round;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Assert(result != null);
|
||||
return result;
|
||||
}
|
||||
@@ -118,24 +132,35 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
// What we want is that every player sung the same amount of songs
|
||||
// So we keep track how many songs each palyer sung
|
||||
List<int> numSung = new List<int>(numPlayer);
|
||||
for (int i = 0; i < numPlayer; i++)
|
||||
var numSung = new List<int>(numPlayer);
|
||||
for (var i = 0; i < numPlayer; i++)
|
||||
{
|
||||
numSung.Add(0);
|
||||
List<CRound> combinations = new List<CRound>();
|
||||
}
|
||||
|
||||
var combinations = new List<CRound>();
|
||||
// Posibly add more rounds than requested if the song count per player is unequal
|
||||
for (int i = 0; i < numRounds * 10; i++)
|
||||
for (var i = 0; i < numRounds * 10; i++)
|
||||
{
|
||||
if (combinations.Count == 0)
|
||||
{
|
||||
_AddCombinations(numPlayer, playersPerRound, combinations);
|
||||
List<int> playersInRound = _GetPlayersForRound(numSung);
|
||||
CRound curRound = _GetMatchingCombination(playersInRound, numSung, combinations);
|
||||
foreach (int player in curRound.Players)
|
||||
}
|
||||
|
||||
var playersInRound = _GetPlayersForRound(numSung);
|
||||
var curRound = _GetMatchingCombination(playersInRound, numSung, combinations);
|
||||
foreach (var player in curRound.Players)
|
||||
{
|
||||
numSung[player]++;
|
||||
}
|
||||
|
||||
_Rounds.Add(curRound);
|
||||
combinations.Remove(curRound);
|
||||
//Stop if we have enough rounds and all players sung the same amount of songs
|
||||
if (_Rounds.Count >= numRounds && numSung.All(ct => ct == numSung[0]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,10 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using VocaluxeLib.Game;
|
||||
using VocaluxeLib.Menu;
|
||||
using VocaluxeLib.Songs;
|
||||
using VocaluxeLib.Utils;
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
@@ -31,7 +29,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
public class CResultTableRow : IComparable
|
||||
{
|
||||
public int Position;
|
||||
public Guid PlayerID;
|
||||
public Guid PlayerId;
|
||||
public int NumPlayed;
|
||||
public int NumWon;
|
||||
public int NumSingPoints;
|
||||
@@ -42,13 +40,16 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
var row = obj as CResultTableRow;
|
||||
if (row != null)
|
||||
{
|
||||
int res = row.NumGamePoints.CompareTo(NumGamePoints);
|
||||
var res = row.NumGamePoints.CompareTo(NumGamePoints);
|
||||
if (res == 0)
|
||||
{
|
||||
res = row.NumSingPoints.CompareTo(NumSingPoints);
|
||||
if (res == 0)
|
||||
{
|
||||
res = row.NumWon.CompareTo(NumWon);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -69,7 +70,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
|
||||
// ReSharper disable ClassNeverInstantiated.Global
|
||||
public sealed class CPartyModeChallenge : CPartyMode
|
||||
// ReSharper restore ClassNeverInstantiated.Global
|
||||
// ReSharper restore ClassNeverInstantiated.Global
|
||||
{
|
||||
public override int MinMics
|
||||
{
|
||||
@@ -123,12 +124,12 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
public int NumJokers;
|
||||
public bool RefillJokers;
|
||||
public int[] Jokers;
|
||||
public List<Guid> ProfileIDs;
|
||||
public List<Guid> ProfileIds;
|
||||
|
||||
public ESongSource SongSource;
|
||||
public ESongSorting Sorting;
|
||||
public int CategoryIndex;
|
||||
public int PlaylistID;
|
||||
public int PlaylistId;
|
||||
|
||||
public EGameMode GameMode;
|
||||
public int NumMedleySongs;
|
||||
@@ -144,7 +145,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
|
||||
private struct SStats
|
||||
{
|
||||
public Guid ProfileID;
|
||||
public Guid ProfileId;
|
||||
public int SingPoints;
|
||||
public int GamePoints;
|
||||
public int Won;
|
||||
@@ -158,13 +159,13 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
_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.Selection.NumJokers = new int[] { 5, 5 };
|
||||
_ScreenSongOptions.Selection.TeamNames = new string[] { "foo", "bar" };
|
||||
|
||||
_ScreenSongOptions.Sorting.SearchString = String.Empty;
|
||||
_ScreenSongOptions.Sorting.SearchString = string.Empty;
|
||||
_ScreenSongOptions.Sorting.SearchActive = false;
|
||||
_ScreenSongOptions.Sorting.DuetOptions = EDuetOptions.NoDuets;
|
||||
_ScreenSongOptions.Sorting.FilterPlaylistID = -1;
|
||||
_ScreenSongOptions.Sorting.FilterPlaylistId = -1;
|
||||
|
||||
GameData = new SData
|
||||
{
|
||||
@@ -174,10 +175,10 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
NumJokers = 5,
|
||||
RefillJokers = true,
|
||||
CurrentRoundNr = 1,
|
||||
ProfileIDs = new List<Guid>(),
|
||||
ProfileIds = new List<Guid>(),
|
||||
Sorting = CBase.Config.GetSongSorting(),
|
||||
SongSource = ESongSource.TR_SONGSOURCE_ALLSONGS,
|
||||
PlaylistID = 0,
|
||||
PlaylistId = 0,
|
||||
CategoryIndex = 0,
|
||||
GameMode = EGameMode.TR_GAMEMODE_NORMAL,
|
||||
NumMedleySongs = 5,
|
||||
@@ -197,7 +198,9 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
_ScreenSongOptions.Selection.CategoryIndex = -1;
|
||||
|
||||
if (CBase.Config.GetTabs() == EOffOn.TR_CONFIG_ON && _ScreenSongOptions.Sorting.SongSorting != ESongSorting.TR_CONFIG_NONE)
|
||||
{
|
||||
_ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_ON;
|
||||
}
|
||||
|
||||
GameData.ResultTable = new List<CResultTableRow>();
|
||||
}
|
||||
@@ -205,16 +208,15 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
public override bool Init()
|
||||
{
|
||||
if (!base.Init())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SetDefaults();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void UpdateGame()
|
||||
{
|
||||
|
||||
}
|
||||
public override void UpdateGame() { }
|
||||
|
||||
private IMenu _GetNextScreen()
|
||||
{
|
||||
@@ -272,6 +274,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
_Stage = EStage.SongSelection;
|
||||
_PrepareSongSelection();
|
||||
}
|
||||
|
||||
break;
|
||||
case EStage.SongSelection:
|
||||
_Stage = EStage.Singing;
|
||||
@@ -284,6 +287,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
default:
|
||||
throw new ArgumentException("Invalid stage: " + _Stage);
|
||||
}
|
||||
|
||||
_FadeToScreen();
|
||||
}
|
||||
|
||||
@@ -306,6 +310,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
default: // Rest is not allowed
|
||||
throw new ArgumentException("Invalid stage: " + _Stage);
|
||||
}
|
||||
|
||||
_FadeToScreen();
|
||||
}
|
||||
|
||||
@@ -322,7 +327,9 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
public override void OnSongChange(int songIndex, ref SScreenSongOptions screenSongOptions)
|
||||
{
|
||||
if (_ScreenSongOptions.Selection.SelectNextRandomSong && songIndex != -1)
|
||||
{
|
||||
_ScreenSongOptions.Selection.SelectNextRandomSong = false;
|
||||
}
|
||||
|
||||
_ScreenSongOptions.Selection.SongIndex = songIndex;
|
||||
|
||||
@@ -358,24 +365,29 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
public override void JokerUsed(int teamNr)
|
||||
{
|
||||
if (_ScreenSongOptions.Selection.NumJokers == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (teamNr >= _ScreenSongOptions.Selection.NumJokers.Length)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GameData.RefillJokers)
|
||||
{
|
||||
CRound round = GameData.Rounds[GameData.CurrentRoundNr - 1];
|
||||
var round = GameData.Rounds[GameData.CurrentRoundNr - 1];
|
||||
GameData.Jokers[round.Players[teamNr]]--;
|
||||
}
|
||||
|
||||
_ScreenSongOptions.Selection.NumJokers[teamNr]--;
|
||||
_ScreenSongOptions.Selection.RandomOnly = true;
|
||||
_ScreenSongOptions.Selection.CategoryChangeAllowed = false;
|
||||
}
|
||||
|
||||
public override void SongSelected(int songID)
|
||||
public override void SongSelected(int songId)
|
||||
{
|
||||
_PrepareRound(new int[] { songID });
|
||||
_PrepareRound(new int[] { songId });
|
||||
|
||||
Next();
|
||||
}
|
||||
@@ -383,8 +395,10 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
public override void LeavingHighscore()
|
||||
{
|
||||
//Remember sung songs, so they don't will be selected a second time
|
||||
for(int i = 0; i < CBase.Game.GetNumSongs(); i++)
|
||||
CBase.Songs.AddPartySongSung(CBase.Game.GetSong(i).ID);
|
||||
for (var i = 0; i < CBase.Game.GetNumSongs(); i++)
|
||||
{
|
||||
CBase.Songs.AddPartySongSung(CBase.Game.GetSong(i).Id);
|
||||
}
|
||||
|
||||
GameData.CurrentRoundNr++;
|
||||
|
||||
@@ -397,17 +411,19 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
private void _PrepareMedleyRound()
|
||||
{
|
||||
//Select songs for medley
|
||||
int[] songIDs = new int[GameData.NumMedleySongs];
|
||||
for (int i = 0; i < GameData.NumMedleySongs; i++)
|
||||
var songIds = new int[GameData.NumMedleySongs];
|
||||
for (var i = 0; i < GameData.NumMedleySongs; i++)
|
||||
{
|
||||
if (GameData.Songs.Count == 0)
|
||||
{
|
||||
_UpdateSongList();
|
||||
}
|
||||
|
||||
songIDs[i] = GameData.Songs[0];
|
||||
songIds[i] = GameData.Songs[0];
|
||||
GameData.Songs.RemoveAt(0);
|
||||
}
|
||||
|
||||
_PrepareRound(songIDs);
|
||||
_PrepareRound(songIds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -425,7 +441,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
case ESongSource.TR_SONGSOURCE_ALLSONGS:
|
||||
_ScreenSongOptions.Sorting.SongSorting = CBase.Config.GetSongSorting();
|
||||
_ScreenSongOptions.Sorting.Tabs = CBase.Config.GetTabs();
|
||||
_ScreenSongOptions.Sorting.FilterPlaylistID = -1;
|
||||
_ScreenSongOptions.Sorting.FilterPlaylistId = -1;
|
||||
|
||||
_ScreenSongOptions.Selection.SongIndex = -1;
|
||||
_ScreenSongOptions.Selection.CategoryIndex = -1;
|
||||
@@ -435,7 +451,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
case ESongSource.TR_SONGSOURCE_CATEGORY:
|
||||
_ScreenSongOptions.Sorting.SongSorting = GameData.Sorting;
|
||||
_ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_ON;
|
||||
_ScreenSongOptions.Sorting.FilterPlaylistID = -1;
|
||||
_ScreenSongOptions.Sorting.FilterPlaylistId = -1;
|
||||
|
||||
_ScreenSongOptions.Selection.CategoryIndex = GameData.CategoryIndex;
|
||||
_ScreenSongOptions.Selection.CategoryChangeAllowed = false;
|
||||
@@ -444,7 +460,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
case ESongSource.TR_SONGSOURCE_PLAYLIST:
|
||||
_ScreenSongOptions.Sorting.SongSorting = CBase.Config.GetSongSorting();
|
||||
_ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_OFF;
|
||||
_ScreenSongOptions.Sorting.FilterPlaylistID = GameData.PlaylistID;
|
||||
_ScreenSongOptions.Sorting.FilterPlaylistId = GameData.PlaylistId;
|
||||
|
||||
_ScreenSongOptions.Selection.CategoryChangeAllowed = false;
|
||||
break;
|
||||
@@ -457,9 +473,9 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
/// <summary>
|
||||
/// Prepare next game and fill song queue based on configuration and given songs.
|
||||
/// </summary>
|
||||
/// <param name="songIDs">Array of SongIDs that are selected</param>
|
||||
/// <param name="songIds">Array of SongIds that are selected</param>
|
||||
/// <returns>false, if something can't setup correctly</returns>
|
||||
private bool _PrepareRound(int[] songIDs)
|
||||
private bool _PrepareRound(int[] songIds)
|
||||
{
|
||||
//Reset game
|
||||
CBase.Game.Reset();
|
||||
@@ -467,73 +483,86 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
|
||||
#region PlayerNames
|
||||
CBase.Game.SetNumPlayer(GameData.NumPlayerAtOnce);
|
||||
SPlayer[] players = CBase.Game.GetPlayers();
|
||||
var players = CBase.Game.GetPlayers();
|
||||
if (players == null || players.Length < GameData.NumPlayerAtOnce)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Get current round
|
||||
CRound c = GameData.Rounds[GameData.CurrentRoundNr - 1];
|
||||
var c = GameData.Rounds[GameData.CurrentRoundNr - 1];
|
||||
|
||||
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
for (var i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
//try to fill with correct player data
|
||||
if (c != null)
|
||||
players[i].ProfileID = GameData.ProfileIDs[c.Players[i]];
|
||||
{
|
||||
players[i].ProfileId = GameData.ProfileIds[c.Players[i]];
|
||||
}
|
||||
else
|
||||
players[i].ProfileID = Guid.Empty;
|
||||
{
|
||||
players[i].ProfileId = Guid.Empty;
|
||||
}
|
||||
}
|
||||
#endregion PlayerNames
|
||||
|
||||
#region SongQueue
|
||||
//Add all songs with configure game mode to song queue
|
||||
for (int i = 0; i < songIDs.Length; i++)
|
||||
CBase.Game.AddSong(songIDs[i], GameData.GameMode);
|
||||
for (var i = 0; i < songIds.Length; i++)
|
||||
{
|
||||
CBase.Game.AddSong(songIds[i], GameData.GameMode);
|
||||
}
|
||||
#endregion SongQueue
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private void _SetNumJokers()
|
||||
{
|
||||
int[] jokers = new int[GameData.NumPlayerAtOnce];
|
||||
var jokers = new int[GameData.NumPlayerAtOnce];
|
||||
if (GameData.RefillJokers)
|
||||
{
|
||||
for (int i = 0; i < jokers.Length; i++)
|
||||
jokers[i] = GameData.NumJokers;
|
||||
{
|
||||
for (var i = 0; i < jokers.Length; i++)
|
||||
{
|
||||
jokers[i] = GameData.NumJokers;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GameData.Jokers == null)
|
||||
{
|
||||
GameData.Jokers = new int[GameData.NumPlayer];
|
||||
for (int i = 0; i < GameData.ProfileIDs.Count; i++)
|
||||
for (var i = 0; i < GameData.ProfileIds.Count; i++)
|
||||
{
|
||||
GameData.Jokers[i] = GameData.NumJokers;
|
||||
}
|
||||
}
|
||||
CRound round = GameData.Rounds[GameData.CurrentRoundNr - 1];
|
||||
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
|
||||
var round = GameData.Rounds[GameData.CurrentRoundNr - 1];
|
||||
for (var i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
jokers[i] = GameData.Jokers[round.Players[i]];
|
||||
}
|
||||
}
|
||||
|
||||
_ScreenSongOptions.Selection.NumJokers = jokers;
|
||||
}
|
||||
|
||||
private void _SetTeamNames()
|
||||
{
|
||||
if (GameData.NumPlayerAtOnce < 1 || GameData.ProfileIDs.Count < GameData.NumPlayerAtOnce)
|
||||
if (GameData.NumPlayerAtOnce < 1 || GameData.ProfileIds.Count < GameData.NumPlayerAtOnce)
|
||||
{
|
||||
_ScreenSongOptions.Selection.TeamNames = new string[] {"foo", "bar"};
|
||||
_ScreenSongOptions.Selection.TeamNames = new string[] { "foo", "bar" };
|
||||
return;
|
||||
}
|
||||
|
||||
_ScreenSongOptions.Selection.TeamNames = new string[GameData.NumPlayerAtOnce];
|
||||
CRound c = GameData.Rounds[GameData.CurrentRoundNr - 1];
|
||||
var c = GameData.Rounds[GameData.CurrentRoundNr - 1];
|
||||
|
||||
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
_ScreenSongOptions.Selection.TeamNames[i] = CBase.Profiles.GetPlayerName(GameData.ProfileIDs[c.Players[i]]);
|
||||
for (var i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
_ScreenSongOptions.Selection.TeamNames[i] = CBase.Profiles.GetPlayerName(GameData.ProfileIds[c.Players[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -543,37 +572,43 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
private void _UpdateSongList()
|
||||
{
|
||||
if (GameData.Songs.Count > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (GameData.SongSource)
|
||||
{
|
||||
case ESongSource.TR_SONGSOURCE_PLAYLIST:
|
||||
for (int i = 0; i < CBase.Playlist.GetSongCount(GameData.PlaylistID); i++)
|
||||
for (var 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))
|
||||
var id = CBase.Playlist.GetSong(GameData.PlaylistId, i).SongId;
|
||||
if (CBase.Songs.GetSongById(id).IsGameModeAvailable(EGameMode.TR_GAMEMODE_MEDLEY))
|
||||
{
|
||||
GameData.Songs.Add(id);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case ESongSource.TR_SONGSOURCE_ALLSONGS:
|
||||
ReadOnlyCollection<CSong> avSongs = CBase.Songs.GetSongs();
|
||||
GameData.Songs.AddRange(avSongs.Where(song => song.AvailableGameModes.Contains(EGameMode.TR_GAMEMODE_MEDLEY)).Select(song => song.ID));
|
||||
var avSongs = CBase.Songs.GetSongs();
|
||||
GameData.Songs.AddRange(avSongs.Where(song => song.IsGameModeAvailable(EGameMode.TR_GAMEMODE_MEDLEY)).Select(song => song.Id));
|
||||
break;
|
||||
|
||||
case ESongSource.TR_SONGSOURCE_CATEGORY:
|
||||
//Save old sorting to roll it back after getting songs for configured category
|
||||
ESongSorting oldSorting = CBase.Config.GetSongSorting();
|
||||
CBase.Songs.SortSongs(GameData.Sorting, EOffOn.TR_CONFIG_ON, CBase.Config.GetIgnoreArticles() ,String.Empty, EDuetOptions.NoDuets, -1);
|
||||
var oldSorting = CBase.Config.GetSongSorting();
|
||||
CBase.Songs.SortSongs(GameData.Sorting, EOffOn.TR_CONFIG_ON, CBase.Config.GetIgnoreArticles(), string.Empty, EDuetOptions.NoDuets, -1);
|
||||
|
||||
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));
|
||||
GameData.Songs.AddRange(avSongs.Where(song => song.IsGameModeAvailable(EGameMode.TR_GAMEMODE_MEDLEY)).Select(song => song.Id));
|
||||
|
||||
CBase.Songs.SetCategory(-1);
|
||||
CBase.Songs.SortSongs(oldSorting, CBase.Config.GetTabs(), CBase.Config.GetIgnoreArticles(), String.Empty, EDuetOptions.NoDuets, -1);
|
||||
CBase.Songs.SortSongs(oldSorting, CBase.Config.GetTabs(), CBase.Config.GetIgnoreArticles(), string.Empty, EDuetOptions.NoDuets, -1);
|
||||
break;
|
||||
}
|
||||
|
||||
GameData.Songs.Shuffle();
|
||||
}
|
||||
|
||||
@@ -582,41 +617,46 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
//Prepare results table
|
||||
if (GameData.ResultTable.Count == 0)
|
||||
{
|
||||
for (int i = 0; i < GameData.NumPlayer; i++)
|
||||
for (var i = 0; i < GameData.NumPlayer; i++)
|
||||
{
|
||||
var row = new CResultTableRow { PlayerID = GameData.ProfileIDs[i], NumPlayed = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0 };
|
||||
var row = new CResultTableRow { PlayerId = GameData.ProfileIds[i], NumPlayed = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0 };
|
||||
GameData.ResultTable.Add(row);
|
||||
}
|
||||
|
||||
GameData.Results = new int[GameData.NumRounds, GameData.NumPlayerAtOnce];
|
||||
for (int i = 0; i < GameData.NumRounds; i++)
|
||||
for (var i = 0; i < GameData.NumRounds; i++)
|
||||
{
|
||||
for (int j = 0; j < GameData.NumPlayerAtOnce; j++)
|
||||
for (var j = 0; j < GameData.NumPlayerAtOnce; j++)
|
||||
{
|
||||
GameData.Results[i, j] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Get points from game
|
||||
CPoints points = CBase.Game.GetPoints();
|
||||
SPlayer[] players = CBase.Game.GetPlayers();
|
||||
var points = CBase.Game.GetPoints();
|
||||
var players = CBase.Game.GetPlayers();
|
||||
|
||||
//Go over all rounds and sum up points
|
||||
for (int round = 0; round < points.NumRounds; round++)
|
||||
for (var round = 0; round < points.NumRounds; round++)
|
||||
{
|
||||
SPlayer[] res = points.GetPlayer(round, GameData.NumPlayerAtOnce);
|
||||
var res = points.GetPlayer(round, GameData.NumPlayerAtOnce);
|
||||
|
||||
if (res == null || res.Length < GameData.NumPlayerAtOnce)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int p = 0; p < GameData.NumPlayerAtOnce; p++)
|
||||
for (var p = 0; p < GameData.NumPlayerAtOnce; p++)
|
||||
{
|
||||
players[p].Points += res[p].Points;
|
||||
players[p].PointsGoldenNotes += res[p].PointsGoldenNotes;
|
||||
players[p].PointsLineBonus += res[p].PointsLineBonus;
|
||||
}
|
||||
}
|
||||
|
||||
//Calculate average points
|
||||
for (int p = 0; p < GameData.NumPlayerAtOnce; p++)
|
||||
for (var p = 0; p < GameData.NumPlayerAtOnce; p++)
|
||||
{
|
||||
players[p].Points /= points.NumRounds;
|
||||
players[p].PointsGoldenNotes /= points.NumRounds;
|
||||
@@ -626,15 +666,15 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
GameData.Results[GameData.CurrentRoundNr - 2, p] = (int)Math.Round(players[p].Points);
|
||||
}
|
||||
|
||||
List<SStats> stats = _GetPointsForPlayer(players);
|
||||
var stats = _GetPointsForPlayer(players);
|
||||
|
||||
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
for (var i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
//Find matching row in results table
|
||||
int index = -1;
|
||||
for (int j = 0; j < GameData.ResultTable.Count; j++)
|
||||
var index = -1;
|
||||
for (var j = 0; j < GameData.ResultTable.Count; j++)
|
||||
{
|
||||
if (stats[i].ProfileID == GameData.ResultTable[j].PlayerID)
|
||||
if (stats[i].ProfileId == GameData.ResultTable[j].PlayerId)
|
||||
{
|
||||
index = j;
|
||||
break;
|
||||
@@ -642,8 +682,11 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
}
|
||||
|
||||
if (index == -1)
|
||||
{
|
||||
continue;
|
||||
CResultTableRow row = GameData.ResultTable[index];
|
||||
}
|
||||
|
||||
var row = GameData.ResultTable[index];
|
||||
|
||||
//Update results entry
|
||||
row.NumPlayed++;
|
||||
@@ -657,13 +700,16 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
GameData.ResultTable.Sort();
|
||||
|
||||
//Update position-number
|
||||
int pos = 1;
|
||||
int lastPoints = 0;
|
||||
int lastSingPoints = 0;
|
||||
foreach (CResultTableRow resultRow in GameData.ResultTable)
|
||||
var pos = 1;
|
||||
var lastPoints = 0;
|
||||
var lastSingPoints = 0;
|
||||
foreach (var resultRow in GameData.ResultTable)
|
||||
{
|
||||
if (lastPoints > resultRow.NumGamePoints || lastSingPoints > resultRow.NumSingPoints)
|
||||
{
|
||||
pos++;
|
||||
}
|
||||
|
||||
resultRow.Position = pos;
|
||||
lastPoints = resultRow.NumGamePoints;
|
||||
lastSingPoints = resultRow.NumSingPoints;
|
||||
@@ -673,21 +719,21 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
private List<SStats> _GetPointsForPlayer(SPlayer[] results)
|
||||
{
|
||||
var result = new List<SStats>();
|
||||
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
for (var i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
var stat = new SStats {ProfileID = results[i].ProfileID, SingPoints = (int)Math.Round(results[i].Points), Won = 0, GamePoints = 0};
|
||||
var stat = new SStats { ProfileId = results[i].ProfileId, SingPoints = (int)Math.Round(results[i].Points), Won = 0, GamePoints = 0 };
|
||||
result.Add(stat);
|
||||
}
|
||||
|
||||
result.Sort((s1, s2) => s1.SingPoints.CompareTo(s2.SingPoints));
|
||||
|
||||
int current = result[result.Count - 1].SingPoints;
|
||||
int points = result.Count;
|
||||
bool wonset = false;
|
||||
var current = result[result.Count - 1].SingPoints;
|
||||
var points = result.Count;
|
||||
var wonset = false;
|
||||
|
||||
for (int i = result.Count - 1; i >= 0; i--)
|
||||
for (var i = result.Count - 1; i >= 0; i--)
|
||||
{
|
||||
SStats res = result[i];
|
||||
var res = result[i];
|
||||
|
||||
if (i < result.Count - 1)
|
||||
{
|
||||
@@ -700,7 +746,10 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
else
|
||||
{
|
||||
if (!wonset)
|
||||
{
|
||||
res.Won = 1;
|
||||
}
|
||||
|
||||
res.GamePoints = points;
|
||||
}
|
||||
}
|
||||
@@ -719,4 +768,4 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
// ReSharper disable UnusedMember.Global
|
||||
public class CPartyScreenChallengeConfig : CPartyScreenChallenge
|
||||
// ReSharper restore UnusedMember.Global
|
||||
// ReSharper restore UnusedMember.Global
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
@@ -46,14 +46,14 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
base.Init();
|
||||
|
||||
_ThemeSelectSlides = new string[] { _SelectSlideNumPlayers, _SelectSlideNumMics, _SelectSlideNumRounds, _SelectSlideNumJokers, _SelectSlideRefillJokers };
|
||||
_ThemeButtons = new string[] {_ButtonNext, _ButtonBack};
|
||||
_ThemeButtons = new string[] { _ButtonNext, _ButtonBack };
|
||||
}
|
||||
|
||||
public override bool HandleInput(SKeyEvent keyEvent)
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
if (keyEvent.KeyPressed) { }
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
@@ -67,10 +67,15 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
_UpdateSlides();
|
||||
|
||||
if (_Buttons[_ButtonBack].Selected)
|
||||
{
|
||||
_PartyMode.Back();
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonNext].Selected)
|
||||
{
|
||||
_PartyMode.Next();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Keys.Left:
|
||||
@@ -82,6 +87,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -93,14 +99,20 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
_UpdateSlides();
|
||||
if (_Buttons[_ButtonBack].Selected)
|
||||
{
|
||||
_PartyMode.Back();
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonNext].Selected)
|
||||
{
|
||||
_PartyMode.Next();
|
||||
}
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
{
|
||||
_PartyMode.Back();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -121,22 +133,26 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
// build num player slide (min player ... max player);
|
||||
_SelectSlides[_SelectSlideNumPlayers].Clear();
|
||||
for (int i = _PartyMode.MinPlayers; i <= _PartyMode.MaxPlayers; i++)
|
||||
for (var i = _PartyMode.MinPlayers; i <= _PartyMode.MaxPlayers; i++)
|
||||
{
|
||||
_SelectSlides[_SelectSlideNumPlayers].AddValue(i.ToString());
|
||||
}
|
||||
|
||||
_SelectSlides[_SelectSlideNumPlayers].SelectedValue = _PartyMode.GameData.NumPlayer.ToString();
|
||||
|
||||
// build num joker slide 1 to 10
|
||||
_SelectSlides[_SelectSlideNumJokers].Clear();
|
||||
for (int i = 1; i <= 10; i++)
|
||||
for (var i = 1; i <= 10; i++)
|
||||
{
|
||||
_SelectSlides[_SelectSlideNumJokers].AddValue(i.ToString());
|
||||
}
|
||||
|
||||
_SelectSlides[_SelectSlideNumJokers].SelectedValue = "5";
|
||||
|
||||
//build joker config slide
|
||||
_SelectSlides[_SelectSlideRefillJokers].Clear();
|
||||
_SelectSlides[_SelectSlideRefillJokers].AddValue(CBase.Language.Translate("TR_BUTTON_NO", PartyModeID));
|
||||
_SelectSlides[_SelectSlideRefillJokers].AddValue(CBase.Language.Translate("TR_BUTTON_YES", PartyModeID));
|
||||
_SelectSlides[_SelectSlideRefillJokers].AddValue(CBase.Language.Translate("TR_BUTTON_NO", PartyModeId));
|
||||
_SelectSlides[_SelectSlideRefillJokers].AddValue(CBase.Language.Translate("TR_BUTTON_YES", PartyModeId));
|
||||
_SelectSlides[_SelectSlideRefillJokers].SelectLastValue();
|
||||
|
||||
_UpdateMicsAtOnce();
|
||||
@@ -146,22 +162,25 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
|
||||
private void _UpdateSlides()
|
||||
{
|
||||
int player = _PartyMode.GameData.NumPlayer;
|
||||
int mics = _PartyMode.GameData.NumPlayerAtOnce;
|
||||
var player = _PartyMode.GameData.NumPlayer;
|
||||
var mics = _PartyMode.GameData.NumPlayerAtOnce;
|
||||
_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.NumJokers = _SelectSlides[_SelectSlideNumJokers].Selection + 1;
|
||||
_PartyMode.GameData.RefillJokers = (_SelectSlides[_SelectSlideRefillJokers].Selection == 1) ? true : false;
|
||||
_PartyMode.GameData.RefillJokers = _SelectSlides[_SelectSlideRefillJokers].Selection == 1 ? true : false;
|
||||
|
||||
_UpdateMicsAtOnce();
|
||||
_SetRoundSteps();
|
||||
|
||||
if (player != _PartyMode.GameData.NumPlayer || mics != _PartyMode.GameData.NumPlayerAtOnce)
|
||||
{
|
||||
int num = CHelper.CombinationCount(_PartyMode.GameData.NumPlayer, _PartyMode.GameData.NumPlayerAtOnce);
|
||||
var num = CHelper.CombinationCount(_PartyMode.GameData.NumPlayer, _PartyMode.GameData.NumPlayerAtOnce);
|
||||
while (num > _MaxNumRounds)
|
||||
{
|
||||
num -= _RoundSteps;
|
||||
}
|
||||
|
||||
_PartyMode.GameData.NumRounds = num;
|
||||
}
|
||||
|
||||
@@ -170,15 +189,20 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
|
||||
private void _UpdateMicsAtOnce()
|
||||
{
|
||||
int maxNum = Math.Min(_PartyMode.MaxMics, _PartyMode.GameData.NumPlayer);
|
||||
var maxNum = Math.Min(_PartyMode.MaxMics, _PartyMode.GameData.NumPlayer);
|
||||
|
||||
if (_PartyMode.GameData.NumPlayerAtOnce > maxNum)
|
||||
{
|
||||
_PartyMode.GameData.NumPlayerAtOnce = maxNum;
|
||||
}
|
||||
|
||||
// build mics at once slide
|
||||
_SelectSlides[_SelectSlideNumMics].Clear();
|
||||
for (int i = 1; i <= maxNum; i++)
|
||||
for (var i = 1; i <= maxNum; i++)
|
||||
{
|
||||
_SelectSlides[_SelectSlideNumMics].AddValue(i.ToString());
|
||||
}
|
||||
|
||||
_SelectSlides[_SelectSlideNumMics].Selection = _PartyMode.GameData.NumPlayerAtOnce - _PartyMode.MinPlayers;
|
||||
}
|
||||
|
||||
@@ -186,8 +210,11 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
// build num rounds slide
|
||||
_SelectSlides[_SelectSlideNumRounds].Clear();
|
||||
for (int i = _RoundSteps; i <= _MaxNumRounds; i += _RoundSteps)
|
||||
for (var i = _RoundSteps; i <= _MaxNumRounds; i += _RoundSteps)
|
||||
{
|
||||
_SelectSlides[_SelectSlideNumRounds].AddValue(i.ToString());
|
||||
}
|
||||
|
||||
_SelectSlides[_SelectSlideNumRounds].Selection = _PartyMode.GameData.NumRounds / _RoundSteps - 1;
|
||||
}
|
||||
|
||||
@@ -199,8 +226,8 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
return;
|
||||
}
|
||||
|
||||
int res = _PartyMode.GameData.NumPlayer / _PartyMode.GameData.NumPlayerAtOnce;
|
||||
int mod = _PartyMode.GameData.NumPlayer % _PartyMode.GameData.NumPlayerAtOnce;
|
||||
var res = _PartyMode.GameData.NumPlayer / _PartyMode.GameData.NumPlayerAtOnce;
|
||||
var mod = _PartyMode.GameData.NumPlayer % _PartyMode.GameData.NumPlayerAtOnce;
|
||||
|
||||
_RoundSteps = mod == 0 ? res : _PartyMode.GameData.NumPlayer;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
|
||||
// ReSharper disable UnusedMember.Global
|
||||
public class CPartyScreenChallengeMain : CPartyScreenChallenge
|
||||
// ReSharper restore UnusedMember.Global
|
||||
// ReSharper restore UnusedMember.Global
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
@@ -97,17 +97,17 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
base.Init();
|
||||
|
||||
_ThemeTexts = new string[]
|
||||
{
|
||||
_TextPosition, _TextPlayerName, _TextNumPlayed, _TextWon, _TextSingPoints, _TextGamePoints, _TextNextPlayer, _TextPopupReallyExit, _TextRoundNumber,
|
||||
_TextRoundPlayer,
|
||||
_TextRoundScore, _TextFinishMessage, _TextFinishPlayerWin, _TextNextPlayerMessage
|
||||
};
|
||||
{
|
||||
_TextPosition, _TextPlayerName, _TextNumPlayed, _TextWon, _TextSingPoints, _TextGamePoints, _TextNextPlayer, _TextPopupReallyExit, _TextRoundNumber,
|
||||
_TextRoundPlayer,
|
||||
_TextRoundScore, _TextFinishMessage, _TextFinishPlayerWin, _TextNextPlayerMessage
|
||||
};
|
||||
_ThemeButtons = new string[]
|
||||
{
|
||||
_ButtonNextRound, _ButtonBack, _ButtonExit, _ButtonPopupYes, _ButtonPopupNo, _ButtonPlayerScrollDown, _ButtonPlayerScrollUp, _ButtonRoundsScrollDown,
|
||||
_ButtonRoundsScrollUp
|
||||
};
|
||||
_ThemeStatics = new string[] {_StaticPopupBG, _StaticNextPlayer};
|
||||
{
|
||||
_ButtonNextRound, _ButtonBack, _ButtonExit, _ButtonPopupYes, _ButtonPopupNo, _ButtonPlayerScrollDown, _ButtonPlayerScrollUp, _ButtonRoundsScrollDown,
|
||||
_ButtonRoundsScrollUp
|
||||
};
|
||||
_ThemeStatics = new string[] { _StaticPopupBG, _StaticNextPlayer };
|
||||
}
|
||||
|
||||
public override void LoadTheme(string xmlPath)
|
||||
@@ -119,7 +119,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
_NextPlayerTexts = new List<CText>();
|
||||
_NextPlayerStatics = new List<CStatic>();
|
||||
|
||||
for (int i = 0; i < _PartyMode.MaxPlayers; i++)
|
||||
for (var i = 0; i < _PartyMode.MaxPlayers; i++)
|
||||
{
|
||||
_NextPlayerTexts.Add(GetNewText(_Texts[_TextNextPlayer]));
|
||||
_AddText(_NextPlayerTexts[_NextPlayerTexts.Count - 1]);
|
||||
@@ -127,6 +127,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
_AddStatic(_NextPlayerStatics[_NextPlayerStatics.Count - 1]);
|
||||
_NextPlayerStatics[_NextPlayerStatics.Count - 1].Aspect = EAspect.Crop;
|
||||
}
|
||||
|
||||
_Statics[_StaticNextPlayer].Visible = false;
|
||||
}
|
||||
|
||||
@@ -134,7 +135,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
base.HandleInput(keyEvent);
|
||||
|
||||
if (keyEvent.KeyPressed) {}
|
||||
if (keyEvent.KeyPressed) { }
|
||||
else
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
@@ -144,42 +145,76 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (_PartyMode.GameData.CurrentRoundNr == 1)
|
||||
{
|
||||
_PartyMode.Back();
|
||||
}
|
||||
else
|
||||
{
|
||||
_ShowPopup(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_ShowPopup(false);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (_Buttons[_ButtonNextRound].Selected)
|
||||
{
|
||||
_PartyMode.Next();
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonBack].Selected && _PartyMode.GameData.CurrentRoundNr == 1)
|
||||
{
|
||||
_PartyMode.Back();
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonExit].Selected && _PartyMode.GameData.CurrentRoundNr > 1)
|
||||
{
|
||||
_ShowPopup(true);
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonPlayerScrollUp].Selected)
|
||||
{
|
||||
_ScrollPlayerTable(-1);
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonPlayerScrollDown].Selected)
|
||||
{
|
||||
_ScrollPlayerTable(1);
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonRoundsScrollUp].Selected)
|
||||
{
|
||||
_ScrollRoundsTable(-1);
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonRoundsScrollDown].Selected)
|
||||
{
|
||||
_ScrollRoundsTable(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_Buttons[_ButtonPopupYes].Selected)
|
||||
{
|
||||
_EndParty();
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonPopupNo].Selected)
|
||||
{
|
||||
_ShowPopup(false);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -192,26 +227,51 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (_Buttons[_ButtonNextRound].Selected)
|
||||
{
|
||||
_PartyMode.Next();
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonBack].Selected && _PartyMode.GameData.CurrentRoundNr == 1)
|
||||
{
|
||||
_PartyMode.Back();
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonExit].Selected && _PartyMode.GameData.CurrentRoundNr > 1)
|
||||
{
|
||||
_ShowPopup(true);
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonPlayerScrollUp].Selected)
|
||||
{
|
||||
_ScrollPlayerTable(-1);
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonPlayerScrollDown].Selected)
|
||||
{
|
||||
_ScrollPlayerTable(1);
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonRoundsScrollUp].Selected)
|
||||
{
|
||||
_ScrollRoundsTable(-1);
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonRoundsScrollDown].Selected)
|
||||
{
|
||||
_ScrollRoundsTable(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_Buttons[_ButtonPopupYes].Selected)
|
||||
{
|
||||
_EndParty();
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonPopupNo].Selected)
|
||||
{
|
||||
_ShowPopup(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,20 +280,31 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (_PartyMode.GameData.CurrentRoundNr == 1)
|
||||
{
|
||||
_PartyMode.Back();
|
||||
}
|
||||
else
|
||||
{
|
||||
_ShowPopup(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_ShowPopup(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (mouseEvent.Wheel != 0)
|
||||
{
|
||||
if (CHelper.IsInBounds(_RoundsTableScrollArea, mouseEvent))
|
||||
{
|
||||
_ScrollRoundsTable(mouseEvent.Wheel);
|
||||
}
|
||||
|
||||
if (CHelper.IsInBounds(_PlayerTableScrollArea, mouseEvent))
|
||||
{
|
||||
_ScrollPlayerTable(mouseEvent.Wheel);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -250,9 +321,14 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
_UpdateNextPlayerPositions();
|
||||
_UpdateNextPlayerContents();
|
||||
if (_PartyMode.GameData.CurrentRoundNr == 1)
|
||||
{
|
||||
_BuildRoundsTable();
|
||||
}
|
||||
else
|
||||
{
|
||||
_ScrollRoundsTable(_PartyMode.GameData.CurrentRoundNr - 2);
|
||||
}
|
||||
|
||||
_UpdateRoundsTable();
|
||||
|
||||
if (_PartyMode.GameData.CurrentRoundNr == 1)
|
||||
@@ -305,16 +381,18 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
_Buttons[_ButtonPopupNo].Visible = _ExitPopupVisible;
|
||||
|
||||
if (_ExitPopupVisible)
|
||||
{
|
||||
_SelectElement(_Buttons[_ButtonPopupNo]);
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdateNextPlayerPositions()
|
||||
{
|
||||
float x = (float)CBase.Settings.GetRenderW() / 2 -
|
||||
((_PartyMode.GameData.NumPlayerAtOnce * _Statics[_StaticNextPlayer].Rect.W) + ((_PartyMode.GameData.NumPlayerAtOnce - 1) * 15)) / 2;
|
||||
var x = (float)CBase.Settings.GetRenderW() / 2 -
|
||||
(_PartyMode.GameData.NumPlayerAtOnce * _Statics[_StaticNextPlayer].Rect.W + (_PartyMode.GameData.NumPlayerAtOnce - 1) * 15) / 2;
|
||||
const float staticY = 885;
|
||||
const float textY = 825;
|
||||
for (int i = 0; i < _PartyMode.GameData.NumPlayerAtOnce; i++)
|
||||
for (var i = 0; i < _PartyMode.GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
//static
|
||||
_NextPlayerStatics[i].X = x;
|
||||
@@ -327,7 +405,8 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
|
||||
x += _Statics[_StaticNextPlayer].Rect.W + 15;
|
||||
}
|
||||
for (int i = _PartyMode.GameData.NumPlayerAtOnce; i < _PartyMode.MaxPlayers; i++)
|
||||
|
||||
for (var i = _PartyMode.GameData.NumPlayerAtOnce; i < _PartyMode.MaxPlayers; i++)
|
||||
{
|
||||
_NextPlayerStatics[i].Visible = false;
|
||||
_NextPlayerTexts[i].Visible = false;
|
||||
@@ -339,9 +418,9 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
if (_PartyMode.GameData.CurrentRoundNr <= _PartyMode.GameData.Rounds.Count)
|
||||
{
|
||||
_Texts[_TextNextPlayerMessage].Visible = true;
|
||||
for (int i = 0; i < _PartyMode.GameData.NumPlayerAtOnce; i++)
|
||||
for (var i = 0; i < _PartyMode.GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
Guid id = _PartyMode.GameData.ProfileIDs[_PartyMode.GameData.Rounds[_PartyMode.GameData.CurrentRoundNr - 1].Players[i]];
|
||||
var id = _PartyMode.GameData.ProfileIds[_PartyMode.GameData.Rounds[_PartyMode.GameData.CurrentRoundNr - 1].Players[i]];
|
||||
_NextPlayerStatics[i].Texture = CBase.Profiles.GetAvatar(id);
|
||||
_NextPlayerTexts[i].Text = CBase.Profiles.GetPlayerName(id);
|
||||
_NextPlayerTexts[i].Color = CBase.Themes.GetPlayerColor(i + 1);
|
||||
@@ -350,7 +429,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
else
|
||||
{
|
||||
_Texts[_TextNextPlayerMessage].Visible = false;
|
||||
for (int i = 0; i < _PartyMode.GameData.NumPlayerAtOnce; i++)
|
||||
for (var i = 0; i < _PartyMode.GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
_NextPlayerStatics[i].Visible = false;
|
||||
_NextPlayerTexts[i].Visible = false;
|
||||
@@ -362,21 +441,22 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
//Create lists
|
||||
_RoundsTable = new List<CRoundsTableRow>();
|
||||
for (int i = 0; i < 5; i++)
|
||||
for (var i = 0; i < 5; i++)
|
||||
{
|
||||
var rtr = new CRoundsTableRow {TextPlayer = new List<CText>(), TextScores = new List<CText>()};
|
||||
var rtr = new CRoundsTableRow { TextPlayer = new List<CText>(), TextScores = new List<CText>() };
|
||||
_RoundsTable.Add(rtr);
|
||||
}
|
||||
|
||||
//Create statics and texts for rounds
|
||||
foreach (CRoundsTableRow roundRow in _RoundsTable)
|
||||
foreach (var roundRow in _RoundsTable)
|
||||
{
|
||||
//Round-number
|
||||
CText text = GetNewText(_Texts[_TextRoundNumber]);
|
||||
var text = GetNewText(_Texts[_TextRoundNumber]);
|
||||
_AddText(text);
|
||||
roundRow.Number = text;
|
||||
for (int row = 0; row < 2; row++)
|
||||
for (var row = 0; row < 2; row++)
|
||||
{
|
||||
for (int column = 0; column < 3; column++)
|
||||
for (var column = 0; column < 3; column++)
|
||||
{
|
||||
//Player
|
||||
text = GetNewText(_Texts[_TextRoundPlayer]);
|
||||
@@ -399,39 +479,42 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
_NumRoundsVisible = _PartyMode.GameData.NumPlayerAtOnce <= numPlayerInOneRow ? 5 : 3;
|
||||
|
||||
if (_NumRoundsVisible > _PartyMode.GameData.Rounds.Count)
|
||||
{
|
||||
_NumRoundsVisible = _PartyMode.GameData.Rounds.Count;
|
||||
}
|
||||
|
||||
float numberX = _Texts[_TextRoundNumber].X;
|
||||
float numberY = _Texts[_TextRoundNumber].Y;
|
||||
var numberX = _Texts[_TextRoundNumber].X;
|
||||
var numberY = _Texts[_TextRoundNumber].Y;
|
||||
|
||||
_RoundsTableScrollArea.X = numberX;
|
||||
_RoundsTableScrollArea.Y = numberY;
|
||||
_RoundsTableScrollArea.W = CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20;
|
||||
|
||||
float delta = _Texts[_TextRoundNumber].Rect.H;
|
||||
var delta = _Texts[_TextRoundNumber].Rect.H;
|
||||
|
||||
//Update statics and texts for rounds
|
||||
foreach (CRoundsTableRow roundRow in _RoundsTable)
|
||||
foreach (var roundRow in _RoundsTable)
|
||||
{
|
||||
//Round-number
|
||||
roundRow.Number.X = numberX;
|
||||
roundRow.Number.Y = numberY;
|
||||
var numInnerRows = (int)Math.Ceiling(_PartyMode.GameData.NumPlayerAtOnce / ((double)numPlayerInOneRow));
|
||||
for (int row = 0; row < numInnerRows; row++)
|
||||
var numInnerRows = (int)Math.Ceiling(_PartyMode.GameData.NumPlayerAtOnce / (double)numPlayerInOneRow);
|
||||
for (var row = 0; row < numInnerRows; row++)
|
||||
{
|
||||
int num = (row + 1) * numPlayerInOneRow;
|
||||
int numPlayerInThisRow = numPlayerInOneRow;
|
||||
var num = (row + 1) * numPlayerInOneRow;
|
||||
var numPlayerInThisRow = numPlayerInOneRow;
|
||||
if (num > _PartyMode.GameData.NumPlayerAtOnce)
|
||||
{
|
||||
num = _PartyMode.GameData.NumPlayerAtOnce;
|
||||
numPlayerInThisRow = _PartyMode.GameData.NumPlayerAtOnce - (row * numPlayerInOneRow);
|
||||
numPlayerInThisRow = _PartyMode.GameData.NumPlayerAtOnce - row * numPlayerInOneRow;
|
||||
}
|
||||
for (int column = row * numPlayerInOneRow; column < num; column++)
|
||||
|
||||
for (var column = row * numPlayerInOneRow; column < num; column++)
|
||||
{
|
||||
//Player
|
||||
float x = numberX + 15 + (CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow * (column - row * numPlayerInOneRow) +
|
||||
((CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2;
|
||||
float maxw = ((CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2 - 5;
|
||||
var x = numberX + 15 + (CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow * (column - row * numPlayerInOneRow) +
|
||||
(CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow / 2;
|
||||
var maxw = (CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow / 2 - 5;
|
||||
roundRow.TextPlayer[column].X = x;
|
||||
roundRow.TextPlayer[column].Y = numberY;
|
||||
roundRow.TextPlayer[column].W = maxw;
|
||||
@@ -440,33 +523,40 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
roundRow.TextScores[column].Y = numberY + delta;
|
||||
roundRow.TextScores[column].W = maxw;
|
||||
}
|
||||
|
||||
numberY = numberY + 2 * delta;
|
||||
}
|
||||
|
||||
numberY = numberY + delta / 2;
|
||||
}
|
||||
|
||||
_RoundsTableScrollArea.H = numberY - _RoundsTableScrollArea.Y;
|
||||
}
|
||||
|
||||
private void _UpdateRoundsTable()
|
||||
{
|
||||
for (int i = 0; i < _RoundsTable.Count; i++)
|
||||
for (var i = 0; i < _RoundsTable.Count; i++)
|
||||
{
|
||||
for (int p = 0; p < _RoundsTable[i].TextPlayer.Count; p++)
|
||||
for (var p = 0; p < _RoundsTable[i].TextPlayer.Count; p++)
|
||||
{
|
||||
if (_PartyMode.GameData.Rounds.Count > i + _RoundsTableOffset && _PartyMode.GameData.Rounds[i + _RoundsTableOffset].Players.Count > p)
|
||||
{
|
||||
_RoundsTable[i].Number.Visible = true;
|
||||
_RoundsTable[i].TextPlayer[p].Visible = true;
|
||||
_RoundsTable[i].TextScores[p].Visible = true;
|
||||
_RoundsTable[i].Number.Text = (i + 1 + _RoundsTableOffset) + ")";
|
||||
_RoundsTable[i].Number.Text = i + 1 + _RoundsTableOffset + ")";
|
||||
_RoundsTable[i].TextPlayer[p].Text =
|
||||
CBase.Profiles.GetPlayerName(_PartyMode.GameData.ProfileIDs[_PartyMode.GameData.Rounds[i + _RoundsTableOffset].Players[p]]);
|
||||
CBase.Profiles.GetPlayerName(_PartyMode.GameData.ProfileIds[_PartyMode.GameData.Rounds[i + _RoundsTableOffset].Players[p]]);
|
||||
// ReSharper disable ConvertIfStatementToConditionalTernaryExpression
|
||||
if ((_PartyMode.GameData.CurrentRoundNr - 1) > i + _RoundsTableOffset)
|
||||
if (_PartyMode.GameData.CurrentRoundNr - 1 > i + _RoundsTableOffset)
|
||||
// ReSharper restore ConvertIfStatementToConditionalTernaryExpression
|
||||
{
|
||||
_RoundsTable[i].TextScores[p].Text = _PartyMode.GameData.Results[i + _RoundsTableOffset, p].ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
_RoundsTable[i].TextScores[p].Text = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -474,10 +564,11 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
_RoundsTable[i].TextScores[p].Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (_PartyMode.GameData.Rounds.Count < i + _RoundsTableOffset || i + 1 > _NumRoundsVisible)
|
||||
{
|
||||
_RoundsTable[i].Number.Visible = false;
|
||||
for (int p = 0; p < _RoundsTable[i].TextPlayer.Count; p++)
|
||||
for (var p = 0; p < _RoundsTable[i].TextPlayer.Count; p++)
|
||||
{
|
||||
_RoundsTable[i].TextPlayer[p].Visible = false;
|
||||
_RoundsTable[i].TextScores[p].Visible = false;
|
||||
@@ -491,24 +582,24 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
|
||||
private void _BuildPlayerTable()
|
||||
{
|
||||
_PlayerTableScrollArea = new SRectF {X = _Texts[_TextPosition].X, Y = _Texts[_TextPosition].Y, W = _Texts[_TextGamePoints].X - _Texts[_TextPosition].X};
|
||||
_PlayerTableScrollArea = new SRectF { X = _Texts[_TextPosition].X, Y = _Texts[_TextPosition].Y, W = _Texts[_TextGamePoints].X - _Texts[_TextPosition].X };
|
||||
|
||||
_PlayerTable = new List<STableRow>();
|
||||
float delta = _Texts[_TextPosition].Rect.H * 1.2f;
|
||||
var delta = _Texts[_TextPosition].Rect.H * 1.2f;
|
||||
|
||||
float h = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
var row = new STableRow
|
||||
{
|
||||
Pos = GetNewText(_Texts[_TextPosition]),
|
||||
Name = GetNewText(_Texts[_TextPlayerName]),
|
||||
Rounds = GetNewText(_Texts[_TextNumPlayed]),
|
||||
Won = GetNewText(_Texts[_TextWon]),
|
||||
SingPoints = GetNewText(_Texts[_TextSingPoints]),
|
||||
GamePoints = GetNewText(_Texts[_TextGamePoints])
|
||||
};
|
||||
{
|
||||
Pos = GetNewText(_Texts[_TextPosition]),
|
||||
Name = GetNewText(_Texts[_TextPlayerName]),
|
||||
Rounds = GetNewText(_Texts[_TextNumPlayed]),
|
||||
Won = GetNewText(_Texts[_TextWon]),
|
||||
SingPoints = GetNewText(_Texts[_TextSingPoints]),
|
||||
GamePoints = GetNewText(_Texts[_TextGamePoints])
|
||||
};
|
||||
|
||||
row.Pos.Y += delta * (i + 1);
|
||||
row.Name.Y += delta * (i + 1);
|
||||
@@ -517,7 +608,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
row.SingPoints.Y += delta * (i + 1);
|
||||
row.GamePoints.Y += delta * (i + 1);
|
||||
|
||||
row.Pos.Text = (i + 1) + ".";
|
||||
row.Pos.Text = i + 1 + ".";
|
||||
|
||||
row.Pos.Visible = false;
|
||||
row.Name.Visible = false;
|
||||
@@ -537,14 +628,15 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
|
||||
h = delta * (i + 1);
|
||||
}
|
||||
|
||||
_PlayerTableScrollArea.H = h + delta;
|
||||
}
|
||||
|
||||
private void _UpdatePlayerTable()
|
||||
{
|
||||
for (int i = 0; i < _PlayerTable.Count; i++)
|
||||
for (var i = 0; i < _PlayerTable.Count; i++)
|
||||
{
|
||||
STableRow row = _PlayerTable[i];
|
||||
var row = _PlayerTable[i];
|
||||
|
||||
if (i + _PlayerTableOffset < _PartyMode.GameData.ResultTable.Count)
|
||||
{
|
||||
@@ -556,7 +648,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
row.GamePoints.Visible = true;
|
||||
|
||||
row.Pos.Text = _PartyMode.GameData.ResultTable[i + _PlayerTableOffset].Position + ".";
|
||||
row.Name.Text = CBase.Profiles.GetPlayerName(_PartyMode.GameData.ResultTable[i + _PlayerTableOffset].PlayerID);
|
||||
row.Name.Text = CBase.Profiles.GetPlayerName(_PartyMode.GameData.ResultTable[i + _PlayerTableOffset].PlayerId);
|
||||
row.Rounds.Text = _PartyMode.GameData.ResultTable[i + _PlayerTableOffset].NumPlayed.ToString();
|
||||
row.Won.Text = _PartyMode.GameData.ResultTable[i + _PlayerTableOffset].NumWon.ToString();
|
||||
row.SingPoints.Text = _PartyMode.GameData.ResultTable[i + _PlayerTableOffset].NumSingPoints.ToString();
|
||||
@@ -574,21 +666,31 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
}
|
||||
|
||||
_Buttons[_ButtonPlayerScrollUp].Visible = _PlayerTableOffset > 0;
|
||||
_Buttons[_ButtonPlayerScrollDown].Visible = _PartyMode.GameData.ProfileIDs.Count - _NumPlayerVisible - _PlayerTableOffset > 0;
|
||||
_Buttons[_ButtonPlayerScrollDown].Visible = _PartyMode.GameData.ProfileIds.Count - _NumPlayerVisible - _PlayerTableOffset > 0;
|
||||
}
|
||||
|
||||
private void _ScrollPlayerTable(int offset)
|
||||
{
|
||||
if (_PartyMode.GameData.ProfileIDs.Count <= _NumPlayerVisible)
|
||||
if (_PartyMode.GameData.ProfileIds.Count <= _NumPlayerVisible)
|
||||
{
|
||||
_PlayerTableOffset = 0;
|
||||
}
|
||||
else if (offset < 0 && _PlayerTableOffset + offset >= 0)
|
||||
{
|
||||
_PlayerTableOffset += offset;
|
||||
}
|
||||
else if (offset < 0 && _PlayerTableOffset + offset < 0)
|
||||
{
|
||||
_PlayerTableOffset = 0;
|
||||
else if (offset > 0 && _PlayerTableOffset + offset <= _PartyMode.GameData.ProfileIDs.Count - _NumPlayerVisible)
|
||||
}
|
||||
else if (offset > 0 && _PlayerTableOffset + offset <= _PartyMode.GameData.ProfileIds.Count - _NumPlayerVisible)
|
||||
{
|
||||
_PlayerTableOffset += offset;
|
||||
else if (offset > 0 && _PlayerTableOffset + offset > _PartyMode.GameData.ProfileIDs.Count - _NumPlayerVisible)
|
||||
_PlayerTableOffset = _PartyMode.GameData.ProfileIDs.Count - _NumPlayerVisible;
|
||||
}
|
||||
else if (offset > 0 && _PlayerTableOffset + offset > _PartyMode.GameData.ProfileIds.Count - _NumPlayerVisible)
|
||||
{
|
||||
_PlayerTableOffset = _PartyMode.GameData.ProfileIds.Count - _NumPlayerVisible;
|
||||
}
|
||||
|
||||
_UpdatePlayerTable();
|
||||
}
|
||||
@@ -596,36 +698,51 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
private void _ScrollRoundsTable(int offset)
|
||||
{
|
||||
if (_PartyMode.GameData.Rounds.Count <= _NumRoundsVisible)
|
||||
{
|
||||
_RoundsTableOffset = 0;
|
||||
}
|
||||
else if (offset < 0 && _RoundsTableOffset + offset >= 0)
|
||||
{
|
||||
_RoundsTableOffset += offset;
|
||||
}
|
||||
else if (offset < 0 && _RoundsTableOffset + offset < 0)
|
||||
{
|
||||
_RoundsTableOffset = 0;
|
||||
}
|
||||
else if (offset > 0 && _RoundsTableOffset + offset <= _PartyMode.GameData.Rounds.Count - _NumRoundsVisible)
|
||||
{
|
||||
_RoundsTableOffset += offset;
|
||||
}
|
||||
else if (offset > 0 && _RoundsTableOffset + offset > _PartyMode.GameData.Rounds.Count - _NumRoundsVisible)
|
||||
{
|
||||
_RoundsTableOffset = _PartyMode.GameData.Rounds.Count - _NumRoundsVisible;
|
||||
}
|
||||
|
||||
_UpdateRoundsTable();
|
||||
}
|
||||
|
||||
private string _GetPlayerWinString()
|
||||
{
|
||||
string s = "";
|
||||
var s = "";
|
||||
|
||||
for (int i = 0; i < _PartyMode.GameData.ResultTable.Count; i++)
|
||||
for (var i = 0; i < _PartyMode.GameData.ResultTable.Count; i++)
|
||||
{
|
||||
if (_PartyMode.GameData.ResultTable[i].Position == 1)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
s += ", ";
|
||||
s += CBase.Profiles.GetPlayerName(_PartyMode.GameData.ResultTable[i].PlayerID);
|
||||
}
|
||||
|
||||
s += CBase.Profiles.GetPlayerName(_PartyMode.GameData.ResultTable[i].PlayerId);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
// ReSharper disable UnusedMember.Global
|
||||
public class CPartyScreenChallengeNames : CMenuPartyNameSelection
|
||||
// ReSharper restore UnusedMember.Global
|
||||
// ReSharper restore UnusedMember.Global
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
@@ -45,24 +45,32 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
base.OnShow();
|
||||
SetPartyModeData(_PartyMode.GameData.NumPlayer);
|
||||
while (_PartyMode.GameData.ProfileIDs.Count > _NumPlayer)
|
||||
_PartyMode.GameData.ProfileIDs.RemoveAt(_PartyMode.GameData.ProfileIDs.Count - 1);
|
||||
while (_PartyMode.GameData.ProfileIds.Count > _NumPlayer)
|
||||
{
|
||||
_PartyMode.GameData.ProfileIds.RemoveAt(_PartyMode.GameData.ProfileIds.Count - 1);
|
||||
}
|
||||
|
||||
List<Guid>[] ids = new List<Guid>[] {_PartyMode.GameData.ProfileIDs};
|
||||
var ids = new List<Guid>[] { _PartyMode.GameData.ProfileIds };
|
||||
SetPartyModeProfiles(ids);
|
||||
}
|
||||
|
||||
public override void Back()
|
||||
{
|
||||
if (_TeamList.Length == 1)
|
||||
_PartyMode.GameData.ProfileIDs = _TeamList[0];
|
||||
{
|
||||
_PartyMode.GameData.ProfileIds = _TeamList[0];
|
||||
}
|
||||
|
||||
_PartyMode.Back();
|
||||
}
|
||||
|
||||
public override void Next()
|
||||
{
|
||||
if (_TeamList.Length == 1)
|
||||
_PartyMode.GameData.ProfileIDs = _TeamList[0];
|
||||
{
|
||||
_PartyMode.GameData.ProfileIds = _TeamList[0];
|
||||
}
|
||||
|
||||
_PartyMode.Next();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using VocaluxeLib.Menu;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.Challenge
|
||||
{
|
||||
@@ -26,7 +22,7 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
Source = _PartyMode.GameData.SongSource;
|
||||
Sorting = _PartyMode.GameData.Sorting;
|
||||
Category = _PartyMode.GameData.CategoryIndex;
|
||||
Playlist = _PartyMode.GameData.PlaylistID;
|
||||
Playlist = _PartyMode.GameData.PlaylistId;
|
||||
SongMode = _PartyMode.GameData.GameMode;
|
||||
NumMedleySongs = _PartyMode.GameData.NumMedleySongs;
|
||||
|
||||
@@ -62,9 +58,9 @@ namespace VocaluxeLib.PartyModes.Challenge
|
||||
_PartyMode.GameData.SongSource = Source;
|
||||
_PartyMode.GameData.Sorting = Sorting;
|
||||
_PartyMode.GameData.CategoryIndex = Category;
|
||||
_PartyMode.GameData.PlaylistID = Playlist;
|
||||
_PartyMode.GameData.PlaylistId = Playlist;
|
||||
_PartyMode.GameData.GameMode = SongMode;
|
||||
_PartyMode.GameData.NumMedleySongs = NumMedleySongs;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<CodeAnalysisRuleSet>..\..\CheckingRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWin|AnyCPU'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -40,6 +41,7 @@
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugLinux|AnyCPU'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -52,6 +54,7 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseLinux|AnyCPU'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -65,6 +68,7 @@
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'InstallerWin|AnyCPU'">
|
||||
<OutputPath>bin</OutputPath>
|
||||
@@ -78,6 +82,7 @@
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CChallengeRounds.cs" />
|
||||
@@ -119,4 +124,4 @@ rm -f "$(SolutionDir)Output\PartyModes\$(TargetName)\Code\GlobalSuppressions.cs"
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -17,12 +17,10 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using VocaluxeLib.Game;
|
||||
using VocaluxeLib.Menu;
|
||||
using VocaluxeLib.Songs;
|
||||
using VocaluxeLib.Utils;
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
@@ -30,7 +28,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
public class CRound
|
||||
{
|
||||
public int[] SongIDs;
|
||||
public int[] SongIds;
|
||||
public int SingerTeam1;
|
||||
public int SingerTeam2;
|
||||
public int PointsTeam1;
|
||||
@@ -90,7 +88,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
|
||||
public readonly EGameMode[] AvailableGameModes = { EGameMode.TR_GAMEMODE_NORMAL, EGameMode.TR_GAMEMODE_SHORTSONG, EGameMode.TR_GAMEMODE_DUET };
|
||||
|
||||
private enum EStage
|
||||
private enum EStage
|
||||
{
|
||||
Config,
|
||||
Songs,
|
||||
@@ -106,13 +104,13 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
public int NumFields;
|
||||
public int NumJockers;
|
||||
public int Team;
|
||||
public List<Guid> ProfileIDsTeam1;
|
||||
public List<Guid> ProfileIDsTeam2;
|
||||
public List<Guid> ProfileIdsTeam1;
|
||||
public List<Guid> ProfileIdsTeam2;
|
||||
|
||||
public ESongSource SongSource;
|
||||
public ESongSorting Sorting;
|
||||
public int CategoryIndex;
|
||||
public int PlaylistID;
|
||||
public int PlaylistId;
|
||||
|
||||
public EGameMode GameMode;
|
||||
public int NumMedleySongs;
|
||||
@@ -137,35 +135,35 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_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.Selection.NumJokers = new int[] { 5, 5 };
|
||||
_ScreenSongOptions.Selection.TeamNames = new string[] { "foo", "bar" };
|
||||
|
||||
_ScreenSongOptions.Sorting.SearchString = String.Empty;
|
||||
_ScreenSongOptions.Sorting.SearchString = string.Empty;
|
||||
_ScreenSongOptions.Sorting.SearchActive = false;
|
||||
_ScreenSongOptions.Sorting.DuetOptions = EDuetOptions.NoDuets;
|
||||
|
||||
GameData = new SData
|
||||
{
|
||||
NumPlayerTeam1 = 2,
|
||||
NumPlayerTeam2 = 2,
|
||||
NumFields = 9,
|
||||
NumJockers = 1,
|
||||
ProfileIDsTeam1 = new List<Guid>(),
|
||||
ProfileIDsTeam2 = new List<Guid>(),
|
||||
CurrentRoundNr = 0,
|
||||
FieldNr = 0,
|
||||
Sorting = CBase.Config.GetSongSorting(),
|
||||
SongSource = ESongSource.TR_SONGSOURCE_ALLSONGS,
|
||||
PlaylistID = 0,
|
||||
CategoryIndex = 0,
|
||||
GameMode = EGameMode.TR_GAMEMODE_NORMAL,
|
||||
NumMedleySongs = 5,
|
||||
Rounds = new List<CRound>(),
|
||||
Songs = new List<int>(),
|
||||
NumJokerRandom = new int[2],
|
||||
NumJokerRetry = new int[2],
|
||||
RefillJokers = EOffOn.TR_CONFIG_OFF
|
||||
};
|
||||
{
|
||||
NumPlayerTeam1 = 2,
|
||||
NumPlayerTeam2 = 2,
|
||||
NumFields = 9,
|
||||
NumJockers = 1,
|
||||
ProfileIdsTeam1 = new List<Guid>(),
|
||||
ProfileIdsTeam2 = new List<Guid>(),
|
||||
CurrentRoundNr = 0,
|
||||
FieldNr = 0,
|
||||
Sorting = CBase.Config.GetSongSorting(),
|
||||
SongSource = ESongSource.TR_SONGSOURCE_ALLSONGS,
|
||||
PlaylistId = 0,
|
||||
CategoryIndex = 0,
|
||||
GameMode = EGameMode.TR_GAMEMODE_NORMAL,
|
||||
NumMedleySongs = 5,
|
||||
Rounds = new List<CRound>(),
|
||||
Songs = new List<int>(),
|
||||
NumJokerRandom = new int[2],
|
||||
NumJokerRetry = new int[2],
|
||||
RefillJokers = EOffOn.TR_CONFIG_OFF
|
||||
};
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
@@ -178,7 +176,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_ScreenSongOptions.Selection.SongIndex = -1;
|
||||
|
||||
if (CBase.Config.GetTabs() == EOffOn.TR_CONFIG_ON && _ScreenSongOptions.Sorting.SongSorting != ESongSorting.TR_CONFIG_NONE)
|
||||
{
|
||||
_ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_ON;
|
||||
}
|
||||
|
||||
GameData.Songs.Clear();
|
||||
GameData.Rounds.Clear();
|
||||
@@ -187,7 +187,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
public override bool Init()
|
||||
{
|
||||
if (!base.Init())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SetDefaults();
|
||||
return true;
|
||||
@@ -224,7 +226,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
private void _FadeToScreen()
|
||||
{
|
||||
if (CBase.Graphics.GetNextScreen() != _GetNextScreen())
|
||||
{
|
||||
CBase.Graphics.FadeTo(_GetNextScreen());
|
||||
}
|
||||
}
|
||||
|
||||
public void Next()
|
||||
@@ -253,11 +257,15 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_Stage = EStage.Main;
|
||||
GameData.Team = GameData.Team == 1 ? 0 : 1;
|
||||
if (GameData.RefillJokers == EOffOn.TR_CONFIG_ON)
|
||||
{
|
||||
_SetNumJokers();
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("Invalid stage: " + _Stage);
|
||||
}
|
||||
|
||||
_FadeToScreen();
|
||||
}
|
||||
|
||||
@@ -280,6 +288,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
default: // Rest is not allowed
|
||||
throw new ArgumentException("Invalid stage: " + _Stage);
|
||||
}
|
||||
|
||||
_FadeToScreen();
|
||||
}
|
||||
|
||||
@@ -308,16 +317,16 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
throw new ArgumentException("Not required!");
|
||||
}
|
||||
|
||||
public override void JokerUsed(int teamNr) {}
|
||||
public override void JokerUsed(int teamNr) { }
|
||||
|
||||
public override void SongSelected(int songID)
|
||||
public override void SongSelected(int songId)
|
||||
{
|
||||
throw new ArgumentException("Not required!");
|
||||
}
|
||||
|
||||
public override void LeavingHighscore()
|
||||
{
|
||||
CBase.Songs.AddPartySongSung(CBase.Game.GetSong(0).ID);
|
||||
CBase.Songs.AddPartySongSung(CBase.Game.GetSong(0).Id);
|
||||
_UpdateScores();
|
||||
Next();
|
||||
}
|
||||
@@ -325,7 +334,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
private void _CreateRounds()
|
||||
{
|
||||
GameData.Rounds = new List<CRound>();
|
||||
for (int i = 0; i < GameData.NumFields; i++)
|
||||
for (var i = 0; i < GameData.NumFields; i++)
|
||||
{
|
||||
var r = new CRound();
|
||||
GameData.Rounds.Add(r);
|
||||
@@ -335,33 +344,39 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
public void UpdateSongList()
|
||||
{
|
||||
if (GameData.Songs.Count > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (GameData.SongSource)
|
||||
{
|
||||
case ESongSource.TR_SONGSOURCE_PLAYLIST:
|
||||
for (int i = 0; i < CBase.Playlist.GetSongCount(GameData.PlaylistID); i++)
|
||||
for (var 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(GameData.GameMode))
|
||||
var id = CBase.Playlist.GetSong(GameData.PlaylistId, i).SongId;
|
||||
if (CBase.Songs.GetSongById(id).IsGameModeAvailable(GameData.GameMode))
|
||||
{
|
||||
GameData.Songs.Add(id);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case ESongSource.TR_SONGSOURCE_ALLSONGS:
|
||||
ReadOnlyCollection<CSong> avSongs = CBase.Songs.GetSongs();
|
||||
GameData.Songs.AddRange(avSongs.Where(song => song.AvailableGameModes.Contains(GameData.GameMode)).Select(song => song.ID));
|
||||
var avSongs = CBase.Songs.GetSongs();
|
||||
GameData.Songs.AddRange(avSongs.Where(song => song.IsGameModeAvailable(GameData.GameMode)).Select(song => song.Id));
|
||||
break;
|
||||
|
||||
case ESongSource.TR_SONGSOURCE_CATEGORY:
|
||||
CBase.Songs.SortSongs(GameData.Sorting, EOffOn.TR_CONFIG_ON, CBase.Config.GetIgnoreArticles(), "", EDuetOptions.All, -1);
|
||||
CBase.Songs.SetCategory(GameData.CategoryIndex);
|
||||
avSongs = CBase.Songs.GetVisibleSongs();
|
||||
GameData.Songs.AddRange(avSongs.Where(song => song.AvailableGameModes.Contains(GameData.GameMode)).Select(song => song.ID));
|
||||
GameData.Songs.AddRange(avSongs.Where(song => song.IsGameModeAvailable(GameData.GameMode)).Select(song => song.Id));
|
||||
|
||||
CBase.Songs.SetCategory(-1);
|
||||
break;
|
||||
}
|
||||
|
||||
GameData.Songs.Shuffle();
|
||||
}
|
||||
|
||||
@@ -372,32 +387,37 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
|
||||
CBase.Game.SetNumPlayer(2);
|
||||
|
||||
SPlayer[] players = CBase.Game.GetPlayers();
|
||||
var players = CBase.Game.GetPlayers();
|
||||
if (players == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (players.Length < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CRound round = GameData.Rounds[roundNr];
|
||||
var round = GameData.Rounds[roundNr];
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
//default values
|
||||
players[i].ProfileID = Guid.Empty;
|
||||
players[i].ProfileId = Guid.Empty;
|
||||
}
|
||||
|
||||
//try to fill with the right data
|
||||
players[0].ProfileID = GameData.ProfileIDsTeam1[round.SingerTeam1];
|
||||
players[1].ProfileID = GameData.ProfileIDsTeam2[round.SingerTeam2];
|
||||
players[0].ProfileId = GameData.ProfileIdsTeam1[round.SingerTeam1];
|
||||
players[1].ProfileId = GameData.ProfileIdsTeam2[round.SingerTeam2];
|
||||
|
||||
foreach(int song in round.SongIDs)
|
||||
foreach (var song in round.SongIds)
|
||||
{
|
||||
CBase.Game.AddSong(song, GameData.GameMode);
|
||||
}
|
||||
}
|
||||
|
||||
private void _SetNumJokers()
|
||||
{
|
||||
|
||||
GameData.NumJokerRandom[0] = GameData.NumJockers;
|
||||
GameData.NumJokerRandom[1] = GameData.NumJockers;
|
||||
|
||||
@@ -423,19 +443,23 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
private void _UpdateScores()
|
||||
{
|
||||
if (!GameData.Rounds[GameData.FieldNr].Finished)
|
||||
{
|
||||
GameData.CurrentRoundNr++;
|
||||
}
|
||||
|
||||
CPoints points = CBase.Game.GetPoints();
|
||||
SPlayer[] results = CBase.Game.GetPlayers();
|
||||
var points = CBase.Game.GetPoints();
|
||||
var results = CBase.Game.GetPlayers();
|
||||
|
||||
if (results == null || results.Length < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Sum up all points
|
||||
for (int r = 0; r < points.NumRounds; r++)
|
||||
for (var r = 0; r < points.NumRounds; r++)
|
||||
{
|
||||
SPlayer[] player = points.GetPlayer(r, 2);
|
||||
for (int i = 0; i < 2; i++)
|
||||
var player = points.GetPlayer(r, 2);
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
results[i].Points += player[i].Points;
|
||||
results[i].PointsGoldenNotes += player[i].PointsGoldenNotes;
|
||||
@@ -444,7 +468,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
}
|
||||
|
||||
//Calc average of points
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
results[i].Points /= points.NumRounds;
|
||||
results[i].PointsGoldenNotes /= points.NumRounds;
|
||||
@@ -456,9 +480,13 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
GameData.Rounds[GameData.FieldNr].PointsTeam2 = (int)Math.Round(results[1].Points);
|
||||
GameData.Rounds[GameData.FieldNr].Finished = true;
|
||||
if (GameData.Rounds[GameData.FieldNr].PointsTeam1 < GameData.Rounds[GameData.FieldNr].PointsTeam2)
|
||||
{
|
||||
GameData.Rounds[GameData.FieldNr].Winner = 2;
|
||||
}
|
||||
else if (GameData.Rounds[GameData.FieldNr].PointsTeam1 > GameData.Rounds[GameData.FieldNr].PointsTeam2)
|
||||
{
|
||||
GameData.Rounds[GameData.FieldNr].Winner = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameData.Rounds[GameData.FieldNr].Finished = false;
|
||||
|
||||
@@ -16,11 +16,8 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Songs;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
@@ -71,10 +68,15 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_UpdateSlides();
|
||||
|
||||
if (_Buttons[_ButtonBack].Selected)
|
||||
{
|
||||
_PartyMode.Back();
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonNext].Selected)
|
||||
{
|
||||
_PartyMode.Next();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Keys.Left:
|
||||
@@ -86,6 +88,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -97,14 +100,20 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
_UpdateSlides();
|
||||
if (_Buttons[_ButtonBack].Selected)
|
||||
{
|
||||
_PartyMode.Back();
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonNext].Selected)
|
||||
{
|
||||
_PartyMode.Next();
|
||||
}
|
||||
}
|
||||
|
||||
if (mouseEvent.RB)
|
||||
{
|
||||
_PartyMode.Back();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -135,8 +144,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_SelectSlides[_SelectSlideNumFields].SelectedTag = _PartyMode.GameData.NumFields;
|
||||
|
||||
_SelectSlides[_SelectSlideNumJockers].Clear();
|
||||
for (int i = 0; i <= 3; i++)
|
||||
for (var i = 0; i <= 3; i++)
|
||||
{
|
||||
_SelectSlides[_SelectSlideNumJockers].AddValue(i);
|
||||
}
|
||||
|
||||
_SelectSlides[_SelectSlideNumJockers].SelectedTag = _PartyMode.GameData.NumJockers;
|
||||
|
||||
|
||||
@@ -17,10 +17,8 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Menu;
|
||||
using VocaluxeLib.Songs;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
@@ -71,7 +69,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
private const string _StaticTeam2 = "StaticTeam2";
|
||||
|
||||
private readonly string[] _EqualizerTeam = new string[]
|
||||
{"EqualizerTeam1", "EqualizerTeam2"};
|
||||
{ "EqualizerTeam1", "EqualizerTeam2" };
|
||||
|
||||
private bool _ExitPopupVisible;
|
||||
|
||||
@@ -97,12 +95,12 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
base.Init();
|
||||
|
||||
_ThemeTexts = new string[]
|
||||
{_TextPopupReallyExit, _TextTeamChoosing, _TextFinishMessage, _TextNextPlayerT1, _TextNextPlayerT2, _TextNextPlayerNameT1, _TextNextPlayerNameT2};
|
||||
{ _TextPopupReallyExit, _TextTeamChoosing, _TextFinishMessage, _TextNextPlayerT1, _TextNextPlayerT2, _TextNextPlayerNameT1, _TextNextPlayerNameT2 };
|
||||
_ThemeButtons = new string[]
|
||||
{
|
||||
_ButtonNextRound, _ButtonBack, _ButtonExit, _ButtonPopupYes, _ButtonPopupNo, _ButtonField, _ButtonJokerRandomT1, _ButtonJokerRandomT2, _ButtonJokerRetryT1,
|
||||
_ButtonJokerRetryT2, _ButtonSwitchPlayerT1, _ButtonSwitchPlayerT2
|
||||
};
|
||||
{
|
||||
_ButtonNextRound, _ButtonBack, _ButtonExit, _ButtonPopupYes, _ButtonPopupNo, _ButtonField, _ButtonJokerRandomT1, _ButtonJokerRandomT2, _ButtonJokerRetryT1,
|
||||
_ButtonJokerRetryT2, _ButtonSwitchPlayerT1, _ButtonSwitchPlayerT2
|
||||
};
|
||||
_ThemeStatics = new string[] { _StaticPopupBG, _StaticAvatarT1, _StaticAvatarT2, _StaticTeam1, _StaticTeam2 };
|
||||
|
||||
var texts = new List<string>();
|
||||
@@ -135,28 +133,48 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (_PartyMode.GameData.CurrentRoundNr == 1 && _Status != EStatus.FieldSelected)
|
||||
{
|
||||
_Back();
|
||||
}
|
||||
else if (_Status == EStatus.None)
|
||||
{
|
||||
_EndParty();
|
||||
}
|
||||
else
|
||||
{
|
||||
_ShowPopup(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_ShowPopup(false);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (_Buttons[_ButtonNextRound].Selected)
|
||||
{
|
||||
_NextRound();
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonBack].Selected && _PartyMode.GameData.CurrentRoundNr == 1 && _Status != EStatus.FieldSelected)
|
||||
{
|
||||
_Back();
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonExit].Selected && (_PartyMode.GameData.CurrentRoundNr > 1 || _Status == EStatus.FieldSelected) && _Status != EStatus.None)
|
||||
{
|
||||
_ShowPopup(true);
|
||||
}
|
||||
else if (_Status == EStatus.None)
|
||||
{
|
||||
_EndParty();
|
||||
for (int i = 0; i < _PartyMode.GameData.NumFields; i++)
|
||||
}
|
||||
|
||||
for (var i = 0; i < _PartyMode.GameData.NumFields; i++)
|
||||
{
|
||||
switch (_Status)
|
||||
{
|
||||
@@ -166,6 +184,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_PartyMode.GameData.FieldNr = i;
|
||||
_FieldSelected();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EStatus.JokerRetry:
|
||||
@@ -174,35 +193,61 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_PartyMode.GameData.FieldNr = i;
|
||||
_FieldSelectedAgain();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_Status == EStatus.FieldSelected)
|
||||
{
|
||||
if (_Buttons[_ButtonJokerRandomT1].Selected)
|
||||
{
|
||||
_UseJoker(0, 0);
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonJokerRandomT2].Selected)
|
||||
{
|
||||
_UseJoker(1, 0);
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonJokerRetryT1].Selected)
|
||||
{
|
||||
_UseJoker(0, 1);
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonJokerRetryT2].Selected)
|
||||
{
|
||||
_UseJoker(1, 1);
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonSwitchPlayerT1].Selected)
|
||||
{
|
||||
_ChangePlayer(0, true);
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonSwitchPlayerT2].Selected)
|
||||
{
|
||||
_ChangePlayer(1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_Buttons[_ButtonPopupYes].Selected)
|
||||
{
|
||||
_EndParty();
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonPopupNo].Selected)
|
||||
{
|
||||
_ShowPopup(false);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -215,17 +260,28 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (_Buttons[_ButtonNextRound].Selected)
|
||||
{
|
||||
_NextRound();
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonBack].Selected)
|
||||
{
|
||||
_Back();
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonExit].Selected)
|
||||
{
|
||||
if (_Status == EStatus.None)
|
||||
{
|
||||
_EndParty();
|
||||
}
|
||||
else
|
||||
{
|
||||
_ShowPopup(true);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < _PartyMode.GameData.NumFields; i++)
|
||||
|
||||
for (var i = 0; i < _PartyMode.GameData.NumFields; i++)
|
||||
{
|
||||
switch (_Status)
|
||||
{
|
||||
@@ -235,6 +291,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_PartyMode.GameData.FieldNr = i;
|
||||
_FieldSelected();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EStatus.JokerRetry:
|
||||
@@ -243,31 +300,55 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_PartyMode.GameData.FieldNr = i;
|
||||
_FieldSelectedAgain();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_Status == EStatus.FieldSelected)
|
||||
{
|
||||
if (_Buttons[_ButtonJokerRandomT1].Selected)
|
||||
{
|
||||
_UseJoker(0, 0);
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonJokerRandomT2].Selected)
|
||||
{
|
||||
_UseJoker(1, 0);
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonJokerRetryT1].Selected)
|
||||
{
|
||||
_UseJoker(0, 1);
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonJokerRetryT2].Selected)
|
||||
{
|
||||
_UseJoker(1, 1);
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonSwitchPlayerT1].Selected)
|
||||
{
|
||||
_ChangePlayer(0, true);
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonSwitchPlayerT2].Selected)
|
||||
{
|
||||
_ChangePlayer(1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_Buttons[_ButtonPopupYes].Selected)
|
||||
{
|
||||
_EndParty();
|
||||
}
|
||||
|
||||
if (_Buttons[_ButtonPopupNo].Selected)
|
||||
{
|
||||
_ShowPopup(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,14 +357,22 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
if (!_ExitPopupVisible)
|
||||
{
|
||||
if (_PartyMode.GameData.CurrentRoundNr == 1 && _Status != EStatus.FieldSelected)
|
||||
{
|
||||
_Back();
|
||||
}
|
||||
else if (_Status == EStatus.None)
|
||||
{
|
||||
_EndParty();
|
||||
}
|
||||
else
|
||||
{
|
||||
_ShowPopup(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_ShowPopup(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (mouseEvent.Wheel != 0) { }
|
||||
@@ -322,7 +411,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_UpdateFields();
|
||||
_UpdateFieldContents();
|
||||
|
||||
int winner = _GetWinner();
|
||||
var winner = _GetWinner();
|
||||
if (_PartyMode.GameData.CurrentRoundNr <= _PartyMode.GameData.NumFields && winner == 0)
|
||||
{
|
||||
_UpdateTeamChoosingMessage();
|
||||
@@ -354,14 +443,15 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
if (winner > 0)
|
||||
{
|
||||
_Texts[_TextFinishMessage].Color = CBase.Themes.GetPlayerColor(winner);
|
||||
_Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_WINNER", PartyModeID) + " " + CBase.Language.Translate("TR_TEAM", PartyModeID) + " " +
|
||||
_Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_WINNER", PartyModeId) + " " + CBase.Language.Translate("TR_TEAM", PartyModeId) + " " +
|
||||
winner;
|
||||
}
|
||||
else
|
||||
{
|
||||
_Texts[_TextFinishMessage].Color = new SColorF(1, 1, 1, 1);
|
||||
_Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_NOWINNER", PartyModeID);
|
||||
_Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_NOWINNER", PartyModeId);
|
||||
}
|
||||
|
||||
_SelectElement(_Buttons[_ButtonExit]);
|
||||
}
|
||||
|
||||
@@ -371,9 +461,11 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
if (!_Equalizers[_EqualizerTeam[0]].Visible)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
CBase.Record.AnalyzeBuffer(i);
|
||||
_Equalizers["EqualizerTeam" + (i + 1)].Update(CBase.Record.ToneWeigth(i), CBase.Record.GetMaxVolume(i));
|
||||
@@ -384,9 +476,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
|
||||
private void _CreateFields()
|
||||
{
|
||||
for (int i = 0; i < 25; i++)
|
||||
for (var i = 0; i < 25; i++)
|
||||
{
|
||||
CButton f = GetNewButton(_Buttons[_ButtonField]);
|
||||
var f = GetNewButton(_Buttons[_ButtonField]);
|
||||
f.Visible = false;
|
||||
_AddButton(f);
|
||||
_Fields.Add(f);
|
||||
@@ -396,16 +488,16 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
private void _UpdateFields()
|
||||
{
|
||||
var numOneRow = (int)Math.Sqrt(_PartyMode.GameData.NumFields);
|
||||
float fieldSizeY = ((float)CBase.Settings.GetRenderH() - 150 - numOneRow * _FieldSpace) / numOneRow;
|
||||
float fieldSizeX = ((float)CBase.Settings.GetRenderW() - 300 - numOneRow * _FieldSpace) / numOneRow;
|
||||
var fieldSizeY = ((float)CBase.Settings.GetRenderH() - 150 - numOneRow * _FieldSpace) / numOneRow;
|
||||
var fieldSizeX = ((float)CBase.Settings.GetRenderW() - 300 - numOneRow * _FieldSpace) / numOneRow;
|
||||
_FieldSize = Math.Min(fieldSizeX, fieldSizeY);
|
||||
_FieldFirstX = (float)CBase.Settings.GetRenderW() / 2 - (numOneRow * _FieldSize + (numOneRow - 1) * _FieldSpace) / 2;
|
||||
_FieldFirstY = 140 + (CBase.Settings.GetRenderH() - 140) / 2 - (numOneRow * _FieldSize + numOneRow * _FieldSpace) / 2;
|
||||
int row = 0;
|
||||
int column = 0;
|
||||
float x = _FieldFirstX;
|
||||
float y = _FieldFirstY;
|
||||
for (int i = 0; i < _Fields.Count; i++)
|
||||
var row = 0;
|
||||
var column = 0;
|
||||
var x = _FieldFirstX;
|
||||
var y = _FieldFirstY;
|
||||
for (var i = 0; i < _Fields.Count; i++)
|
||||
{
|
||||
if (i < _PartyMode.GameData.NumFields)
|
||||
{
|
||||
@@ -416,7 +508,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_Fields[i].Visible = true;
|
||||
_Fields[i].Selectable = true;
|
||||
column++;
|
||||
if ((i + 1) >= numOneRow * (row + 1))
|
||||
if (i + 1 >= numOneRow * (row + 1))
|
||||
{
|
||||
column = 0;
|
||||
row++;
|
||||
@@ -424,7 +516,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
x = _FieldFirstX;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = _FieldFirstX + _FieldSize * column + _FieldSpace * column;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -436,7 +530,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
|
||||
private void _UpdateFieldContents()
|
||||
{
|
||||
for (int i = 0; i < _PartyMode.GameData.Rounds.Count; i++)
|
||||
for (var i = 0; i < _PartyMode.GameData.Rounds.Count; i++)
|
||||
{
|
||||
_Fields[i].Selectable = true;
|
||||
_Fields[i].Texture = _Buttons[_ButtonField].Texture;
|
||||
@@ -445,26 +539,34 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
if (_PartyMode.GameData.Rounds[i].Finished)
|
||||
{
|
||||
_Fields[i].Selectable = false;
|
||||
_Fields[i].Texture = CBase.Songs.GetSongByID(_PartyMode.GameData.Rounds[i].SongIDs[0]).CoverTextureBig;
|
||||
_Fields[i].Texture = CBase.Songs.GetSongById(_PartyMode.GameData.Rounds[i].SongIds[0]).CoverTextureBig;
|
||||
_Fields[i].Color = CBase.Themes.GetPlayerColor(_PartyMode.GameData.Rounds[i].Winner);
|
||||
_Fields[i].SelColor = CBase.Themes.GetPlayerColor(_PartyMode.GameData.Rounds[i].Winner);
|
||||
}
|
||||
|
||||
if (_Status == EStatus.FieldSelected && _PartyMode.GameData.FieldNr == i)
|
||||
{
|
||||
_Fields[i].Texture = CBase.Songs.GetSongByID(_PartyMode.GameData.Rounds[i].SongIDs[0]).CoverTextureBig;
|
||||
_Fields[i].Texture = CBase.Songs.GetSongById(_PartyMode.GameData.Rounds[i].SongIds[0]).CoverTextureBig;
|
||||
_Fields[i].Color = new SColorF(1, 1, 1, 1);
|
||||
_Fields[i].SelColor = new SColorF(1, 1, 1, 1);
|
||||
_Fields[i].Selectable = false;
|
||||
}
|
||||
|
||||
if (_Status == EStatus.JokerRetry && _PartyMode.GameData.Rounds[i].Finished)
|
||||
{
|
||||
_Fields[i].SelColor = CBase.Themes.GetPlayerColor(_PartyMode.GameData.Team + 1);
|
||||
_Fields[i].Selectable = true;
|
||||
}
|
||||
|
||||
if (_Status == EStatus.JokerRetry && !_PartyMode.GameData.Rounds[i].Finished)
|
||||
{
|
||||
_Fields[i].Selectable = false;
|
||||
}
|
||||
|
||||
if (_Status == EStatus.FieldSelected)
|
||||
{
|
||||
_Fields[i].Selectable = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,17 +576,18 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
_ChangePlayer();
|
||||
}
|
||||
|
||||
_PartyMode.UpdateSongList();
|
||||
int[] songIDs = new int[_PartyMode.GameData.GameMode == EGameMode.TR_GAMEMODE_MEDLEY ? _PartyMode.GameData.NumMedleySongs : 1];
|
||||
for (int i = 0; i < songIDs.Length; i++)
|
||||
var songIds = new int[_PartyMode.GameData.GameMode == EGameMode.TR_GAMEMODE_MEDLEY ? _PartyMode.GameData.NumMedleySongs : 1];
|
||||
for (var i = 0; i < songIds.Length; i++)
|
||||
{
|
||||
songIDs[i] = _PartyMode.GameData.Songs[0];
|
||||
songIds[i] = _PartyMode.GameData.Songs[0];
|
||||
_PartyMode.GameData.Songs.RemoveAt(0);
|
||||
}
|
||||
|
||||
_StartPreview(songIDs[0]);
|
||||
_StartPreview(songIds[0]);
|
||||
_Status = EStatus.FieldSelected;
|
||||
_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SongIDs = songIDs;
|
||||
_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SongIds = songIds;
|
||||
_UpdateFieldContents();
|
||||
_UpdateJokerButtons();
|
||||
_UpdateSwitchPlayerButtons();
|
||||
@@ -498,10 +601,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
|
||||
private void _FieldSelectedAgain()
|
||||
{
|
||||
int[] songIDs = _PartyMode.GameData.Rounds[_OldSelectedField].SongIDs;
|
||||
_StartPreview(songIDs[0]);
|
||||
var songIds = _PartyMode.GameData.Rounds[_OldSelectedField].SongIds;
|
||||
_StartPreview(songIds[0]);
|
||||
_Status = EStatus.FieldSelected;
|
||||
_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SongIDs = songIDs;
|
||||
_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SongIds = songIds;
|
||||
_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam1 = _PartyMode.GameData.Rounds[_OldSelectedField].SingerTeam1;
|
||||
_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam2 = _PartyMode.GameData.Rounds[_OldSelectedField].SingerTeam2;
|
||||
_UpdateFieldContents();
|
||||
@@ -516,32 +619,31 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_SelectElement(_Buttons[_ButtonNextRound]);
|
||||
}
|
||||
|
||||
private void _StartPreview(int songID)
|
||||
private void _StartPreview(int songId)
|
||||
{
|
||||
CSong song = CBase.Songs.GetSongByID(songID);
|
||||
var song = CBase.Songs.GetSongById(songId);
|
||||
CBase.BackgroundMusic.LoadPreview(song);
|
||||
}
|
||||
|
||||
private int _GetRamdom(int max)
|
||||
{
|
||||
lock (syncLock)
|
||||
{
|
||||
return random.Next(max+1);
|
||||
{
|
||||
return random.Next(max + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void _ChangePlayer(int teamNr = -1, bool next = false)
|
||||
{
|
||||
|
||||
if (_PartyMode.GameData.ProfileIDsTeam1.Count > 0 && (teamNr == 0 || teamNr == -1))
|
||||
if (_PartyMode.GameData.ProfileIdsTeam1.Count > 0 && (teamNr == 0 || teamNr == -1))
|
||||
{
|
||||
idPlayer1 = _GetTeamPlayer(idPlayer1, _PartyMode.GameData.ProfileIDsTeam1.Count, next);
|
||||
idPlayer1 = _GetTeamPlayer(idPlayer1, _PartyMode.GameData.ProfileIdsTeam1.Count, next);
|
||||
_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam1 = idPlayer1;
|
||||
}
|
||||
|
||||
if (_PartyMode.GameData.ProfileIDsTeam2.Count > 0 && (teamNr == 1 || teamNr == -1))
|
||||
if (_PartyMode.GameData.ProfileIdsTeam2.Count > 0 && (teamNr == 1 || teamNr == -1))
|
||||
{
|
||||
idPlayer2 = _GetTeamPlayer(idPlayer2, _PartyMode.GameData.ProfileIDsTeam2.Count, next);
|
||||
idPlayer2 = _GetTeamPlayer(idPlayer2, _PartyMode.GameData.ProfileIdsTeam2.Count, next);
|
||||
_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam2 = idPlayer2;
|
||||
}
|
||||
|
||||
@@ -553,15 +655,16 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
if (next)
|
||||
{
|
||||
idPlayer++;
|
||||
if (idPlayer >= _PartyMode.GameData.ProfileIDsTeam1.Count)
|
||||
if (idPlayer >= _PartyMode.GameData.ProfileIdsTeam1.Count)
|
||||
{
|
||||
idPlayer = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
idPlayer = _GetRamdom(_PartyMode.GameData.ProfileIDsTeam1.Count - 1);
|
||||
idPlayer = _GetRamdom(_PartyMode.GameData.ProfileIdsTeam1.Count - 1);
|
||||
}
|
||||
|
||||
return idPlayer;
|
||||
}
|
||||
|
||||
@@ -572,13 +675,13 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_Texts[_TextNextPlayerNameT1].Visible = true;
|
||||
_Texts[_TextNextPlayerNameT2].Visible = true;
|
||||
_Texts[_TextNextPlayerNameT1].Text =
|
||||
CBase.Profiles.GetPlayerName(_PartyMode.GameData.ProfileIDsTeam1[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam1]);
|
||||
CBase.Profiles.GetPlayerName(_PartyMode.GameData.ProfileIdsTeam1[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam1]);
|
||||
_Texts[_TextNextPlayerNameT2].Text =
|
||||
CBase.Profiles.GetPlayerName(_PartyMode.GameData.ProfileIDsTeam2[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam2]);
|
||||
CBase.Profiles.GetPlayerName(_PartyMode.GameData.ProfileIdsTeam2[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam2]);
|
||||
_Statics[_StaticAvatarT1].Visible = true;
|
||||
_Statics[_StaticAvatarT2].Visible = true;
|
||||
_Statics[_StaticAvatarT1].Texture = CBase.Profiles.GetAvatar(_PartyMode.GameData.ProfileIDsTeam1[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam1]);
|
||||
_Statics[_StaticAvatarT2].Texture = CBase.Profiles.GetAvatar(_PartyMode.GameData.ProfileIDsTeam2[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam2]);
|
||||
_Statics[_StaticAvatarT1].Texture = CBase.Profiles.GetAvatar(_PartyMode.GameData.ProfileIdsTeam1[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam1]);
|
||||
_Statics[_StaticAvatarT2].Texture = CBase.Profiles.GetAvatar(_PartyMode.GameData.ProfileIdsTeam2[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam2]);
|
||||
_Statics[_StaticTeam1].Visible = true;
|
||||
_Statics[_StaticTeam2].Visible = true;
|
||||
_Equalizers[_EqualizerTeam[0]].Visible = true;
|
||||
@@ -596,6 +699,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_PartyMode.GameData.NumJokerRandom[teamNr]--;
|
||||
_FieldSelected(true);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
//Retry-Joker
|
||||
@@ -610,20 +714,26 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_UpdateFieldContents();
|
||||
_Buttons[_ButtonNextRound].Visible = false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
_UpdateJokerButtons();
|
||||
}
|
||||
|
||||
private void _UpdateTeamChoosingMessage()
|
||||
{
|
||||
_Texts[_TextTeamChoosing].Color = CBase.Themes.GetPlayerColor(_PartyMode.GameData.Team + 1);
|
||||
_Texts[_TextTeamChoosing].Text = CBase.Language.Translate("TR_TEAM", PartyModeID) + " " + (_PartyMode.GameData.Team + 1) + "! " +
|
||||
CBase.Language.Translate("TR_SCREENMAIN_TEAM_CHOOSE", PartyModeID);
|
||||
_Texts[_TextTeamChoosing].Text = CBase.Language.Translate("TR_TEAM", PartyModeId) + " " + (_PartyMode.GameData.Team + 1) + "! " +
|
||||
CBase.Language.Translate("TR_SCREENMAIN_TEAM_CHOOSE", PartyModeId);
|
||||
if (_Status == EStatus.JokerRetry || _Status == EStatus.FieldChoosing)
|
||||
{
|
||||
_Texts[_TextTeamChoosing].Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_Texts[_TextTeamChoosing].Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void _UpdateJokerButtons()
|
||||
@@ -649,7 +759,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_Buttons[_ButtonSwitchPlayerT1].Visible = true;
|
||||
_Buttons[_ButtonSwitchPlayerT2].Visible = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void _NextRound()
|
||||
@@ -672,7 +781,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_Buttons[_ButtonPopupNo].Visible = _ExitPopupVisible;
|
||||
|
||||
if (_ExitPopupVisible)
|
||||
{
|
||||
_SelectElement(_Buttons[_ButtonPopupNo]);
|
||||
}
|
||||
}
|
||||
|
||||
private void _Back()
|
||||
@@ -683,51 +794,71 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
private void _BuildWinnerPossibilities()
|
||||
{
|
||||
var numOneRow = (int)Math.Sqrt(_PartyMode.GameData.NumFields);
|
||||
_Possibilities = new int[(numOneRow * 2) + 2, numOneRow];
|
||||
for (int i = 0; i < _Possibilities.GetLength(0); i++)
|
||||
_Possibilities = new int[numOneRow * 2 + 2, numOneRow];
|
||||
for (var i = 0; i < _Possibilities.GetLength(0); i++)
|
||||
{
|
||||
if (i < numOneRow)
|
||||
{
|
||||
for (int c = 0; c < numOneRow; c++)
|
||||
for (var c = 0; c < numOneRow; c++)
|
||||
{
|
||||
_Possibilities[i, c] = i * numOneRow + c;
|
||||
}
|
||||
}
|
||||
else if (i < numOneRow * 2)
|
||||
{
|
||||
for (int c = 0; c < numOneRow; c++)
|
||||
_Possibilities[i, c] = (i - numOneRow) + (c * numOneRow);
|
||||
for (var c = 0; c < numOneRow; c++)
|
||||
{
|
||||
_Possibilities[i, c] = i - numOneRow + c * numOneRow;
|
||||
}
|
||||
}
|
||||
else if (i == _Possibilities.GetLength(0) - 2)
|
||||
{
|
||||
for (int c = 0; c < numOneRow; c++)
|
||||
for (var c = 0; c < numOneRow; c++)
|
||||
{
|
||||
_Possibilities[i, c] = (numOneRow + 1) * c;
|
||||
}
|
||||
}
|
||||
else if (i == _Possibilities.GetLength(0) - 1)
|
||||
{
|
||||
for (int c = 0; c < numOneRow; c++)
|
||||
for (var c = 0; c < numOneRow; c++)
|
||||
{
|
||||
_Possibilities[i, c] = (numOneRow - 1) * c + (numOneRow - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int _GetWinner()
|
||||
{
|
||||
for (int i = 0; i < _Possibilities.GetLength(0); i++)
|
||||
for (var i = 0; i < _Possibilities.GetLength(0); i++)
|
||||
{
|
||||
var check = new List<int>();
|
||||
for (int j = 0; j < _Possibilities.GetLength(1); j++)
|
||||
for (var j = 0; j < _Possibilities.GetLength(1); j++)
|
||||
{
|
||||
if (_PartyMode.GameData.Rounds[_Possibilities[i, j]].Winner > 0)
|
||||
{
|
||||
check.Add(_PartyMode.GameData.Rounds[_Possibilities[i, j]].Winner);
|
||||
}
|
||||
}
|
||||
|
||||
if (check.Count != _Possibilities.GetLength(1))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Check for winner
|
||||
if (check.Contains(1) && !check.Contains(2))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (check.Contains(2) && !check.Contains(1))
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,14 +17,13 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
// ReSharper disable UnusedMember.Global
|
||||
public class CPartyScreenTicTacToeNames : CMenuPartyNameSelection
|
||||
// ReSharper restore UnusedMember.Global
|
||||
// ReSharper restore UnusedMember.Global
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
protected override int _ScreenVersion
|
||||
@@ -44,14 +43,19 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
while (_PartyMode.GameData.ProfileIDsTeam1.Count > _PartyMode.GameData.NumPlayerTeam1)
|
||||
_PartyMode.GameData.ProfileIDsTeam1.RemoveAt(_PartyMode.GameData.ProfileIDsTeam1.Count - 1);
|
||||
while (_PartyMode.GameData.ProfileIDsTeam2.Count > _PartyMode.GameData.NumPlayerTeam2)
|
||||
_PartyMode.GameData.ProfileIDsTeam2.RemoveAt(_PartyMode.GameData.ProfileIDsTeam2.Count - 1);
|
||||
while (_PartyMode.GameData.ProfileIdsTeam1.Count > _PartyMode.GameData.NumPlayerTeam1)
|
||||
{
|
||||
_PartyMode.GameData.ProfileIdsTeam1.RemoveAt(_PartyMode.GameData.ProfileIdsTeam1.Count - 1);
|
||||
}
|
||||
|
||||
while (_PartyMode.GameData.ProfileIdsTeam2.Count > _PartyMode.GameData.NumPlayerTeam2)
|
||||
{
|
||||
_PartyMode.GameData.ProfileIdsTeam2.RemoveAt(_PartyMode.GameData.ProfileIdsTeam2.Count - 1);
|
||||
}
|
||||
|
||||
SetPartyModeData(2, _PartyMode.GameData.NumPlayerTeam1 + _PartyMode.GameData.NumPlayerTeam2,
|
||||
new int[] {_PartyMode.GameData.NumPlayerTeam1, _PartyMode.GameData.NumPlayerTeam2});
|
||||
List<Guid>[] ids = new List<Guid>[] {_PartyMode.GameData.ProfileIDsTeam1, _PartyMode.GameData.ProfileIDsTeam2};
|
||||
new int[] { _PartyMode.GameData.NumPlayerTeam1, _PartyMode.GameData.NumPlayerTeam2 });
|
||||
var ids = new List<Guid>[] { _PartyMode.GameData.ProfileIdsTeam1, _PartyMode.GameData.ProfileIdsTeam2 };
|
||||
SetPartyModeProfiles(ids);
|
||||
}
|
||||
|
||||
@@ -59,14 +63,16 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
if (_TeamList.Length == 2)
|
||||
{
|
||||
_PartyMode.GameData.ProfileIDsTeam1 = _TeamList[0];
|
||||
_PartyMode.GameData.ProfileIDsTeam2 = _TeamList[1];
|
||||
_PartyMode.GameData.ProfileIdsTeam1 = _TeamList[0];
|
||||
_PartyMode.GameData.ProfileIdsTeam2 = _TeamList[1];
|
||||
}
|
||||
|
||||
if (_NumPlayerTeams.Length == 2)
|
||||
{
|
||||
_PartyMode.GameData.NumPlayerTeam1 = _NumPlayerTeams[0];
|
||||
_PartyMode.GameData.NumPlayerTeam2 = _NumPlayerTeams[1];
|
||||
}
|
||||
|
||||
_PartyMode.Back();
|
||||
}
|
||||
|
||||
@@ -74,13 +80,14 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
{
|
||||
if (_TeamList.Length == 2)
|
||||
{
|
||||
_PartyMode.GameData.ProfileIDsTeam1 = _TeamList[0];
|
||||
_PartyMode.GameData.ProfileIDsTeam2 = _TeamList[1];
|
||||
_PartyMode.GameData.ProfileIdsTeam1 = _TeamList[0];
|
||||
_PartyMode.GameData.ProfileIdsTeam2 = _TeamList[1];
|
||||
}
|
||||
_PartyMode.GameData.NumPlayerTeam1 = _PartyMode.GameData.ProfileIDsTeam1.Count;
|
||||
_PartyMode.GameData.NumPlayerTeam2 = _PartyMode.GameData.ProfileIDsTeam2.Count;
|
||||
|
||||
_PartyMode.GameData.NumPlayerTeam1 = _PartyMode.GameData.ProfileIdsTeam1.Count;
|
||||
_PartyMode.GameData.NumPlayerTeam2 = _PartyMode.GameData.ProfileIdsTeam2.Count;
|
||||
|
||||
_PartyMode.Next();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
@@ -40,7 +39,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
Source = _PartyMode.GameData.SongSource;
|
||||
Sorting = _PartyMode.GameData.Sorting;
|
||||
Category = _PartyMode.GameData.CategoryIndex;
|
||||
Playlist = _PartyMode.GameData.PlaylistID;
|
||||
Playlist = _PartyMode.GameData.PlaylistId;
|
||||
SongMode = _PartyMode.GameData.GameMode;
|
||||
NumMedleySongs = _PartyMode.GameData.NumMedleySongs;
|
||||
|
||||
@@ -76,9 +75,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
|
||||
_PartyMode.GameData.SongSource = Source;
|
||||
_PartyMode.GameData.Sorting = Sorting;
|
||||
_PartyMode.GameData.CategoryIndex = Category;
|
||||
_PartyMode.GameData.PlaylistID = Playlist;
|
||||
_PartyMode.GameData.PlaylistId = Playlist;
|
||||
_PartyMode.GameData.GameMode = SongMode;
|
||||
_PartyMode.GameData.NumMedleySongs = NumMedleySongs;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<CodeAnalysisRuleSet>..\..\CheckingRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWin|AnyCPU'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -40,6 +41,7 @@
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugLinux|AnyCPU'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -52,6 +54,7 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseLinux|AnyCPU'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -65,6 +68,7 @@
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'InstallerWin|AnyCPU'">
|
||||
<OutputPath>bin</OutputPath>
|
||||
@@ -78,6 +82,7 @@
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CPartyScreenTicTacToeSongs.cs" />
|
||||
@@ -119,4 +124,4 @@ rm -f "$(SolutionDir)Output\PartyModes\$(TargetName)\Code\GlobalSuppressions.cs"
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
Reference in new issue
Block a user