From 188a9b933283bb51f5399b073235ac816deac9d0 Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Mon, 17 Dec 2012 20:39:57 +0100 Subject: [PATCH] removed duplicate code files --- .../Challenge/Code/ChallengeRounds.cs | 85 --- .../Challenge/Code/PartyModeChallenge.cs | 384 ------------- .../Code/PartyScreenChallengeConfig.cs | 257 --------- .../Code/PartyScreenChallengeMain.cs | 131 ----- .../Code/PartyScreenChallengeNames.cs | 513 ------------------ 5 files changed, 1370 deletions(-) delete mode 100644 Output/PartyModes/Challenge/Code/ChallengeRounds.cs delete mode 100644 Output/PartyModes/Challenge/Code/PartyModeChallenge.cs delete mode 100644 Output/PartyModes/Challenge/Code/PartyScreenChallengeConfig.cs delete mode 100644 Output/PartyModes/Challenge/Code/PartyScreenChallengeMain.cs delete mode 100644 Output/PartyModes/Challenge/Code/PartyScreenChallengeNames.cs diff --git a/Output/PartyModes/Challenge/Code/ChallengeRounds.cs b/Output/PartyModes/Challenge/Code/ChallengeRounds.cs deleted file mode 100644 index 5a40bc1e..00000000 --- a/Output/PartyModes/Challenge/Code/ChallengeRounds.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Vocaluxe.PartyModes -{ - public class ChallengeRounds - { - private List _Rounds; - - public ChallengeRounds(int NumRounds, int NumPlayer, int NumPlayerAtOnce) - { - BuildRounds(NumRounds, NumPlayer, NumPlayerAtOnce); - } - - public ChallengeRound GetRound(int RoundNr) - { - return null; - } - - private void BuildRounds(int NumRounds, int NumPlayer, int NumPlayerAtOnce) - { - _Rounds = new List(); - - if (NumPlayerAtOnce < 1 || NumPlayerAtOnce > 6 || NumPlayer < 1 || NumRounds < 1) - return; - - switch (NumPlayerAtOnce) - { - case 1: - for (int i = 0; i < NumRounds; i++) - { - - } - break; - - case 2: - break; - - case 3: - break; - - case 4: - break; - - case 5: - break; - - case 6: - break; - - default: - break; - } - } - - - } - - public class ChallengeRound - { - private List _ProfileIDs; - - public int NumPlayer { get{ return _ProfileIDs.Count; } } - - - public ChallengeRound() - { - _ProfileIDs = new List(); - } - - public void AddPlayer(int ProfileID) - { - _ProfileIDs.Add(ProfileID); - } - - public int GetPlayer(int Nr) - { - if (Nr >= _ProfileIDs.Count) - return -1; - - return _ProfileIDs[Nr]; - } - } -} diff --git a/Output/PartyModes/Challenge/Code/PartyModeChallenge.cs b/Output/PartyModes/Challenge/Code/PartyModeChallenge.cs deleted file mode 100644 index 232411a3..00000000 --- a/Output/PartyModes/Challenge/Code/PartyModeChallenge.cs +++ /dev/null @@ -1,384 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using Vocaluxe.Menu; - -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 ProfileIDs; - } - - public struct DataToScreenMain - { - public int CurrentRoundNr; - - } - #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 ProfileIDs; - } - - public struct FromScreenMain - { - public bool FadeToSongSelection; - } - #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; - - enum EStage - { - NotStarted, - Config, - Names, - Main, - Singing - } - - struct Data - { - public int NumPlayer; - public int NumPlayerAtOnce; - public int NumRounds; - public List ProfileIDs; - - public int CurrentRoundNr; - } - - 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.SearchStringVisible = 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(); - } - - public override bool Init() - { - _Stage = EStage.NotStarted; - - _ScreenSongOptions.Sorting.IgnoreArticles = _Base.Config.GetIgnoreArticles(); - _ScreenSongOptions.Sorting.SongSorting = ESongSorting.TR_CONFIG_FOLDER; - _ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_ON; - - 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; - } - 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(); - 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.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) - Screen.DataToScreen(ToScreenMain); - break; - case EStage.Main: - AlternativeScreen = EScreens.ScreenSong; - break; - case EStage.Singing: - _Screens.TryGetValue("PartyScreenChallengeMain", out Screen); - if (_Screens != null) - 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 SetSearchString(string SearchString, bool Visible) - { - _ScreenSongOptions.Sorting.SearchString = SearchString; - _ScreenSongOptions.Sorting.SearchStringVisible = 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; - - - } - - private void StartNextRound() - { - _ScreenSongOptions.Selection.RandomOnly = false; - _ScreenSongOptions.Selection.CategoryChangeAllowed = true; - SetNumJokers(); - SetTeamNames(); - _Base.Graphics.FadeTo(EScreens.ScreenSong); - } - - 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.NumPlayerAtOnce > 6 || GameData.ProfileIDs.Count < GameData.NumPlayerAtOnce || profiles.Length < GameData.NumPlayerAtOnce) - { - _ScreenSongOptions.Selection.TeamNames = new string[] { "foo", "bar" }; - return; - } - - _ScreenSongOptions.Selection.TeamNames = new string[GameData.NumPlayerAtOnce]; - - for (int i = 0; i < GameData.NumPlayerAtOnce; i++) - { - if (GameData.ProfileIDs[i] < profiles.Length) - _ScreenSongOptions.Selection.TeamNames[i] = profiles[GameData.ProfileIDs[i]].PlayerName; - else - _ScreenSongOptions.Selection.TeamNames[i] = "foobar"; - } - } - } -} \ No newline at end of file diff --git a/Output/PartyModes/Challenge/Code/PartyScreenChallengeConfig.cs b/Output/PartyModes/Challenge/Code/PartyScreenChallengeConfig.cs deleted file mode 100644 index f16799fd..00000000 --- a/Output/PartyModes/Challenge/Code/PartyScreenChallengeConfig.cs +++ /dev/null @@ -1,257 +0,0 @@ -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); - } - } -} diff --git a/Output/PartyModes/Challenge/Code/PartyScreenChallengeMain.cs b/Output/PartyModes/Challenge/Code/PartyScreenChallengeMain.cs deleted file mode 100644 index ba0fc37f..00000000 --- a/Output/PartyModes/Challenge/Code/PartyScreenChallengeMain.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; - -using Vocaluxe.Menu; - -namespace Vocaluxe.PartyModes -{ - 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 ButtonNextRound = "ButtonNextRound"; - - private DataFromScreen Data; - - public PartyScreenChallengeMain() - { - Data = new DataFromScreen(); - Data.ScreenMain = new FromScreenMain(); - } - - protected override void Init() - { - base.Init(); - - _ThemeName = "PartyScreenChallengeMain"; - _ThemeButtons = new string[] { "ButtonNextRound" }; - _ScreenVersion = ScreenVersion; - } - - public override void LoadTheme(string XmlPath) - { - base.LoadTheme(XmlPath); - } - - public override void DataToScreen(object ReceivedData) - { - DataToScreenMain data = new DataToScreenMain(); - - try - { - data = (DataToScreenMain)ReceivedData; - - } - 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: - EndParty(); - break; - - case Keys.Enter: - if (Buttons[htButtons(ButtonNextRound)].Selected) - NextRound(); - break; - } - } - return true; - } - - public override bool HandleMouse(MouseEvent MouseEvent) - { - base.HandleMouse(MouseEvent); - - if (MouseEvent.LB && IsMouseOver(MouseEvent)) - { - if (Buttons[htButtons(ButtonNextRound)].Selected) - NextRound(); - } - - if (MouseEvent.RB) - { - EndParty(); - } - - return true; - } - - public override void OnShow() - { - base.OnShow(); - } - - 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.FadeToSongSelection = true; - _PartyMode.DataFromScreen(_ThemeName, Data); - } - - private void EndParty() - { - //TODO - } - } -} diff --git a/Output/PartyModes/Challenge/Code/PartyScreenChallengeNames.cs b/Output/PartyModes/Challenge/Code/PartyScreenChallengeNames.cs deleted file mode 100644 index 975eaa02..00000000 --- a/Output/PartyModes/Challenge/Code/PartyScreenChallengeNames.cs +++ /dev/null @@ -1,513 +0,0 @@ -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 PlayerChooseButtons; - private List 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 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; - - //TODO: Get this data from party-mode! - 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(); - - Data.ScreenNames.ProfileIDs = new List(); - - _ThemeName = "PartyScreenChallengeNames"; - List buttons = new List(); - _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(); - 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(); - - NumPlayer = config.NumPlayer; - } - 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(); - - 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(); - - OnAdd(); - } - - if (MouseEvent.RB && IsMouseOver(MouseEvent)) - { - OnRemove(); - } - - return true; - } - - public override void OnShow() - { - base.OnShow(); - - AddButtonPlayerDestination(); - AddButtonPlayerChoose(); - - 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(); - 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(); - 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, but if selected and guest - if (Data.ScreenNames.ProfileIDs[p] == i && _Base.Profiles.GetProfiles()[i].GuestProfile == EOffOn.TR_CONFIG_OFF) - { - visible = false; - } - } - 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; - else - Buttons[htButtons(ButtonNext)].Visible = false; - } - - private void 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(); - } - } - } - } - - private void 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(); - } - } - } - } - - 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); - } - } -}