From 1b9e8fbe851a7e433fcf03dc64ab76cbc080c0c3 Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Mon, 3 Dec 2012 22:29:17 +0100 Subject: [PATCH] added double click (start song) --- Vocaluxe/Base/CUtility.cs | 40 ++++++++++++++++++++++++++++----- Vocaluxe/Screens/CScreenSong.cs | 28 +++++++++++++++++++++++ 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/Vocaluxe/Base/CUtility.cs b/Vocaluxe/Base/CUtility.cs index bfd28130..4eca0857 100644 --- a/Vocaluxe/Base/CUtility.cs +++ b/Vocaluxe/Base/CUtility.cs @@ -68,6 +68,7 @@ namespace Vocaluxe.Base public int X; public int Y; public bool LB; //left button click + public bool LD; //left button double click public bool RB; //right button click public bool MB; //middle button click @@ -82,11 +83,12 @@ namespace Vocaluxe.Base public Modifier Mod; public int Wheel; - public MouseEvent(bool alt, bool shift, bool ctrl, int x, int y, bool lb, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh) + public MouseEvent(bool alt, bool shift, bool ctrl, int x, int y, bool lb, bool ld, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh) { X = x; Y = y; LB = lb; + LD = ld; RB = rb; MB = mb; @@ -327,6 +329,8 @@ namespace Vocaluxe.Base private bool _ModCTRL; private bool _ModSHIFT; + private System.Diagnostics.Stopwatch _timer; + public int X { get { return _x; } @@ -347,13 +351,16 @@ namespace Vocaluxe.Base _EventsPool = new List(); _CurrentPool = new List(); + + _timer = new System.Diagnostics.Stopwatch(); } - private void Add(bool alt, bool shift, bool ctrl, int x, int y, bool lb, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh) + private void Add(bool alt, bool shift, bool ctrl, int x, int y, bool lb, bool ld, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh) { x = (int)((float)x * (float)CSettings.iRenderW / (float)CDraw.GetScreenWidth()); y = (int)((float)y * (float)CSettings.iRenderH / (float)CDraw.GetScreenHeight()); - MouseEvent pool = new MouseEvent(alt, shift, ctrl, x, y, lb, rb, -wheel/120, lbh, rbh, mb, mbh); + + MouseEvent pool = new MouseEvent(alt, shift, ctrl, x, y, lb, ld, rb, -wheel / 120, lbh, rbh, mb, mbh); lock (_CopyLock) { @@ -380,21 +387,42 @@ namespace Vocaluxe.Base public void MouseMove(MouseEventArgs e) { CheckModifiers(); - Add(_ModALT, _ModSHIFT, _ModCTRL, e.X, e.Y, false, false, e.Delta, e.Button == MouseButtons.Left, e.Button == MouseButtons.Right, + Add(_ModALT, _ModSHIFT, _ModCTRL, e.X, e.Y, false, false, false, e.Delta, e.Button == MouseButtons.Left, e.Button == MouseButtons.Right, false, e.Button == MouseButtons.Middle); } public void MouseWheel(MouseEventArgs e) { CheckModifiers(); - Add(_ModALT, _ModSHIFT, _ModCTRL, e.X, e.Y, false, false, e.Delta, e.Button == MouseButtons.Left, e.Button == MouseButtons.Right, + Add(_ModALT, _ModSHIFT, _ModCTRL, e.X, e.Y, false, false, false, e.Delta, e.Button == MouseButtons.Left, e.Button == MouseButtons.Right, false, e.Button == MouseButtons.Middle); } public void MouseDown(MouseEventArgs e) { CheckModifiers(); - Add(_ModALT, _ModSHIFT, _ModCTRL, e.X, e.Y, e.Button == MouseButtons.Left, e.Button == MouseButtons.Right, e.Delta, false, false, + + bool lb = e.Button == MouseButtons.Left; + bool ld = false; + if (lb) + { + if (_timer.IsRunning && _timer.ElapsedMilliseconds < 450) + { + ld = true; + _timer.Reset(); + } + else + { + _timer.Reset(); + _timer.Start(); + } + } + else + { + _timer.Reset(); + } + + Add(_ModALT, _ModSHIFT, _ModCTRL, e.X, e.Y, lb, ld, e.Button == MouseButtons.Right, e.Delta, false, false, e.Button == MouseButtons.Middle, false); } diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index e11d1c01..9a0b0e71 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -380,6 +380,15 @@ namespace Vocaluxe.Screens } } + if (MouseEvent.LD) + { + if (CSongs.NumVisibleSongs > 0 && SongMenus[htSongMenus(SongMenu)].GetActualSelection() != -1) + { + StartVisibleSong(SongMenus[htSongMenus(SongMenu)].GetActualSelection()); + return true; + } + } + SongMenus[htSongMenus(SongMenu)].HandleMouse(ref MouseEvent); if (MouseEvent.LB) @@ -592,6 +601,25 @@ namespace Vocaluxe.Screens } } + private void StartVisibleSong(int SongNr) + { + if (CSongs.Category >= 0 && SongNr >= 0 && CSongs.NumVisibleSongs > SongNr) + { + EGameMode gm; + if (CSongs.VisibleSongs[SongNr].IsDuet) + gm = GameModes.EGameMode.TR_GAMEMODE_DUET; + else + gm = GameModes.EGameMode.TR_GAMEMODE_NORMAL; + + CGame.Reset(); + CGame.ClearSongs(); + + CGame.AddVisibleSong(SongNr, gm); + + CGraphics.FadeTo(EScreens.ScreenNames); + } + } + private void StartMedleySong(int SongNr) { if ((CSongs.Category >= 0) && (SongNr >= 0))