Merge branch 'develop' of github.com:Vocaluxe/Vocaluxe into tic-tac-toe
Conflicts: Vocaluxe.sln
This commit is contained in:
commit
765323f93e
21 files changed
+4696
-96
No files matched your search
@@ -0,0 +1,262 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Vocaluxe.Menu;
|
||||
|
||||
namespace Vocaluxe.PartyModes
|
||||
{
|
||||
public class ChallengeRounds
|
||||
{
|
||||
private Random _Rand;
|
||||
private int _NumPlayer;
|
||||
|
||||
public List<Combination> Rounds;
|
||||
|
||||
public ChallengeRounds(int NumRounds, int NumPlayer, int NumPlayerAtOnce)
|
||||
{
|
||||
Rounds = new List<Combination>();
|
||||
_Rand = new Random(System.DateTime.Now.Millisecond);
|
||||
|
||||
if (NumPlayerAtOnce < 1 || NumRounds < 1 || NumPlayer == 0)
|
||||
_NumPlayer = 0;
|
||||
else
|
||||
{
|
||||
_NumPlayer = NumPlayer;
|
||||
BuildRounds(NumRounds, NumPlayerAtOnce, _Rand);
|
||||
}
|
||||
}
|
||||
|
||||
public Combination GetRound(int RoundNr)
|
||||
{
|
||||
if (RoundNr >= Rounds.Count || _NumPlayer == 0 || Rounds.Count == 0)
|
||||
return null;
|
||||
|
||||
return Rounds[RoundNr];
|
||||
}
|
||||
|
||||
private void BuildRounds(int NumRounds, int NumPlayerAtOnce, Random Rand)
|
||||
{
|
||||
Combinations Combinations = new Combinations(_NumPlayer, NumPlayerAtOnce, Rand);
|
||||
Rounds.Add(Combinations.GetNextCombination(null));
|
||||
|
||||
for (int i = 1; i < NumRounds; i++)
|
||||
{
|
||||
|
||||
Rounds.Add(Combinations.GetNextCombination(GetPlayerDemand(i)));
|
||||
}
|
||||
}
|
||||
|
||||
private List<int> GetPlayerDemand(int RoundIndex)
|
||||
{
|
||||
List<int> NumPlayed = new List<int>(_NumPlayer);
|
||||
for (int i = 0; i < _NumPlayer; i++)
|
||||
{
|
||||
NumPlayed.Add(0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < RoundIndex; i++)
|
||||
{
|
||||
foreach (int PlayerIndex in Rounds[i].Player)
|
||||
{
|
||||
NumPlayed[PlayerIndex]++;
|
||||
}
|
||||
}
|
||||
|
||||
int max = 0;
|
||||
foreach (int p in NumPlayed)
|
||||
{
|
||||
if (p > max)
|
||||
max = p;
|
||||
}
|
||||
|
||||
int num = Rounds[0].Player.Count;
|
||||
List<int> result = new List<int>();
|
||||
List<int> other = new List<int>();
|
||||
List<int> last = new List<int>();
|
||||
|
||||
for (int i = 0; i < NumPlayed.Count; i++)
|
||||
{
|
||||
if (RoundIndex == 0 || NumPlayed[i] < max)
|
||||
{
|
||||
if (RoundIndex == 0 || RoundIndex > 0 && NumPlayed[i] < max && !Rounds[RoundIndex - 1].IsAvailable(i))
|
||||
result.Add(i);
|
||||
else if (NumPlayed[i] < max)
|
||||
other.Add(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RoundIndex > 0)
|
||||
{
|
||||
if (!Rounds[RoundIndex - 1].IsAvailable(i))
|
||||
other.Add(i);
|
||||
else
|
||||
last.Add(i);
|
||||
}
|
||||
else
|
||||
last.Add(i);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
while (result.Count < num && other.Count > 0)
|
||||
{
|
||||
int n = other.Count;
|
||||
int r = _Rand.Next(n);
|
||||
result.Add(other[r]);
|
||||
other.RemoveAt(r);
|
||||
}
|
||||
|
||||
while (result.Count < num)
|
||||
{
|
||||
int n = last.Count;
|
||||
int r = _Rand.Next(n);
|
||||
result.Add(last[r]);
|
||||
last.RemoveAt(r);
|
||||
}
|
||||
|
||||
while (result.Count > num)
|
||||
{
|
||||
int n = result.Count;
|
||||
int r = _Rand.Next(n);
|
||||
result.RemoveAt(r);
|
||||
}
|
||||
|
||||
result.Sort();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
class Combinations
|
||||
{
|
||||
private List<Combination> _Combs;
|
||||
private Random _Rand;
|
||||
private int _NumPlayer;
|
||||
private int _NumMics;
|
||||
|
||||
public Combinations(int NumPlayer, int NumMics, Random Rand)
|
||||
{
|
||||
_Combs = new List<Combination>();
|
||||
_NumMics = NumMics;
|
||||
_NumPlayer = NumPlayer;
|
||||
_Rand = Rand;
|
||||
}
|
||||
|
||||
public Combination GetNextCombination(List<int> PlayerNrDemand)
|
||||
{
|
||||
if (_Combs.Count == 0)
|
||||
Create();
|
||||
|
||||
Combination combs = new Combination();
|
||||
|
||||
if (_NumPlayer == _NumMics)
|
||||
{
|
||||
return _Combs[0];
|
||||
}
|
||||
|
||||
//filter against PlayerNrDemand
|
||||
List<Combination> combsFiltered = new List<Combination>();
|
||||
if (PlayerNrDemand != null)
|
||||
{
|
||||
for (int i = 0; i < _Combs.Count; i++)
|
||||
{
|
||||
if (_Combs[i].IsAvailableAll(PlayerNrDemand))
|
||||
combsFiltered.Add(_Combs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//1st fallback
|
||||
if (PlayerNrDemand != null && combsFiltered.Count == 0)
|
||||
{
|
||||
for (int i = 0; i < _Combs.Count; i++)
|
||||
{
|
||||
if (_Combs[i].IsAvailableSomeone(PlayerNrDemand))
|
||||
combsFiltered.Add(_Combs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//2nd fallback
|
||||
if (combsFiltered.Count == 0)
|
||||
{
|
||||
for (int i = 0; i < _Combs.Count; i++)
|
||||
{
|
||||
combsFiltered.Add(_Combs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int num = combsFiltered.Count;
|
||||
int rand = _Rand.Next(num);
|
||||
Combination c = new Combination();
|
||||
for (int i = 0; i < combsFiltered[rand].Player.Count; i++)
|
||||
{
|
||||
c.Player.Add(combsFiltered[rand].Player[i]);
|
||||
}
|
||||
_Combs.Remove(combsFiltered[rand]);
|
||||
|
||||
return combsFiltered[rand];
|
||||
}
|
||||
|
||||
private void Create()
|
||||
{
|
||||
_Combs.Clear();
|
||||
|
||||
int num = (int)Math.Pow(2, _NumPlayer);
|
||||
|
||||
for (int i = 1; i <= num; i++)
|
||||
{
|
||||
Combination c = new Combination();
|
||||
|
||||
for (int j = 0; j < _NumPlayer; j++)
|
||||
{
|
||||
if ((i & (1 << j)) > 0)
|
||||
{
|
||||
c.Player.Add(j);
|
||||
}
|
||||
}
|
||||
|
||||
if (c.Player.Count == _NumMics)
|
||||
_Combs.Add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Combination
|
||||
{
|
||||
public List<int> Player;
|
||||
|
||||
public Combination()
|
||||
{
|
||||
Player = new List<int>();
|
||||
}
|
||||
|
||||
public bool IsAvailable(int PlayerIndex)
|
||||
{
|
||||
foreach (int p in Player)
|
||||
{
|
||||
if (p == PlayerIndex)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsAvailableAll(List<int> PlayerIndices)
|
||||
{
|
||||
bool result = true;
|
||||
foreach (int p in PlayerIndices)
|
||||
{
|
||||
result &= IsAvailable(p);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool IsAvailableSomeone(List<int> PlayerIndices)
|
||||
{
|
||||
bool result = false;
|
||||
foreach (int p in PlayerIndices)
|
||||
{
|
||||
result |= IsAvailable(p);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,787 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Vocaluxe.Menu;
|
||||
using Vocaluxe.Menu.SongMenu;
|
||||
|
||||
namespace Vocaluxe.PartyModes
|
||||
{
|
||||
#region Communication
|
||||
#region ToScreen
|
||||
public struct DataToScreenConfig
|
||||
{
|
||||
public int NumPlayer;
|
||||
public int NumPlayerAtOnce;
|
||||
public int NumRounds;
|
||||
}
|
||||
|
||||
public struct DataToScreenNames
|
||||
{
|
||||
public int NumPlayer;
|
||||
public List<int> ProfileIDs;
|
||||
}
|
||||
|
||||
public struct DataToScreenMain
|
||||
{
|
||||
public int CurrentRoundNr;
|
||||
public int NumPlayerAtOnce;
|
||||
public List<Combination> Combs;
|
||||
public int[,] Results;
|
||||
public List<ResultTableRow> ResultTable;
|
||||
public List<int> ProfileIDs;
|
||||
}
|
||||
|
||||
public class ResultTableRow : IComparable
|
||||
{
|
||||
public int Position;
|
||||
public int PlayerID;
|
||||
public int NumPlayed;
|
||||
public int NumRounds;
|
||||
public int NumWon;
|
||||
public int NumSingPoints;
|
||||
public int NumGamePoints;
|
||||
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
if (obj is ResultTableRow)
|
||||
{
|
||||
ResultTableRow row = (ResultTableRow)obj;
|
||||
|
||||
int res = row.NumGamePoints.CompareTo(NumGamePoints);
|
||||
if (res == 0)
|
||||
{
|
||||
res = row.NumSingPoints.CompareTo(NumSingPoints);
|
||||
if (res == 0)
|
||||
{
|
||||
res = row.NumWon.CompareTo(NumWon);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
throw new ArgumentException("object is not a ResultTableRow");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion ToScreen
|
||||
|
||||
#region FromScreen
|
||||
public struct DataFromScreen
|
||||
{
|
||||
public FromScreenConfig ScreenConfig;
|
||||
public FromScreenNames ScreenNames;
|
||||
public FromScreenMain ScreenMain;
|
||||
}
|
||||
|
||||
public struct FromScreenConfig
|
||||
{
|
||||
public int NumPlayer;
|
||||
public int NumPlayerAtOnce;
|
||||
public int NumRounds;
|
||||
}
|
||||
|
||||
public struct FromScreenNames
|
||||
{
|
||||
public bool FadeToConfig;
|
||||
public bool FadeToMain;
|
||||
public List<int> ProfileIDs;
|
||||
}
|
||||
|
||||
public struct FromScreenMain
|
||||
{
|
||||
public bool FadeToSongSelection;
|
||||
public bool FadeToNameSelection;
|
||||
}
|
||||
#endregion FromScreen
|
||||
#endregion Communication
|
||||
|
||||
public sealed class PartyModeChallenge : CPartyMode
|
||||
{
|
||||
private const int MaxPlayer = 12;
|
||||
private const int MinPlayer = 1;
|
||||
private const int MaxTeams = 0;
|
||||
private const int MinTeams = 0;
|
||||
private const int MaxNumRounds = 100;
|
||||
private const int NumSongs = 5;
|
||||
|
||||
enum EStage
|
||||
{
|
||||
NotStarted,
|
||||
Config,
|
||||
Names,
|
||||
Main,
|
||||
Singing
|
||||
}
|
||||
|
||||
struct Data
|
||||
{
|
||||
public int NumPlayer;
|
||||
public int NumPlayerAtOnce;
|
||||
public int NumRounds;
|
||||
public List<int> ProfileIDs;
|
||||
|
||||
public ChallengeRounds Rounds;
|
||||
public List<ResultTableRow> ResultTable;
|
||||
public int[,] Results;
|
||||
|
||||
public int CurrentRoundNr;
|
||||
|
||||
public int[] CatSongIndices;
|
||||
}
|
||||
|
||||
struct Stats
|
||||
{
|
||||
public int ProfileID;
|
||||
public int SingPoints;
|
||||
public int GamePoints;
|
||||
public int Won;
|
||||
}
|
||||
|
||||
private DataToScreenConfig ToScreenConfig;
|
||||
private DataToScreenNames ToScreenNames;
|
||||
private DataToScreenMain ToScreenMain;
|
||||
|
||||
private Data GameData;
|
||||
private EStage _Stage;
|
||||
|
||||
public PartyModeChallenge()
|
||||
{
|
||||
_ScreenSongOptions.Selection.RandomOnly = false;
|
||||
_ScreenSongOptions.Selection.PartyMode = true;
|
||||
_ScreenSongOptions.Selection.CategoryChangeAllowed = true;
|
||||
_ScreenSongOptions.Selection.NumJokers = new int[] { 5, 5 };
|
||||
_ScreenSongOptions.Selection.TeamNames = new string[] { "foo", "bar" };
|
||||
|
||||
_ScreenSongOptions.Sorting.SearchString = String.Empty;
|
||||
_ScreenSongOptions.Sorting.SearchActive = false;
|
||||
_ScreenSongOptions.Sorting.ShowDuetSongs = false;
|
||||
|
||||
_Stage = EStage.NotStarted;
|
||||
|
||||
ToScreenConfig = new DataToScreenConfig();
|
||||
ToScreenNames = new DataToScreenNames();
|
||||
ToScreenMain = new DataToScreenMain();
|
||||
|
||||
GameData = new Data();
|
||||
GameData.NumPlayer = 4;
|
||||
GameData.NumPlayerAtOnce = 2;
|
||||
GameData.NumRounds = 2;
|
||||
GameData.CurrentRoundNr = 1;
|
||||
GameData.ProfileIDs = new List<int>();
|
||||
GameData.CatSongIndices = null;
|
||||
GameData.Results = null;
|
||||
}
|
||||
|
||||
public override bool Init()
|
||||
{
|
||||
_Stage = EStage.NotStarted;
|
||||
|
||||
_ScreenSongOptions.Sorting.IgnoreArticles = _Base.Config.GetIgnoreArticles();
|
||||
_ScreenSongOptions.Sorting.SongSorting = _Base.Config.GetSongSorting();
|
||||
_ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_OFF;
|
||||
_ScreenSongOptions.Selection.SongIndex = -1;
|
||||
|
||||
if (_Base.Config.GetTabs() == EOffOn.TR_CONFIG_ON && _ScreenSongOptions.Sorting.SongSorting != ESongSorting.TR_CONFIG_NONE)
|
||||
_ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_ON;
|
||||
|
||||
ToScreenMain.ResultTable = new List<ResultTableRow>();
|
||||
GameData.ResultTable = new List<ResultTableRow>();
|
||||
|
||||
_Base.Songs.SortSongs(ESongSorting.TR_CONFIG_NONE, EOffOn.TR_CONFIG_OFF, EOffOn.TR_CONFIG_OFF, String.Empty, false);
|
||||
_Base.Songs.SetCategory(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void DataFromScreen(string ScreenName, Object Data)
|
||||
{
|
||||
DataFromScreen data = new DataFromScreen();
|
||||
switch (ScreenName)
|
||||
{
|
||||
case "PartyScreenChallengeConfig":
|
||||
|
||||
try
|
||||
{
|
||||
data = (DataFromScreen)Data;
|
||||
GameData.NumPlayer = data.ScreenConfig.NumPlayer;
|
||||
GameData.NumPlayerAtOnce = data.ScreenConfig.NumPlayerAtOnce;
|
||||
GameData.NumRounds = data.ScreenConfig.NumRounds;
|
||||
|
||||
_Stage = EStage.Config;
|
||||
_Base.Graphics.FadeTo(EScreens.ScreenPartyDummy);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_Base.Log.LogError("Error in party mode challenge. Can't cast received data from screen " + ScreenName + ". " + e.Message);
|
||||
}
|
||||
break;
|
||||
|
||||
case "PartyScreenChallengeNames":
|
||||
try
|
||||
{
|
||||
data = (DataFromScreen)Data;
|
||||
if (data.ScreenNames.FadeToConfig)
|
||||
_Stage = EStage.NotStarted;
|
||||
else
|
||||
{
|
||||
GameData.ProfileIDs = data.ScreenNames.ProfileIDs;
|
||||
_Stage = EStage.Names;
|
||||
}
|
||||
|
||||
_Base.Graphics.FadeTo(EScreens.ScreenPartyDummy);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_Base.Log.LogError("Error in party mode challenge. Can't cast received data from screen " + ScreenName + ". " + e.Message);
|
||||
}
|
||||
break;
|
||||
|
||||
case "PartyScreenChallengeMain":
|
||||
try
|
||||
{
|
||||
data = (DataFromScreen)Data;
|
||||
if (data.ScreenMain.FadeToSongSelection)
|
||||
_Stage = EStage.Singing;
|
||||
if (data.ScreenMain.FadeToNameSelection)
|
||||
_Stage = EStage.Config;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_Base.Log.LogError("Error in party mode challenge. Can't cast received data from screen " + ScreenName + ". " + e.Message);
|
||||
}
|
||||
|
||||
|
||||
if (_Stage == EStage.Singing)
|
||||
StartNextRound();
|
||||
if (_Stage == EStage.Config)
|
||||
_Base.Graphics.FadeTo(EScreens.ScreenPartyDummy);
|
||||
break;
|
||||
|
||||
default:
|
||||
_Base.Log.LogError("Error in party mode challenge. Wrong screen is sending: " + ScreenName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateGame()
|
||||
{
|
||||
/*
|
||||
if (_Base.Songs.GetCurrentCategoryIndex() != -1 || _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF)
|
||||
_ScreenSongOptions.Selection.RandomOnly = true;
|
||||
else
|
||||
_ScreenSongOptions.Selection.RandomOnly = false;*/
|
||||
}
|
||||
|
||||
public override CMenuParty GetNextPartyScreen(out EScreens AlternativeScreen)
|
||||
{
|
||||
CMenuParty Screen = null;
|
||||
AlternativeScreen = EScreens.ScreenSong;
|
||||
|
||||
switch (_Stage)
|
||||
{
|
||||
case EStage.NotStarted:
|
||||
_Screens.TryGetValue("PartyScreenChallengeConfig", out Screen);
|
||||
if (_Screens != null)
|
||||
{
|
||||
ToScreenConfig.NumPlayer = GameData.NumPlayer;
|
||||
ToScreenConfig.NumPlayerAtOnce = GameData.NumPlayerAtOnce;
|
||||
ToScreenConfig.NumRounds = GameData.NumRounds;
|
||||
Screen.DataToScreen(ToScreenConfig);
|
||||
}
|
||||
break;
|
||||
case EStage.Config:
|
||||
_Screens.TryGetValue("PartyScreenChallengeNames", out Screen);
|
||||
if (_Screens != null)
|
||||
{
|
||||
ToScreenNames.NumPlayer = GameData.NumPlayer;
|
||||
ToScreenNames.ProfileIDs = GameData.ProfileIDs;
|
||||
Screen.DataToScreen(ToScreenNames);
|
||||
}
|
||||
break;
|
||||
case EStage.Names:
|
||||
_Screens.TryGetValue("PartyScreenChallengeMain", out Screen);
|
||||
if (_Screens != null)
|
||||
{
|
||||
_Base.Songs.ResetPartySongSung();
|
||||
ToScreenMain.ResultTable = new List<ResultTableRow>();
|
||||
GameData.ResultTable = new List<ResultTableRow>();
|
||||
GameData.Rounds = new ChallengeRounds(GameData.NumRounds, GameData.NumPlayer, GameData.NumPlayerAtOnce);
|
||||
GameData.CurrentRoundNr = 1;
|
||||
ToScreenMain.CurrentRoundNr = 1;
|
||||
ToScreenMain.NumPlayerAtOnce = GameData.NumPlayerAtOnce;
|
||||
ToScreenMain.Combs = GameData.Rounds.Rounds;
|
||||
ToScreenMain.ProfileIDs = GameData.ProfileIDs;
|
||||
UpdateScores();
|
||||
ToScreenMain.ResultTable = GameData.ResultTable;
|
||||
ToScreenMain.Results = GameData.Results;
|
||||
Screen.DataToScreen(ToScreenMain);
|
||||
}
|
||||
break;
|
||||
case EStage.Main:
|
||||
//nothing to do
|
||||
break;
|
||||
case EStage.Singing:
|
||||
_Screens.TryGetValue("PartyScreenChallengeMain", out Screen);
|
||||
if (_Screens != null)
|
||||
{
|
||||
UpdateScores();
|
||||
ToScreenMain.CurrentRoundNr = GameData.CurrentRoundNr;
|
||||
ToScreenMain.Combs = GameData.Rounds.Rounds;
|
||||
ToScreenMain.Results = GameData.Results;
|
||||
Screen.DataToScreen(ToScreenMain);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return Screen;
|
||||
}
|
||||
|
||||
public override EScreens GetStartScreen()
|
||||
{
|
||||
return EScreens.ScreenPartyDummy;
|
||||
}
|
||||
|
||||
public override EScreens GetMainScreen()
|
||||
{
|
||||
return EScreens.ScreenPartyDummy;
|
||||
}
|
||||
|
||||
public override ScreenSongOptions GetScreenSongOptions()
|
||||
{
|
||||
_ScreenSongOptions.Sorting.SongSorting = _Base.Config.GetSongSorting();
|
||||
_ScreenSongOptions.Sorting.Tabs = _Base.Config.GetTabs();
|
||||
_ScreenSongOptions.Sorting.IgnoreArticles = _Base.Config.GetIgnoreArticles();
|
||||
|
||||
return _ScreenSongOptions;
|
||||
}
|
||||
|
||||
public override void OnSongChange(int SongIndex, ref ScreenSongOptions ScreenSongOptions)
|
||||
{
|
||||
if (_ScreenSongOptions.Selection.SongIndex != -1)
|
||||
_ScreenSongOptions.Selection.SongIndex = -1;
|
||||
|
||||
if (_ScreenSongOptions.Selection.SelectNextRandomSong && SongIndex != -1)
|
||||
{
|
||||
_ScreenSongOptions.Selection.SelectNextRandomSong = false;
|
||||
CreateCatSongIndices();
|
||||
|
||||
if (GameData.CatSongIndices != null)
|
||||
{
|
||||
if (GameData.CatSongIndices[_Base.Songs.GetCurrentCategoryIndex()] == -1)
|
||||
GameData.CatSongIndices[_Base.Songs.GetCurrentCategoryIndex()] = SongIndex;
|
||||
}
|
||||
}
|
||||
|
||||
ScreenSongOptions = _ScreenSongOptions;
|
||||
}
|
||||
|
||||
public override void OnCategoryChange(int CategoryIndex, ref ScreenSongOptions ScreenSongOptions)
|
||||
{
|
||||
if (GameData.CatSongIndices != null && CategoryIndex != -1)
|
||||
{
|
||||
if (GameData.CatSongIndices[CategoryIndex] == -1)
|
||||
_ScreenSongOptions.Selection.SelectNextRandomSong = true;
|
||||
else
|
||||
_ScreenSongOptions.Selection.SongIndex = GameData.CatSongIndices[CategoryIndex];
|
||||
}
|
||||
|
||||
if (GameData.CatSongIndices == null && CategoryIndex != -1)
|
||||
_ScreenSongOptions.Selection.SelectNextRandomSong = true;
|
||||
|
||||
if (CategoryIndex == -1)
|
||||
_ScreenSongOptions.Selection.RandomOnly = false;
|
||||
|
||||
if (_ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF || CategoryIndex != -1)
|
||||
_ScreenSongOptions.Selection.RandomOnly = true;
|
||||
|
||||
ScreenSongOptions = _ScreenSongOptions;
|
||||
}
|
||||
|
||||
public override void SetSearchString(string SearchString, bool Visible)
|
||||
{
|
||||
_ScreenSongOptions.Sorting.SearchString = SearchString;
|
||||
_ScreenSongOptions.Sorting.SearchActive = Visible;
|
||||
}
|
||||
|
||||
public override int GetMaxPlayer()
|
||||
{
|
||||
return MaxPlayer;
|
||||
}
|
||||
|
||||
public override int GetMinPlayer()
|
||||
{
|
||||
return MinPlayer;
|
||||
}
|
||||
|
||||
public override int GetMaxTeams()
|
||||
{
|
||||
return MaxTeams;
|
||||
}
|
||||
|
||||
public override int GetMinTeams()
|
||||
{
|
||||
return MinTeams;
|
||||
}
|
||||
|
||||
public override int GetMaxNumRounds()
|
||||
{
|
||||
return MaxNumRounds;
|
||||
}
|
||||
|
||||
public override void JokerUsed(int TeamNr)
|
||||
{
|
||||
if (_ScreenSongOptions.Selection.NumJokers == null)
|
||||
return;
|
||||
|
||||
if (TeamNr >= _ScreenSongOptions.Selection.NumJokers.Length)
|
||||
return;
|
||||
|
||||
_ScreenSongOptions.Selection.NumJokers[TeamNr]--;
|
||||
_ScreenSongOptions.Selection.RandomOnly = true;
|
||||
_ScreenSongOptions.Selection.CategoryChangeAllowed = false;
|
||||
}
|
||||
|
||||
public override void SongSelected(int SongID)
|
||||
{
|
||||
}
|
||||
|
||||
public override void LeavingHighscore()
|
||||
{
|
||||
GameData.CurrentRoundNr++;
|
||||
_Base.Graphics.FadeTo(EScreens.ScreenPartyDummy);
|
||||
}
|
||||
|
||||
private void StartNextRound()
|
||||
{
|
||||
_ScreenSongOptions.Selection.RandomOnly = _ScreenSongOptions.Sorting.Tabs != EOffOn.TR_CONFIG_ON;
|
||||
_ScreenSongOptions.Selection.CategoryChangeAllowed = _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_ON;
|
||||
SetNumJokers();
|
||||
SetTeamNames();
|
||||
GameData.CatSongIndices = null;
|
||||
|
||||
if (RandomizeSongs())
|
||||
_Base.Graphics.FadeTo(EScreens.ScreenSing);
|
||||
}
|
||||
|
||||
private bool RandomizeSongs()
|
||||
{
|
||||
_Base.Game.Reset();
|
||||
_Base.Game.ClearSongs();
|
||||
|
||||
#region PlayerNames
|
||||
_Base.Game.SetNumPlayer(GameData.NumPlayerAtOnce);
|
||||
SPlayer[] player = _Base.Game.GetPlayer();
|
||||
if (player == null)
|
||||
return false;
|
||||
|
||||
if (player.Length < GameData.NumPlayerAtOnce)
|
||||
return false;
|
||||
|
||||
SProfile[] profiles = _Base.Profiles.GetProfiles();
|
||||
Combination c = GameData.Rounds.GetRound(GameData.CurrentRoundNr - 1);
|
||||
|
||||
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
//default values
|
||||
player[i].Name = "foobar";
|
||||
player[i].Difficulty = EGameDifficulty.TR_CONFIG_EASY;
|
||||
player[i].ProfileID = -1;
|
||||
|
||||
//try to fill with the right data
|
||||
if (c != null)
|
||||
{
|
||||
if (GameData.ProfileIDs[c.Player[i]] < profiles.Length)
|
||||
{
|
||||
player[i].Name = profiles[GameData.ProfileIDs[c.Player[i]]].PlayerName;
|
||||
player[i].Difficulty = profiles[GameData.ProfileIDs[c.Player[i]]].Difficulty;
|
||||
player[i].ProfileID = GameData.ProfileIDs[c.Player[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion PlayerNames
|
||||
|
||||
#region SongQueque
|
||||
if (_Base.Songs.GetNumVisibleSongs() < NumSongs)
|
||||
_Base.Songs.ResetPartySongSung();
|
||||
|
||||
EGameMode gm = EGameMode.TR_GAMEMODE_MEDLEY;
|
||||
List<int> IDs = new List<int>();
|
||||
|
||||
CSong[] VisSongs = _Base.Songs.GetSongsNotSung();
|
||||
if (VisSongs == null)
|
||||
{
|
||||
_Base.Log.LogError("PartyChallengeMedleyMode Error: There are no songs!");
|
||||
_Base.Graphics.FadeTo(EScreens.ScreenParty);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < VisSongs.Length; i++)
|
||||
{
|
||||
foreach (EGameMode mode in VisSongs[i].AvailableGameModes)
|
||||
{
|
||||
if (mode == EGameMode.TR_GAMEMODE_MEDLEY)
|
||||
IDs.Add(VisSongs[i].ID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (IDs.Count == 0)
|
||||
{
|
||||
_Base.Log.LogError("PartyChallengeMedleyMode Error: There are no medley songs!");
|
||||
_Base.Graphics.FadeTo(EScreens.ScreenParty);
|
||||
return false;
|
||||
}
|
||||
|
||||
int s = 0;
|
||||
while (s < NumSongs && IDs.Count > 0)
|
||||
{
|
||||
int SongID = IDs[_Base.Game.GetRandom(IDs.Count)];
|
||||
_Base.Game.AddSong(SongID, gm);
|
||||
_Base.Songs.AddPartySongSung(SongID);
|
||||
IDs.Remove(SongID);
|
||||
s++;
|
||||
}
|
||||
return true;
|
||||
#endregion SongQueque
|
||||
}
|
||||
|
||||
private void SetNumJokers()
|
||||
{
|
||||
switch (GameData.NumPlayerAtOnce)
|
||||
{
|
||||
case 1:
|
||||
_ScreenSongOptions.Selection.NumJokers = new int[] { 10 };
|
||||
break;
|
||||
|
||||
case 2:
|
||||
_ScreenSongOptions.Selection.NumJokers = new int[] { 5, 5 };
|
||||
break;
|
||||
|
||||
case 3:
|
||||
_ScreenSongOptions.Selection.NumJokers = new int[] { 4, 4, 4 };
|
||||
break;
|
||||
|
||||
case 4:
|
||||
_ScreenSongOptions.Selection.NumJokers = new int[] { 3, 3, 3, 3 };
|
||||
break;
|
||||
|
||||
case 5:
|
||||
_ScreenSongOptions.Selection.NumJokers = new int[] { 2, 2, 2, 2, 2 };
|
||||
break;
|
||||
|
||||
case 6:
|
||||
_ScreenSongOptions.Selection.NumJokers = new int[] { 2, 2, 2, 2, 2, 2 };
|
||||
break;
|
||||
default:
|
||||
_ScreenSongOptions.Selection.NumJokers = new int[] { 5, 5 };
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetTeamNames()
|
||||
{
|
||||
SProfile[] profiles = _Base.Profiles.GetProfiles();
|
||||
|
||||
if (profiles == null)
|
||||
{
|
||||
_ScreenSongOptions.Selection.TeamNames = new string[] { "foo", "bar" };
|
||||
return;
|
||||
}
|
||||
|
||||
if (GameData.NumPlayerAtOnce < 1 || GameData.ProfileIDs.Count < GameData.NumPlayerAtOnce || profiles.Length < GameData.NumPlayerAtOnce)
|
||||
{
|
||||
_ScreenSongOptions.Selection.TeamNames = new string[] { "foo", "bar" };
|
||||
return;
|
||||
}
|
||||
|
||||
_ScreenSongOptions.Selection.TeamNames = new string[GameData.NumPlayerAtOnce];
|
||||
Combination c = GameData.Rounds.GetRound(GameData.CurrentRoundNr - 1);
|
||||
|
||||
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
if (c != null)
|
||||
{
|
||||
if (GameData.ProfileIDs[c.Player[i]] < profiles.Length)
|
||||
_ScreenSongOptions.Selection.TeamNames[i] = profiles[GameData.ProfileIDs[c.Player[i]]].PlayerName;
|
||||
else
|
||||
_ScreenSongOptions.Selection.TeamNames[i] = "foobar";
|
||||
}
|
||||
else
|
||||
_ScreenSongOptions.Selection.TeamNames[i] = "foobar";
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateScores()
|
||||
{
|
||||
if (GameData.ResultTable.Count == 0)
|
||||
{
|
||||
for (int i = 0; i < GameData.NumPlayer; i++)
|
||||
{
|
||||
ResultTableRow row = new ResultTableRow();
|
||||
row.PlayerID = GameData.ProfileIDs[i];
|
||||
row.NumPlayed = 0;
|
||||
row.NumRounds = 0;
|
||||
row.NumWon = 0;
|
||||
row.NumSingPoints = 0;
|
||||
row.NumGamePoints = 0;
|
||||
GameData.ResultTable.Add(row);
|
||||
}
|
||||
|
||||
GameData.Results = new int[GameData.NumRounds, GameData.NumPlayerAtOnce];
|
||||
for (int i = 0; i < GameData.NumRounds; i++)
|
||||
{
|
||||
for (int j = 0; j < GameData.NumPlayerAtOnce; j++)
|
||||
{
|
||||
GameData.Results[i, j] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CPoints GamePoints = _Base.Game.GetPoints();
|
||||
if (GamePoints == null || GamePoints.NumPlayer < GameData.NumPlayerAtOnce)
|
||||
return;
|
||||
|
||||
SPlayer[] results = GamePoints.GetPlayer(0, GameData.NumPlayerAtOnce);
|
||||
if (results == null)
|
||||
return;
|
||||
|
||||
if (results.Length < GameData.NumPlayerAtOnce)
|
||||
return;
|
||||
|
||||
if (GamePoints.NumRounds == 0)
|
||||
return;
|
||||
|
||||
for (int i = 1; i < GamePoints.NumRounds; i++)
|
||||
{
|
||||
SPlayer[] temp = GamePoints.GetPlayer(i, GameData.NumPlayerAtOnce);
|
||||
for (int p = 0; p < GameData.NumPlayerAtOnce; p++)
|
||||
{
|
||||
results[p].Points += temp[p].Points;
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < GameData.NumPlayerAtOnce; j++)
|
||||
{
|
||||
results[j].Points = results[j].Points / GamePoints.NumRounds;
|
||||
GameData.Results[GameData.CurrentRoundNr - 2, j] = (int)Math.Round(results[j].Points);
|
||||
}
|
||||
|
||||
List<Stats> points = GetPointsForPlayer(results);
|
||||
|
||||
for (int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
int index = -1;
|
||||
for (int j = 0; j < GameData.ResultTable.Count; j++)
|
||||
{
|
||||
if (points[i].ProfileID == GameData.ResultTable[j].PlayerID)
|
||||
{
|
||||
index = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
ResultTableRow row = GameData.ResultTable[index];
|
||||
|
||||
row.NumPlayed++;
|
||||
row.NumWon += points[i].Won;
|
||||
row.NumRounds += 1;
|
||||
row.NumSingPoints += points[i].SingPoints;
|
||||
row.NumGamePoints += points[i].GamePoints;
|
||||
|
||||
GameData.ResultTable[index] = row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GameData.ResultTable.Sort();
|
||||
|
||||
//Update position-number
|
||||
int pos = 1;
|
||||
int lastPoints = 0;
|
||||
int lastSingPoints = 0;
|
||||
for (int i = 0; i < GameData.ResultTable.Count; i++ )
|
||||
{
|
||||
if (lastPoints > GameData.ResultTable[i].NumGamePoints || lastSingPoints > GameData.ResultTable[i].NumSingPoints)
|
||||
pos++;
|
||||
GameData.ResultTable[i].Position = pos;
|
||||
lastPoints = GameData.ResultTable[i].NumGamePoints;
|
||||
lastSingPoints = GameData.ResultTable[i].NumSingPoints;
|
||||
}
|
||||
}
|
||||
|
||||
private List<Stats> GetPointsForPlayer(SPlayer[] Results)
|
||||
{
|
||||
List<Stats> result = new List<Stats>();
|
||||
for(int i = 0; i < GameData.NumPlayerAtOnce; i++)
|
||||
{
|
||||
Stats stat = new Stats();
|
||||
stat.ProfileID = Results[i].ProfileID;
|
||||
stat.SingPoints = (int)Math.Round(Results[i].Points);
|
||||
stat.Won = 0;
|
||||
stat.GamePoints = 0;
|
||||
result.Add(stat);
|
||||
}
|
||||
|
||||
result.Sort(delegate(Stats s1, Stats s2) { return s1.SingPoints.CompareTo(s2.SingPoints); });
|
||||
|
||||
int current = result[result.Count - 1].SingPoints;
|
||||
int points = result.Count;
|
||||
bool wonset = false;
|
||||
|
||||
for (int i = result.Count - 1; i >= 0; i--)
|
||||
{
|
||||
Stats res = result[i];
|
||||
|
||||
if (i < result.Count - 1)
|
||||
{
|
||||
if (current > res.SingPoints)
|
||||
{
|
||||
res.GamePoints = i * 2;
|
||||
wonset = true;
|
||||
points = res.GamePoints;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!wonset)
|
||||
res.Won = 1;
|
||||
res.GamePoints = points;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.GamePoints = i * 2;
|
||||
res.Won = 1;
|
||||
}
|
||||
|
||||
current = res.SingPoints;
|
||||
|
||||
result[i] = res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void CreateCatSongIndices()
|
||||
{
|
||||
if (GameData.CatSongIndices == null && _Base.Songs.GetNumCategories() > 0 && _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_ON)
|
||||
{
|
||||
GameData.CatSongIndices = new int[_Base.Songs.GetNumCategories()];
|
||||
for (int i = 0; i < GameData.CatSongIndices.Length; i++)
|
||||
{
|
||||
GameData.CatSongIndices[i] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (_Base.Songs.GetNumCategories() == 0 || _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF)
|
||||
GameData.CatSongIndices = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{6F3E1874-F28A-40E9-AFBD-31934D593678}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>PartyModeChallenge</RootNamespace>
|
||||
<AssemblyName>PartyModeChallenge</AssemblyName>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugWin|x86' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\Output\PartyModes\ChallengeMedley\Code</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;WIN</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseWin|x86' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\Output\PartyModes\ChallengeMedley\Code</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<DefineConstants>WIN</DefineConstants>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugWin|x64'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\Output\PartyModes\ChallengeMedley\Code</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;WIN</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWin|x64'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\Output\PartyModes\ChallengeMedley\Code</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<DefineConstants>WIN</DefineConstants>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugLinux|x86' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\Output\PartyModes\ChallengeMedley\Code</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;LINUX</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseLinux|x86' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\Output\PartyModes\ChallengeMedley\Code</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<DefineConstants>LINUX</DefineConstants>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugLinux|x64'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\Output\PartyModes\ChallengeMedley\Code</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;LINUX</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseLinux|x64'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\Output\PartyModes\ChallengeMedley\Code</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<DefineConstants>LINUX</DefineConstants>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ChallengeRounds.cs">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Compile>
|
||||
<Compile Include="PartyModeChallenge.cs">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Compile>
|
||||
<Compile Include="PartyScreenChallengeConfig.cs">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Compile>
|
||||
<Compile Include="PartyScreenChallengeMain.cs">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Compile>
|
||||
<Compile Include="PartyScreenChallengeNames.cs">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\VocaluxeLib\VocaluxeLib.csproj">
|
||||
<Project>{D2B6DDEF-E0E1-4DDF-A73A-E6ACEF5C95EC}</Project>
|
||||
<Name>VocaluxeLib</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.XML" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,257 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Vocaluxe.Menu;
|
||||
|
||||
namespace Vocaluxe.PartyModes
|
||||
{
|
||||
public class PartyScreenChallengeConfig : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
const int ScreenVersion = 1;
|
||||
|
||||
const string SelectSlideNumPlayers = "SelectSlideNumPlayers";
|
||||
const string SelectSlideNumMics = "SelectSlideNumMics";
|
||||
const string SelectSlideNumRounds = "SelectSlideNumRounds";
|
||||
const string ButtonNext = "ButtonNext";
|
||||
const string ButtonBack = "ButtonBack";
|
||||
|
||||
private int _MaxNumMics = 2;
|
||||
private int _MaxNumRounds = 100;
|
||||
private int _RoundSteps = 1;
|
||||
|
||||
DataFromScreen Data;
|
||||
|
||||
public PartyScreenChallengeConfig()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ThemeName = "PartyScreenChallengeConfig";
|
||||
_ThemeSelectSlides = new string[] { SelectSlideNumPlayers, SelectSlideNumMics, SelectSlideNumRounds };
|
||||
_ThemeButtons = new string[] { ButtonNext, ButtonBack };
|
||||
_ScreenVersion = ScreenVersion;
|
||||
|
||||
Data = new DataFromScreen();
|
||||
FromScreenConfig config = new FromScreenConfig();
|
||||
config.NumPlayer = 4;
|
||||
config.NumPlayerAtOnce = 2;
|
||||
config.NumRounds = 12;
|
||||
Data.ScreenConfig = config;
|
||||
}
|
||||
|
||||
public override void LoadTheme(string XmlPath)
|
||||
{
|
||||
base.LoadTheme(XmlPath);
|
||||
}
|
||||
|
||||
public override void DataToScreen(object ReceivedData)
|
||||
{
|
||||
DataToScreenConfig config = new DataToScreenConfig();
|
||||
|
||||
try
|
||||
{
|
||||
config = (DataToScreenConfig)ReceivedData;
|
||||
Data.ScreenConfig.NumPlayer = config.NumPlayer;
|
||||
Data.ScreenConfig.NumPlayerAtOnce = config.NumPlayerAtOnce;
|
||||
Data.ScreenConfig.NumRounds = config.NumRounds;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_Base.Log.LogError("Error in party mode screen challenge config. Can't cast received data from game mode " + _ThemeName + ". " + e.Message);;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override bool HandleInput(KeyEvent KeyEvent)
|
||||
{
|
||||
base.HandleInput(KeyEvent);
|
||||
|
||||
if (KeyEvent.KeyPressed)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (KeyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
Back();
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
UpdateSlides();
|
||||
|
||||
if (Buttons[htButtons(ButtonBack)].Selected)
|
||||
Back();
|
||||
|
||||
if (Buttons[htButtons(ButtonNext)].Selected)
|
||||
Next();
|
||||
break;
|
||||
|
||||
case Keys.Left:
|
||||
UpdateSlides();
|
||||
break;
|
||||
|
||||
case Keys.Right:
|
||||
UpdateSlides();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(MouseEvent MouseEvent)
|
||||
{
|
||||
base.HandleMouse(MouseEvent);
|
||||
|
||||
if (MouseEvent.LB && IsMouseOver(MouseEvent))
|
||||
{
|
||||
UpdateSlides();
|
||||
if (Buttons[htButtons(ButtonBack)].Selected)
|
||||
Back();
|
||||
|
||||
if (Buttons[htButtons(ButtonNext)].Selected)
|
||||
Next();
|
||||
}
|
||||
|
||||
if (MouseEvent.RB)
|
||||
{
|
||||
Back();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
_MaxNumMics = _Base.Config.GetMaxNumMics();
|
||||
if (_MaxNumMics > 6)
|
||||
_MaxNumMics = 6;
|
||||
|
||||
_MaxNumRounds = _PartyMode.GetMaxNumRounds();
|
||||
|
||||
RebuildSlides();
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
}
|
||||
|
||||
private void RebuildSlides()
|
||||
{
|
||||
// build num player slide (min player ... max player);
|
||||
SelectSlides[htSelectSlides(SelectSlideNumPlayers)].Clear();
|
||||
for (int i = _PartyMode.GetMinPlayer(); i <= _PartyMode.GetMaxPlayer(); i++)
|
||||
{
|
||||
SelectSlides[htSelectSlides(SelectSlideNumPlayers)].AddValue(i.ToString());
|
||||
}
|
||||
SelectSlides[htSelectSlides(SelectSlideNumPlayers)].Selection = Data.ScreenConfig.NumPlayer - _PartyMode.GetMinPlayer();
|
||||
|
||||
UpdateMicsAtOnce();
|
||||
SetRoundSteps();
|
||||
UpdateSlideRounds();
|
||||
}
|
||||
|
||||
private void UpdateSlides()
|
||||
{
|
||||
int player = Data.ScreenConfig.NumPlayer;
|
||||
int mics = Data.ScreenConfig.NumPlayerAtOnce;
|
||||
Data.ScreenConfig.NumPlayer = SelectSlides[htSelectSlides(SelectSlideNumPlayers)].Selection + _PartyMode.GetMinPlayer();
|
||||
Data.ScreenConfig.NumPlayerAtOnce = SelectSlides[htSelectSlides(SelectSlideNumMics)].Selection + _PartyMode.GetMinPlayer();
|
||||
Data.ScreenConfig.NumRounds = (SelectSlides[htSelectSlides(SelectSlideNumRounds)].Selection + 1) * _RoundSteps;
|
||||
|
||||
UpdateMicsAtOnce();
|
||||
SetRoundSteps();
|
||||
|
||||
if (player != Data.ScreenConfig.NumPlayer || mics != Data.ScreenConfig.NumPlayerAtOnce)
|
||||
{
|
||||
int num = CHelper.nCk(Data.ScreenConfig.NumPlayer, Data.ScreenConfig.NumPlayerAtOnce);
|
||||
while (num > _MaxNumRounds)
|
||||
{
|
||||
num -= _RoundSteps;
|
||||
}
|
||||
Data.ScreenConfig.NumRounds = num;
|
||||
}
|
||||
|
||||
UpdateSlideRounds();
|
||||
}
|
||||
|
||||
private void UpdateMicsAtOnce()
|
||||
{
|
||||
//Data.ScreenConfig.NumPlayerAtOnce
|
||||
int MaxNum = _MaxNumMics;
|
||||
if (Data.ScreenConfig.NumPlayer < _MaxNumMics)
|
||||
MaxNum = Data.ScreenConfig.NumPlayer;
|
||||
|
||||
if (Data.ScreenConfig.NumPlayerAtOnce > MaxNum)
|
||||
Data.ScreenConfig.NumPlayerAtOnce = MaxNum;
|
||||
|
||||
// build mics at once slide
|
||||
SelectSlides[htSelectSlides(SelectSlideNumMics)].Clear();
|
||||
for (int i = 1; i <= MaxNum; i++)
|
||||
{
|
||||
SelectSlides[htSelectSlides(SelectSlideNumMics)].AddValue(i.ToString());
|
||||
}
|
||||
SelectSlides[htSelectSlides(SelectSlideNumMics)].Selection = Data.ScreenConfig.NumPlayerAtOnce - _PartyMode.GetMinPlayer();
|
||||
}
|
||||
|
||||
private void UpdateSlideRounds()
|
||||
{
|
||||
// build num rounds slide
|
||||
SelectSlides[htSelectSlides(SelectSlideNumRounds)].Clear();
|
||||
for (int i = _RoundSteps; i <= _MaxNumRounds; i += _RoundSteps)
|
||||
{
|
||||
SelectSlides[htSelectSlides(SelectSlideNumRounds)].AddValue(i.ToString());
|
||||
}
|
||||
SelectSlides[htSelectSlides(SelectSlideNumRounds)].Selection = Data.ScreenConfig.NumRounds / _RoundSteps - 1;
|
||||
}
|
||||
|
||||
private void SetRoundSteps()
|
||||
{
|
||||
if (Data.ScreenConfig.NumPlayerAtOnce < 1 || Data.ScreenConfig.NumPlayer < 1 || Data.ScreenConfig.NumPlayerAtOnce > Data.ScreenConfig.NumPlayer)
|
||||
{
|
||||
_RoundSteps = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
int res = Data.ScreenConfig.NumPlayer / Data.ScreenConfig.NumPlayerAtOnce;
|
||||
int mod = Data.ScreenConfig.NumPlayer % Data.ScreenConfig.NumPlayerAtOnce;
|
||||
|
||||
if (mod == 0)
|
||||
_RoundSteps = res;
|
||||
else
|
||||
_RoundSteps = Data.ScreenConfig.NumPlayer;
|
||||
}
|
||||
|
||||
private void Back()
|
||||
{
|
||||
FadeTo(EScreens.ScreenParty);
|
||||
}
|
||||
|
||||
private void Next()
|
||||
{
|
||||
_PartyMode.DataFromScreen(_ThemeName, Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,659 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Vocaluxe.Menu;
|
||||
|
||||
namespace Vocaluxe.PartyModes
|
||||
{
|
||||
struct TableRow
|
||||
{
|
||||
public CText Pos;
|
||||
public CText Name;
|
||||
public CText Rounds;
|
||||
public CText Won;
|
||||
public CText SingPoints;
|
||||
public CText GamePoints;
|
||||
}
|
||||
|
||||
class RoundsTableRow
|
||||
{
|
||||
public CText Number;
|
||||
public List<CText> TextPlayer;
|
||||
public List<CText> TextScores;
|
||||
}
|
||||
|
||||
|
||||
public class PartyScreenChallengeMain : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
const int ScreenVersion = 1;
|
||||
|
||||
const string TextPosition = "TextPosition";
|
||||
const string TextPlayerName = "TextPlayerName";
|
||||
const string TextNumPlayed = "TextNumPlayed";
|
||||
const string TextWon = "TextWon";
|
||||
const string TextSingPoints = "TextSingPoints";
|
||||
const string TextGamePoints = "TextGamePoints";
|
||||
const string TextNextPlayer = "TextNextPlayer";
|
||||
const string TextPopupReallyExit = "TextPopupReallyExit";
|
||||
const string TextRoundPlayer = "TextRoundPlayer";
|
||||
const string TextRoundScore = "TextRoundScore";
|
||||
const string TextRoundNumber = "TextRoundNumber";
|
||||
const string TextFinishMessage = "TextFinishMessage";
|
||||
const string TextFinishPlayerWin = "TextFinishPlayerWin";
|
||||
const string TextNextPlayerMessage = "TextNextPlayerMessage";
|
||||
|
||||
const string ButtonNextRound = "ButtonNextRound";
|
||||
const string ButtonBack = "ButtonBack";
|
||||
const string ButtonExit = "ButtonExit";
|
||||
const string ButtonPopupYes = "ButtonPopupYes";
|
||||
const string ButtonPopupNo = "ButtonPopupNo";
|
||||
const string ButtonPlayerScrollUp = "ButtonPlayerScrollUp";
|
||||
const string ButtonPlayerScrollDown = "ButtonPlayerScrollDown";
|
||||
const string ButtonRoundsScrollUp = "ButtonRoundsScrollUp";
|
||||
const string ButtonRoundsScrollDown = "ButtonRoundsScrollDown";
|
||||
|
||||
const string StaticPopupBG = "StaticPopupBG";
|
||||
const string StaticNextPlayer = "StaticNextPlayer";
|
||||
|
||||
private bool ExitPopupVisible = false;
|
||||
|
||||
private DataFromScreen Data;
|
||||
private DataToScreenMain GameState;
|
||||
private List<TableRow> PlayerTable;
|
||||
private List<RoundsTableRow> RoundsTable;
|
||||
|
||||
private List<CText> NextPlayerTexts;
|
||||
private List<CStatic> NextPlayerStatics;
|
||||
|
||||
private SRectF RoundsTableScrollArea;
|
||||
private SRectF PlayerTableScrollArea;
|
||||
private int RoundsTableOffset = 0;
|
||||
private int PlayerTableOffset = 0;
|
||||
private int NumPlayerVisible = 10;
|
||||
private int NumRoundsVisible = 3;
|
||||
|
||||
public PartyScreenChallengeMain()
|
||||
{
|
||||
Data = new DataFromScreen();
|
||||
Data.ScreenMain = new FromScreenMain();
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
_ThemeName = "PartyScreenChallengeMain";
|
||||
_ThemeTexts = new string[] { 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 };
|
||||
_ScreenVersion = ScreenVersion;
|
||||
}
|
||||
|
||||
public override void LoadTheme(string XmlPath)
|
||||
{
|
||||
base.LoadTheme(XmlPath);
|
||||
|
||||
GameState = new DataToScreenMain();
|
||||
BuildPlayerTable();
|
||||
CreateRoundsTable();
|
||||
NextPlayerTexts = new List<CText>();
|
||||
NextPlayerStatics = new List<CStatic>();
|
||||
|
||||
for (int i = 0; i < _PartyMode.GetMaxPlayer(); i++)
|
||||
{
|
||||
NextPlayerTexts.Add(GetNewText(Texts[htTexts(TextNextPlayer)]));
|
||||
AddText(NextPlayerTexts[NextPlayerTexts.Count - 1]);
|
||||
NextPlayerStatics.Add(GetNewStatic(Statics[htStatics(StaticNextPlayer)]));
|
||||
AddStatic(NextPlayerStatics[NextPlayerStatics.Count - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
public override void DataToScreen(object ReceivedData)
|
||||
{
|
||||
DataToScreenMain data = new DataToScreenMain();
|
||||
|
||||
try
|
||||
{
|
||||
data = (DataToScreenMain)ReceivedData;
|
||||
GameState = data;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_Base.Log.LogError("Error in party mode screen challenge main. Can't cast received data from game mode " + _ThemeName + ". " + e.Message); ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override bool HandleInput(KeyEvent KeyEvent)
|
||||
{
|
||||
base.HandleInput(KeyEvent);
|
||||
|
||||
if (KeyEvent.KeyPressed)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (KeyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
if (!ExitPopupVisible)
|
||||
if (GameState.CurrentRoundNr == 1)
|
||||
Back();
|
||||
else
|
||||
ShowPopup(true);
|
||||
else
|
||||
ShowPopup(false);
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
if (!ExitPopupVisible)
|
||||
{
|
||||
if (Buttons[htButtons(ButtonNextRound)].Selected)
|
||||
NextRound();
|
||||
if (Buttons[htButtons(ButtonBack)].Selected && GameState.CurrentRoundNr == 1)
|
||||
Back();
|
||||
if (Buttons[htButtons(ButtonExit)].Selected && GameState.CurrentRoundNr > 1)
|
||||
ShowPopup(true);
|
||||
if (Buttons[htButtons(ButtonPlayerScrollUp)].Selected)
|
||||
ScrollPlayerTable(-1);
|
||||
if (Buttons[htButtons(ButtonPlayerScrollDown)].Selected)
|
||||
ScrollPlayerTable(1);
|
||||
if (Buttons[htButtons(ButtonRoundsScrollUp)].Selected)
|
||||
ScrollRoundsTable(-1);
|
||||
if (Buttons[htButtons(ButtonRoundsScrollDown)].Selected)
|
||||
ScrollRoundsTable(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Buttons[htButtons(ButtonPopupYes)].Selected)
|
||||
EndParty();
|
||||
if (Buttons[htButtons(ButtonPopupNo)].Selected)
|
||||
ShowPopup(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(MouseEvent MouseEvent)
|
||||
{
|
||||
base.HandleMouse(MouseEvent);
|
||||
|
||||
if (MouseEvent.LB && IsMouseOver(MouseEvent))
|
||||
{
|
||||
if (!ExitPopupVisible)
|
||||
{
|
||||
if (Buttons[htButtons(ButtonNextRound)].Selected)
|
||||
NextRound();
|
||||
if (Buttons[htButtons(ButtonBack)].Selected && GameState.CurrentRoundNr == 1)
|
||||
Back();
|
||||
if (Buttons[htButtons(ButtonExit)].Selected && GameState.CurrentRoundNr > 1)
|
||||
ShowPopup(true);
|
||||
if (Buttons[htButtons(ButtonPlayerScrollUp)].Selected)
|
||||
ScrollPlayerTable(-1);
|
||||
if (Buttons[htButtons(ButtonPlayerScrollDown)].Selected)
|
||||
ScrollPlayerTable(1);
|
||||
if (Buttons[htButtons(ButtonRoundsScrollUp)].Selected)
|
||||
ScrollRoundsTable(-1);
|
||||
if (Buttons[htButtons(ButtonRoundsScrollDown)].Selected)
|
||||
ScrollRoundsTable(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Buttons[htButtons(ButtonPopupYes)].Selected)
|
||||
EndParty();
|
||||
if (Buttons[htButtons(ButtonPopupNo)].Selected)
|
||||
ShowPopup(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (MouseEvent.RB)
|
||||
{
|
||||
if (!ExitPopupVisible)
|
||||
if (GameState.CurrentRoundNr == 1)
|
||||
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;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
PlayerTableOffset = 0;
|
||||
RoundsTableOffset = 0;
|
||||
|
||||
UpdatePlayerTable();
|
||||
UpdateNextPlayerPositions();
|
||||
UpdateNextPlayerContents();
|
||||
if (GameState.CurrentRoundNr == 1)
|
||||
BuildRoundsTable();
|
||||
else
|
||||
ScrollRoundsTable(GameState.CurrentRoundNr - 2);
|
||||
UpdateRoundsTable();
|
||||
|
||||
if (GameState.CurrentRoundNr == 1)
|
||||
{
|
||||
Buttons[htButtons(ButtonBack)].Visible = true;
|
||||
Buttons[htButtons(ButtonExit)].Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Buttons[htButtons(ButtonBack)].Visible = false;
|
||||
Buttons[htButtons(ButtonExit)].Visible = true;
|
||||
}
|
||||
|
||||
if (GameState.CurrentRoundNr <= GameState.Combs.Count)
|
||||
{
|
||||
Buttons[htButtons(ButtonNextRound)].Visible = true;
|
||||
Texts[htTexts(TextFinishMessage)].Visible = false;
|
||||
Texts[htTexts(TextFinishPlayerWin)].Visible = false;
|
||||
SetInteractionToButton(Buttons[htButtons(ButtonNextRound)]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Buttons[htButtons(ButtonNextRound)].Visible = false;
|
||||
Texts[htTexts(TextFinishMessage)].Visible = true;
|
||||
Texts[htTexts(TextFinishPlayerWin)].Visible = true;
|
||||
Texts[htTexts(TextFinishPlayerWin)].Text = GetPlayerWinString();
|
||||
SetInteractionToButton(Buttons[htButtons(ButtonExit)]);
|
||||
}
|
||||
|
||||
ShowPopup(false);
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
}
|
||||
|
||||
private void NextRound()
|
||||
{
|
||||
Data.ScreenMain.FadeToNameSelection = false;
|
||||
Data.ScreenMain.FadeToSongSelection = true;
|
||||
_PartyMode.DataFromScreen(_ThemeName, Data);
|
||||
}
|
||||
|
||||
private void EndParty()
|
||||
{
|
||||
FadeTo(EScreens.ScreenParty);
|
||||
}
|
||||
|
||||
private void ShowPopup(bool Visible)
|
||||
{
|
||||
ExitPopupVisible = Visible;
|
||||
|
||||
Statics[htStatics(StaticPopupBG)].Visible = ExitPopupVisible;
|
||||
Texts[htTexts(TextPopupReallyExit)].Visible = ExitPopupVisible;
|
||||
Buttons[htButtons(ButtonPopupYes)].Visible = ExitPopupVisible;
|
||||
Buttons[htButtons(ButtonPopupNo)].Visible = ExitPopupVisible;
|
||||
|
||||
if (ExitPopupVisible)
|
||||
SetInteractionToButton(Buttons[htButtons(ButtonPopupNo)]);
|
||||
}
|
||||
|
||||
private void Back()
|
||||
{
|
||||
Data.ScreenMain.FadeToNameSelection = true;
|
||||
Data.ScreenMain.FadeToSongSelection = false;
|
||||
_PartyMode.DataFromScreen(_ThemeName, Data);
|
||||
}
|
||||
|
||||
private void UpdateNextPlayerPositions()
|
||||
{
|
||||
float x = _Base.Settings.GetRenderW()/2 - ((GameState.NumPlayerAtOnce * Statics[htStatics(StaticNextPlayer)].Rect.W) + ((GameState.NumPlayerAtOnce-1) * 15))/2;
|
||||
float static_y = 590;
|
||||
float text_y = 550;
|
||||
for (int i = 0; i < GameState.NumPlayerAtOnce; i++)
|
||||
{
|
||||
//static
|
||||
NextPlayerStatics[i].Rect.X = x;
|
||||
NextPlayerStatics[i].Rect.Y = static_y;
|
||||
NextPlayerStatics[i].Visible = true;
|
||||
//text
|
||||
NextPlayerTexts[i].X = x + Statics[htStatics(StaticNextPlayer)].Rect.W / 2;
|
||||
NextPlayerTexts[i].Y = text_y;
|
||||
NextPlayerTexts[i].Visible = true;
|
||||
|
||||
x += Statics[htStatics(StaticNextPlayer)].Rect.W + 15;
|
||||
}
|
||||
for (int i = GameState.NumPlayerAtOnce; i < _PartyMode.GetMaxPlayer(); i++)
|
||||
{
|
||||
NextPlayerStatics[i].Visible = false;
|
||||
NextPlayerTexts[i].Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateNextPlayerContents()
|
||||
{
|
||||
if (GameState.CurrentRoundNr <= GameState.Combs.Count)
|
||||
{
|
||||
Texts[htTexts(TextNextPlayerMessage)].Visible = true;
|
||||
SProfile[] profiles = _Base.Profiles.GetProfiles();
|
||||
for (int i = 0; i < GameState.NumPlayerAtOnce; i++)
|
||||
{
|
||||
int pid = GameState.Combs[GameState.CurrentRoundNr - 1].Player[i];
|
||||
NextPlayerStatics[i].Texture = profiles[GameState.ProfileIDs[pid]].Avatar.Texture;
|
||||
NextPlayerTexts[i].Text = profiles[GameState.ProfileIDs[pid]].PlayerName;
|
||||
NextPlayerTexts[i].Color = _Base.Theme.GetPlayerColor((i + 1));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Texts[htTexts(TextNextPlayerMessage)].Visible = false;
|
||||
for (int i = 0; i < GameState.NumPlayerAtOnce; i++)
|
||||
{
|
||||
NextPlayerStatics[i].Visible = false;
|
||||
NextPlayerTexts[i].Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateRoundsTable()
|
||||
{
|
||||
//Create lists
|
||||
RoundsTable = new List<RoundsTableRow>();
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
RoundsTableRow rtr = new RoundsTableRow();
|
||||
rtr.TextPlayer = new List<CText>();
|
||||
rtr.TextScores = new List<CText>();
|
||||
RoundsTable.Add(rtr);
|
||||
}
|
||||
//Create statics and texts for rounds
|
||||
for (int round = 0; round < RoundsTable.Count; round++)
|
||||
{
|
||||
//Round-number
|
||||
CText text = GetNewText(Texts[htTexts(TextRoundNumber)]);
|
||||
AddText(text);
|
||||
RoundsTable[round].Number = text;
|
||||
for (int row = 0; row < 2; row++)
|
||||
{
|
||||
for (int column = 0; column < 3; column++)
|
||||
{
|
||||
//Player
|
||||
text = GetNewText(Texts[htTexts(TextRoundPlayer)]);
|
||||
AddText(text);
|
||||
RoundsTable[round].TextPlayer.Add(text);
|
||||
//Score
|
||||
text = GetNewText(Texts[htTexts(TextRoundScore)]);
|
||||
AddText(text);
|
||||
RoundsTable[round].TextScores.Add(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildRoundsTable()
|
||||
{
|
||||
RoundsTableScrollArea = new SRectF();
|
||||
|
||||
int NumPlayerInOneRow = 3;
|
||||
if (GameState.NumPlayerAtOnce <= NumPlayerInOneRow)
|
||||
NumRoundsVisible = 5;
|
||||
else
|
||||
NumRoundsVisible = 3;
|
||||
|
||||
if (NumRoundsVisible > GameState.Combs.Count)
|
||||
NumRoundsVisible = GameState.Combs.Count;
|
||||
|
||||
float x = Texts[htTexts(TextRoundNumber)].X;
|
||||
float y = Texts[htTexts(TextRoundNumber)].Y;
|
||||
|
||||
RoundsTableScrollArea.X = x;
|
||||
RoundsTableScrollArea.Y = y;
|
||||
RoundsTableScrollArea.W = _Base.Settings.GetRenderW() - Texts[htTexts(TextRoundNumber)].X - 20;
|
||||
|
||||
float delta = Texts[htTexts(TextRoundNumber)].Height;
|
||||
|
||||
//Update statics and texts for rounds
|
||||
for (int round = 0; round < RoundsTable.Count; round++)
|
||||
{
|
||||
//Round-number
|
||||
RoundsTable[round].Number.X = x;
|
||||
RoundsTable[round].Number.Y = y;
|
||||
int NumInnerRows = (int)Math.Ceiling(GameState.NumPlayerAtOnce / ((double)NumPlayerInOneRow));
|
||||
for (int row = 0; row < NumInnerRows; row++)
|
||||
{
|
||||
int num = (row + 1) * NumPlayerInOneRow;
|
||||
int NumPlayerInThisRow = NumPlayerInOneRow;
|
||||
if (num > GameState.NumPlayerAtOnce)
|
||||
{
|
||||
num = GameState.NumPlayerAtOnce;
|
||||
NumPlayerInThisRow = GameState.NumPlayerAtOnce - (row * NumPlayerInOneRow);
|
||||
}
|
||||
for (int column = row * NumPlayerInOneRow; column < num; column++)
|
||||
{
|
||||
//Player
|
||||
float _x = x + 15 + (_Base.Settings.GetRenderW() - Texts[htTexts(TextRoundNumber)].X - 20) / NumPlayerInThisRow * (column - row * NumPlayerInOneRow) + ((_Base.Settings.GetRenderW() - Texts[htTexts(TextRoundNumber)].X - 20) / NumPlayerInThisRow) / 2;
|
||||
float maxw = ((_Base.Settings.GetRenderW() - Texts[htTexts(TextRoundNumber)].X - 20) / NumPlayerInThisRow) / 2 - 5;
|
||||
RoundsTable[round].TextPlayer[column].X = _x;
|
||||
RoundsTable[round].TextPlayer[column].Y = y;
|
||||
RoundsTable[round].TextPlayer[column].MaxWidth = maxw;
|
||||
//Score
|
||||
RoundsTable[round].TextScores[column] = RoundsTable[round].TextScores[column];
|
||||
RoundsTable[round].TextScores[column].X = _x;
|
||||
RoundsTable[round].TextScores[column].Y = y + delta;
|
||||
RoundsTable[round].TextScores[column].MaxWidth = maxw;
|
||||
}
|
||||
y = y + delta + delta;
|
||||
}
|
||||
y = y + delta / 2;
|
||||
}
|
||||
RoundsTableScrollArea.H = y - RoundsTableScrollArea.Y;
|
||||
}
|
||||
|
||||
private void UpdateRoundsTable()
|
||||
{
|
||||
SProfile[] profile = _Base.Profiles.GetProfiles();
|
||||
for (int i = 0; i < RoundsTable.Count; i++)
|
||||
{
|
||||
for(int p = 0; p < RoundsTable[i].TextPlayer.Count; p++)
|
||||
{
|
||||
if (GameState.Combs.Count > i + RoundsTableOffset && GameState.Combs[i + RoundsTableOffset].Player.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).ToString() + ")";
|
||||
int pID = GameState.ProfileIDs[GameState.Combs[i + RoundsTableOffset].Player[p]];
|
||||
RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName;
|
||||
if ((GameState.CurrentRoundNr - 1) > i + RoundsTableOffset)
|
||||
RoundsTable[i].TextScores[p].Text = GameState.Results[i + RoundsTableOffset, p].ToString();
|
||||
else
|
||||
RoundsTable[i].TextScores[p].Text = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
RoundsTable[i].TextPlayer[p].Visible = false;
|
||||
RoundsTable[i].TextScores[p].Visible = false;
|
||||
}
|
||||
}
|
||||
if (GameState.Combs.Count < i + RoundsTableOffset || i + 1 > NumRoundsVisible)
|
||||
{
|
||||
RoundsTable[i].Number.Visible = false;
|
||||
for (int p = 0; p < RoundsTable[i].TextPlayer.Count; p++)
|
||||
{
|
||||
RoundsTable[i].TextPlayer[p].Visible = false;
|
||||
RoundsTable[i].TextScores[p].Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Buttons[htButtons(ButtonRoundsScrollUp)].Visible = RoundsTableOffset > 0;
|
||||
Buttons[htButtons(ButtonRoundsScrollDown)].Visible = GameState.Combs.Count - NumRoundsVisible - RoundsTableOffset > 0;
|
||||
}
|
||||
|
||||
private void BuildPlayerTable()
|
||||
{
|
||||
PlayerTableScrollArea = new SRectF();
|
||||
PlayerTableScrollArea.X = Texts[htTexts(TextPosition)].X;
|
||||
PlayerTableScrollArea.Y = Texts[htTexts(TextPosition)].Y;
|
||||
PlayerTableScrollArea.W = Texts[htTexts(TextGamePoints)].X - Texts[htTexts(TextPosition)].X;
|
||||
|
||||
PlayerTable = new List<TableRow>();
|
||||
float delta = Texts[htTexts(TextPosition)].Height * 1.2f;
|
||||
|
||||
float h = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
TableRow row = new TableRow();
|
||||
|
||||
row.Pos = GetNewText(Texts[htTexts(TextPosition)]);
|
||||
row.Name = GetNewText(Texts[htTexts(TextPlayerName)]);
|
||||
row.Rounds = GetNewText(Texts[htTexts(TextNumPlayed)]);
|
||||
row.Won = GetNewText(Texts[htTexts(TextWon)]);
|
||||
row.SingPoints = GetNewText(Texts[htTexts(TextSingPoints)]);
|
||||
row.GamePoints = GetNewText(Texts[htTexts(TextGamePoints)]);
|
||||
|
||||
row.Pos.Y += delta * (i + 1);
|
||||
row.Name.Y += delta * (i + 1);
|
||||
row.Rounds.Y += delta * (i + 1);
|
||||
row.Won.Y += delta * (i + 1);
|
||||
row.SingPoints.Y += delta * (i + 1);
|
||||
row.GamePoints.Y += delta * (i + 1);
|
||||
|
||||
row.Pos.Text = (i + 1).ToString() + ".";
|
||||
|
||||
row.Pos.Visible = false;
|
||||
row.Name.Visible = false;
|
||||
row.Rounds.Visible = false;
|
||||
row.Won.Visible = false;
|
||||
row.SingPoints.Visible = false;
|
||||
row.GamePoints.Visible = false;
|
||||
|
||||
AddText(row.Pos);
|
||||
AddText(row.Name);
|
||||
AddText(row.Rounds);
|
||||
AddText(row.Won);
|
||||
AddText(row.SingPoints);
|
||||
AddText(row.GamePoints);
|
||||
|
||||
PlayerTable.Add(row);
|
||||
|
||||
h = delta * (i + 1);
|
||||
}
|
||||
PlayerTableScrollArea.H = h + delta;
|
||||
}
|
||||
|
||||
private void UpdatePlayerTable()
|
||||
{
|
||||
SProfile[] profiles = _Base.Profiles.GetProfiles();
|
||||
|
||||
for (int i = 0; i < PlayerTable.Count; i++)
|
||||
{
|
||||
TableRow row = PlayerTable[i];
|
||||
|
||||
if (i+PlayerTableOffset < GameState.ResultTable.Count)
|
||||
{
|
||||
row.Pos.Visible = true;
|
||||
row.Name.Visible = true;
|
||||
row.Rounds.Visible = true;
|
||||
row.Won.Visible = true;
|
||||
row.SingPoints.Visible = true;
|
||||
row.GamePoints.Visible = true;
|
||||
|
||||
row.Pos.Text = GameState.ResultTable[i + PlayerTableOffset].Position.ToString() + ".";
|
||||
row.Name.Text = profiles[GameState.ResultTable[i+PlayerTableOffset].PlayerID].PlayerName;
|
||||
row.Rounds.Text = GameState.ResultTable[i+PlayerTableOffset].NumRounds.ToString();
|
||||
row.Won.Text = GameState.ResultTable[i+PlayerTableOffset].NumWon.ToString();
|
||||
row.SingPoints.Text = GameState.ResultTable[i+PlayerTableOffset].NumSingPoints.ToString();
|
||||
row.GamePoints.Text = GameState.ResultTable[i+PlayerTableOffset].NumGamePoints.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
row.Pos.Visible = false;
|
||||
row.Name.Visible = false;
|
||||
row.Rounds.Visible = false;
|
||||
row.Won.Visible = false;
|
||||
row.SingPoints.Visible = false;
|
||||
row.GamePoints.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
Buttons[htButtons(ButtonPlayerScrollUp)].Visible = PlayerTableOffset > 0;
|
||||
Buttons[htButtons(ButtonPlayerScrollDown)].Visible = GameState.ProfileIDs.Count - NumPlayerVisible - PlayerTableOffset > 0;
|
||||
}
|
||||
|
||||
private void ScrollPlayerTable(int Offset)
|
||||
{
|
||||
if (GameState.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 <= GameState.ProfileIDs.Count - NumPlayerVisible)
|
||||
PlayerTableOffset += Offset;
|
||||
else if (Offset > 0 && PlayerTableOffset + Offset > GameState.ProfileIDs.Count - NumPlayerVisible)
|
||||
PlayerTableOffset = GameState.ProfileIDs.Count - NumPlayerVisible;
|
||||
|
||||
UpdatePlayerTable();
|
||||
}
|
||||
|
||||
private void ScrollRoundsTable(int Offset)
|
||||
{
|
||||
if (GameState.Combs.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 <= GameState.Combs.Count - NumRoundsVisible)
|
||||
RoundsTableOffset += Offset;
|
||||
else if (Offset > 0 && RoundsTableOffset + Offset > GameState.Combs.Count - NumRoundsVisible)
|
||||
RoundsTableOffset = GameState.Combs.Count - NumRoundsVisible;
|
||||
|
||||
UpdateRoundsTable();
|
||||
}
|
||||
|
||||
private string GetPlayerWinString()
|
||||
{
|
||||
string s = "";
|
||||
SProfile[] profiles = _Base.Profiles.GetProfiles();
|
||||
|
||||
for (int i = 0; i < GameState.ResultTable.Count; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
s += ", ";
|
||||
if (GameState.ResultTable[i].Position == 1)
|
||||
s += profiles[GameState.ResultTable[i].PlayerID].PlayerName;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,534 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Vocaluxe.Menu;
|
||||
|
||||
namespace Vocaluxe.PartyModes
|
||||
{
|
||||
public class PartyScreenChallengeNames : CMenuParty
|
||||
{
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
const int ScreenVersion = 1;
|
||||
|
||||
const string ButtonNext = "ButtonNext";
|
||||
const string ButtonBack = "ButtonBack";
|
||||
const string ButtonPlayerDestination = "ButtonPlayerDestination";
|
||||
const string ButtonPlayerChoose = "ButtonPlayerChoose";
|
||||
|
||||
private List<CPlayerChooseButton> PlayerChooseButtons;
|
||||
private List<CButton> PlayerDestinationButtons;
|
||||
//PlayerDestinationButtons-Option
|
||||
private const int PlayerDestinationButtonsNumH = 3;
|
||||
private const int PlayerDestinationButtonsNumW = 4;
|
||||
private const int PlayerDestinationButtonsFirstX = 900;
|
||||
private const int PlayerDestinationButtonsFirstY = 105;
|
||||
private const int PlayerDestinationButtonsSpaceH = 15;
|
||||
private const int PlayerDestinationButtonsSpaceW = 25;
|
||||
//PlayerChooseButtons-Option
|
||||
private List<int> PlayerChooseButtonsVisibleProfiles;
|
||||
private const int PlayerChooseButtonsNumH = 7;
|
||||
private const int PlayerChooseButtonsNumW = 4;
|
||||
private const int PlayerChooseButtonsFirstX = 52;
|
||||
private const int PlayerChooseButtonsFirstY = 105;
|
||||
private const int PlayerChooseButtonsSpaceH = 15;
|
||||
private const int PlayerChooseButtonsSpaceW = 25;
|
||||
private int PlayerChooseButtonsOffset = 0;
|
||||
|
||||
private CStatic chooseAvatarStatic;
|
||||
private bool SelectingMouseActive = false;
|
||||
private int OldMouseX = 0;
|
||||
private int OldMouseY = 0;
|
||||
private int SelectedPlayerNr = -1;
|
||||
private bool ButtonsAdded = false;
|
||||
|
||||
private int NumPlayer = 4;
|
||||
|
||||
private DataFromScreen Data;
|
||||
|
||||
private class CPlayerChooseButton
|
||||
{
|
||||
public CButton Button;
|
||||
public int ProfileID;
|
||||
}
|
||||
|
||||
public PartyScreenChallengeNames()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
chooseAvatarStatic = GetNewStatic();
|
||||
chooseAvatarStatic.Visible = false;
|
||||
|
||||
PlayerChooseButtonsVisibleProfiles = new List<int>();
|
||||
|
||||
Data.ScreenNames.ProfileIDs = new List<int>();
|
||||
|
||||
_ThemeName = "PartyScreenChallengeNames";
|
||||
List<string> buttons = new List<string>();
|
||||
_ThemeButtons = new string[] { ButtonBack, ButtonNext, ButtonPlayerDestination, ButtonPlayerChoose };
|
||||
_ScreenVersion = ScreenVersion;
|
||||
|
||||
Data = new DataFromScreen();
|
||||
FromScreenNames names = new FromScreenNames();
|
||||
names.FadeToConfig = false;
|
||||
names.FadeToMain = false;
|
||||
names.ProfileIDs = new List<int>();
|
||||
Data.ScreenNames = names;
|
||||
}
|
||||
|
||||
public override void LoadTheme(string XmlPath)
|
||||
{
|
||||
base.LoadTheme(XmlPath);
|
||||
}
|
||||
|
||||
public override void DataToScreen(object ReceivedData)
|
||||
{
|
||||
DataToScreenNames config = new DataToScreenNames();
|
||||
|
||||
try
|
||||
{
|
||||
config = (DataToScreenNames)ReceivedData;
|
||||
Data.ScreenNames.ProfileIDs = config.ProfileIDs;
|
||||
if (Data.ScreenNames.ProfileIDs == null)
|
||||
Data.ScreenNames.ProfileIDs = new List<int>();
|
||||
|
||||
NumPlayer = config.NumPlayer;
|
||||
|
||||
while (Data.ScreenNames.ProfileIDs.Count > NumPlayer)
|
||||
{
|
||||
Data.ScreenNames.ProfileIDs.RemoveAt(Data.ScreenNames.ProfileIDs.Count - 1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_Base.Log.LogError("Error in party mode screen challenge names. Can't cast received data from game mode " + _ThemeName + ". " + e.Message); ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override bool HandleInput(KeyEvent KeyEvent)
|
||||
{
|
||||
base.HandleInput(KeyEvent);
|
||||
|
||||
if (KeyEvent.KeyPressed)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (KeyEvent.Key)
|
||||
{
|
||||
case Keys.Back:
|
||||
case Keys.Escape:
|
||||
Back();
|
||||
break;
|
||||
|
||||
case Keys.Enter:
|
||||
if (Buttons[htButtons(ButtonBack)].Selected)
|
||||
Back();
|
||||
|
||||
if (Buttons[htButtons(ButtonNext)].Selected)
|
||||
Next();
|
||||
|
||||
if (!OnAdd())
|
||||
OnRemove();
|
||||
break;
|
||||
|
||||
case Keys.Delete:
|
||||
OnRemove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool HandleMouse(MouseEvent MouseEvent)
|
||||
{
|
||||
base.HandleMouse(MouseEvent);
|
||||
|
||||
/*
|
||||
//Check if LeftButton is hold and Select-Mode inactive
|
||||
if (MouseEvent.LBH && !SelectingMouseActive)
|
||||
{
|
||||
//Save mouse-coords
|
||||
OldMouseX = MouseEvent.X;
|
||||
OldMouseY = MouseEvent.Y;
|
||||
//Check if mouse if over tile
|
||||
for (int i = 0; i < PlayerChooseButtons.Count; i++)
|
||||
{
|
||||
if (PlayerChooseButtons[i].Button.Selected)
|
||||
{
|
||||
SelectedPlayerNr = PlayerChooseButtons[i].ProfileID;
|
||||
if (SelectedPlayerNr != -1)
|
||||
{
|
||||
//Activate mouse-selecting
|
||||
SelectingMouseActive = true;
|
||||
//Update of Drag/Drop-Texture
|
||||
chooseAvatarStatic.Visible = true;
|
||||
chooseAvatarStatic.Rect = PlayerChooseButtons[i].Button.Rect;
|
||||
chooseAvatarStatic.Rect.Z = -100;
|
||||
chooseAvatarStatic.Color = new SColorF(1, 1, 1, 1);
|
||||
chooseAvatarStatic.Texture = _Base.Profiles.GetProfiles()[SelectedPlayerNr].Avatar.Texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
//Check if LeftButton is hold and Select-Mode active
|
||||
if (MouseEvent.LBH && SelectingMouseActive)
|
||||
{
|
||||
//Update coords for Drag/Drop-Texture
|
||||
chooseAvatarStatic.Rect.X += (MouseEvent.X - OldMouseX);
|
||||
chooseAvatarStatic.Rect.Y += (MouseEvent.Y - OldMouseY);
|
||||
OldMouseX = MouseEvent.X;
|
||||
OldMouseY = MouseEvent.Y;
|
||||
}
|
||||
// LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar
|
||||
else if (SelectingMouseActive)
|
||||
{
|
||||
//Check if really a player was selected
|
||||
if (SelectedPlayerNr != -1)
|
||||
{
|
||||
//Foreach Drop-Area
|
||||
for (int i = 0; i < PlayerDestinationButtons.Count; i++)
|
||||
{
|
||||
//Check first, if area is "active"
|
||||
if (PlayerDestinationButtons[i].Visible == true)
|
||||
{
|
||||
//Check if Mouse is in area
|
||||
if (CHelper.IsInBounds(PlayerDestinationButtons[i].Rect, MouseEvent))
|
||||
{
|
||||
int added = -1;
|
||||
//Add Player-ID to list.
|
||||
if (Data.ScreenNames.ProfileIDs.Count < (i + 1))
|
||||
{
|
||||
Data.ScreenNames.ProfileIDs.Add(SelectedPlayerNr);
|
||||
added = Data.ScreenNames.ProfileIDs.Count - 1;
|
||||
}
|
||||
else if (Data.ScreenNames.ProfileIDs.Count >= (i + 1))
|
||||
{
|
||||
Data.ScreenNames.ProfileIDs[i] = SelectedPlayerNr;
|
||||
added = i;
|
||||
}
|
||||
UpdateButtonNext();
|
||||
//Update texture and name
|
||||
PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
|
||||
PlayerDestinationButtons[added].SColor = new SColorF(1, 1, 1, 1);
|
||||
PlayerDestinationButtons[added].Texture = chooseAvatarStatic.Texture;
|
||||
PlayerDestinationButtons[added].STexture = chooseAvatarStatic.Texture;
|
||||
PlayerDestinationButtons[added].Text.Text = _Base.Profiles.GetProfiles()[SelectedPlayerNr].PlayerName;
|
||||
//Update Tiles-List
|
||||
UpdateButtonPlayerChoose();
|
||||
}
|
||||
}
|
||||
}
|
||||
SelectedPlayerNr = -1;
|
||||
}
|
||||
//Reset variables
|
||||
SelectingMouseActive = false;
|
||||
chooseAvatarStatic.Visible = false;
|
||||
}
|
||||
|
||||
if (MouseEvent.LB && IsMouseOver(MouseEvent))
|
||||
{
|
||||
if (Buttons[htButtons(ButtonBack)].Selected)
|
||||
Back();
|
||||
|
||||
if (Buttons[htButtons(ButtonNext)].Selected)
|
||||
Next();
|
||||
|
||||
if (!OnAdd())
|
||||
OnRemove();
|
||||
}
|
||||
|
||||
if (MouseEvent.RB)
|
||||
{
|
||||
Back();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
base.OnShow();
|
||||
|
||||
if (!ButtonsAdded)
|
||||
{
|
||||
AddButtonPlayerDestination();
|
||||
AddButtonPlayerChoose();
|
||||
ButtonsAdded = true;
|
||||
}
|
||||
|
||||
UpdateButtonPlayerDestination();
|
||||
UpdateButtonPlayerChoose();
|
||||
|
||||
UpdateButtonNext();
|
||||
}
|
||||
|
||||
public override bool UpdateGame()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Draw()
|
||||
{
|
||||
base.Draw();
|
||||
if (chooseAvatarStatic.Visible)
|
||||
chooseAvatarStatic.Draw();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
}
|
||||
|
||||
private void AddButtonPlayerDestination()
|
||||
{
|
||||
Buttons[htButtons(ButtonPlayerDestination)].Visible = false;
|
||||
PlayerDestinationButtons = new List<CButton>();
|
||||
int row = 0;
|
||||
int column = 0;
|
||||
for (int i = 1; i <= _PartyMode.GetMaxPlayer(); i++)
|
||||
{
|
||||
CButton b = GetNewButton(Buttons[htButtons(ButtonPlayerDestination)]);
|
||||
b.Rect.X = PlayerDestinationButtonsFirstX + column * (b.Rect.W + PlayerDestinationButtonsSpaceH);
|
||||
b.Rect.Y = PlayerDestinationButtonsFirstY + row * (b.Rect.H + PlayerDestinationButtonsSpaceW);
|
||||
PlayerDestinationButtons.Add(b);
|
||||
column++;
|
||||
if (column >= PlayerDestinationButtonsNumH)
|
||||
{
|
||||
row++;
|
||||
column = 0;
|
||||
}
|
||||
b.Visible = true;
|
||||
b.Enabled = false;
|
||||
AddButton(b);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddButtonPlayerChoose()
|
||||
{
|
||||
Buttons[htButtons(ButtonPlayerChoose)].Visible = false;
|
||||
PlayerChooseButtons = new List<CPlayerChooseButton>();
|
||||
int row = 0;
|
||||
int column = 0;
|
||||
for (int i = 1; i <= PlayerChooseButtonsNumH * PlayerChooseButtonsNumW; i++)
|
||||
{
|
||||
CButton b = GetNewButton(Buttons[htButtons(ButtonPlayerChoose)]);
|
||||
b.Rect.X = PlayerChooseButtonsFirstX + column * (b.Rect.W + PlayerChooseButtonsSpaceH);
|
||||
b.Rect.Y = PlayerChooseButtonsFirstY + row * (b.Rect.H + PlayerChooseButtonsSpaceW);
|
||||
CPlayerChooseButton pcb = new CPlayerChooseButton();
|
||||
pcb.Button = b;
|
||||
pcb.ProfileID = -1;
|
||||
PlayerChooseButtons.Add(pcb);
|
||||
column++;
|
||||
if (column >= PlayerChooseButtonsNumH)
|
||||
{
|
||||
row++;
|
||||
column = 0;
|
||||
}
|
||||
b.Visible = true;
|
||||
b.Enabled = false;
|
||||
AddButton(b);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButtonPlayerChoose()
|
||||
{
|
||||
UpdateVisibleProfiles();
|
||||
if ((PlayerChooseButtonsNumW * PlayerChooseButtonsNumH) * (PlayerChooseButtonsOffset + 1) - PlayerChooseButtonsVisibleProfiles.Count >= (PlayerChooseButtonsNumW * PlayerChooseButtonsNumH) * PlayerChooseButtonsOffset)
|
||||
{
|
||||
UpdateButtonPlayerChoose(PlayerChooseButtonsOffset - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateButtonPlayerChoose(PlayerChooseButtonsOffset);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButtonPlayerChoose(int Offset)
|
||||
{
|
||||
int NumButtonPlayerChoose = PlayerChooseButtonsNumW * PlayerChooseButtonsNumH;
|
||||
if (Offset < 0)
|
||||
Offset = 0;
|
||||
|
||||
if (NumButtonPlayerChoose * (Offset + 1) - PlayerChooseButtonsVisibleProfiles.Count <= NumButtonPlayerChoose)
|
||||
{
|
||||
for (int i = 0; i < NumButtonPlayerChoose; i++)
|
||||
{
|
||||
if ((i + Offset * NumButtonPlayerChoose) < PlayerChooseButtonsVisibleProfiles.Count)
|
||||
{
|
||||
PlayerChooseButtons[i].ProfileID = PlayerChooseButtonsVisibleProfiles[i + Offset * NumButtonPlayerChoose];
|
||||
PlayerChooseButtons[i].Button.Text.Text = _Base.Profiles.GetProfiles()[PlayerChooseButtonsVisibleProfiles[i + Offset * NumButtonPlayerChoose]].PlayerName;
|
||||
PlayerChooseButtons[i].Button.Texture = _Base.Profiles.GetProfiles()[PlayerChooseButtonsVisibleProfiles[i + Offset * NumButtonPlayerChoose]].Avatar.Texture;
|
||||
PlayerChooseButtons[i].Button.STexture = _Base.Profiles.GetProfiles()[PlayerChooseButtonsVisibleProfiles[i + Offset * NumButtonPlayerChoose]].Avatar.Texture;
|
||||
PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f);
|
||||
PlayerChooseButtons[i].Button.SColor = new SColorF(1, 1, 1, 1);
|
||||
PlayerChooseButtons[i].Button.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerChooseButtons[i].ProfileID = -1;
|
||||
PlayerChooseButtons[i].Button.Text.Text = String.Empty;
|
||||
PlayerChooseButtons[i].Button.Texture = Buttons[htButtons(ButtonPlayerChoose)].Texture;
|
||||
PlayerChooseButtons[i].Button.STexture = Buttons[htButtons(ButtonPlayerChoose)].STexture;
|
||||
PlayerChooseButtons[i].Button.Color = Buttons[htButtons(ButtonPlayerChoose)].Color;
|
||||
PlayerChooseButtons[i].Button.SColor = Buttons[htButtons(ButtonPlayerChoose)].SColor;
|
||||
PlayerChooseButtons[i].Button.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateVisibleProfiles()
|
||||
{
|
||||
PlayerChooseButtonsVisibleProfiles.Clear();
|
||||
for (int i = 0; i < _Base.Profiles.GetProfiles().Length; i++)
|
||||
{
|
||||
bool visible = false;
|
||||
//Show profile only if active
|
||||
if (_Base.Profiles.GetProfiles()[i].Active == EOffOn.TR_CONFIG_ON)
|
||||
{
|
||||
visible = true;
|
||||
|
||||
for (int p = 0; p < Data.ScreenNames.ProfileIDs.Count; p++)
|
||||
{
|
||||
//Don't show profile if is selected
|
||||
if (Data.ScreenNames.ProfileIDs[p] == i)
|
||||
{
|
||||
visible = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (visible)
|
||||
{
|
||||
PlayerChooseButtonsVisibleProfiles.Add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButtonPlayerDestination()
|
||||
{
|
||||
for (int i = 0; i < PlayerDestinationButtons.Count; i++)
|
||||
{
|
||||
if (NumPlayer > i)
|
||||
{
|
||||
PlayerDestinationButtons[i].Visible = true;
|
||||
PlayerDestinationButtons[i].Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerDestinationButtons[i].Visible = false;
|
||||
PlayerDestinationButtons[i].Enabled = false;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < NumPlayer; i++)
|
||||
{
|
||||
if (i < Data.ScreenNames.ProfileIDs.Count)
|
||||
{
|
||||
if (Data.ScreenNames.ProfileIDs[i] != -1)
|
||||
{
|
||||
PlayerDestinationButtons[i].Color = new SColorF(1, 1, 1, 0.6f);
|
||||
PlayerDestinationButtons[i].SColor = new SColorF(1, 1, 1, 1);
|
||||
PlayerDestinationButtons[i].Texture = _Base.Profiles.GetProfiles()[Data.ScreenNames.ProfileIDs[i]].Avatar.Texture;
|
||||
PlayerDestinationButtons[i].STexture = _Base.Profiles.GetProfiles()[Data.ScreenNames.ProfileIDs[i]].Avatar.Texture;
|
||||
PlayerDestinationButtons[i].Text.Text = _Base.Profiles.GetProfiles()[Data.ScreenNames.ProfileIDs[i]].PlayerName;
|
||||
PlayerDestinationButtons[i].Enabled = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerDestinationButtons[i].Color = Buttons[htButtons(ButtonPlayerDestination)].Color;
|
||||
PlayerDestinationButtons[i].SColor = Buttons[htButtons(ButtonPlayerDestination)].SColor;
|
||||
PlayerDestinationButtons[i].Texture = Buttons[htButtons(ButtonPlayerDestination)].Texture;
|
||||
PlayerDestinationButtons[i].STexture = Buttons[htButtons(ButtonPlayerDestination)].STexture;
|
||||
PlayerDestinationButtons[i].Text.Text = String.Empty;
|
||||
PlayerDestinationButtons[i].Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButtonNext()
|
||||
{
|
||||
if (Data.ScreenNames.ProfileIDs.Count == NumPlayer)
|
||||
{
|
||||
Buttons[htButtons(ButtonNext)].Visible = true;
|
||||
SetInteractionToButton(Buttons[htButtons(ButtonNext)]);
|
||||
}
|
||||
else
|
||||
Buttons[htButtons(ButtonNext)].Visible = false;
|
||||
}
|
||||
|
||||
private bool OnAdd()
|
||||
{
|
||||
for (int i = 0; i < PlayerChooseButtons.Count; i++)
|
||||
{
|
||||
if (PlayerChooseButtons[i].Button.Selected && PlayerChooseButtons[i].ProfileID != -1)
|
||||
{
|
||||
if (Data.ScreenNames.ProfileIDs.Count < NumPlayer)
|
||||
{
|
||||
Data.ScreenNames.ProfileIDs.Add(PlayerChooseButtons[i].ProfileID);
|
||||
int added = Data.ScreenNames.ProfileIDs.Count - 1;
|
||||
UpdateButtonNext();
|
||||
//Update texture and name
|
||||
PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
|
||||
PlayerDestinationButtons[added].SColor = new SColorF(1, 1, 1, 1);
|
||||
PlayerDestinationButtons[added].Texture = _Base.Profiles.GetProfiles()[PlayerChooseButtons[i].ProfileID].Avatar.Texture;
|
||||
PlayerDestinationButtons[added].STexture = _Base.Profiles.GetProfiles()[PlayerChooseButtons[i].ProfileID].Avatar.Texture;
|
||||
PlayerDestinationButtons[added].Text.Text = _Base.Profiles.GetProfiles()[PlayerChooseButtons[i].ProfileID].PlayerName;
|
||||
PlayerDestinationButtons[added].Enabled = true;
|
||||
//Update Tiles-List
|
||||
UpdateButtonPlayerChoose();
|
||||
CheckInteraction();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool OnRemove()
|
||||
{
|
||||
for (int i = 0; i < PlayerDestinationButtons.Count; i++)
|
||||
{
|
||||
if (PlayerDestinationButtons[i].Selected)
|
||||
{
|
||||
if ((i + 1) <= Data.ScreenNames.ProfileIDs.Count)
|
||||
{
|
||||
Data.ScreenNames.ProfileIDs.RemoveAt(i);
|
||||
UpdateButtonNext();
|
||||
UpdateButtonPlayerDestination();
|
||||
UpdateButtonPlayerChoose();
|
||||
CheckInteraction();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void Back()
|
||||
{
|
||||
Data.ScreenNames.FadeToConfig = true;
|
||||
Data.ScreenNames.FadeToMain = false;
|
||||
_PartyMode.DataFromScreen(_ThemeName, Data);
|
||||
}
|
||||
|
||||
private void Next()
|
||||
{
|
||||
Data.ScreenNames.FadeToConfig = false;
|
||||
Data.ScreenNames.FadeToMain = true;
|
||||
_PartyMode.DataFromScreen(_ThemeName, Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user