From b07d31f697b6200e45f5df0bc98ed72350ea7246 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sat, 18 Oct 2014 11:27:37 +0200 Subject: [PATCH] Unify object interactions --- .../CPartyScreenChallengeConfig.cs | 2 +- .../CPartyScreenChallengeMain.cs | 2 +- .../CPartyScreenChallengeMedleyConfig.cs | 2 +- .../CPartyScreenChallengeMedleyMain.cs | 2 +- .../CPartyScreenTicTacToeConfig.cs | 2 +- .../CPartyScreenTicTacToeMain.cs | 2 +- Vocaluxe/Screens/CPopupScreenPlayerControl.cs | 15 +- Vocaluxe/Screens/CPopupScreenVolumeControl.cs | 11 +- Vocaluxe/Screens/CScreenHighscore.cs | 2 +- Vocaluxe/Screens/CScreenMain.cs | 2 +- Vocaluxe/Screens/CScreenNames.cs | 2 +- Vocaluxe/Screens/CScreenOptions.cs | 2 +- Vocaluxe/Screens/CScreenOptionsGame.cs | 2 +- Vocaluxe/Screens/CScreenOptionsLyrics.cs | 2 +- Vocaluxe/Screens/CScreenOptionsRecord.cs | 2 +- Vocaluxe/Screens/CScreenOptionsSound.cs | 2 +- Vocaluxe/Screens/CScreenOptionsTheme.cs | 2 +- Vocaluxe/Screens/CScreenOptionsVideo.cs | 2 +- .../Screens/CScreenOptionsVideoAdjustments.cs | 2 +- Vocaluxe/Screens/CScreenParty.cs | 2 +- Vocaluxe/Screens/CScreenProfiles.cs | 2 +- Vocaluxe/Screens/CScreenSing.cs | 2 +- Vocaluxe/Screens/CScreenSong.cs | 2 +- Vocaluxe/Screens/CScreenTest.cs | 2 +- VocaluxeLib/Menu/CInteraction.cs | 52 +- VocaluxeLib/Menu/CMenu.cs | 1364 +---------------- VocaluxeLib/Menu/CMenuPartyNameSelection.cs | 2 +- VocaluxeLib/Menu/CObjectInteractions.cs | 670 +++++--- VocaluxeLib/Menu/COrderedDictionaryLite.cs | 10 +- VocaluxeLib/Menu/CPlaylist.cs | 1091 +++++++------ VocaluxeLib/PartyModes/CScreenPartyDummy.cs | 2 +- 31 files changed, 1046 insertions(+), 2215 deletions(-) diff --git a/PartyModes/PartyModeChallenge/CPartyScreenChallengeConfig.cs b/PartyModes/PartyModeChallenge/CPartyScreenChallengeConfig.cs index 229d68ba..74aad7db 100644 --- a/PartyModes/PartyModeChallenge/CPartyScreenChallengeConfig.cs +++ b/PartyModes/PartyModeChallenge/CPartyScreenChallengeConfig.cs @@ -110,7 +110,7 @@ namespace VocaluxeLib.PartyModes.Challenge { base.HandleMouse(mouseEvent); - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { _UpdateSlides(); if (_Buttons[_ButtonBack].Selected) diff --git a/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs b/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs index 452b9352..c0355ebd 100644 --- a/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs +++ b/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs @@ -207,7 +207,7 @@ namespace VocaluxeLib.PartyModes.Challenge { base.HandleMouse(mouseEvent); - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { if (!_ExitPopupVisible) { diff --git a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs index b39c7052..d2df447b 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyConfig.cs @@ -110,7 +110,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley { base.HandleMouse(mouseEvent); - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { _UpdateSlides(); if (_Buttons[_ButtonBack].Selected) diff --git a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs index 8db8532a..9c382898 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs @@ -207,7 +207,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley { base.HandleMouse(mouseEvent); - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { if (!_ExitPopupVisible) { diff --git a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeConfig.cs b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeConfig.cs index 298e36e6..5500e271 100644 --- a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeConfig.cs +++ b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeConfig.cs @@ -125,7 +125,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe { base.HandleMouse(mouseEvent); - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { _UpdateSlides(); if (_Buttons[_ButtonBack].Selected) diff --git a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs index c0e5f454..bd5f6511 100644 --- a/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs +++ b/PartyModes/PartyModeTicTacToe/CPartyScreenTicTacToeMain.cs @@ -221,7 +221,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe { base.HandleMouse(mouseEvent); - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { if (!_ExitPopupVisible) { diff --git a/Vocaluxe/Screens/CPopupScreenPlayerControl.cs b/Vocaluxe/Screens/CPopupScreenPlayerControl.cs index 4475e1da..9fbfbbf8 100644 --- a/Vocaluxe/Screens/CPopupScreenPlayerControl.cs +++ b/Vocaluxe/Screens/CPopupScreenPlayerControl.cs @@ -79,23 +79,20 @@ namespace Vocaluxe.Screens } } + public override SRectF ScreenArea + { + get { return _Statics[_StaticBG].Rect; } + } + public override void Init() { base.Init(); _ThemeStatics = new string[] {_StaticBG, _StaticCover}; _ThemeTexts = new string[] {_TextCurrentSong}; - _ThemeButtons = new string[] {_ButtonPlay, _ButtonPause, _ButtonPrevious, _ButtonNext, _ButtonRepeat, _ButtonShowVideo, _ButtonSing, _ButtonToBackgroundVideo}; } - public override void LoadTheme(string xmlPath) - { - base.LoadTheme(xmlPath); - - _ScreenArea = _Statics[_StaticBG].Rect; - } - public override bool HandleInput(SKeyEvent keyEvent) { base.HandleInput(keyEvent); @@ -136,7 +133,7 @@ namespace Vocaluxe.Screens public override bool HandleMouse(SMouseEvent mouseEvent) { base.HandleMouse(mouseEvent); - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { if (_Buttons[_ButtonNext].Selected) CBackgroundMusic.Next(); diff --git a/Vocaluxe/Screens/CPopupScreenVolumeControl.cs b/Vocaluxe/Screens/CPopupScreenVolumeControl.cs index 4bfde64c..279da430 100644 --- a/Vocaluxe/Screens/CPopupScreenVolumeControl.cs +++ b/Vocaluxe/Screens/CPopupScreenVolumeControl.cs @@ -30,9 +30,13 @@ namespace Vocaluxe.Screens } private const string _StaticBG = "StaticBG"; - private const string _SelectSlideVolume = "SelectSlideVolume"; + public override SRectF ScreenArea + { + get { return _Statics[_StaticBG].Rect; } + } + public override void Init() { base.Init(); @@ -45,7 +49,6 @@ namespace Vocaluxe.Screens { base.LoadTheme(xmlPath); - _ScreenArea = _Statics[_StaticBG].Rect; _SelectSlides[_SelectSlideVolume].AddValues(new string[] {"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100"}); } @@ -64,7 +67,7 @@ namespace Vocaluxe.Screens _SaveConfig(); return true; } - if (mouseEvent.Wheel > 0 && CHelper.IsInBounds(_ScreenArea, mouseEvent)) + if (mouseEvent.Wheel > 0 && CHelper.IsInBounds(ScreenArea, mouseEvent)) { if (_SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel >= 0) _SelectSlides[_SelectSlideVolume].Selection = _SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel; @@ -73,7 +76,7 @@ namespace Vocaluxe.Screens _SaveConfig(); return true; } - if (mouseEvent.Wheel < 0 && CHelper.IsInBounds(_ScreenArea, mouseEvent)) + if (mouseEvent.Wheel < 0 && CHelper.IsInBounds(ScreenArea, mouseEvent)) { if (_SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel < _SelectSlides[_SelectSlideVolume].NumValues) _SelectSlides[_SelectSlideVolume].Selection = _SelectSlides[_SelectSlideVolume].Selection - mouseEvent.Wheel; diff --git a/Vocaluxe/Screens/CScreenHighscore.cs b/Vocaluxe/Screens/CScreenHighscore.cs index 6f0f5913..e92a7681 100644 --- a/Vocaluxe/Screens/CScreenHighscore.cs +++ b/Vocaluxe/Screens/CScreenHighscore.cs @@ -130,7 +130,7 @@ namespace Vocaluxe.Screens public override bool HandleMouse(SMouseEvent mouseEvent) { - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) {} + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) {} if (mouseEvent.LB) _LeaveScreen(); diff --git a/Vocaluxe/Screens/CScreenMain.cs b/Vocaluxe/Screens/CScreenMain.cs index c932a1d6..228674d3 100644 --- a/Vocaluxe/Screens/CScreenMain.cs +++ b/Vocaluxe/Screens/CScreenMain.cs @@ -116,7 +116,7 @@ namespace Vocaluxe.Screens { base.HandleMouse(mouseEvent); - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { if (_Buttons[_ButtonSing].Selected) { diff --git a/Vocaluxe/Screens/CScreenNames.cs b/Vocaluxe/Screens/CScreenNames.cs index 4e9b3b06..4f4e3ea6 100644 --- a/Vocaluxe/Screens/CScreenNames.cs +++ b/Vocaluxe/Screens/CScreenNames.cs @@ -453,7 +453,7 @@ namespace Vocaluxe.Screens stopSelectingFast = true; } } - else if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + else if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { if (_Buttons[_ButtonBack].Selected) CGraphics.FadeTo(EScreens.ScreenSong); diff --git a/Vocaluxe/Screens/CScreenOptions.cs b/Vocaluxe/Screens/CScreenOptions.cs index 12fba76d..b9a0a543 100644 --- a/Vocaluxe/Screens/CScreenOptions.cs +++ b/Vocaluxe/Screens/CScreenOptions.cs @@ -92,7 +92,7 @@ namespace Vocaluxe.Screens { base.HandleMouse(mouseEvent); - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { if (_Buttons[_ButtonOptionsGame].Selected) CGraphics.FadeTo(EScreens.ScreenOptionsGame); diff --git a/Vocaluxe/Screens/CScreenOptionsGame.cs b/Vocaluxe/Screens/CScreenOptionsGame.cs index aec51f65..d42ee36c 100644 --- a/Vocaluxe/Screens/CScreenOptionsGame.cs +++ b/Vocaluxe/Screens/CScreenOptionsGame.cs @@ -113,7 +113,7 @@ namespace Vocaluxe.Screens CGraphics.FadeTo(EScreens.ScreenOptions); } - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { if (_Buttons[_ButtonExit].Selected) { diff --git a/Vocaluxe/Screens/CScreenOptionsLyrics.cs b/Vocaluxe/Screens/CScreenOptionsLyrics.cs index 6a7f6c79..ed8d1522 100644 --- a/Vocaluxe/Screens/CScreenOptionsLyrics.cs +++ b/Vocaluxe/Screens/CScreenOptionsLyrics.cs @@ -99,7 +99,7 @@ namespace Vocaluxe.Screens _SaveConfig(); CGraphics.FadeTo(EScreens.ScreenOptions); } - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { _SaveConfig(); if (_Buttons[_ButtonExit].Selected) diff --git a/Vocaluxe/Screens/CScreenOptionsRecord.cs b/Vocaluxe/Screens/CScreenOptionsRecord.cs index a81b7696..ce1e48c2 100644 --- a/Vocaluxe/Screens/CScreenOptionsRecord.cs +++ b/Vocaluxe/Screens/CScreenOptionsRecord.cs @@ -186,7 +186,7 @@ namespace Vocaluxe.Screens CGraphics.FadeTo(EScreens.ScreenOptions); } - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { if (_SelectSlides[_SelectSlideRecordDevices].Selected) _OnDeviceEvent(); diff --git a/Vocaluxe/Screens/CScreenOptionsSound.cs b/Vocaluxe/Screens/CScreenOptionsSound.cs index 657b8c5f..6ac538a7 100644 --- a/Vocaluxe/Screens/CScreenOptionsSound.cs +++ b/Vocaluxe/Screens/CScreenOptionsSound.cs @@ -115,7 +115,7 @@ namespace Vocaluxe.Screens _SaveConfig(); CGraphics.FadeTo(EScreens.ScreenOptions); } - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { _SaveConfig(); if (_Buttons[_ButtonExit].Selected) diff --git a/Vocaluxe/Screens/CScreenOptionsTheme.cs b/Vocaluxe/Screens/CScreenOptionsTheme.cs index b03ccee4..78749e29 100644 --- a/Vocaluxe/Screens/CScreenOptionsTheme.cs +++ b/Vocaluxe/Screens/CScreenOptionsTheme.cs @@ -119,7 +119,7 @@ namespace Vocaluxe.Screens if (mouseEvent.RB) _Close(); - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { if (_Buttons[_ButtonExit].Selected) _Close(); diff --git a/Vocaluxe/Screens/CScreenOptionsVideo.cs b/Vocaluxe/Screens/CScreenOptionsVideo.cs index 81fdb4eb..ceace1c2 100644 --- a/Vocaluxe/Screens/CScreenOptionsVideo.cs +++ b/Vocaluxe/Screens/CScreenOptionsVideo.cs @@ -141,7 +141,7 @@ namespace Vocaluxe.Screens CGraphics.FadeTo(EScreens.ScreenOptions); } - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { if (_SelectSlides[_SelectSlideWebcamDevices].Selected) _OnDeviceEvent(); diff --git a/Vocaluxe/Screens/CScreenOptionsVideoAdjustments.cs b/Vocaluxe/Screens/CScreenOptionsVideoAdjustments.cs index 5759652c..5b9c62a4 100644 --- a/Vocaluxe/Screens/CScreenOptionsVideoAdjustments.cs +++ b/Vocaluxe/Screens/CScreenOptionsVideoAdjustments.cs @@ -81,7 +81,7 @@ namespace Vocaluxe.Screens CGraphics.FadeTo(EScreens.ScreenOptionsVideo); } - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { _SaveConfig(); if (_Buttons[_ButtonExit].Selected) diff --git a/Vocaluxe/Screens/CScreenParty.cs b/Vocaluxe/Screens/CScreenParty.cs index 504e68d3..373314dc 100644 --- a/Vocaluxe/Screens/CScreenParty.cs +++ b/Vocaluxe/Screens/CScreenParty.cs @@ -89,7 +89,7 @@ namespace Vocaluxe.Screens { base.HandleMouse(mouseEvent); - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { if (_Buttons[_ButtonStart].Selected) _StartPartyMode(); diff --git a/Vocaluxe/Screens/CScreenProfiles.cs b/Vocaluxe/Screens/CScreenProfiles.cs index 532f3a8a..b77d19bf 100644 --- a/Vocaluxe/Screens/CScreenProfiles.cs +++ b/Vocaluxe/Screens/CScreenProfiles.cs @@ -196,7 +196,7 @@ namespace Vocaluxe.Screens if (_EditMode == EEditMode.None) base.HandleMouse(mouseEvent); - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { if (_Buttons[_ButtonExit].Selected) CGraphics.FadeTo(EScreens.ScreenMain); diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 64e59518..627e55bf 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -302,7 +302,7 @@ namespace Vocaluxe.Screens _SetInteractionToButton(_Buttons[_ButtonContinue]); } - if (mouseEvent.LB && _IsMouseOver(mouseEvent) && _Pause) + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent) && _Pause) { if (_Buttons[_ButtonContinue].Selected && _Pause) _TogglePause(); diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 57a5ed16..92b37d1f 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -476,7 +476,7 @@ namespace Vocaluxe.Screens if (mouseEvent.LB) { - if (_IsMouseOver(mouseEvent)) + if (_IsMouseOverCurSelection(mouseEvent)) { if (_Buttons[_ButtonOpenOptions].Selected) { diff --git a/Vocaluxe/Screens/CScreenTest.cs b/Vocaluxe/Screens/CScreenTest.cs index 7ccc303d..accdc14c 100644 --- a/Vocaluxe/Screens/CScreenTest.cs +++ b/Vocaluxe/Screens/CScreenTest.cs @@ -89,7 +89,7 @@ namespace Vocaluxe.Screens public override bool HandleMouse(SMouseEvent mouseEvent) { - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) {} + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) {} if (mouseEvent.LB) CGraphics.FadeTo(EScreens.ScreenMain); diff --git a/VocaluxeLib/Menu/CInteraction.cs b/VocaluxeLib/Menu/CInteraction.cs index cf67de78..c1b917bb 100644 --- a/VocaluxeLib/Menu/CInteraction.cs +++ b/VocaluxeLib/Menu/CInteraction.cs @@ -35,39 +35,45 @@ namespace VocaluxeLib.Menu class CInteraction { - private readonly int _Num; - private readonly EType _Type; - - public int Num - { - get { return _Num; } - } - - public EType Type - { - get { return _Type; } - } + public readonly int Num; + public readonly EType Type; public bool ThemeEditorOnly { get { - return _Type == EType.Background || - _Type == EType.NameSelection || - _Type == EType.Text || - _Type == EType.Static || - _Type == EType.SongMenu || - _Type == EType.Lyric || - _Type == EType.SingNote || - _Type == EType.Equalizer || - _Type == EType.Playlist; + return Type == EType.Background || + Type == EType.NameSelection || + Type == EType.Text || + Type == EType.Static || + Type == EType.SongMenu || + Type == EType.Lyric || + Type == EType.SingNote || + Type == EType.Equalizer || + Type == EType.Playlist; + } + } + + public bool DrawAsForeground + { + get + { + return Type == EType.Button || + Type == EType.SelectSlide || + Type == EType.Static || + Type == EType.NameSelection || + Type == EType.Text || + Type == EType.SongMenu || + Type == EType.Equalizer || + Type == EType.Playlist || + Type == EType.ParticleEffect; } } public CInteraction(int num, EType type) { - _Num = num; - _Type = type; + Num = num; + Type = type; } } } \ No newline at end of file diff --git a/VocaluxeLib/Menu/CMenu.cs b/VocaluxeLib/Menu/CMenu.cs index 2618c94d..64a9f33d 100644 --- a/VocaluxeLib/Menu/CMenu.cs +++ b/VocaluxeLib/Menu/CMenu.cs @@ -17,7 +17,6 @@ using System; using System.Collections.Generic; -using System.Drawing; using System.IO; using System.Windows.Forms; using System.Xml.Serialization; @@ -59,20 +58,10 @@ namespace VocaluxeLib.Menu public float Z; } - public abstract class CMenu : IMenu + public abstract class CMenu : CObjectInteractions, IMenu { - private readonly List _Interactions; - private int _Selection; public string ThemePath { get; private set; } - private int _PrevMouseX; - private int _PrevMouseY; - - private int _MouseDX; - private int _MouseDY; - - protected bool _Active; - protected abstract int _ScreenVersion { get; } public int PartyModeID { get; protected set; } public string ThemeName { get; set; } @@ -93,64 +82,20 @@ namespace VocaluxeLib.Menu protected string[] _ThemeParticleEffects; protected string[] _ThemeScreenSettings; - protected readonly COrderedDictionaryLite _Buttons; - protected readonly COrderedDictionaryLite _Texts; - protected readonly COrderedDictionaryLite _Backgrounds; - protected readonly COrderedDictionaryLite _Statics; - protected readonly COrderedDictionaryLite _SelectSlides; - protected readonly COrderedDictionaryLite _SongMenus; - protected readonly COrderedDictionaryLite _Lyrics; - protected readonly COrderedDictionaryLite _SingNotes; - protected readonly COrderedDictionaryLite _NameSelections; - protected readonly COrderedDictionaryLite _Equalizers; - protected readonly COrderedDictionaryLite _Playlists; - protected readonly COrderedDictionaryLite _ParticleEffects; - protected readonly COrderedDictionaryLite _ScreenSettings; // ReSharper restore MemberCanBePrivate.Global - protected SRectF _ScreenArea; - public SRectF ScreenArea - { - get { return _ScreenArea; } - } - protected CMenu() { PartyModeID = -1; - - _Interactions = new List(); - _Backgrounds = new COrderedDictionaryLite(this); - _Buttons = new COrderedDictionaryLite(this); - _Texts = new COrderedDictionaryLite(this); - _Statics = new COrderedDictionaryLite(this); - _SelectSlides = new COrderedDictionaryLite(this); - _SongMenus = new COrderedDictionaryLite(this); - _Lyrics = new COrderedDictionaryLite(this); - _SingNotes = new COrderedDictionaryLite(this); - _NameSelections = new COrderedDictionaryLite(this); - _Equalizers = new COrderedDictionaryLite(this); - _Playlists = new COrderedDictionaryLite(this); - _ParticleEffects = new COrderedDictionaryLite(this); - _ScreenSettings = new COrderedDictionaryLite(this); } - public virtual void Init() + public override void Init() { + base.Init(); ThemeName = GetType().Name; if (ThemeName[0] == 'C' && Char.IsUpper(ThemeName[1])) ThemeName = ThemeName.Remove(0, 1); - _Selection = 0; - - _PrevMouseX = 0; - _PrevMouseY = 0; - - _MouseDX = 0; - _MouseDY = 0; - - _Active = false; - _ScreenArea = CBase.Settings.GetRenderRect(); - _ThemeBackgrounds = null; _ThemeStatics = null; _ThemeTexts = null; @@ -166,24 +111,6 @@ namespace VocaluxeLib.Menu _ThemeScreenSettings = null; } - private void _ClearElements() - { - _Interactions.Clear(); - _Backgrounds.Clear(); - _Buttons.Clear(); - _Texts.Clear(); - _Statics.Clear(); - _SelectSlides.Clear(); - _SongMenus.Clear(); - _Lyrics.Clear(); - _SingNotes.Clear(); - _NameSelections.Clear(); - _Equalizers.Clear(); - _Playlists.Clear(); - _ParticleEffects.Clear(); - _ScreenSettings.Clear(); - } - protected static void _FadeTo(EScreens nextScreen) { CBase.Graphics.FadeTo(nextScreen); @@ -493,75 +420,6 @@ namespace VocaluxeLib.Menu } #endregion ThemeHandler - #region GetLists - /*public List GetButtons() - { - return _Buttons; - } - - public List GetTexts() - { - return _Texts; - } - - public List GetBackgrounds() - { - return _Backgrounds; - } - - public List GetStatics() - { - return _Statics; - } - - public List GetSelectSlides() - { - return _SelectSlides; - } - - public List GetSongMenus() - { - return _SongMenus; - } - - public List GetLyrics() - { - return _Lyrics; - } - - public List GetSingNotes() - { - return _SingNotes; - } - - public List GetNameSelections() - { - return _NameSelections; - } - - public List GetEqualizers() - { - return _Equalizers; - } - - public List GetPlaylists() - { - return _Playlists; - } - - public List GetParticleEffects() - { - return _ParticleEffects; - } - - public List GetScreenSettings() - { - return _ScreenSettings; - }*/ - #endregion GetLists - - #region ElementHandler - #region Create Elements // ReSharper disable UnusedMember.Global // ReSharper disable MemberCanBeProtected.Global @@ -659,188 +517,21 @@ namespace VocaluxeLib.Menu // ReSharper restore UnusedMember.Global #endregion Create Elements - #endregion ElementHandler - - #region MenuHandler - public virtual bool HandleInput(SKeyEvent keyEvent) + public override bool HandleInputThemeEditor(SKeyEvent keyEvent) { - if (!CBase.Settings.IsTabNavigation()) - { - if (keyEvent.Key == Keys.Left) - { - if (_Interactions.Count > 0 && _Interactions[_Selection].Type == EType.SelectSlide && keyEvent.Mod != EModifier.Shift) - keyEvent.Handled = PrevElement(); - else - keyEvent.Handled = _NextInteraction(keyEvent); - } - - if (keyEvent.Key == Keys.Right) - { - if (_Interactions.Count > 0 && _Interactions[_Selection].Type == EType.SelectSlide && keyEvent.Mod != EModifier.Shift) - keyEvent.Handled = NextElement(); - else - keyEvent.Handled = _NextInteraction(keyEvent); - } - - if (keyEvent.Key == Keys.Up || keyEvent.Key == Keys.Down) - keyEvent.Handled = _NextInteraction(keyEvent); - } - else - { - if (keyEvent.Key == Keys.Tab) - { - if (keyEvent.Mod == EModifier.Shift) - PrevInteraction(); - else - NextInteraction(); - } - - if (keyEvent.Key == Keys.Left) - PrevElement(); - - if (keyEvent.Key == Keys.Right) - NextElement(); - } - - return true; - } - - public virtual bool HandleMouse(SMouseEvent mouseEvent) - { - int selection = _Selection; - ProcessMouseMove(mouseEvent.X, mouseEvent.Y); - if (selection != _Selection) - { - _UnsetHighlighted(selection); - _SetHighlighted(_Selection); - } - - if (mouseEvent.LB) - ProcessMouseClick(mouseEvent.X, mouseEvent.Y); - - _PrevMouseX = mouseEvent.X; - _PrevMouseY = mouseEvent.Y; - - return true; - } - - public virtual bool HandleInputThemeEditor(SKeyEvent keyEvent) - { - _UnsetHighlighted(_Selection); if (!keyEvent.KeyPressed) { switch (keyEvent.Key) { case Keys.S: CBase.Graphics.SaveTheme(); - break; - + return true; case Keys.R: _ReloadThemeEditMode(); - break; - - case Keys.Up: - if (keyEvent.Mod == EModifier.Ctrl) - _MoveElement(0, -1); - - if (keyEvent.Mod == EModifier.Shift) - _ResizeElement(0, 1); - - break; - case Keys.Down: - if (keyEvent.Mod == EModifier.Ctrl) - _MoveElement(0, 1); - - if (keyEvent.Mod == EModifier.Shift) - _ResizeElement(0, -1); - - break; - - case Keys.Right: - if (keyEvent.Mod == EModifier.Ctrl) - _MoveElement(1, 0); - - if (keyEvent.Mod == EModifier.Shift) - _ResizeElement(1, 0); - - if (keyEvent.Mod == EModifier.None) - NextInteraction(); - break; - case Keys.Left: - if (keyEvent.Mod == EModifier.Ctrl) - _MoveElement(-1, 0); - - if (keyEvent.Mod == EModifier.Shift) - _ResizeElement(-1, 0); - - if (keyEvent.Mod == EModifier.None) - PrevInteraction(); - break; + return true; } } - return true; - } - - public virtual bool HandleMouseThemeEditor(SMouseEvent mouseEvent) - { - _UnsetHighlighted(_Selection); - _MouseDX = mouseEvent.X - _PrevMouseX; - _MouseDY = mouseEvent.Y - _PrevMouseY; - - int stepX = 0; - int stepY = 0; - - if ((mouseEvent.Mod & EModifier.Ctrl) == EModifier.Ctrl) - { - _PrevMouseX = mouseEvent.X; - _PrevMouseY = mouseEvent.Y; - } - else - { - while (Math.Abs(mouseEvent.X - _PrevMouseX) >= 5) - { - if (mouseEvent.X - _PrevMouseX >= 5) - stepX += 5; - - if (mouseEvent.X - _PrevMouseX <= -5) - stepX -= 5; - - _PrevMouseX = mouseEvent.X - (_MouseDX - stepX); - } - - while (Math.Abs(mouseEvent.Y - _PrevMouseY) >= 5) - { - if (mouseEvent.Y - _PrevMouseY >= 5) - stepY += 5; - - if (mouseEvent.Y - _PrevMouseY <= -5) - stepY -= 5; - - _PrevMouseY = mouseEvent.Y - (_MouseDY - stepY); - } - } - - if (mouseEvent.LBH) - { - //if (IsMouseOver(MouseEvent.X, _PrevMouseY)) - //{ - if (mouseEvent.Mod == EModifier.None) - _MoveElement(stepX, stepY); - - if (mouseEvent.Mod == EModifier.Ctrl) - _MoveElement(_MouseDX, _MouseDY); - - if (mouseEvent.Mod == EModifier.Shift) - _ResizeElement(stepX, stepY); - - if (mouseEvent.Mod == (EModifier.Shift | EModifier.Ctrl)) - _ResizeElement(_MouseDX, _MouseDY); - //} - } - else - ProcessMouseMove(mouseEvent.X, mouseEvent.Y); - - return true; + return base.HandleInputThemeEditor(keyEvent); } public abstract bool UpdateGame(); @@ -863,7 +554,11 @@ namespace VocaluxeLib.Menu _PauseBG(); _Active = false; } - #endregion MenuHandler + + public virtual SRectF ScreenArea + { + get { return CBase.Settings.GetRenderRect(); } + } protected void _ResumeBG() { @@ -877,1042 +572,7 @@ namespace VocaluxeLib.Menu bg.Pause(); } - #region Drawing - public virtual bool Draw() - { - _DrawBG(); - _DrawFG(); - return true; - } - - protected void _DrawBG() - { - foreach (CBackground bg in _Backgrounds) - bg.Draw(); - } - - protected void _DrawFG() - { - if (_Interactions.Count <= 0) - return; - - var items = new List(); - - for (int i = 0; i < _Interactions.Count; i++) - { - if (!_IsVisible(i) || - (_Interactions[i].Type != EType.Button && _Interactions[i].Type != EType.SelectSlide && _Interactions[i].Type != EType.Static && - _Interactions[i].Type != EType.NameSelection && _Interactions[i].Type != EType.Text && _Interactions[i].Type != EType.SongMenu && - _Interactions[i].Type != EType.Equalizer && _Interactions[i].Type != EType.Playlist && _Interactions[i].Type != EType.ParticleEffect)) - continue; - var zs = new SZSort {ID = i, Z = _GetZValue(i)}; - items.Add(zs); - } - - if (items.Count <= 0) - return; - - - items.Sort((s1, s2) => s2.Z.CompareTo(s1.Z)); - - for (int i = 0; i < items.Count; i++) - _DrawInteraction(items[i].ID); - } - #endregion Drawing - - #region Elements - // ReSharper disable MemberCanBePrivate.Global - protected void _AddBackground(CBackground bg, String key = null) - { - _AddInteraction(_Backgrounds.Add(bg, key), EType.Background); - } - - protected void _AddButton(CButton button, String key = null) - { - _AddInteraction(_Buttons.Add(button, key), EType.Button); - } - - protected void _AddSelectSlide(CSelectSlide slide, String key = null) - { - _AddInteraction(_SelectSlides.Add(slide, key), EType.SelectSlide); - } - - protected void _AddStatic(CStatic stat, String key = null) - { - _AddInteraction(_Statics.Add(stat, key), EType.Static); - } - - protected void _AddText(CText text, String key = null) - { - _AddInteraction(_Texts.Add(text, key), EType.Text); - } - - protected void _AddSongMenu(CSongMenu songmenu, String key = null) - { - _AddInteraction(_SongMenus.Add(songmenu, key), EType.SongMenu); - } - - protected void _AddLyric(CLyric lyric, String key = null) - { - _AddInteraction(_Lyrics.Add(lyric, key), EType.Lyric); - } - - protected void _AddSingNote(CSingNotes sn, String key = null) - { - _AddInteraction(_SingNotes.Add(sn, key), EType.SingNote); - } - - protected void _AddNameSelection(CNameSelection ns, String key = null) - { - _AddInteraction(_NameSelections.Add(ns, key), EType.NameSelection); - } - - protected void _AddEqualizer(CEqualizer eq, String key = null) - { - _AddInteraction(_Equalizers.Add(eq, key), EType.Equalizer); - } - - protected void _AddPlaylist(CPlaylist pls, String key = null) - { - _AddInteraction(_Playlists.Add(pls, key), EType.Playlist); - } - - protected void _AddParticleEffect(CParticleEffect pe, String key = null) - { - _AddInteraction(_ParticleEffects.Add(pe, key), EType.ParticleEffect); - } - - protected void _AddScreenSetting(CScreenSetting se, String key = null) - { - _ScreenSettings.Add(se, key); - } - - // ReSharper restore MemberCanBePrivate.Global - #endregion Elements - - #region InteractionHandling - protected void _CheckInteraction() - { - if (!_IsEnabled(_Selection) || !_IsVisible(_Selection)) - PrevInteraction(); - } - - public void NextInteraction() - { - if (_Interactions.Count > 0) - _NextInteraction(); - } - - public void PrevInteraction() - { - if (_Interactions.Count > 0) - _PrevInteraction(); - } - - /// - /// Selects the next element in a menu Interaction. - /// - /// True if the next element is selected. False if either there is no next element or the Interaction does not provide such a method. - public bool NextElement() - { - if (_Interactions.Count > 0) - return _NextElement(); - - return false; - } - - /// - /// Selects the previous element in a menu Interaction. - /// - /// True if the previous element is selected. False if either there is no next element or the Interaction does not provide such a method. - public bool PrevElement() - { - if (_Interactions.Count > 0) - return _PrevElement(); - - return false; - } - - protected void _SetInteractionToButton(CButton button) - { - for (int i = 0; i < _Interactions.Count; i++) - { - if (_Interactions[i].Type != EType.Button) - continue; - if (_Buttons[_Interactions[i].Num] != button) - continue; - _UnsetSelected(); - _UnsetHighlighted(_Selection); - _Selection = i; - _SetSelected(); - return; - } - } - - protected void _SetInteractionToSelectSlide(CSelectSlide slide) - { - for (int i = 0; i < _Interactions.Count; i++) - { - if (_Interactions[i].Type == EType.SelectSlide) - { - if (_SelectSlides[_Interactions[i].Num] == slide) - { - _UnsetSelected(); - _UnsetHighlighted(_Selection); - _Selection = i; - _SetSelected(); - return; - } - } - } - } - - public void ProcessMouseClick(int x, int y) - { - if (_Selection >= _Interactions.Count || _Selection < 0) - return; - - if (_Interactions[_Selection].Type == EType.SelectSlide) - { - if (_SelectSlides[_Interactions[_Selection].Num].Visible) - _SelectSlides[_Interactions[_Selection].Num].ProcessMouseLBClick(x, y); - } - } - - public void ProcessMouseMove(int x, int y) - { - _SelectByMouse(x, y); - - if (_Selection >= _Interactions.Count || _Selection < 0) - return; - - if (_Interactions[_Selection].Type == EType.SelectSlide) - { - if (_SelectSlides[_Interactions[_Selection].Num].Visible) - _SelectSlides[_Interactions[_Selection].Num].ProcessMouseMove(x, y); - } - } - - private void _SelectByMouse(int x, int y) - { - float z = CBase.Settings.GetZFar(); - for (int i = 0; i < _Interactions.Count; i++) - { - if ((CBase.Settings.GetProgramState() != EProgramState.EditTheme) && (_Interactions[i].ThemeEditorOnly || !_IsVisible(i) || !_IsEnabled(i))) - continue; - if (!_IsMouseOver(x, y, _Interactions[i])) - continue; - if (_GetZValue(_Interactions[i]) > z) - continue; - z = _GetZValue(_Interactions[i]); - _UnsetSelected(); - _Selection = i; - _SetSelected(); - } - } - - protected bool _IsMouseOver(SMouseEvent mouseEvent) - { - return _IsMouseOver(mouseEvent.X, mouseEvent.Y); - } - - private bool _IsMouseOver(int x, int y) - { - if (_Selection >= _Interactions.Count || _Selection < 0) - return false; - - return _Interactions.Count > 0 && _IsMouseOver(x, y, _Interactions[_Selection]); - } - - private bool _IsMouseOver(int x, int y, CInteraction interact) - { - bool result = CHelper.IsInBounds(_GetRect(interact), x, y); - if (result) - return true; - if (interact.Type == EType.SelectSlide) - { - return CHelper.IsInBounds(_SelectSlides[interact.Num].RectArrowLeft, x, y) || - CHelper.IsInBounds(_SelectSlides[interact.Num].RectArrowRight, x, y); - } - return false; - } - - private float _GetZValue(CInteraction interact) - { - switch (interact.Type) - { - case EType.Button: - return _Buttons[interact.Num].Rect.Z; - case EType.SelectSlide: - return _SelectSlides[interact.Num].Rect.Z; - case EType.Static: - return _Statics[interact.Num].Rect.Z; - case EType.SongMenu: - return _SongMenus[interact.Num].Rect.Z; - case EType.Text: - return _Texts[interact.Num].Z; - case EType.Lyric: - return _Lyrics[interact.Num].Rect.Z; - case EType.NameSelection: - return _NameSelections[interact.Num].Rect.Z; - case EType.Equalizer: - return _Equalizers[interact.Num].Rect.Z; - case EType.Playlist: - return _Playlists[interact.Num].Rect.Z; - case EType.ParticleEffect: - return _ParticleEffects[interact.Num].Rect.Z; - } - return CBase.Settings.GetZFar(); - } - - private float _GetZValue(int interaction) - { - return _GetZValue(_Interactions[interaction]); - } - - private void _NextInteraction() - { - _UnsetSelected(); - if (CBase.Settings.GetProgramState() != EProgramState.EditTheme) - { - bool found = false; - int start = _Selection; - do - { - start++; - if (start > _Interactions.Count - 1) - start = 0; - - if ((start == _Selection) || (!_Interactions[start].ThemeEditorOnly && _IsVisible(start) && _IsEnabled(start))) - found = true; - } while (!found); - _Selection = start; - } - else - { - _Selection++; - if (_Selection > _Interactions.Count - 1) - _Selection = 0; - } - _SetSelected(); - } - - private void _PrevInteraction() - { - _UnsetSelected(); - if (CBase.Settings.GetProgramState() != EProgramState.EditTheme) - { - bool found = false; - int start = _Selection; - do - { - start--; - if (start < 0) - start = _Interactions.Count - 1; - - if ((start == _Selection) || (!_Interactions[start].ThemeEditorOnly && _IsVisible(start) && _IsEnabled(start))) - found = true; - } while (!found); - _Selection = start; - } - else - { - _Selection--; - if (_Selection < 0) - _Selection = _Interactions.Count - 1; - } - _SetSelected(); - } - - /// - /// Selects the next best interaction in a menu. - /// - /// - /// - private bool _NextInteraction(SKeyEvent key) - { - var directions = new SKeyEvent[4]; - var distances = new float[4]; - var stages = new int[4]; - var elements = new int[4]; - - for (int i = 0; i < 4; i++) - directions[i] = new SKeyEvent(); - - directions[0].Key = Keys.Up; - directions[1].Key = Keys.Right; - directions[2].Key = Keys.Down; - directions[3].Key = Keys.Left; - - for (int i = 0; i < 4; i++) - elements[i] = _GetNextElement(directions[i], out distances[i], out stages[i]); - - int element = _Selection; - int stage = int.MaxValue; - int direction = -1; - - int mute = -1; - switch (key.Key) - { - case Keys.Up: - mute = 2; - break; - case Keys.Right: - mute = 3; - break; - case Keys.Down: - mute = 0; - break; - case Keys.Left: - mute = 1; - break; - } - - for (int i = 0; i < 4; i++) - { - if (i != mute && elements[i] != _Selection && (stages[i] <= stage && directions[i].Key == key.Key)) - { - stage = stages[i]; - element = elements[i]; - direction = i; - } - } - - if (direction != -1) - { - // select the new element - if (directions[direction].Key == key.Key) - { - _UnsetHighlighted(_Selection); - _UnsetSelected(); - - _Selection = element; - _SetSelected(); - _SetHighlighted(_Selection); - - return true; - } - } - return false; - } - - private int _GetNextElement(SKeyEvent key, out float distance, out int stage) - { - distance = float.MaxValue; - int min = _Selection; - SRectF actualRect = _GetRect(_Selection); - stage = int.MaxValue; - - for (int i = 0; i < _Interactions.Count; i++) - { - if (i != _Selection && !_Interactions[i].ThemeEditorOnly && _IsVisible(i) && _IsEnabled(i)) - { - SRectF targetRect = _GetRect(i); - float dist = _GetDistanceDirect(key, actualRect, targetRect); - if (dist >= 0f && dist < distance) - { - distance = dist; - min = i; - stage = 10; - } - } - } - - if (min == _Selection) - { - for (int i = 0; i < _Interactions.Count; i++) - { - if (i != _Selection && !_Interactions[i].ThemeEditorOnly && _IsVisible(i) && _IsEnabled(i)) - { - SRectF targetRect = _GetRect(i); - float dist = _GetDistance180(key, actualRect, targetRect); - if (dist >= 0f && dist < distance) - { - distance = dist; - min = i; - stage = 20; - } - } - } - } - - if (min == _Selection) - { - switch (key.Key) - { - case Keys.Up: - actualRect = new SRectF(actualRect.X, CBase.Settings.GetRenderH(), 1, 1, actualRect.Z); - break; - case Keys.Down: - actualRect = new SRectF(actualRect.X, 0, 1, 1, actualRect.Z); - break; - case Keys.Left: - actualRect = new SRectF(CBase.Settings.GetRenderW(), actualRect.Y, 1, 1, actualRect.Z); - break; - case Keys.Right: - actualRect = new SRectF(0, actualRect.Y, 1, 1, actualRect.Z); - break; - } - - for (int i = 0; i < _Interactions.Count; i++) - { - if (i != _Selection && !_Interactions[i].ThemeEditorOnly && _IsVisible(i) && _IsEnabled(i)) - { - SRectF targetRect = _GetRect(i); - float dist = _GetDistance180(key, actualRect, targetRect); - if (dist >= 0f && dist < distance) - { - distance = dist; - min = i; - stage = 30; - } - } - } - } - return min; - } - - private float _GetDistanceDirect(SKeyEvent key, SRectF actualRect, SRectF targetRect) - { - var source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f); - var dest = new PointF(targetRect.X + targetRect.W / 2f, targetRect.Y + targetRect.H / 2f); - - var vector = new PointF(dest.X - source.X, dest.Y - source.Y); - var distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y); - bool inDirection = false; - switch (key.Key) - { - case Keys.Up: - if (vector.Y < 0f && (targetRect.X + targetRect.W > actualRect.X && actualRect.X + actualRect.W > targetRect.X)) - inDirection = true; - break; - - case Keys.Down: - if (vector.Y > 0f && (targetRect.X + targetRect.W > actualRect.X && actualRect.X + actualRect.W > targetRect.X)) - inDirection = true; - break; - - case Keys.Left: - if (vector.X < 0f && (targetRect.Y + targetRect.H > actualRect.Y && actualRect.Y + actualRect.H > targetRect.Y)) - inDirection = true; - break; - - case Keys.Right: - if (vector.X > 0f && (targetRect.Y + targetRect.H > actualRect.Y && actualRect.Y + actualRect.H > targetRect.Y)) - inDirection = true; - break; - } - return !inDirection ? float.MaxValue : distance; - } - - private float _GetDistance180(SKeyEvent key, SRectF actualRect, SRectF targetRect) - { - var source = new PointF(actualRect.X + actualRect.W / 2f, actualRect.Y + actualRect.H / 2f); - var dest = new PointF(targetRect.X + targetRect.W / 2f, targetRect.Y + targetRect.H / 2f); - - var vector = new PointF(dest.X - source.X, dest.Y - source.Y); - var distance = (float)Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y); - bool inDirection = false; - switch (key.Key) - { - case Keys.Up: - if (vector.Y < 0f) - inDirection = true; - break; - - case Keys.Down: - if (vector.Y > 0f) - inDirection = true; - break; - - case Keys.Left: - if (vector.X < 0f) - inDirection = true; - break; - - case Keys.Right: - if (vector.X > 0f) - inDirection = true; - break; - } - return !inDirection ? float.MaxValue : distance; - } - - /// - /// Selects the next element in a menu interaction. - /// - /// True if the next element is selected. False if either there is no next element or the interaction does not provide such a method. - private bool _NextElement() - { - if (_Interactions[_Selection].Type == EType.SelectSlide) - return _SelectSlides[_Interactions[_Selection].Num].NextValue(); - - return false; - } - - /// - /// Selects the previous element in a menu interaction. - /// - /// - /// True if the previous element is selected. False if either there is no previous element or the interaction does not provide such a method. - /// - private bool _PrevElement() - { - if (_Interactions[_Selection].Type == EType.SelectSlide) - return _SelectSlides[_Interactions[_Selection].Num].PrevValue(); - - return false; - } - - private void _SetSelected() - { - switch (_Interactions[_Selection].Type) - { - case EType.Button: - _Buttons[_Interactions[_Selection].Num].Selected = true; - break; - case EType.SelectSlide: - _SelectSlides[_Interactions[_Selection].Num].Selected = true; - break; - case EType.Static: - _Statics[_Interactions[_Selection].Num].Selected = true; - break; - case EType.Text: - _Texts[_Interactions[_Selection].Num].Selected = true; - break; - case EType.SongMenu: - _SongMenus[_Interactions[_Selection].Num].Selected = true; - break; - case EType.Lyric: - _Lyrics[_Interactions[_Selection].Num].Selected = true; - break; - case EType.NameSelection: - _NameSelections[_Interactions[_Selection].Num].Selected = true; - break; - case EType.Equalizer: - _Equalizers[_Interactions[_Selection].Num].Selected = true; - break; - case EType.Playlist: - _Playlists[_Interactions[_Selection].Num].Selected = true; - break; - case EType.ParticleEffect: - _ParticleEffects[_Interactions[_Selection].Num].Selected = true; - break; - } - } - - private void _UnsetSelected() - { - switch (_Interactions[_Selection].Type) - { - case EType.Button: - _Buttons[_Interactions[_Selection].Num].Selected = false; - break; - case EType.SelectSlide: - _SelectSlides[_Interactions[_Selection].Num].Selected = false; - break; - case EType.Static: - _Statics[_Interactions[_Selection].Num].Selected = false; - break; - case EType.Text: - _Texts[_Interactions[_Selection].Num].Selected = false; - break; - case EType.SongMenu: - _SongMenus[_Interactions[_Selection].Num].Selected = false; - break; - case EType.Lyric: - _Lyrics[_Interactions[_Selection].Num].Selected = false; - break; - case EType.NameSelection: - _NameSelections[_Interactions[_Selection].Num].Selected = false; - break; - case EType.Equalizer: - _Equalizers[_Interactions[_Selection].Num].Selected = false; - break; - case EType.Playlist: - _Playlists[_Interactions[_Selection].Num].Selected = false; - break; - case EType.ParticleEffect: - _ParticleEffects[_Interactions[_Selection].Num].Selected = false; - break; - } - } - - private void _SetHighlighted(int selection) - { - if (selection >= _Interactions.Count || selection < 0) - return; - - switch (_Interactions[selection].Type) - { - case EType.Button: - //_Buttons[_Interactions[selection].Num].Selected = true; - break; - case EType.SelectSlide: - _SelectSlides[_Interactions[selection].Num].Highlighted = true; - break; - case EType.Static: - //_Statics[_Interactions[selection].Num].Selected = true; - break; - case EType.Text: - //_Texts[_Interactions[selection].Num].Selected = true; - break; - case EType.SongMenu: - //_SongMenus[_Interactions[selection].Num].Selected = true; - break; - case EType.Lyric: - //_Lyrics[_Interactions[selection].Num].Selected = true; - break; - case EType.NameSelection: - //_NameSelections[_Interactions[selection].Num].Selected = true; - break; - case EType.Playlist: - //_Playlists[_Interactions[_Selection].Num].Selected = true; - break; - } - } - - private void _UnsetHighlighted(int selection) - { - if (selection >= _Interactions.Count || selection < 0) - return; - - switch (_Interactions[selection].Type) - { - case EType.Button: - //_Buttons[_Interactions[selection].Num].Selected = false; - break; - case EType.SelectSlide: - _SelectSlides[_Interactions[selection].Num].Highlighted = false; - break; - case EType.Static: - //_Statics[_Interactions[selection].Num].Selected = false; - break; - case EType.Text: - //_Texts[_Interactions[selection].Num].Selected = false; - break; - case EType.SongMenu: - //_SongMenus[_Interactions[selection].Num].Selected = false; - break; - case EType.Lyric: - //_Lyrics[_Interactions[selection].Num].Selected = false; - break; - case EType.NameSelection: - //_NameSelections[_Interactions[selection].Num].Selected = false; - break; - case EType.Playlist: - //_Playlists[_Interactions[_Selection].Num].Selected = true; - break; - } - } - - // ReSharper disable UnusedMember.Local - private void _ToggleHighlighted() - { - if (_Selection >= _Interactions.Count || _Selection < 0) - return; - - if (_Interactions[_Selection].Type == EType.SelectSlide) - _SelectSlides[_Interactions[_Selection].Num].Highlighted = !_SelectSlides[_Interactions[_Selection].Num].Highlighted; - } - - private bool _IsHighlighted() - { - if (_Selection >= _Interactions.Count || _Selection < 0) - return false; - - return _Interactions[_Selection].Type == EType.SelectSlide && _SelectSlides[_Interactions[_Selection].Num].Highlighted; - } - - // ReSharper restore UnusedMember.Local - - private bool _IsVisible(int interaction) - { - if (_Selection >= _Interactions.Count || _Selection < 0) - return false; - - switch (_Interactions[interaction].Type) - { - case EType.Button: - return _Buttons[_Interactions[interaction].Num].Visible; - - case EType.SelectSlide: - return _SelectSlides[_Interactions[interaction].Num].Visible; - - case EType.Static: - return _Statics[_Interactions[interaction].Num].Visible; - - case EType.Text: - return _Texts[_Interactions[interaction].Num].Visible; - - case EType.SongMenu: - return _SongMenus[_Interactions[interaction].Num].Visible; - - case EType.Lyric: - return _Lyrics[_Interactions[interaction].Num].Visible; - - case EType.NameSelection: - return _NameSelections[_Interactions[interaction].Num].Visible; - - case EType.Equalizer: - return _Equalizers[_Interactions[interaction].Num].Visible; - - case EType.Playlist: - return _Playlists[_Interactions[interaction].Num].Visible; - - case EType.ParticleEffect: - return _ParticleEffects[_Interactions[interaction].Num].Visible; - } - - return false; - } - - private bool _IsEnabled(int interaction) - { - if (_Selection >= _Interactions.Count || _Selection < 0) - return false; - - switch (_Interactions[interaction].Type) - { - case EType.Button: - return _Buttons[_Interactions[interaction].Num].Enabled; - - case EType.SelectSlide: - return _SelectSlides[_Interactions[interaction].Num].Visible; - - case EType.Static: - return false; //_Statics[_Interactions[interaction].Num].Visible; - - case EType.Text: - return false; //_Texts[_Interactions[interaction].Num].Visible; - - case EType.SongMenu: - return _SongMenus[_Interactions[interaction].Num].Visible; - - case EType.Lyric: - return false; //_Lyrics[_Interactions[interaction].Num].Visible; - - case EType.NameSelection: - return _NameSelections[_Interactions[interaction].Num].Visible; - - case EType.Equalizer: - return false; //_Equalizers[_Interactions[interaction].Num].Visible; - - case EType.Playlist: - return _Playlists[_Interactions[interaction].Num].Visible; - - case EType.ParticleEffect: - return false; //_ParticleEffects[_Interactions[interaction].Num].Visible; - } - - return false; - } - - private SRectF _GetRect(CInteraction interaction) - { - var result = new SRectF(); - switch (interaction.Type) - { - case EType.Button: - return _Buttons[interaction.Num].Rect; - - case EType.SelectSlide: - return _SelectSlides[interaction.Num].Rect; - - case EType.Static: - return _Statics[interaction.Num].Rect; - - case EType.Text: - return _Texts[interaction.Num].Rect; - - case EType.SongMenu: - return _SongMenus[interaction.Num].Rect; - - case EType.Lyric: - return _Lyrics[interaction.Num].Rect; - - case EType.NameSelection: - return _NameSelections[interaction.Num].Rect; - - case EType.Equalizer: - return _Equalizers[interaction.Num].Rect; - - case EType.Playlist: - return _Playlists[interaction.Num].Rect; - - case EType.ParticleEffect: - return _ParticleEffects[interaction.Num].Rect; - } - - return result; - } - - private SRectF _GetRect(int interaction) - { - return _GetRect(_Interactions[interaction]); - } - - private void _AddInteraction(int num, EType type) - { - _Interactions.Add(new CInteraction(num, type)); - if (!_Interactions[_Selection].ThemeEditorOnly) - _SetSelected(); - else - _NextInteraction(); - } - - private void _DrawInteraction(int interaction) - { - switch (_Interactions[interaction].Type) - { - case EType.Button: - _Buttons[_Interactions[interaction].Num].Draw(); - break; - - case EType.SelectSlide: - _SelectSlides[_Interactions[interaction].Num].Draw(); - break; - - case EType.Static: - _Statics[_Interactions[interaction].Num].Draw(); - break; - - case EType.Text: - _Texts[_Interactions[interaction].Num].Draw(); - break; - - case EType.SongMenu: - _SongMenus[_Interactions[interaction].Num].Draw(); - break; - - case EType.NameSelection: - _NameSelections[_Interactions[interaction].Num].Draw(); - break; - - case EType.Equalizer: - if (!_Equalizers[_Interactions[interaction].Num].ScreenHandles) - { - //TODO: - //Call Update-Method of Equalizer and give infos about bg-sound. - //_Equalizers[_Interactions[interaction].Num].Draw(); - } - break; - - case EType.Playlist: - _Playlists[_Interactions[interaction].Num].Draw(); - break; - - case EType.ParticleEffect: - _ParticleEffects[_Interactions[interaction].Num].Draw(); - break; - - //TODO: - //case EType.TLyric: - // _Lyrics[_Interactions[interaction].Num].Draw(0); - // break; - } - } - #endregion InteractionHandling - #region Theme Handling - private void _MoveElement(int stepX, int stepY) - { - if (_Interactions.Count > 0) - { - switch (_Interactions[_Selection].Type) - { - case EType.Button: - _Buttons[_Interactions[_Selection].Num].MoveElement(stepX, stepY); - break; - - case EType.SelectSlide: - _SelectSlides[_Interactions[_Selection].Num].MoveElement(stepX, stepY); - break; - - case EType.Static: - _Statics[_Interactions[_Selection].Num].MoveElement(stepX, stepY); - break; - - case EType.Text: - _Texts[_Interactions[_Selection].Num].MoveElement(stepX, stepY); - break; - - case EType.SongMenu: - _SongMenus[_Interactions[_Selection].Num].MoveElement(stepX, stepY); - break; - - case EType.Lyric: - _Lyrics[_Interactions[_Selection].Num].MoveElement(stepX, stepY); - break; - - case EType.NameSelection: - _NameSelections[_Interactions[_Selection].Num].MoveElement(stepX, stepY); - break; - - case EType.Equalizer: - _Equalizers[_Interactions[_Selection].Num].MoveElement(stepX, stepY); - break; - - case EType.Playlist: - _Playlists[_Interactions[_Selection].Num].MoveElement(stepX, stepY); - break; - - case EType.ParticleEffect: - _ParticleEffects[_Interactions[_Selection].Num].MoveElement(stepX, stepY); - break; - } - } - } - - private void _ResizeElement(int stepW, int stepH) - { - if (_Interactions.Count > 0) - { - switch (_Interactions[_Selection].Type) - { - case EType.Button: - _Buttons[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); - break; - - case EType.SelectSlide: - _SelectSlides[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); - break; - - case EType.Static: - _Statics[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); - break; - - case EType.Text: - _Texts[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); - break; - - case EType.SongMenu: - _SongMenus[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); - break; - - case EType.Lyric: - _Lyrics[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); - break; - - case EType.NameSelection: - _NameSelections[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); - break; - - case EType.Equalizer: - _Equalizers[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); - break; - - case EType.Playlist: - _Playlists[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); - break; - - case EType.ParticleEffect: - _ParticleEffects[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); - break; - } - } - } - private bool _CheckVersion(int reqVersion, CXMLReader xmlReader) { int actualVersion = 0; diff --git a/VocaluxeLib/Menu/CMenuPartyNameSelection.cs b/VocaluxeLib/Menu/CMenuPartyNameSelection.cs index f5a39dee..26f20764 100644 --- a/VocaluxeLib/Menu/CMenuPartyNameSelection.cs +++ b/VocaluxeLib/Menu/CMenuPartyNameSelection.cs @@ -434,7 +434,7 @@ namespace VocaluxeLib.Menu } } - else if (mouseEvent.LB && _IsMouseOver(mouseEvent)) + else if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { if (_Buttons[_ButtonBack].Selected) Back(); diff --git a/VocaluxeLib/Menu/CObjectInteractions.cs b/VocaluxeLib/Menu/CObjectInteractions.cs index c2c99823..80197edd 100644 --- a/VocaluxeLib/Menu/CObjectInteractions.cs +++ b/VocaluxeLib/Menu/CObjectInteractions.cs @@ -19,115 +19,95 @@ using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; +using VocaluxeLib.Menu.SingNotes; +using VocaluxeLib.Menu.SongMenu; namespace VocaluxeLib.Menu { - class CObjectInteractions + public abstract class CObjectInteractions { - private List _Interactions; + private readonly List _Interactions = new List(); private int _Selection; - private List _Statics; - private List _Texts; - private List _Buttons; - private List _SelectSlides; - private int _PrevMouseX; private int _PrevMouseY; protected int _MouseDX; protected int _MouseDY; - public bool Active; + protected bool _Active; - protected SRectF _ScreenArea; - - public SRectF ScreenArea - { - get { return _ScreenArea; } - } + protected readonly COrderedDictionaryLite _Buttons; + protected readonly COrderedDictionaryLite _Texts; + protected readonly COrderedDictionaryLite _Backgrounds; + protected readonly COrderedDictionaryLite _Statics; + protected readonly COrderedDictionaryLite _SelectSlides; + protected readonly COrderedDictionaryLite _SongMenus; + protected readonly COrderedDictionaryLite _Lyrics; + protected readonly COrderedDictionaryLite _SingNotes; + protected readonly COrderedDictionaryLite _NameSelections; + protected readonly COrderedDictionaryLite _Equalizers; + protected readonly COrderedDictionaryLite _Playlists; + protected readonly COrderedDictionaryLite _ParticleEffects; + protected readonly COrderedDictionaryLite _ScreenSettings; public CObjectInteractions() { - _Init(); + _Backgrounds = new COrderedDictionaryLite(this); + _Buttons = new COrderedDictionaryLite(this); + _Texts = new COrderedDictionaryLite(this); + _Statics = new COrderedDictionaryLite(this); + _SelectSlides = new COrderedDictionaryLite(this); + _SongMenus = new COrderedDictionaryLite(this); + _Lyrics = new COrderedDictionaryLite(this); + _SingNotes = new COrderedDictionaryLite(this); + _NameSelections = new COrderedDictionaryLite(this); + _Equalizers = new COrderedDictionaryLite(this); + _Playlists = new COrderedDictionaryLite(this); + _ParticleEffects = new COrderedDictionaryLite(this); + _ScreenSettings = new COrderedDictionaryLite(this); } - protected void _Init() + public virtual void Init() { - _Interactions = new List(); _Selection = 0; - _Statics = new List(); - _Texts = new List(); - _Buttons = new List(); - _SelectSlides = new List(); - _PrevMouseX = 0; _PrevMouseY = 0; _MouseDX = 0; _MouseDY = 0; - Active = false; - _ScreenArea = CBase.Settings.GetRenderRect(); + _Active = false; } - public void Clear() + protected void _ClearElements() { _Interactions.Clear(); - _Statics.Clear(); - _Texts.Clear(); + _Backgrounds.Clear(); _Buttons.Clear(); + _Texts.Clear(); + _Statics.Clear(); _SelectSlides.Clear(); - - _Selection = 0; - - _PrevMouseX = 0; - _PrevMouseY = 0; - - _MouseDX = 0; - _MouseDY = 0; - - Active = false; + _SongMenus.Clear(); + _Lyrics.Clear(); + _SingNotes.Clear(); + _NameSelections.Clear(); + _Equalizers.Clear(); + _Playlists.Clear(); + _ParticleEffects.Clear(); + _ScreenSettings.Clear(); } - #region GetLists - public List GetButtons() - { - return _Buttons; - } - - public List GetSelectSlides() - { - return _SelectSlides; - } - #endregion GetLists - - #region ElementHandler - - #region Get Arrays - public CButton[] Buttons - { - get { return _Buttons.ToArray(); } - } - - public CSelectSlide[] SelectSlides - { - get { return _SelectSlides.ToArray(); } - } - #endregion Get Arrays - - #endregion ElementHandler - #region MenuHandler - public bool HandleInput(SKeyEvent keyEvent) + public virtual bool HandleInput(SKeyEvent keyEvent) { if (!CBase.Settings.IsTabNavigation()) { if (keyEvent.Key == Keys.Left) { if (_Interactions.Count > 0 && _Interactions[_Selection].Type == EType.SelectSlide && keyEvent.Mod != EModifier.Shift) - keyEvent.Handled = PrevElement(); + keyEvent.Handled = _PrevElement(); else keyEvent.Handled = _NextInteraction(keyEvent); } @@ -135,7 +115,7 @@ namespace VocaluxeLib.Menu if (keyEvent.Key == Keys.Right) { if (_Interactions.Count > 0 && _Interactions[_Selection].Type == EType.SelectSlide && keyEvent.Mod != EModifier.Shift) - keyEvent.Handled = NextElement(); + keyEvent.Handled = _NextElement(); else keyEvent.Handled = _NextInteraction(keyEvent); } @@ -154,16 +134,16 @@ namespace VocaluxeLib.Menu } if (keyEvent.Key == Keys.Left) - PrevElement(); + _PrevElement(); if (keyEvent.Key == Keys.Right) - NextElement(); + _NextElement(); } return true; } - public bool HandleMouse(SMouseEvent mouseEvent) + public virtual bool HandleMouse(SMouseEvent mouseEvent) { int selection = _Selection; ProcessMouseMove(mouseEvent.X, mouseEvent.Y); @@ -182,18 +162,13 @@ namespace VocaluxeLib.Menu return true; } - public bool HandleInputThemeEditor(SKeyEvent keyEvent) + public virtual bool HandleInputThemeEditor(SKeyEvent keyEvent) { _UnsetHighlighted(_Selection); - if (keyEvent.KeyPressed) {} - else + if (!keyEvent.KeyPressed) { switch (keyEvent.Key) { - case Keys.S: - CBase.Graphics.SaveTheme(); - break; - case Keys.Up: if (keyEvent.Mod == EModifier.Ctrl) _MoveElement(0, -1); @@ -236,7 +211,7 @@ namespace VocaluxeLib.Menu return true; } - public bool HandleMouseThemeEditor(SMouseEvent mouseEvent) + public virtual bool HandleMouseThemeEditor(SMouseEvent mouseEvent) { _UnsetHighlighted(_Selection); _MouseDX = mouseEvent.X - _PrevMouseX; @@ -300,7 +275,20 @@ namespace VocaluxeLib.Menu #endregion MenuHandler #region Drawing - public void Draw() + public virtual bool Draw() + { + _DrawBG(); + _DrawFG(); + return true; + } + + protected void _DrawBG() + { + foreach (CBackground bg in _Backgrounds) + bg.Draw(); + } + + protected void _DrawFG() { if (_Interactions.Count <= 0) return; @@ -309,14 +297,7 @@ namespace VocaluxeLib.Menu for (int i = 0; i < _Interactions.Count; i++) { - if (_IsVisible(i) && ( - _Interactions[i].Type == EType.Button || - _Interactions[i].Type == EType.SelectSlide || - _Interactions[i].Type == EType.Static || - _Interactions[i].Type == EType.NameSelection || - _Interactions[i].Type == EType.Text || - _Interactions[i].Type == EType.SongMenu || - _Interactions[i].Type == EType.Equalizer)) + if (_IsVisible(i) && _Interactions[i].DrawAsForeground) { var zs = new SZSort {ID = i, Z = _GetZValue(i)}; items.Add(zs); @@ -334,35 +315,72 @@ namespace VocaluxeLib.Menu } #endregion Drawing - #region Elements - public int AddStatic(CStatic stat) + #region Element-Adding + protected void _AddBackground(CBackground bg, String key = null) { - _Statics.Add(stat); - _AddInteraction(_Statics.Count - 1, EType.Static); - return _Statics.Count - 1; + _AddInteraction(_Backgrounds.Add(bg, key), EType.Background); } - public int AddText(CText text) + protected void _AddButton(CButton button, String key = null) { - _Texts.Add(text); - _AddInteraction(_Texts.Count - 1, EType.Text); - return _Texts.Count - 1; + _AddInteraction(_Buttons.Add(button, key), EType.Button); } - public int AddButton(CButton button) + protected void _AddSelectSlide(CSelectSlide slide, String key = null) { - _Buttons.Add(button); - _AddInteraction(_Buttons.Count - 1, EType.Button); - return _Buttons.Count - 1; + _AddInteraction(_SelectSlides.Add(slide, key), EType.SelectSlide); } - public int AddSelectSlide(CSelectSlide slide) + protected void _AddStatic(CStatic stat, String key = null) { - _SelectSlides.Add(slide); - _AddInteraction(_SelectSlides.Count - 1, EType.SelectSlide); - return _SelectSlides.Count - 1; + _AddInteraction(_Statics.Add(stat, key), EType.Static); } - #endregion Elements + + protected void _AddText(CText text, String key = null) + { + _AddInteraction(_Texts.Add(text, key), EType.Text); + } + + protected void _AddSongMenu(CSongMenu songmenu, String key = null) + { + _AddInteraction(_SongMenus.Add(songmenu, key), EType.SongMenu); + } + + protected void _AddLyric(CLyric lyric, String key = null) + { + _AddInteraction(_Lyrics.Add(lyric, key), EType.Lyric); + } + + protected void _AddSingNote(CSingNotes sn, String key = null) + { + _AddInteraction(_SingNotes.Add(sn, key), EType.SingNote); + } + + protected void _AddNameSelection(CNameSelection ns, String key = null) + { + _AddInteraction(_NameSelections.Add(ns, key), EType.NameSelection); + } + + protected void _AddEqualizer(CEqualizer eq, String key = null) + { + _AddInteraction(_Equalizers.Add(eq, key), EType.Equalizer); + } + + protected void _AddPlaylist(CPlaylist pls, String key = null) + { + _AddInteraction(_Playlists.Add(pls, key), EType.Playlist); + } + + protected void _AddParticleEffect(CParticleEffect pe, String key = null) + { + _AddInteraction(_ParticleEffects.Add(pe, key), EType.ParticleEffect); + } + + protected void _AddScreenSetting(CScreenSetting se, String key = null) + { + _ScreenSettings.Add(se, key); + } + #endregion Element-Adding #region InteractionHandling public void NextInteraction() @@ -378,9 +396,9 @@ namespace VocaluxeLib.Menu } /// - /// Selects the next element in a menu interaction. + /// Selects the next element in a menu Interaction. /// - /// True if the next element is selected. False if either there is no next element or the interaction does not provide such a method. + /// True if the next element is selected. False if either there is no next element or the Interaction does not provide such a method. public bool NextElement() { if (_Interactions.Count > 0) @@ -390,9 +408,9 @@ namespace VocaluxeLib.Menu } /// - /// Selects the previous element in a menu interaction. + /// Selects the previous element in a menu Interaction. /// - /// True if the previous element is selected. False if either there is no next element or the interaction does not provide such a method. + /// True if the previous element is selected. False if either there is no next element or the Interaction does not provide such a method. public bool PrevElement() { if (_Interactions.Count > 0) @@ -401,42 +419,42 @@ namespace VocaluxeLib.Menu return false; } - public bool SetInteractionToButton(CButton button) + protected void _SetInteractionToButton(CButton button) { + if (!button.Visible) + return; for (int i = 0; i < _Interactions.Count; i++) { - if (_Interactions[i].Type == EType.Button) + if (_Interactions[i].Type != EType.Button) + continue; + if (_Buttons[_Interactions[i].Num] == button) { - if (_Buttons[_Interactions[i].Num].Visible && _Buttons[_Interactions[i].Num] == button) - { - _UnsetSelected(); - _UnsetHighlighted(_Selection); - _Selection = i; - _SetSelected(); - return true; - } + _UnsetSelected(); + _UnsetHighlighted(_Selection); + _Selection = i; + _SetSelected(); + return; } } - return false; } - public bool SetInteractionToSelectSlide(CSelectSlide slide) + protected void _SetInteractionToSelectSlide(CSelectSlide slide) { + if (!slide.Visible) + return; for (int i = 0; i < _Interactions.Count; i++) { - if (_Interactions[i].Type == EType.SelectSlide) + if (_Interactions[i].Type != EType.SelectSlide) + continue; + if (_SelectSlides[_Interactions[i].Num] == slide) { - if (_SelectSlides[_Interactions[i].Num].Visible && _SelectSlides[_Interactions[i].Num] == slide) - { - _UnsetSelected(); - _UnsetHighlighted(_Selection); - _Selection = i; - _SetSelected(); - return true; - } + _UnsetSelected(); + _UnsetHighlighted(_Selection); + _Selection = i; + _SetSelected(); + return; } } - return false; } public void ProcessMouseClick(int x, int y) @@ -453,7 +471,7 @@ namespace VocaluxeLib.Menu public void ProcessMouseMove(int x, int y) { - SelectByMouse(x, y); + _SelectByMouse(x, y); if (_Selection >= _Interactions.Count || _Selection < 0) return; @@ -465,54 +483,46 @@ namespace VocaluxeLib.Menu } } - public void SelectByMouse(int x, int y) + private void _SelectByMouse(int x, int y) { float z = CBase.Settings.GetZFar(); for (int i = 0; i < _Interactions.Count; i++) { - if ((CBase.Settings.GetProgramState() == EProgramState.EditTheme) || (!_Interactions[i].ThemeEditorOnly && _IsVisible(i) && _IsEnabled(i))) - { - if (_IsMouseOver(x, y, _Interactions[i])) - { - if (_GetZValue(_Interactions[i]) <= z) - { - z = _GetZValue(_Interactions[i]); - _UnsetSelected(); - _Selection = i; - _SetSelected(); - } - } - } + if ((CBase.Settings.GetProgramState() != EProgramState.EditTheme) && (_Interactions[i].ThemeEditorOnly || !_IsVisible(i) || !_IsEnabled(i))) + continue; + if (!_IsMouseOverElement(x, y, _Interactions[i])) + continue; + if (_GetZValue(_Interactions[i]) > z) + continue; + z = _GetZValue(_Interactions[i]); + _UnsetSelected(); + _Selection = i; + _SetSelected(); } } - public bool IsMouseOver(SMouseEvent mouseEvent) + protected bool _IsMouseOverCurSelection(SMouseEvent mouseEvent) { - return IsMouseOver(mouseEvent.X, mouseEvent.Y); + return _IsMouseOverCurSelection(mouseEvent.X, mouseEvent.Y); } - public bool IsMouseOver(int x, int y) + private bool _IsMouseOverCurSelection(int x, int y) { if (_Selection >= _Interactions.Count || _Selection < 0) return false; - return _Interactions.Count > 0 && _IsMouseOver(x, y, _Interactions[_Selection]); + return _Interactions.Count > 0 && _IsMouseOverElement(x, y, _Interactions[_Selection]); } - private bool _IsMouseOver(int x, int y, CInteraction interact) + private bool _IsMouseOverElement(int x, int y, CInteraction interact) { - switch (interact.Type) + bool result = CHelper.IsInBounds(_GetRect(interact), x, y); + if (result) + return true; + if (interact.Type == EType.SelectSlide) { - case EType.Button: - if (CHelper.IsInBounds(_Buttons[interact.Num].Rect, x, y)) - return true; - break; - case EType.SelectSlide: - if (CHelper.IsInBounds(_SelectSlides[interact.Num].Rect, x, y) || - CHelper.IsInBounds(_SelectSlides[interact.Num].RectArrowLeft, x, y) || - CHelper.IsInBounds(_SelectSlides[interact.Num].RectArrowRight, x, y)) - return true; - break; + return CHelper.IsInBounds(_SelectSlides[interact.Num].RectArrowLeft, x, y) || + CHelper.IsInBounds(_SelectSlides[interact.Num].RectArrowRight, x, y); } return false; } @@ -521,33 +531,33 @@ namespace VocaluxeLib.Menu { switch (interact.Type) { - case EType.Static: - return _Statics[interact.Num].Rect.Z; - case EType.Text: - return _Texts[interact.Num].Z; case EType.Button: return _Buttons[interact.Num].Rect.Z; case EType.SelectSlide: return _SelectSlides[interact.Num].Rect.Z; + case EType.Static: + return _Statics[interact.Num].Rect.Z; + case EType.SongMenu: + return _SongMenus[interact.Num].Rect.Z; + case EType.Text: + return _Texts[interact.Num].Z; + case EType.Lyric: + return _Lyrics[interact.Num].Rect.Z; + case EType.NameSelection: + return _NameSelections[interact.Num].Rect.Z; + case EType.Equalizer: + return _Equalizers[interact.Num].Rect.Z; + case EType.Playlist: + return _Playlists[interact.Num].Rect.Z; + case EType.ParticleEffect: + return _ParticleEffects[interact.Num].Rect.Z; } return CBase.Settings.GetZFar(); } private float _GetZValue(int interaction) { - switch (_Interactions[interaction].Type) - { - case EType.Static: - return _Statics[_Interactions[interaction].Num].Rect.Z; - case EType.Text: - return _Texts[_Interactions[interaction].Num].Z; - case EType.Button: - return _Buttons[_Interactions[interaction].Num].Rect.Z; - case EType.SelectSlide: - return _SelectSlides[_Interactions[interaction].Num].Rect.Z; - } - - return CBase.Settings.GetZFar(); + return _GetZValue(_Interactions[interaction]); } private void _NextInteraction() @@ -854,6 +864,30 @@ namespace VocaluxeLib.Menu case EType.SelectSlide: _SelectSlides[_Interactions[_Selection].Num].Selected = true; break; + case EType.Static: + _Statics[_Interactions[_Selection].Num].Selected = true; + break; + case EType.Text: + _Texts[_Interactions[_Selection].Num].Selected = true; + break; + case EType.SongMenu: + _SongMenus[_Interactions[_Selection].Num].Selected = true; + break; + case EType.Lyric: + _Lyrics[_Interactions[_Selection].Num].Selected = true; + break; + case EType.NameSelection: + _NameSelections[_Interactions[_Selection].Num].Selected = true; + break; + case EType.Equalizer: + _Equalizers[_Interactions[_Selection].Num].Selected = true; + break; + case EType.Playlist: + _Playlists[_Interactions[_Selection].Num].Selected = true; + break; + case EType.ParticleEffect: + _ParticleEffects[_Interactions[_Selection].Num].Selected = true; + break; } } @@ -867,6 +901,30 @@ namespace VocaluxeLib.Menu case EType.SelectSlide: _SelectSlides[_Interactions[_Selection].Num].Selected = false; break; + case EType.Static: + _Statics[_Interactions[_Selection].Num].Selected = false; + break; + case EType.Text: + _Texts[_Interactions[_Selection].Num].Selected = false; + break; + case EType.SongMenu: + _SongMenus[_Interactions[_Selection].Num].Selected = false; + break; + case EType.Lyric: + _Lyrics[_Interactions[_Selection].Num].Selected = false; + break; + case EType.NameSelection: + _NameSelections[_Interactions[_Selection].Num].Selected = false; + break; + case EType.Equalizer: + _Equalizers[_Interactions[_Selection].Num].Selected = false; + break; + case EType.Playlist: + _Playlists[_Interactions[_Selection].Num].Selected = false; + break; + case EType.ParticleEffect: + _ParticleEffects[_Interactions[_Selection].Num].Selected = false; + break; } } @@ -938,41 +996,42 @@ namespace VocaluxeLib.Menu } } - private void _ToggleHighlighted() - { - if (_Selection >= _Interactions.Count || _Selection < 0) - return; - - if (_Interactions[_Selection].Type == EType.SelectSlide) - _SelectSlides[_Interactions[_Selection].Num].Highlighted = !_SelectSlides[_Interactions[_Selection].Num].Highlighted; - } - - private bool _IsHighlighted() + private bool _IsVisible(int interaction) { if (_Selection >= _Interactions.Count || _Selection < 0) return false; - if (_Interactions[_Selection].Type == EType.SelectSlide) - return _SelectSlides[_Interactions[_Selection].Num].Highlighted; - - return false; - } - - private bool _IsVisible(int interaction) - { switch (_Interactions[interaction].Type) { + case EType.Button: + return _Buttons[_Interactions[interaction].Num].Visible; + + case EType.SelectSlide: + return _SelectSlides[_Interactions[interaction].Num].Visible; + case EType.Static: return _Statics[_Interactions[interaction].Num].Visible; case EType.Text: return _Texts[_Interactions[interaction].Num].Visible; - case EType.Button: - return _Buttons[_Interactions[interaction].Num].Visible; + case EType.SongMenu: + return _SongMenus[_Interactions[interaction].Num].Visible; - case EType.SelectSlide: - return _SelectSlides[_Interactions[interaction].Num].Visible; + case EType.Lyric: + return _Lyrics[_Interactions[interaction].Num].Visible; + + case EType.NameSelection: + return _NameSelections[_Interactions[interaction].Num].Visible; + + case EType.Equalizer: + return _Equalizers[_Interactions[interaction].Num].Visible; + + case EType.Playlist: + return _Playlists[_Interactions[interaction].Num].Visible; + + case EType.ParticleEffect: + return _ParticleEffects[_Interactions[interaction].Num].Visible; } return false; @@ -980,6 +1039,9 @@ namespace VocaluxeLib.Menu private bool _IsEnabled(int interaction) { + if (_Selection >= _Interactions.Count || _Selection < 0) + return false; + switch (_Interactions[interaction].Type) { case EType.Button: @@ -993,26 +1055,73 @@ namespace VocaluxeLib.Menu case EType.Text: return false; //_Texts[_Interactions[interaction].Num].Visible; + + case EType.SongMenu: + return _SongMenus[_Interactions[interaction].Num].Visible; + + case EType.Lyric: + return false; //_Lyrics[_Interactions[interaction].Num].Visible; + + case EType.NameSelection: + return _NameSelections[_Interactions[interaction].Num].Visible; + + case EType.Equalizer: + return false; //_Equalizers[_Interactions[interaction].Num].Visible; + + case EType.Playlist: + return _Playlists[_Interactions[interaction].Num].Visible; + + case EType.ParticleEffect: + return false; //_ParticleEffects[_Interactions[interaction].Num].Visible; } return false; } - private SRectF _GetRect(int interaction) + private SRectF _GetRect(CInteraction interaction) { var result = new SRectF(); - switch (_Interactions[interaction].Type) + switch (interaction.Type) { case EType.Button: - return _Buttons[_Interactions[interaction].Num].Rect; + return _Buttons[interaction.Num].Rect; case EType.SelectSlide: - return _SelectSlides[_Interactions[interaction].Num].Rect; + return _SelectSlides[interaction.Num].Rect; + + case EType.Static: + return _Statics[interaction.Num].Rect; + + case EType.Text: + return _Texts[interaction.Num].Rect; + + case EType.SongMenu: + return _SongMenus[interaction.Num].Rect; + + case EType.Lyric: + return _Lyrics[interaction.Num].Rect; + + case EType.NameSelection: + return _NameSelections[interaction.Num].Rect; + + case EType.Equalizer: + return _Equalizers[interaction.Num].Rect; + + case EType.Playlist: + return _Playlists[interaction.Num].Rect; + + case EType.ParticleEffect: + return _ParticleEffects[interaction.Num].Rect; } return result; } + private SRectF _GetRect(int interaction) + { + return _GetRect(_Interactions[interaction]); + } + private void _AddInteraction(int num, EType type) { _Interactions.Add(new CInteraction(num, type)); @@ -1024,9 +1133,16 @@ namespace VocaluxeLib.Menu private void _DrawInteraction(int interaction) { - bool sel; switch (_Interactions[interaction].Type) { + case EType.Button: + _Buttons[_Interactions[interaction].Num].Draw(); + break; + + case EType.SelectSlide: + _SelectSlides[_Interactions[interaction].Num].Draw(); + break; + case EType.Static: _Statics[_Interactions[interaction].Num].Draw(); break; @@ -1035,21 +1151,35 @@ namespace VocaluxeLib.Menu _Texts[_Interactions[interaction].Num].Draw(); break; - case EType.Button: - sel = _Buttons[_Interactions[interaction].Num].Selected; - if (!Active) - _Buttons[_Interactions[interaction].Num].Selected = false; - _Buttons[_Interactions[interaction].Num].Draw(); - _Buttons[_Interactions[interaction].Num].Selected = sel; + case EType.SongMenu: + _SongMenus[_Interactions[interaction].Num].Draw(); break; - case EType.SelectSlide: - sel = _SelectSlides[_Interactions[interaction].Num].Selected; - if (!Active) - _SelectSlides[_Interactions[interaction].Num].Selected = false; - _SelectSlides[_Interactions[interaction].Num].Draw(); - _SelectSlides[_Interactions[interaction].Num].Selected = sel; + case EType.NameSelection: + _NameSelections[_Interactions[interaction].Num].Draw(); break; + + case EType.Equalizer: + if (!_Equalizers[_Interactions[interaction].Num].ScreenHandles) + { + //TODO: + //Call Update-Method of Equalizer and give infos about bg-sound. + //_Equalizers[_Interactions[interaction].Num].Draw(); + } + break; + + case EType.Playlist: + _Playlists[_Interactions[interaction].Num].Draw(); + break; + + case EType.ParticleEffect: + _ParticleEffects[_Interactions[interaction].Num].Draw(); + break; + + //TODO: + //case EType.TLyric: + // _Lyrics[_Interactions[interaction].Num].Draw(0); + // break; } } #endregion InteractionHandling @@ -1057,35 +1187,97 @@ namespace VocaluxeLib.Menu #region Theme Handling private void _MoveElement(int stepX, int stepY) { - if (_Interactions.Count > 0) + if (_Interactions.Count <= 0) + return; + switch (_Interactions[_Selection].Type) { - switch (_Interactions[_Selection].Type) - { - case EType.Button: - _Buttons[_Interactions[_Selection].Num].MoveElement(stepX, stepY); - break; + case EType.Button: + _Buttons[_Interactions[_Selection].Num].MoveElement(stepX, stepY); + break; - case EType.SelectSlide: - _SelectSlides[_Interactions[_Selection].Num].MoveElement(stepX, stepY); - break; - } + case EType.SelectSlide: + _SelectSlides[_Interactions[_Selection].Num].MoveElement(stepX, stepY); + break; + + case EType.Static: + _Statics[_Interactions[_Selection].Num].MoveElement(stepX, stepY); + break; + + case EType.Text: + _Texts[_Interactions[_Selection].Num].MoveElement(stepX, stepY); + break; + + case EType.SongMenu: + _SongMenus[_Interactions[_Selection].Num].MoveElement(stepX, stepY); + break; + + case EType.Lyric: + _Lyrics[_Interactions[_Selection].Num].MoveElement(stepX, stepY); + break; + + case EType.NameSelection: + _NameSelections[_Interactions[_Selection].Num].MoveElement(stepX, stepY); + break; + + case EType.Equalizer: + _Equalizers[_Interactions[_Selection].Num].MoveElement(stepX, stepY); + break; + + case EType.Playlist: + _Playlists[_Interactions[_Selection].Num].MoveElement(stepX, stepY); + break; + + case EType.ParticleEffect: + _ParticleEffects[_Interactions[_Selection].Num].MoveElement(stepX, stepY); + break; } } private void _ResizeElement(int stepW, int stepH) { - if (_Interactions.Count > 0) + if (_Interactions.Count <= 0) + return; + switch (_Interactions[_Selection].Type) { - switch (_Interactions[_Selection].Type) - { - case EType.Button: - _Buttons[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); - break; + case EType.Button: + _Buttons[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); + break; - case EType.SelectSlide: - _SelectSlides[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); - break; - } + case EType.SelectSlide: + _SelectSlides[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); + break; + + case EType.Static: + _Statics[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); + break; + + case EType.Text: + _Texts[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); + break; + + case EType.SongMenu: + _SongMenus[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); + break; + + case EType.Lyric: + _Lyrics[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); + break; + + case EType.NameSelection: + _NameSelections[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); + break; + + case EType.Equalizer: + _Equalizers[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); + break; + + case EType.Playlist: + _Playlists[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); + break; + + case EType.ParticleEffect: + _ParticleEffects[_Interactions[_Selection].Num].ResizeElement(stepW, stepH); + break; } } #endregion Theme Handling diff --git a/VocaluxeLib/Menu/COrderedDictionaryLite.cs b/VocaluxeLib/Menu/COrderedDictionaryLite.cs index fdc24a0b..d1d5463f 100644 --- a/VocaluxeLib/Menu/COrderedDictionaryLite.cs +++ b/VocaluxeLib/Menu/COrderedDictionaryLite.cs @@ -25,13 +25,15 @@ namespace VocaluxeLib.Menu { private readonly List _Items; private readonly Dictionary _HtIndex; - private readonly CMenu _Parent; + private readonly String _ParentName; - public COrderedDictionaryLite(CMenu parent) + public COrderedDictionaryLite(object parent) { _Items = new List(); _HtIndex = new Dictionary(); - _Parent = parent; + _ParentName = parent.GetType().Name; + if (_ParentName[0] == 'C' && Char.IsUpper(_ParentName[1])) + _ParentName = _ParentName.Remove(0, 1); } public T this[int index] @@ -50,7 +52,7 @@ namespace VocaluxeLib.Menu } catch (Exception) { - CBase.Log.LogError("Can't find " + typeof(T).Name.Substring(1) + " Element \"" + key + "\" in Screen " + _Parent.ThemeName); + CBase.Log.LogError("Can't find " + typeof(T).Name.Substring(1) + " Element \"" + key + "\" in " + _ParentName); throw; } } diff --git a/VocaluxeLib/Menu/CPlaylist.cs b/VocaluxeLib/Menu/CPlaylist.cs index 6dc72d39..2fb6d712 100644 --- a/VocaluxeLib/Menu/CPlaylist.cs +++ b/VocaluxeLib/Menu/CPlaylist.cs @@ -46,12 +46,6 @@ namespace VocaluxeLib.Menu { GameMode = EGameMode.TR_GAMEMODE_NORMAL; } - - public CPlaylistSong(CPlaylistSong ps) - { - SongID = ps.SongID; - GameMode = ps.GameMode; - } } [XmlType("Playlist")] @@ -84,7 +78,8 @@ namespace VocaluxeLib.Menu public SThemeSelectSlide SelectSlideGameMode; } - public class CPlaylist : IMenuElement + //TODO: Refactor this class, it is almost unreadable and may not work in some occasions + public class CPlaylist : CObjectInteractions, IMenuElement { private class CPlaylistElementContent { @@ -159,26 +154,23 @@ namespace VocaluxeLib.Menu get { return _ThemeLoaded; } } - private readonly CObjectInteractions _Interactions; + private readonly List _PlaylistElements = new List(); + private readonly List _PlaylistElementContents = new List(); - private readonly List _PlaylistElements; - private readonly List _PlaylistElementContents; - - public SRectF CompleteRect; + private SRectF _CompleteRect; public SRectF Rect; - public SColorF BackgroundColor; - public SColorF BackgroundSelColor; + private SColorF _BackgroundColor; + private SColorF _BackgroundSelColor; - public CButton ButtonPlaylistName; - public CButton ButtonPlaylistClose; - public CButton ButtonPlaylistSave; - public CButton ButtonPlaylistDelete; - public CButton ButtonPlaylistSing; - public CText Text1; - public CSelectSlide SelectSlideGameMode; - public CStatic StaticCover; - public CStatic StaticPlaylistHeader; - public CStatic StaticPlaylistFooter; + private readonly CButton _ButtonPlaylistName; + private readonly CButton _ButtonPlaylistClose; + private readonly CButton _ButtonPlaylistSave; + private readonly CButton _ButtonPlaylistDelete; + private readonly CButton _ButtonPlaylistSing; + private readonly CText _Text1; + private readonly CSelectSlide _SelectSlideGameMode; + private readonly CStatic _StaticPlaylistHeader; + private readonly CStatic _StaticPlaylistFooter; public bool Visible; @@ -189,26 +181,27 @@ namespace VocaluxeLib.Menu set { _Selected = value; - _Interactions.Active = value; - CurrentPlaylistElement = _GetSelectedSelectionNr(); + _Active = value; + _CurrentPlaylistElement = _GetSelectedElementNr(); if (!value) { - if (EditMode == EEditMode.ChangeOrder && _ChangeOrderSource != -1 && _PlaylistElements.Count > _ChangeOrderSource) + if (_EditMode == EEditMode.ChangeOrder && _ChangeOrderSource != -1 && _PlaylistElements.Count > _ChangeOrderSource) { CBase.Playlist.DeleteSong(ActivePlaylistID, _PlaylistElements[_ChangeOrderSource].Content); UpdatePlaylist(); } _ChangeOrderSource = -1; - EditMode = EEditMode.None; + _ChangeOrderElement = null; + _EditMode = EEditMode.None; } } } - public EEditMode EditMode; + private EEditMode _EditMode; public int ActivePlaylistID = -1; - public int Offset; - public int CurrentPlaylistElement = -1; + private int _Offset; + private int _CurrentPlaylistElement = -1; private CPlaylistElement _ChangeOrderElement; private int _ChangeOrderSource = -1; @@ -222,27 +215,15 @@ namespace VocaluxeLib.Menu { _PartyModeID = partyModeID; - Text1 = new CText(_PartyModeID); - StaticCover = new CStatic(_PartyModeID); - StaticPlaylistFooter = new CStatic(_PartyModeID); - StaticPlaylistHeader = new CStatic(_PartyModeID); - ButtonPlaylistName = new CButton(_PartyModeID); - ButtonPlaylistClose = new CButton(_PartyModeID); - ButtonPlaylistDelete = new CButton(_PartyModeID); - ButtonPlaylistSave = new CButton(_PartyModeID); - ButtonPlaylistSing = new CButton(_PartyModeID); - SelectSlideGameMode = new CSelectSlide(_PartyModeID); - - CompleteRect = new SRectF(); - Rect = new SRectF(); - BackgroundColor = new SColorF(); - BackgroundSelColor = new SColorF(); - - _PlaylistElements = new List(); - _PlaylistElementContents = new List(); - - _Interactions = new CObjectInteractions(); - _ChangeOrderElement = new CPlaylistElement(); + _Text1 = new CText(_PartyModeID); + _StaticPlaylistFooter = new CStatic(_PartyModeID); + _StaticPlaylistHeader = new CStatic(_PartyModeID); + _ButtonPlaylistName = new CButton(_PartyModeID); + _ButtonPlaylistClose = new CButton(_PartyModeID); + _ButtonPlaylistDelete = new CButton(_PartyModeID); + _ButtonPlaylistSave = new CButton(_PartyModeID); + _ButtonPlaylistSing = new CButton(_PartyModeID); + _SelectSlideGameMode = new CSelectSlide(_PartyModeID); Visible = false; Selected = false; @@ -253,43 +234,31 @@ namespace VocaluxeLib.Menu _PartyModeID = partyModeID; _Theme = theme; - CompleteRect = new SRectF(); - _PlaylistElements = new List(); - _PlaylistElementContents = new List(); - - _Interactions = new CObjectInteractions(); - _ChangeOrderElement = new CPlaylistElement(); - - Text1 = new CText(_Theme.Text1, _PartyModeID); - StaticCover = new CStatic(_Theme.StaticCover, _PartyModeID); - StaticPlaylistFooter = new CStatic(_Theme.StaticPlaylistFooter, _PartyModeID); - StaticPlaylistHeader = new CStatic(_Theme.StaticPlaylistHeader, _PartyModeID); - ButtonPlaylistName = new CButton(_Theme.ButtonPlaylistName, _PartyModeID); - ButtonPlaylistClose = new CButton(_Theme.ButtonPlaylistClose, _PartyModeID); - ButtonPlaylistDelete = new CButton(_Theme.ButtonPlaylistDelete, _PartyModeID); - ButtonPlaylistSave = new CButton(_Theme.ButtonPlaylistSave, _PartyModeID); - ButtonPlaylistSing = new CButton(_Theme.ButtonPlaylistSing, _PartyModeID); - SelectSlideGameMode = new CSelectSlide(_Theme.SelectSlideGameMode, _PartyModeID); - + _Text1 = new CText(_Theme.Text1, _PartyModeID); + _StaticPlaylistFooter = new CStatic(_Theme.StaticPlaylistFooter, _PartyModeID); + _StaticPlaylistHeader = new CStatic(_Theme.StaticPlaylistHeader, _PartyModeID); + _ButtonPlaylistName = new CButton(_Theme.ButtonPlaylistName, _PartyModeID); + _ButtonPlaylistClose = new CButton(_Theme.ButtonPlaylistClose, _PartyModeID); + _ButtonPlaylistDelete = new CButton(_Theme.ButtonPlaylistDelete, _PartyModeID); + _ButtonPlaylistSave = new CButton(_Theme.ButtonPlaylistSave, _PartyModeID); + _ButtonPlaylistSing = new CButton(_Theme.ButtonPlaylistSing, _PartyModeID); + _SelectSlideGameMode = new CSelectSlide(_Theme.SelectSlideGameMode, _PartyModeID); Visible = false; Selected = false; - - LoadSkin(); } - public void Init() + public override void Init() { - _Interactions.Clear(); - _PrepareList(); - _Interactions.AddStatic(StaticCover); - _Interactions.AddStatic(StaticPlaylistFooter); - _Interactions.AddStatic(StaticPlaylistHeader); - _Interactions.AddButton(ButtonPlaylistName); - _Interactions.AddButton(ButtonPlaylistClose); - _Interactions.AddButton(ButtonPlaylistDelete); - _Interactions.AddButton(ButtonPlaylistSave); - _Interactions.AddButton(ButtonPlaylistSing); + base.Init(); + _AddStatic(_StaticPlaylistFooter); + _AddStatic(_StaticPlaylistHeader); + _AddButton(_ButtonPlaylistName); + _AddButton(_ButtonPlaylistClose); + _AddButton(_ButtonPlaylistDelete); + _AddButton(_ButtonPlaylistSave); + _AddButton(_ButtonPlaylistSing); + LoadSkin(); } public bool LoadTheme(string xmlPath, string elementName, CXMLReader xmlReader) @@ -306,129 +275,129 @@ namespace VocaluxeLib.Menu _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W); _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H); if (xmlReader.GetValue(item + "/ColorBackground", out _Theme.ColorBackground.Name, String.Empty)) - _ThemeLoaded &= _Theme.ColorBackground.Get(_PartyModeID, out BackgroundColor); + _ThemeLoaded &= _Theme.ColorBackground.Get(_PartyModeID, out _BackgroundColor); else { - _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundR", ref BackgroundColor.R); - _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundG", ref BackgroundColor.G); - _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundB", ref BackgroundColor.B); - _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundA", ref BackgroundColor.A); + _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundR", ref _BackgroundColor.R); + _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundG", ref _BackgroundColor.G); + _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundB", ref _BackgroundColor.B); + _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundA", ref _BackgroundColor.A); } if (xmlReader.GetValue(item + "/SColorBackground", out _Theme.SelColorBackground.Name, String.Empty)) - _ThemeLoaded &= _Theme.SelColorBackground.Get(_PartyModeID, out BackgroundSelColor); + _ThemeLoaded &= _Theme.SelColorBackground.Get(_PartyModeID, out _BackgroundSelColor); else { - _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundR", ref BackgroundSelColor.R); - _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundG", ref BackgroundSelColor.G); - _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundB", ref BackgroundSelColor.B); - _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundA", ref BackgroundSelColor.A); + _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundR", ref _BackgroundSelColor.R); + _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundG", ref _BackgroundSelColor.G); + _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundB", ref _BackgroundSelColor.B); + _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundA", ref _BackgroundSelColor.A); } - _ThemeLoaded &= Text1.LoadTheme(item, "TextPart1", xmlReader); + _ThemeLoaded &= _Text1.LoadTheme(item, "TextPart1", xmlReader); - _ThemeLoaded &= StaticCover.LoadTheme(item, "StaticCover", xmlReader); - _ThemeLoaded &= StaticPlaylistHeader.LoadTheme(item, "StaticPlaylistHeader", xmlReader); - _ThemeLoaded &= StaticPlaylistFooter.LoadTheme(item, "StaticPlaylistFooter", xmlReader); + CStatic tmpStatic = new CStatic(_PartyModeID); + _ThemeLoaded &= tmpStatic.LoadTheme(item, "StaticCover", xmlReader); + _ThemeLoaded &= _StaticPlaylistHeader.LoadTheme(item, "StaticPlaylistHeader", xmlReader); + _ThemeLoaded &= _StaticPlaylistFooter.LoadTheme(item, "StaticPlaylistFooter", xmlReader); - _ThemeLoaded &= ButtonPlaylistName.LoadTheme(item, "ButtonPlaylistName", xmlReader); - _ThemeLoaded &= ButtonPlaylistSing.LoadTheme(item, "ButtonPlaylistSing", xmlReader); - _ThemeLoaded &= ButtonPlaylistClose.LoadTheme(item, "ButtonPlaylistClose", xmlReader); - _ThemeLoaded &= ButtonPlaylistSave.LoadTheme(item, "ButtonPlaylistSave", xmlReader); - _ThemeLoaded &= ButtonPlaylistDelete.LoadTheme(item, "ButtonPlaylistDelete", xmlReader); + _ThemeLoaded &= _ButtonPlaylistName.LoadTheme(item, "ButtonPlaylistName", xmlReader); + _ThemeLoaded &= _ButtonPlaylistSing.LoadTheme(item, "ButtonPlaylistSing", xmlReader); + _ThemeLoaded &= _ButtonPlaylistClose.LoadTheme(item, "ButtonPlaylistClose", xmlReader); + _ThemeLoaded &= _ButtonPlaylistSave.LoadTheme(item, "ButtonPlaylistSave", xmlReader); + _ThemeLoaded &= _ButtonPlaylistDelete.LoadTheme(item, "ButtonPlaylistDelete", xmlReader); - _ThemeLoaded &= SelectSlideGameMode.LoadTheme(item, "SelectSlideGameMode", xmlReader); + _ThemeLoaded &= _SelectSlideGameMode.LoadTheme(item, "SelectSlideGameMode", xmlReader); _ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/EntryHeight", ref _Theme.EntryHeight); if (_ThemeLoaded) { _Theme.Name = elementName; - _Theme.ColorBackground.Color = BackgroundColor; - _Theme.SelColorBackground.Color = BackgroundSelColor; - _Theme.Text1 = Text1.GetTheme(); - _Theme.StaticCover = StaticCover.GetTheme(); - _Theme.StaticPlaylistFooter = StaticPlaylistFooter.GetTheme(); - _Theme.StaticPlaylistHeader = StaticPlaylistHeader.GetTheme(); - _Theme.ButtonPlaylistName = ButtonPlaylistName.GetTheme(); - _Theme.ButtonPlaylistSing = ButtonPlaylistSing.GetTheme(); - _Theme.ButtonPlaylistClose = ButtonPlaylistClose.GetTheme(); - _Theme.ButtonPlaylistSave = ButtonPlaylistSave.GetTheme(); - _Theme.ButtonPlaylistDelete = ButtonPlaylistDelete.GetTheme(); + _Theme.ColorBackground.Color = _BackgroundColor; + _Theme.SelColorBackground.Color = _BackgroundSelColor; + _Theme.Text1 = _Text1.GetTheme(); + _Theme.StaticCover = tmpStatic.GetTheme(); + _Theme.StaticPlaylistFooter = _StaticPlaylistFooter.GetTheme(); + _Theme.StaticPlaylistHeader = _StaticPlaylistHeader.GetTheme(); + _Theme.ButtonPlaylistName = _ButtonPlaylistName.GetTheme(); + _Theme.ButtonPlaylistSing = _ButtonPlaylistSing.GetTheme(); + _Theme.ButtonPlaylistClose = _ButtonPlaylistClose.GetTheme(); + _Theme.ButtonPlaylistSave = _ButtonPlaylistSave.GetTheme(); + _Theme.ButtonPlaylistDelete = _ButtonPlaylistDelete.GetTheme(); LoadSkin(); } return _ThemeLoaded; } - public void Draw(bool forceDraw = false) + public override bool Draw() { if (_PlaylistElements.Count <= 0) LoadPlaylist(0); - if (!Visible && CBase.Settings.GetProgramState() != EProgramState.EditTheme && !forceDraw) - return; + if (!Visible && CBase.Settings.GetProgramState() != EProgramState.EditTheme) + return true; for (int i = 0; i < _PlaylistElements.Count; i++) { - if (i == CurrentPlaylistElement && _Selected) + if (i == _CurrentPlaylistElement && _Selected) { _PlaylistElements[i].Background.Texture = CBase.Themes.GetSkinTexture(_Theme.SkinBackgroundSelected, _PartyModeID); - _PlaylistElements[i].Background.Color = BackgroundSelColor; + _PlaylistElements[i].Background.Color = _BackgroundSelColor; } else { _PlaylistElements[i].Background.Texture = CBase.Themes.GetSkinTexture(_Theme.SkinBackground, _PartyModeID); - _PlaylistElements[i].Background.Color = BackgroundColor; + _PlaylistElements[i].Background.Color = _BackgroundColor; } } - _Interactions.Draw(); - if (EditMode == EEditMode.ChangeOrder) + if (_ChangeOrderElement != null) _ChangeOrderElement.Draw(); + return base.Draw(); } public bool IsMouseOver(SMouseEvent mouseEvent) { - return CHelper.IsInBounds(CompleteRect, mouseEvent) || _Interactions.IsMouseOver(mouseEvent); + return CHelper.IsInBounds(_CompleteRect, mouseEvent); } public void UnloadSkin() { - Text1.UnloadSkin(); - ButtonPlaylistClose.UnloadSkin(); - ButtonPlaylistDelete.UnloadSkin(); - ButtonPlaylistName.UnloadSkin(); - ButtonPlaylistSave.UnloadSkin(); - ButtonPlaylistSing.UnloadSkin(); + _Text1.UnloadSkin(); + _ButtonPlaylistClose.UnloadSkin(); + _ButtonPlaylistDelete.UnloadSkin(); + _ButtonPlaylistName.UnloadSkin(); + _ButtonPlaylistSave.UnloadSkin(); + _ButtonPlaylistSing.UnloadSkin(); - StaticCover.UnloadSkin(); - StaticPlaylistFooter.UnloadSkin(); - StaticPlaylistHeader.UnloadSkin(); + _StaticPlaylistFooter.UnloadSkin(); + _StaticPlaylistHeader.UnloadSkin(); - SelectSlideGameMode.UnloadSkin(); + _SelectSlideGameMode.UnloadSkin(); + _ClearElements(); } public void LoadSkin() { - _Theme.ColorBackground.Get(_PartyModeID, out BackgroundColor); - _Theme.SelColorBackground.Get(_PartyModeID, out BackgroundSelColor); + _Theme.ColorBackground.Get(_PartyModeID, out _BackgroundColor); + _Theme.SelColorBackground.Get(_PartyModeID, out _BackgroundSelColor); Rect = _Theme.Rect; - Text1.LoadSkin(); - ButtonPlaylistClose.LoadSkin(); - ButtonPlaylistDelete.LoadSkin(); - ButtonPlaylistName.LoadSkin(); - ButtonPlaylistSave.LoadSkin(); - ButtonPlaylistSing.LoadSkin(); + _Text1.LoadSkin(); + _ButtonPlaylistClose.LoadSkin(); + _ButtonPlaylistDelete.LoadSkin(); + _ButtonPlaylistName.LoadSkin(); + _ButtonPlaylistSave.LoadSkin(); + _ButtonPlaylistSing.LoadSkin(); - StaticCover.LoadSkin(); - StaticPlaylistFooter.LoadSkin(); - StaticPlaylistHeader.LoadSkin(); + _StaticPlaylistFooter.LoadSkin(); + _StaticPlaylistHeader.LoadSkin(); - SelectSlideGameMode.LoadSkin(); + _SelectSlideGameMode.LoadSkin(); _UpdateRect(); - Init(); + _PrepareList(); } public void ReloadSkin() @@ -437,308 +406,309 @@ namespace VocaluxeLib.Menu LoadSkin(); } - public bool HandleInput(SKeyEvent keyEvent) + public override bool HandleInput(SKeyEvent keyEvent) { - if (Selected) + if (!Selected) + return true; + //Active EditMode ignores other input! + if (_EditMode == EEditMode.PlaylistName) { - //Active EditMode ignores other input! - if (EditMode == EEditMode.PlaylistName) + if (keyEvent.KeyPressed && !Char.IsControl(keyEvent.Unicode)) + _ButtonPlaylistName.Text.Text = _ButtonPlaylistName.Text.Text + keyEvent.Unicode; + else { - if (keyEvent.KeyPressed && !Char.IsControl(keyEvent.Unicode)) - ButtonPlaylistName.Text.Text = ButtonPlaylistName.Text.Text + keyEvent.Unicode; - else - { - switch (keyEvent.Key) - { - case Keys.Enter: - CBase.Playlist.SetName(ActivePlaylistID, ButtonPlaylistName.Text.Text); - CBase.Playlist.Save(ActivePlaylistID); - EditMode = EEditMode.None; - ButtonPlaylistName.EditMode = false; - break; - case Keys.Escape: - ButtonPlaylistName.Text.Text = CBase.Playlist.GetName(ActivePlaylistID); - EditMode = EEditMode.None; - ButtonPlaylistName.EditMode = false; - break; - case Keys.Delete: - case Keys.Back: - if (!String.IsNullOrEmpty(ButtonPlaylistName.Text.Text)) - ButtonPlaylistName.Text.Text = ButtonPlaylistName.Text.Text.Remove(ButtonPlaylistName.Text.Text.Length - 1); - break; - } - } - return true; - } - if (CurrentPlaylistElement == -1 || _PlaylistElementContents.Count == 0) - { - //no song is selected - _Interactions.HandleInput(keyEvent); - CurrentPlaylistElement = _GetSelectedSelectionNr(); - - if (CurrentPlaylistElement != -1) - return true; - } - else if (CurrentPlaylistElement != -1) - { - //a song is selected - int scrollLimit = _PlaylistElements.Count / 2; - - //special actions if a song is selected switch (keyEvent.Key) { - case Keys.Up: - if (keyEvent.ModShift) - { - _Interactions.SetInteractionToSelectSlide(_PlaylistElements[0].SelectSlide); - _Interactions.HandleInput(keyEvent); - CurrentPlaylistElement = _GetSelectedSelectionNr(); - } - else if (CurrentPlaylistElement > scrollLimit || _PlaylistElementContents.Count == 0) - { - _Interactions.HandleInput(keyEvent); - CurrentPlaylistElement = _GetSelectedSelectionNr(); - } - else if (CurrentPlaylistElement <= scrollLimit) - { - if (Offset > 0) - { - Offset--; - Update(); - } - else - { - _Interactions.HandleInput(keyEvent); - CurrentPlaylistElement = _GetSelectedSelectionNr(); - } - } - break; - - case Keys.Down: - if (keyEvent.ModShift) - { - for (int i = _PlaylistElements.Count - 1; i >= 0; i--) - { - if (_PlaylistElements[i].SelectSlide.Visible) - { - _Interactions.SetInteractionToSelectSlide(_PlaylistElements[0].SelectSlide); - _Interactions.HandleInput(keyEvent); - CurrentPlaylistElement = _GetSelectedSelectionNr(); - } - } - } - else if (CurrentPlaylistElement >= scrollLimit) - { - if (Offset < _PlaylistElementContents.Count - _PlaylistElements.Count) - { - Offset++; - Update(); - } - else - { - _Interactions.HandleInput(keyEvent); - CurrentPlaylistElement = _GetSelectedSelectionNr(); - } - } - else if (CurrentPlaylistElement < scrollLimit) - { - _Interactions.HandleInput(keyEvent); - CurrentPlaylistElement = _GetSelectedSelectionNr(); - } - break; - - case Keys.Delete: - CBase.Playlist.DeleteSong(ActivePlaylistID, _PlaylistElements[CurrentPlaylistElement].Content); - UpdatePlaylist(); - - if (Offset > 0) - Offset--; - - Update(); - - if (_PlaylistElementContents.Count - 1 < CurrentPlaylistElement) - CurrentPlaylistElement = _PlaylistElementContents.Count - 1; - - if (CurrentPlaylistElement != -1) - _Interactions.SetInteractionToSelectSlide(_PlaylistElements[CurrentPlaylistElement].SelectSlide); - break; - - case Keys.Back: - ClosePlaylist(); //really? or better global? - break; - case Keys.Enter: - _StartPlaylistSong(CurrentPlaylistElement); + CBase.Playlist.SetName(ActivePlaylistID, _ButtonPlaylistName.Text.Text); + CBase.Playlist.Save(ActivePlaylistID); + _EditMode = EEditMode.None; + _ButtonPlaylistName.EditMode = false; break; - - case Keys.Add: //move the selected song up - if (_PlaylistElementContents.Count > 1 && (CurrentPlaylistElement > 0 || Offset > 0)) - { - CBase.Playlist.MoveSongUp(ActivePlaylistID, CurrentPlaylistElement + Offset); - UpdatePlaylist(); - - var key = new SKeyEvent {Key = Keys.Up}; - - if (CurrentPlaylistElement > scrollLimit) - { - _Interactions.HandleInput(key); - CurrentPlaylistElement = _GetSelectedSelectionNr(); - } - else if (CurrentPlaylistElement <= scrollLimit) - { - if (Offset > 0) - { - Offset--; - Update(); - } - else - { - _Interactions.HandleInput(key); - CurrentPlaylistElement = _GetSelectedSelectionNr(); - } - } - } + case Keys.Escape: + _ButtonPlaylistName.Text.Text = CBase.Playlist.GetName(ActivePlaylistID); + _EditMode = EEditMode.None; + _ButtonPlaylistName.EditMode = false; break; - - case Keys.Subtract: //move the selected song down - if (_PlaylistElementContents.Count > 1 && CurrentPlaylistElement + Offset < _PlaylistElementContents.Count - 1) - { - CBase.Playlist.MoveSongDown(ActivePlaylistID, CurrentPlaylistElement + Offset); - UpdatePlaylist(); - - var key = new SKeyEvent {Key = Keys.Down}; - - if (CurrentPlaylistElement >= scrollLimit) - { - if (Offset < _PlaylistElementContents.Count - _PlaylistElements.Count) - { - Offset++; - Update(); - } - else - { - _Interactions.HandleInput(key); - CurrentPlaylistElement = _GetSelectedSelectionNr(); - } - } - else if (CurrentPlaylistElement < scrollLimit) - { - _Interactions.HandleInput(key); - CurrentPlaylistElement = _GetSelectedSelectionNr(); - } - } - break; - - case Keys.PageUp: //scroll up - if (_PlaylistElementContents.Count > 0) - { - Offset -= _PlaylistElements.Count; - - if (Offset < 0) - Offset = 0; - - Update(); - CurrentPlaylistElement = 0; - } - break; - - case Keys.PageDown: //scroll down - if (_PlaylistElementContents.Count > 0) - { - Offset += _PlaylistElements.Count; - - if (Offset > _PlaylistElementContents.Count - _PlaylistElements.Count) - Offset = _PlaylistElementContents.Count - _PlaylistElements.Count; - - if (Offset < 0) - Offset = 0; - - Update(); - - for (int i = _PlaylistElements.Count - 1; i >= 0; i--) - { - if (_PlaylistElements[i].SelectSlide.Visible) - { - CurrentPlaylistElement = i; - break; - } - } - } - break; - - case Keys.Left: - _Interactions.HandleInput(keyEvent); - CurrentPlaylistElement = _GetSelectedSelectionNr(); - - if (CurrentPlaylistElement != -1) - { - CBase.Playlist.GetSong(ActivePlaylistID, CurrentPlaylistElement + Offset).GameMode = - _PlaylistElementContents[CurrentPlaylistElement + Offset].Modes[_PlaylistElements[CurrentPlaylistElement].SelectSlide.Selection]; - UpdatePlaylist(); - } - break; - - case Keys.Right: - _Interactions.HandleInput(keyEvent); - CurrentPlaylistElement = _GetSelectedSelectionNr(); - - if (CurrentPlaylistElement != -1) - { - CBase.Playlist.GetSong(ActivePlaylistID, CurrentPlaylistElement + Offset).GameMode = - _PlaylistElementContents[CurrentPlaylistElement + Offset].Modes[_PlaylistElements[CurrentPlaylistElement].SelectSlide.Selection]; - UpdatePlaylist(); - } + case Keys.Delete: + case Keys.Back: + if (!String.IsNullOrEmpty(_ButtonPlaylistName.Text.Text)) + _ButtonPlaylistName.Text.Text = _ButtonPlaylistName.Text.Text.Remove(_ButtonPlaylistName.Text.Text.Length - 1); break; } - return true; } + return true; + } + if (_CurrentPlaylistElement == -1 || _PlaylistElementContents.Count == 0) + { + //no song is selected + base.HandleInput(keyEvent); + _CurrentPlaylistElement = _GetSelectedElementNr(); - //default actions + if (_CurrentPlaylistElement != -1) + return true; + } + else if (_CurrentPlaylistElement != -1) + { + //a song is selected + int scrollLimit = _PlaylistElements.Count / 2; + + //special actions if a song is selected switch (keyEvent.Key) { - case Keys.Back: - if (ButtonPlaylistName.Selected) + case Keys.Up: + if (keyEvent.ModShift) { - EditMode = EEditMode.PlaylistName; - ButtonPlaylistName.EditMode = true; + _SetInteractionToSelectSlide(_PlaylistElements[0].SelectSlide); + base.HandleInput(keyEvent); + _CurrentPlaylistElement = _GetSelectedElementNr(); } - else - ClosePlaylist(); - break; - - case Keys.Enter: - if (ButtonPlaylistClose.Selected) - ClosePlaylist(); - else if (ButtonPlaylistSing.Selected) - _StartPlaylistSongs(); - else if (ButtonPlaylistSave.Selected) - CBase.Playlist.Save(ActivePlaylistID); - else if (ButtonPlaylistDelete.Selected) + else if (_CurrentPlaylistElement > scrollLimit || _PlaylistElementContents.Count == 0) { - CBase.Playlist.Delete(ActivePlaylistID); - ClosePlaylist(); + base.HandleInput(keyEvent); + _CurrentPlaylistElement = _GetSelectedElementNr(); } - else if (ButtonPlaylistName.Selected) + else if (_CurrentPlaylistElement <= scrollLimit) { - if (EditMode != EEditMode.PlaylistName) + if (_Offset > 0) { - EditMode = EEditMode.PlaylistName; - ButtonPlaylistName.EditMode = true; + _Offset--; + _Update(); } else { - EditMode = EEditMode.None; - ButtonPlaylistName.EditMode = false; + base.HandleInput(keyEvent); + _CurrentPlaylistElement = _GetSelectedElementNr(); } } break; - case Keys.PageDown: - _SetSelectionToLastEntry(); + + case Keys.Down: + if (keyEvent.ModShift) + { + for (int i = _PlaylistElements.Count - 1; i >= 0; i--) + { + if (_PlaylistElements[i].SelectSlide.Visible) + { + _SetInteractionToSelectSlide(_PlaylistElements[0].SelectSlide); + base.HandleInput(keyEvent); + _CurrentPlaylistElement = _GetSelectedElementNr(); + } + } + } + else if (_CurrentPlaylistElement >= scrollLimit) + { + if (_Offset < _PlaylistElementContents.Count - _PlaylistElements.Count) + { + _Offset++; + _Update(); + } + else + { + base.HandleInput(keyEvent); + _CurrentPlaylistElement = _GetSelectedElementNr(); + } + } + else if (_CurrentPlaylistElement < scrollLimit) + { + base.HandleInput(keyEvent); + _CurrentPlaylistElement = _GetSelectedElementNr(); + } break; - case Keys.PageUp: - _SetSelectionToFirstEntry(); + + case Keys.Delete: + CBase.Playlist.DeleteSong(ActivePlaylistID, _PlaylistElements[_CurrentPlaylistElement].Content); + UpdatePlaylist(); + + if (_Offset > 0) + _Offset--; + + _Update(); + + if (_PlaylistElementContents.Count - 1 < _CurrentPlaylistElement) + _CurrentPlaylistElement = _PlaylistElementContents.Count - 1; + + if (_CurrentPlaylistElement != -1) + _SetInteractionToSelectSlide(_PlaylistElements[_CurrentPlaylistElement].SelectSlide); + break; + + case Keys.Back: + ClosePlaylist(); //really? or better global? + break; + + case Keys.Enter: + _StartPlaylistSong(_CurrentPlaylistElement); + break; + + case Keys.Add: //move the selected song up + if (_PlaylistElementContents.Count > 1 && (_CurrentPlaylistElement > 0 || _Offset > 0)) + { + CBase.Playlist.MoveSongUp(ActivePlaylistID, _CurrentPlaylistElement + _Offset); + UpdatePlaylist(); + + var key = new SKeyEvent {Key = Keys.Up}; + + if (_CurrentPlaylistElement > scrollLimit) + { + base.HandleInput(key); + _CurrentPlaylistElement = _GetSelectedElementNr(); + } + else if (_CurrentPlaylistElement <= scrollLimit) + { + if (_Offset > 0) + { + _Offset--; + _Update(); + } + else + { + base.HandleInput(key); + _CurrentPlaylistElement = _GetSelectedElementNr(); + } + } + } + break; + + case Keys.Subtract: //move the selected song down + if (_PlaylistElementContents.Count > 1 && _CurrentPlaylistElement + _Offset < _PlaylistElementContents.Count - 1) + { + CBase.Playlist.MoveSongDown(ActivePlaylistID, _CurrentPlaylistElement + _Offset); + UpdatePlaylist(); + + var key = new SKeyEvent {Key = Keys.Down}; + + if (_CurrentPlaylistElement >= scrollLimit) + { + if (_Offset < _PlaylistElementContents.Count - _PlaylistElements.Count) + { + _Offset++; + _Update(); + } + else + { + base.HandleInput(key); + _CurrentPlaylistElement = _GetSelectedElementNr(); + } + } + else if (_CurrentPlaylistElement < scrollLimit) + { + base.HandleInput(key); + _CurrentPlaylistElement = _GetSelectedElementNr(); + } + } + break; + + case Keys.PageUp: //scroll up + if (_PlaylistElementContents.Count > 0) + { + _Offset -= _PlaylistElements.Count; + + if (_Offset < 0) + _Offset = 0; + + _Update(); + _CurrentPlaylistElement = 0; + } + break; + + case Keys.PageDown: //scroll down + if (_PlaylistElementContents.Count > 0) + { + _Offset += _PlaylistElements.Count; + + if (_Offset > _PlaylistElementContents.Count - _PlaylistElements.Count) + _Offset = _PlaylistElementContents.Count - _PlaylistElements.Count; + + if (_Offset < 0) + _Offset = 0; + + _Update(); + + for (int i = _PlaylistElements.Count - 1; i >= 0; i--) + { + if (_PlaylistElements[i].SelectSlide.Visible) + { + _CurrentPlaylistElement = i; + break; + } + } + } + break; + + case Keys.Left: + base.HandleInput(keyEvent); + _CurrentPlaylistElement = _GetSelectedElementNr(); + + if (_CurrentPlaylistElement != -1) + { + CBase.Playlist.GetSong(ActivePlaylistID, _CurrentPlaylistElement + _Offset).GameMode = + _PlaylistElementContents[_CurrentPlaylistElement + _Offset].Modes[_PlaylistElements[_CurrentPlaylistElement].SelectSlide.Selection]; + UpdatePlaylist(); + } + break; + + case Keys.Right: + base.HandleInput(keyEvent); + _CurrentPlaylistElement = _GetSelectedElementNr(); + + if (_CurrentPlaylistElement != -1) + { + CBase.Playlist.GetSong(ActivePlaylistID, _CurrentPlaylistElement + _Offset).GameMode = + _PlaylistElementContents[_CurrentPlaylistElement + _Offset].Modes[_PlaylistElements[_CurrentPlaylistElement].SelectSlide.Selection]; + UpdatePlaylist(); + } break; } + return true; + } + + //default actions + switch (keyEvent.Key) + { + case Keys.Back: + if (_ButtonPlaylistName.Selected) + { + _EditMode = EEditMode.PlaylistName; + _ButtonPlaylistName.EditMode = true; + _ChangeOrderElement = null; + } + else + ClosePlaylist(); + break; + + case Keys.Enter: + if (_ButtonPlaylistClose.Selected) + ClosePlaylist(); + else if (_ButtonPlaylistSing.Selected) + _StartPlaylistSongs(); + else if (_ButtonPlaylistSave.Selected) + CBase.Playlist.Save(ActivePlaylistID); + else if (_ButtonPlaylistDelete.Selected) + { + CBase.Playlist.Delete(ActivePlaylistID); + ClosePlaylist(); + } + else if (_ButtonPlaylistName.Selected) + { + _ChangeOrderElement = null; + if (_EditMode != EEditMode.PlaylistName) + { + _EditMode = EEditMode.PlaylistName; + _ButtonPlaylistName.EditMode = true; + } + else + { + _EditMode = EEditMode.None; + _ButtonPlaylistName.EditMode = false; + } + } + break; + case Keys.PageDown: + _SetSelectionToLastEntry(); + break; + case Keys.PageUp: + _SetSelectionToFirstEntry(); + break; } return true; } @@ -749,15 +719,15 @@ namespace VocaluxeLib.Menu return; int off = _PlaylistElementContents.Count - _PlaylistElements.Count; - Offset = off >= 0 ? off : 0; + _Offset = off >= 0 ? off : 0; - Update(); + _Update(); for (int i = _PlaylistElements.Count - 1; i >= 0; i--) { if (_PlaylistElements[i].SelectSlide.Visible) { - CurrentPlaylistElement = i; + _CurrentPlaylistElement = i; return; } } @@ -768,13 +738,13 @@ namespace VocaluxeLib.Menu if (_PlaylistElementContents.Count == 0) return; - Offset = 0; - Update(); + _Offset = 0; + _Update(); - CurrentPlaylistElement = 0; + _CurrentPlaylistElement = 0; } - private int _GetSelectedSelectionNr() + private int _GetSelectedElementNr() { for (int i = 0; i < _PlaylistElements.Count; i++) { @@ -790,33 +760,33 @@ namespace VocaluxeLib.Menu return; int off = _PlaylistElementContents.Count - _PlaylistElements.Count; - Offset = off >= 0 ? off : 0; + _Offset = off >= 0 ? off : 0; - Update(); + _Update(); } - public bool HandleMouse(SMouseEvent mouseEvent) + public override bool HandleMouse(SMouseEvent mouseEvent) { - _Interactions.HandleMouse(mouseEvent); + base.HandleMouse(mouseEvent); - if (CHelper.IsInBounds(CompleteRect, mouseEvent) && Visible) + if (CHelper.IsInBounds(_CompleteRect, mouseEvent) && Visible) { //Scroll if (mouseEvent.Wheel > 0) { - if (_PlaylistElements.Count + Offset + mouseEvent.Wheel <= _PlaylistElementContents.Count) + if (_PlaylistElements.Count + _Offset + mouseEvent.Wheel <= _PlaylistElementContents.Count) { - Offset += mouseEvent.Wheel; - Update(); + _Offset += mouseEvent.Wheel; + _Update(); } return true; } if (mouseEvent.Wheel < 0) { - if (Offset + mouseEvent.Wheel >= 0) + if (_Offset + mouseEvent.Wheel >= 0) { - Offset += mouseEvent.Wheel; - Update(); + _Offset += mouseEvent.Wheel; + _Update(); } return true; } @@ -828,9 +798,9 @@ namespace VocaluxeLib.Menu if (_PlaylistElementContents.Count - 1 >= i && CHelper.IsInBounds(_PlaylistElements[i].Background.Rect, mouseEvent)) { hoverSet = true; - CurrentPlaylistElement = i; - _Interactions.SetInteractionToSelectSlide(_PlaylistElements[CurrentPlaylistElement].SelectSlide); - _Interactions.ProcessMouseMove(mouseEvent.X, mouseEvent.Y); + _CurrentPlaylistElement = i; + _SetInteractionToSelectSlide(_PlaylistElements[_CurrentPlaylistElement].SelectSlide); + ProcessMouseMove(mouseEvent.X, mouseEvent.Y); } //Delete Entry with RB @@ -842,9 +812,9 @@ namespace VocaluxeLib.Menu } } if (!hoverSet) - CurrentPlaylistElement = -1; + _CurrentPlaylistElement = -1; - switch (EditMode) + switch (_EditMode) { //Normal mode case EEditMode.None: @@ -852,55 +822,55 @@ namespace VocaluxeLib.Menu //LB actions if (mouseEvent.LB) { - if (CurrentPlaylistElement != -1) + if (_CurrentPlaylistElement != -1) { - CBase.Playlist.GetSong(ActivePlaylistID, CurrentPlaylistElement + Offset).GameMode = - _PlaylistElementContents[CurrentPlaylistElement + Offset].Modes[_PlaylistElements[CurrentPlaylistElement].SelectSlide.Selection]; + CBase.Playlist.GetSong(ActivePlaylistID, _CurrentPlaylistElement + _Offset).GameMode = + _PlaylistElementContents[_CurrentPlaylistElement + _Offset].Modes[_PlaylistElements[_CurrentPlaylistElement].SelectSlide.Selection]; UpdatePlaylist(); } - if (ButtonPlaylistClose.Selected) + if (_ButtonPlaylistClose.Selected) { ClosePlaylist(); return true; } - if (ButtonPlaylistSing.Selected) + if (_ButtonPlaylistSing.Selected) { _StartPlaylistSongs(); return true; } - if (ButtonPlaylistSave.Selected) + if (_ButtonPlaylistSave.Selected) { CBase.Playlist.Save(ActivePlaylistID); return true; } - if (ButtonPlaylistDelete.Selected) + if (_ButtonPlaylistDelete.Selected) { CBase.Playlist.Delete(ActivePlaylistID); ClosePlaylist(); return true; } - if (ButtonPlaylistName.Selected) + if (_ButtonPlaylistName.Selected) { - EditMode = EEditMode.PlaylistName; - ButtonPlaylistName.EditMode = true; + _EditMode = EEditMode.PlaylistName; + _ButtonPlaylistName.EditMode = true; return true; } } //Start selected song with double click - if (mouseEvent.LD && CurrentPlaylistElement != -1) - _StartPlaylistSong(CurrentPlaylistElement); + if (mouseEvent.LD && _CurrentPlaylistElement != -1) + _StartPlaylistSong(_CurrentPlaylistElement); //Change order with holding LB - if (mouseEvent.LBH && CurrentPlaylistElement != -1 && _PlaylistElementContents.Count > 0 && DragAndDropSongID == -1) + if (mouseEvent.LBH && _CurrentPlaylistElement != -1 && _PlaylistElementContents.Count > 0 && DragAndDropSongID == -1) { - _ChangeOrderSource = CurrentPlaylistElement + Offset; + _ChangeOrderSource = _CurrentPlaylistElement + _Offset; //Update of Drag/Drop-Texture if (_ChangeOrderSource >= _PlaylistElementContents.Count) return true; - _ChangeOrderElement = new CPlaylistElement(_PlaylistElements[CurrentPlaylistElement]); + _ChangeOrderElement = new CPlaylistElement(_PlaylistElements[_CurrentPlaylistElement]); _ChangeOrderElement.Background.Rect.Z = CBase.Settings.GetZNear(); _ChangeOrderElement.Cover.Rect.Z = CBase.Settings.GetZNear(); _ChangeOrderElement.SelectSlide.Rect.Z = CBase.Settings.GetZNear(); @@ -909,12 +879,12 @@ namespace VocaluxeLib.Menu _ChangeOrderElement.Text1.Z = CBase.Settings.GetZNear(); _ChangeOrderElement.Background.Texture = CBase.Themes.GetSkinTexture(_Theme.SkinBackground, _PartyModeID); - _ChangeOrderElement.Background.Color = BackgroundColor; + _ChangeOrderElement.Background.Color = _BackgroundColor; _OldMousePosX = mouseEvent.X; _OldMousePosY = mouseEvent.Y; - EditMode = EEditMode.ChangeOrder; + _EditMode = EEditMode.ChangeOrder; } if (!mouseEvent.LBH && DragAndDropSongID != -1) @@ -927,21 +897,21 @@ namespace VocaluxeLib.Menu if (song.IsDuet) gm = EGameMode.TR_GAMEMODE_DUET; - if (CurrentPlaylistElement != -1) + if (_CurrentPlaylistElement != -1) { - CBase.Playlist.InsertSong(ActivePlaylistID, CurrentPlaylistElement + Offset, DragAndDropSongID, gm); + CBase.Playlist.InsertSong(ActivePlaylistID, _CurrentPlaylistElement + _Offset, DragAndDropSongID, gm); UpdatePlaylist(); } else { - if (mouseEvent.Y < _PlaylistElements[0].Background.Rect.Y && Offset == 0) + if (mouseEvent.Y < _PlaylistElements[0].Background.Rect.Y && _Offset == 0) { CBase.Playlist.InsertSong(ActivePlaylistID, 0, DragAndDropSongID, gm); UpdatePlaylist(); } else { - if (_PlaylistElements.Count + Offset >= _PlaylistElementContents.Count) + if (_PlaylistElements.Count + _Offset >= _PlaylistElementContents.Count) { float min = 0f; for (int i = _PlaylistElements.Count - 1; i >= 0; i--) @@ -970,25 +940,25 @@ namespace VocaluxeLib.Menu break; case EEditMode.PlaylistName: - _Interactions.SetInteractionToButton(ButtonPlaylistName); - CurrentPlaylistElement = -1; + _SetInteractionToButton(_ButtonPlaylistName); + _CurrentPlaylistElement = -1; if (mouseEvent.LB) { - if (ButtonPlaylistName.Selected) + if (_ButtonPlaylistName.Selected) { - CBase.Playlist.SetName(ActivePlaylistID, ButtonPlaylistName.Text.Text); + CBase.Playlist.SetName(ActivePlaylistID, _ButtonPlaylistName.Text.Text); CBase.Playlist.Save(ActivePlaylistID); - EditMode = EEditMode.None; + _EditMode = EEditMode.None; return true; } } else if (mouseEvent.RB) { - if (ButtonPlaylistName.Selected) + if (_ButtonPlaylistName.Selected) { - ButtonPlaylistName.Text.Text = CBase.Playlist.GetName(ActivePlaylistID); - EditMode = EEditMode.None; - ButtonPlaylistName.EditMode = false; + _ButtonPlaylistName.Text.Text = CBase.Playlist.GetName(ActivePlaylistID); + _EditMode = EEditMode.None; + _ButtonPlaylistName.EditMode = false; return true; } } @@ -1004,18 +974,18 @@ namespace VocaluxeLib.Menu if (!mouseEvent.LBH) { - if (CurrentPlaylistElement != -1 && CurrentPlaylistElement + Offset != _ChangeOrderSource) + if (_CurrentPlaylistElement != -1 && _CurrentPlaylistElement + _Offset != _ChangeOrderSource) { - CBase.Playlist.MoveSong(ActivePlaylistID, _ChangeOrderSource, CurrentPlaylistElement + Offset); + CBase.Playlist.MoveSong(ActivePlaylistID, _ChangeOrderSource, _CurrentPlaylistElement + _Offset); UpdatePlaylist(); } - else if (CurrentPlaylistElement == -1) + else if (_CurrentPlaylistElement == -1) { - if (mouseEvent.Y < _PlaylistElements[0].Background.Rect.Y && Offset == 0) + if (mouseEvent.Y < _PlaylistElements[0].Background.Rect.Y && _Offset == 0) CBase.Playlist.MoveSong(ActivePlaylistID, _ChangeOrderSource, 0); else { - if (_PlaylistElements.Count + Offset >= _PlaylistElementContents.Count) + if (_PlaylistElements.Count + _Offset >= _PlaylistElementContents.Count) { float min = 0f; for (int i = _PlaylistElements.Count - 1; i >= 0; i--) @@ -1034,7 +1004,8 @@ namespace VocaluxeLib.Menu UpdatePlaylist(); } - EditMode = EEditMode.None; + _EditMode = EEditMode.None; + _ChangeOrderElement = null; } break; } @@ -1050,19 +1021,19 @@ namespace VocaluxeLib.Menu { var en = new CPlaylistElement { - Background = new CStatic(_PartyModeID, _Theme.SkinBackground, BackgroundColor, + Background = new CStatic(_PartyModeID, _Theme.SkinBackground, _BackgroundColor, new SRectF(Rect.X, Rect.Y + (i * _Theme.EntryHeight), Rect.W, _Theme.EntryHeight, Rect.Z)), - Cover = new CStatic(StaticCover) + Cover = new CStatic(_Theme.StaticCover, _PartyModeID) }; en.Cover.Rect.Y += Rect.Y + (i * _Theme.EntryHeight); en.Cover.Rect.X += Rect.X; - en.Text1 = new CText(Text1); + en.Text1 = new CText(_Text1); en.Text1.X += Rect.X; en.Text1.Y += Rect.Y + (i * _Theme.EntryHeight); - en.SelectSlide = new CSelectSlide(SelectSlideGameMode); + en.SelectSlide = new CSelectSlide(_SelectSlideGameMode); en.SelectSlide.Rect.X += Rect.X; en.SelectSlide.Rect.Y += Rect.Y + (i * _Theme.EntryHeight); en.SelectSlide.RectArrowLeft.X += Rect.X; @@ -1073,10 +1044,10 @@ namespace VocaluxeLib.Menu en.Content = -1; _PlaylistElements.Add(en); - _Interactions.AddSelectSlide(en.SelectSlide); - _Interactions.AddText(en.Text1); - _Interactions.AddStatic(en.Background); - _Interactions.AddStatic(en.Cover); + _AddSelectSlide(en.SelectSlide); + _AddText(en.Text1); + _AddStatic(en.Background); + _AddStatic(en.Cover); } } @@ -1085,7 +1056,7 @@ namespace VocaluxeLib.Menu if (!CBase.Playlist.Exists(playlistID)) return false; ActivePlaylistID = playlistID; - ButtonPlaylistName.Text.Text = CBase.Playlist.GetName(ActivePlaylistID); + _ButtonPlaylistName.Text.Text = CBase.Playlist.GetName(ActivePlaylistID); _PlaylistElementContents.Clear(); for (int i = 0; i < CBase.Playlist.GetSongCount(ActivePlaylistID); i++) { @@ -1097,7 +1068,7 @@ namespace VocaluxeLib.Menu }; _PlaylistElementContents.Add(pec); } - Update(); + _Update(); return true; } @@ -1112,7 +1083,7 @@ namespace VocaluxeLib.Menu _PlaylistElementContents.Add(pec); } - Update(); + _Update(); } public void ClosePlaylist() @@ -1124,6 +1095,7 @@ namespace VocaluxeLib.Menu private void _StartPlaylistSongs() { + //TODO: What is if someone uses that in PartyMode? CBase.Game.Reset(); CBase.Game.ClearSongs(); @@ -1132,7 +1104,7 @@ namespace VocaluxeLib.Menu for (int i = 0; i < CBase.Playlist.GetSongCount(ActivePlaylistID); i++) CBase.Game.AddSong(CBase.Playlist.GetSong(ActivePlaylistID, i).SongID, CBase.Playlist.GetSong(ActivePlaylistID, i).GameMode); if (CBase.Game.GetNumSongs() > 0) - CBase.Graphics.FadeTo(EScreens.ScreenNames); //TODO: What is if someone uses that in PartyMode? + CBase.Graphics.FadeTo(EScreens.ScreenNames); } } @@ -1147,41 +1119,40 @@ namespace VocaluxeLib.Menu CBase.Graphics.FadeTo(EScreens.ScreenNames); } - public void Update() + private void _Update() { - if (CBase.Playlist.Exists(ActivePlaylistID)) + if (!CBase.Playlist.Exists(ActivePlaylistID)) + return; + for (int i = 0; i < _PlaylistElements.Count; i++) { - for (int i = 0; i < _PlaylistElements.Count; i++) + if (_Offset + i < _PlaylistElementContents.Count) { - if (Offset + i < _PlaylistElementContents.Count) + _PlaylistElements[i].Content = _Offset + i; + _PlaylistElements[i].Background.Visible = true; + _PlaylistElements[i].Cover.Visible = true; + _PlaylistElements[i].SelectSlide.Visible = true; + _PlaylistElements[i].Text1.Visible = true; + CPlaylistElementContent pec = _PlaylistElementContents[_Offset + i]; + CSong song = CBase.Songs.GetSongByID(pec.SongID); + _PlaylistElements[i].Cover.Texture = song.CoverTextureSmall; + string t1 = CBase.Language.Translate(_Text1.Text).Replace("%a", song.Artist).Replace("%t", song.Title); + _PlaylistElements[i].Text1.Text = /*(Offset + i + 1) + ") " + */ t1; //TODO: Add text field for the number + _PlaylistElements[i].SelectSlide.Clear(); + for (int g = 0; g < pec.Modes.Count; g++) { - _PlaylistElements[i].Content = Offset + i; - _PlaylistElements[i].Background.Visible = true; - _PlaylistElements[i].Cover.Visible = true; - _PlaylistElements[i].SelectSlide.Visible = true; - _PlaylistElements[i].Text1.Visible = true; - CPlaylistElementContent pec = _PlaylistElementContents[Offset + i]; - CSong song = CBase.Songs.GetSongByID(pec.SongID); - _PlaylistElements[i].Cover.Texture = song.CoverTextureSmall; - string t1 = CBase.Language.Translate(Text1.Text).Replace("%a", song.Artist).Replace("%t", song.Title); - _PlaylistElements[i].Text1.Text = /*(Offset + i + 1) + ") " + */ t1; //TODO: Add text field for the number - _PlaylistElements[i].SelectSlide.Clear(); - for (int g = 0; g < pec.Modes.Count; g++) - { - _PlaylistElements[i].SelectSlide.AddValue(Enum.GetName(typeof(EGameMode), pec.Modes[g])); - if (pec.Modes[g] == pec.Mode) - _PlaylistElements[i].SelectSlide.SetSelectionByValueIndex(g); - } - } - else - { - _PlaylistElements[i].Background.Visible = false; - _PlaylistElements[i].Cover.Visible = false; - _PlaylistElements[i].SelectSlide.Visible = false; - _PlaylistElements[i].Text1.Visible = false; - _PlaylistElements[i].Content = -1; + _PlaylistElements[i].SelectSlide.AddValue(Enum.GetName(typeof(EGameMode), pec.Modes[g])); + if (pec.Modes[g] == pec.Mode) + _PlaylistElements[i].SelectSlide.SetSelectionByValueIndex(g); } } + else + { + _PlaylistElements[i].Background.Visible = false; + _PlaylistElements[i].Cover.Visible = false; + _PlaylistElements[i].SelectSlide.Visible = false; + _PlaylistElements[i].Text1.Visible = false; + _PlaylistElements[i].Content = -1; + } } } @@ -1193,52 +1164,52 @@ namespace VocaluxeLib.Menu private void _UpdateRect() { //Check for highest x/y-coords - CompleteRect = Rect; + _CompleteRect = Rect; //ButtonPlaylistClose - if (ButtonPlaylistClose.Rect.X < CompleteRect.X) - CompleteRect.X = ButtonPlaylistClose.Rect.X; - if (ButtonPlaylistClose.Rect.Y < CompleteRect.Y) - CompleteRect.Y = ButtonPlaylistClose.Rect.Y; - if (ButtonPlaylistClose.Rect.W + ButtonPlaylistClose.Rect.X > CompleteRect.W + CompleteRect.X) - CompleteRect.W = ButtonPlaylistClose.Rect.W + ButtonPlaylistClose.Rect.X - CompleteRect.X; - if (ButtonPlaylistClose.Rect.Y + ButtonPlaylistClose.Rect.H > CompleteRect.Y + CompleteRect.H) - CompleteRect.H = ButtonPlaylistClose.Rect.H + ButtonPlaylistClose.Rect.Y - CompleteRect.Y; + if (_ButtonPlaylistClose.Rect.X < _CompleteRect.X) + _CompleteRect.X = _ButtonPlaylistClose.Rect.X; + if (_ButtonPlaylistClose.Rect.Y < _CompleteRect.Y) + _CompleteRect.Y = _ButtonPlaylistClose.Rect.Y; + if (_ButtonPlaylistClose.Rect.W + _ButtonPlaylistClose.Rect.X > _CompleteRect.W + _CompleteRect.X) + _CompleteRect.W = _ButtonPlaylistClose.Rect.W + _ButtonPlaylistClose.Rect.X - _CompleteRect.X; + if (_ButtonPlaylistClose.Rect.Y + _ButtonPlaylistClose.Rect.H > _CompleteRect.Y + _CompleteRect.H) + _CompleteRect.H = _ButtonPlaylistClose.Rect.H + _ButtonPlaylistClose.Rect.Y - _CompleteRect.Y; //ButtonPlaylistName - if (ButtonPlaylistName.Rect.X < CompleteRect.X) - CompleteRect.X = ButtonPlaylistName.Rect.X; - if (ButtonPlaylistName.Rect.Y < CompleteRect.Y) - CompleteRect.Y = ButtonPlaylistName.Rect.Y; - if (ButtonPlaylistName.Rect.W + ButtonPlaylistName.Rect.X > CompleteRect.W + CompleteRect.X) - CompleteRect.W = ButtonPlaylistName.Rect.W + ButtonPlaylistName.Rect.X - CompleteRect.X; - if (ButtonPlaylistName.Rect.Y + ButtonPlaylistName.Rect.H > CompleteRect.Y + CompleteRect.H) - CompleteRect.H = ButtonPlaylistName.Rect.H + ButtonPlaylistName.Rect.Y - CompleteRect.Y; + if (_ButtonPlaylistName.Rect.X < _CompleteRect.X) + _CompleteRect.X = _ButtonPlaylistName.Rect.X; + if (_ButtonPlaylistName.Rect.Y < _CompleteRect.Y) + _CompleteRect.Y = _ButtonPlaylistName.Rect.Y; + if (_ButtonPlaylistName.Rect.W + _ButtonPlaylistName.Rect.X > _CompleteRect.W + _CompleteRect.X) + _CompleteRect.W = _ButtonPlaylistName.Rect.W + _ButtonPlaylistName.Rect.X - _CompleteRect.X; + if (_ButtonPlaylistName.Rect.Y + _ButtonPlaylistName.Rect.H > _CompleteRect.Y + _CompleteRect.H) + _CompleteRect.H = _ButtonPlaylistName.Rect.H + _ButtonPlaylistName.Rect.Y - _CompleteRect.Y; //ButtonPlaylistSing - if (ButtonPlaylistSing.Rect.X < CompleteRect.X) - CompleteRect.X = ButtonPlaylistSing.Rect.X; - if (ButtonPlaylistSing.Rect.Y < CompleteRect.Y) - CompleteRect.Y = ButtonPlaylistSing.Rect.Y; - if (ButtonPlaylistSing.Rect.W + ButtonPlaylistSing.Rect.X > CompleteRect.W + CompleteRect.X) - CompleteRect.W = ButtonPlaylistSing.Rect.W + ButtonPlaylistSing.Rect.X - CompleteRect.X; - if (ButtonPlaylistSing.Rect.Y + ButtonPlaylistSing.Rect.H > CompleteRect.Y + CompleteRect.H) - CompleteRect.H = ButtonPlaylistSing.Rect.H + ButtonPlaylistSing.Rect.Y - CompleteRect.Y; + if (_ButtonPlaylistSing.Rect.X < _CompleteRect.X) + _CompleteRect.X = _ButtonPlaylistSing.Rect.X; + if (_ButtonPlaylistSing.Rect.Y < _CompleteRect.Y) + _CompleteRect.Y = _ButtonPlaylistSing.Rect.Y; + if (_ButtonPlaylistSing.Rect.W + _ButtonPlaylistSing.Rect.X > _CompleteRect.W + _CompleteRect.X) + _CompleteRect.W = _ButtonPlaylistSing.Rect.W + _ButtonPlaylistSing.Rect.X - _CompleteRect.X; + if (_ButtonPlaylistSing.Rect.Y + _ButtonPlaylistSing.Rect.H > _CompleteRect.Y + _CompleteRect.H) + _CompleteRect.H = _ButtonPlaylistSing.Rect.H + _ButtonPlaylistSing.Rect.Y - _CompleteRect.Y; //ButtonPlaylistSave - if (ButtonPlaylistSave.Rect.X < CompleteRect.X) - CompleteRect.X = ButtonPlaylistSave.Rect.X; - if (ButtonPlaylistSave.Rect.Y < CompleteRect.Y) - CompleteRect.Y = ButtonPlaylistSave.Rect.Y; - if (ButtonPlaylistSave.Rect.W + ButtonPlaylistSave.Rect.X > CompleteRect.W + CompleteRect.X) - CompleteRect.W = ButtonPlaylistSave.Rect.W + ButtonPlaylistSave.Rect.X - CompleteRect.X; - if (ButtonPlaylistSave.Rect.Y + ButtonPlaylistSave.Rect.H > CompleteRect.Y + CompleteRect.H) - CompleteRect.H = ButtonPlaylistSave.Rect.H + ButtonPlaylistSave.Rect.Y - CompleteRect.Y; + if (_ButtonPlaylistSave.Rect.X < _CompleteRect.X) + _CompleteRect.X = _ButtonPlaylistSave.Rect.X; + if (_ButtonPlaylistSave.Rect.Y < _CompleteRect.Y) + _CompleteRect.Y = _ButtonPlaylistSave.Rect.Y; + if (_ButtonPlaylistSave.Rect.W + _ButtonPlaylistSave.Rect.X > _CompleteRect.W + _CompleteRect.X) + _CompleteRect.W = _ButtonPlaylistSave.Rect.W + _ButtonPlaylistSave.Rect.X - _CompleteRect.X; + if (_ButtonPlaylistSave.Rect.Y + _ButtonPlaylistSave.Rect.H > _CompleteRect.Y + _CompleteRect.H) + _CompleteRect.H = _ButtonPlaylistSave.Rect.H + _ButtonPlaylistSave.Rect.Y - _CompleteRect.Y; //ButtonPlaylistDelete - if (ButtonPlaylistDelete.Rect.X < CompleteRect.X) - CompleteRect.X = ButtonPlaylistDelete.Rect.X; - if (ButtonPlaylistDelete.Rect.Y < CompleteRect.Y) - CompleteRect.Y = ButtonPlaylistDelete.Rect.Y; - if (ButtonPlaylistDelete.Rect.W + ButtonPlaylistDelete.Rect.X > CompleteRect.W + CompleteRect.X) - CompleteRect.W = ButtonPlaylistDelete.Rect.W + ButtonPlaylistDelete.Rect.X - CompleteRect.X; - if (ButtonPlaylistDelete.Rect.Y + ButtonPlaylistDelete.Rect.H > CompleteRect.Y + CompleteRect.H) - CompleteRect.H = ButtonPlaylistDelete.Rect.H + ButtonPlaylistDelete.Rect.Y - CompleteRect.Y; + if (_ButtonPlaylistDelete.Rect.X < _CompleteRect.X) + _CompleteRect.X = _ButtonPlaylistDelete.Rect.X; + if (_ButtonPlaylistDelete.Rect.Y < _CompleteRect.Y) + _CompleteRect.Y = _ButtonPlaylistDelete.Rect.Y; + if (_ButtonPlaylistDelete.Rect.W + _ButtonPlaylistDelete.Rect.X > _CompleteRect.W + _CompleteRect.X) + _CompleteRect.W = _ButtonPlaylistDelete.Rect.W + _ButtonPlaylistDelete.Rect.X - _CompleteRect.X; + if (_ButtonPlaylistDelete.Rect.Y + _ButtonPlaylistDelete.Rect.H > _CompleteRect.Y + _CompleteRect.H) + _CompleteRect.H = _ButtonPlaylistDelete.Rect.H + _ButtonPlaylistDelete.Rect.Y - _CompleteRect.Y; } #region ThemeEdit diff --git a/VocaluxeLib/PartyModes/CScreenPartyDummy.cs b/VocaluxeLib/PartyModes/CScreenPartyDummy.cs index 0aede3c8..07f4ba5e 100644 --- a/VocaluxeLib/PartyModes/CScreenPartyDummy.cs +++ b/VocaluxeLib/PartyModes/CScreenPartyDummy.cs @@ -71,7 +71,7 @@ namespace VocaluxeLib.PartyModes { base.HandleMouse(mouseEvent); - if (mouseEvent.LB && _IsMouseOver(mouseEvent)) {} + if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) {} if (mouseEvent.RB) _FadeTo(EScreens.ScreenParty);