Beispiel #1
0
        public override bool HandleInput(ref SKeyEvent keyEvent, SScreenSongOptions options)
        {
            if (keyEvent.KeyPressed)
            {
                return(false);
            }

            bool moveAllowed       = !options.Selection.RandomOnly || (options.Selection.CategoryChangeAllowed && !CBase.Songs.IsInCategory());
            bool catChangePossible = CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_ON && options.Selection.CategoryChangeAllowed;

            //If nothing selected set a reasonable default value
            if (keyEvent.IsArrowKey() && moveAllowed && _SelectionNr < 0)
            {
                _SelectionNr = (_PreviewNr < 0) ? _Offset : _PreviewNr;
            }

            switch (keyEvent.Key)
            {
            case Keys.Enter:
                if (CBase.Songs.IsInCategory())
                {
                    if (_SelectionNr >= 0 && _PreviewNr != _SelectionNr)
                    {
                        _PreviewNr       = _SelectionNr;
                        keyEvent.Handled = true;
                    }
                }
                else
                {
                    _EnterCategory(_PreviewNr);
                    keyEvent.Handled = true;
                }
                break;

            case Keys.Escape:
            case Keys.Back:
                if (CBase.Songs.IsInCategory() && catChangePossible)
                {
                    _LeaveCategory();
                    keyEvent.Handled = true;
                }
                break;

            case Keys.PageUp:
                if (catChangePossible)
                {
                    _PrevCategory();
                    keyEvent.Handled = true;
                }
                break;

            case Keys.PageDown:
                if (catChangePossible)
                {
                    _NextCategory();
                    keyEvent.Handled = true;
                }
                break;

            case Keys.Left:
                //Check for >0 so we do not allow selection of nothing (-1)
                if (_SelectionNr > 0 && moveAllowed)
                {
                    _SelectionNr--;
                    keyEvent.Handled = true;
                }
                break;

            case Keys.Right:
                if (moveAllowed)
                {
                    _SelectionNr++;
                    keyEvent.Handled = true;
                }
                break;

            case Keys.Up:
                if (keyEvent.ModShift)
                {
                    if (catChangePossible)
                    {
                        _PrevCategory();
                        keyEvent.Handled = true;
                    }
                }
                else if (_SelectionNr >= _NumW && moveAllowed)
                {
                    _SelectionNr    -= _NumW;
                    keyEvent.Handled = true;
                }
                break;

            case Keys.Down:
                if (keyEvent.ModShift)
                {
                    if (catChangePossible)
                    {
                        _NextCategory();
                        keyEvent.Handled = true;
                    }
                }
                else if (moveAllowed)
                {
                    _SelectionNr    += _NumW;
                    keyEvent.Handled = true;
                }
                break;
            }
            if (!CBase.Songs.IsInCategory())
            {
                _PreviewNr = _SelectionNr;
            }
            return(keyEvent.Handled);
        }
Beispiel #2
0
        public override bool HandleInput(ref SKeyEvent keyEvent, SScreenSongOptions options)
        {
            if (keyEvent.KeyPressed)
            {
                return(false);
            }

            bool moveAllowed       = !options.Selection.RandomOnly || (options.Selection.CategoryChangeAllowed && !CBase.Songs.IsInCategory());
            bool catChangePossible = CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_ON && options.Selection.CategoryChangeAllowed;

            //If nothing selected set a reasonable default value
            if (keyEvent.IsArrowKey() && moveAllowed && _SelectionNr < 0)
            {
                _SelectionNr = (_PreviewNr < 0) ? _Offset : _PreviewNr;
            }

            switch (keyEvent.Key)
            {
            case Keys.Enter:
                if (CBase.Songs.IsInCategory())
                {
                    if (_SelectionNr >= 0 && _PreviewNr != _SelectionNr)
                    {
                        _PreviewSelectedSong();
                        keyEvent.Handled = true;
                    }
                }
                else
                {
                    _EnterCategory(_PreviewNr);
                    keyEvent.Handled = true;
                }
                break;

            case Keys.Escape:
            case Keys.Back:
                if (CBase.Songs.IsInCategory() && catChangePossible)
                {
                    _LeaveCategory();
                    keyEvent.Handled = true;
                }
                break;

            case Keys.PageUp:
                if (catChangePossible && CBase.Songs.IsInCategory() && (keyEvent.Mod == EModifier.Ctrl || keyEvent.Mod == EModifier.Alt))
                {
                    _PrevCategory();
                    keyEvent.Handled = true;
                }
                else if (moveAllowed)
                {
                    int numSongsPerPage = _NumH * _NumW;
                    if ((_SelectionNr - numSongsPerPage) <= 0)
                    {
                        _SelectionNr = 0;
                    }
                    else
                    {
                        _SelectionNr = _SelectionNr - numSongsPerPage;
                    }
                    keyEvent.Handled = true;
                }
                break;

            case Keys.PageDown:
                if (catChangePossible && CBase.Songs.IsInCategory() && (keyEvent.Mod == EModifier.Ctrl || keyEvent.Mod == EModifier.Alt))
                {
                    _NextCategory();
                    keyEvent.Handled = true;
                }
                else if (moveAllowed)
                {
                    int numSongsPerPage   = _NumH * _NumW;
                    int maxCount_PageDown = (CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_ON && !CBase.Songs.IsInCategory() ? CBase.Songs.GetNumCategories() : CBase.Songs.GetNumSongsVisible());
                    if ((_SelectionNr + numSongsPerPage) >= maxCount_PageDown)
                    {
                        _SelectionNr = maxCount_PageDown - 1;
                    }
                    else
                    {
                        _SelectionNr = _SelectionNr + numSongsPerPage;
                    }
                    keyEvent.Handled = true;
                }
                break;

            case Keys.Home:
                if (moveAllowed)
                {
                    _SelectionNr     = 0;
                    keyEvent.Handled = true;
                }
                break;

            case Keys.End:
                int maxCount_End = (CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_ON && !CBase.Songs.IsInCategory() ? CBase.Songs.GetNumCategories() : CBase.Songs.GetNumSongsVisible());
                if (moveAllowed)
                {
                    _SelectionNr     = maxCount_End - 1;
                    keyEvent.Handled = true;
                }
                break;

            case Keys.Left:
                //Check for >0 so we do not allow selection of nothing (-1)
                if (_SelectionNr > 0 && moveAllowed)
                {
                    _SelectionNr--;
                    _AutoplayPreviewIfEnabled();
                    keyEvent.Handled = true;
                }
                break;

            case Keys.Right:
                if (moveAllowed)
                {
                    _SelectionNr++;
                    _AutoplayPreviewIfEnabled();
                    keyEvent.Handled = true;
                }
                break;

            case Keys.Up:
                if (keyEvent.ModShift)
                {
                    if (catChangePossible)
                    {
                        _PrevCategory();
                        keyEvent.Handled = true;
                    }
                }
                else if (_SelectionNr >= _NumW && moveAllowed)
                {
                    _SelectionNr -= _NumW;
                    _AutoplayPreviewIfEnabled();
                    keyEvent.Handled = true;
                }
                break;

            case Keys.Down:
                if (keyEvent.ModShift)
                {
                    if (catChangePossible)
                    {
                        _NextCategory();
                        keyEvent.Handled = true;
                    }
                }
                else if (moveAllowed)
                {
                    _SelectionNr += _NumW;
                    _AutoplayPreviewIfEnabled();
                    keyEvent.Handled = true;
                }
                break;
            }
            if (!CBase.Songs.IsInCategory())
            {
                _PreviewSelectedSong();
            }
            return(keyEvent.Handled);
        }
Beispiel #3
0
        private static bool _HandleInputs(CKeys keys, CMouse mouse)
        {
            SKeyEvent   keyEvent        = new SKeyEvent();
            SMouseEvent mouseEvent      = new SMouseEvent();
            SKeyEvent   inputKeyEvent   = new SKeyEvent();
            SMouseEvent inputMouseEvent = new SMouseEvent();

            bool popupPlayerControlAllowed = CurrentScreen.CurrentMusicType == EMusicType.Background;
            bool popupVolumeControlAllowed = CurrentScreen.CurrentMusicType != EMusicType.None;

            //Hide volume control for bg-music if bg-music is disabled
            if (popupVolumeControlAllowed && (CurrentScreen.CurrentMusicType == EMusicType.Background || CurrentScreen.CurrentMusicType == EMusicType.BackgroundPreview) && CConfig.Config.Sound.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_OFF)
            {
                popupVolumeControlAllowed = false;
            }

            bool resume = true;
            bool eventsAvailable;
            bool inputEventsAvailable = CController.PollKeyEvent(ref inputKeyEvent);

            while ((eventsAvailable = keys.PollEvent(ref keyEvent)) || inputEventsAvailable)
            {
                if (!eventsAvailable)
                {
                    keyEvent = inputKeyEvent;
                }

                if (keyEvent.IsArrowKey() || keyEvent.Key == Keys.NumPad0 || keyEvent.Key == Keys.D0 || keyEvent.Key == Keys.Add)
                {
                    _Cursor.Deactivate();

                    if (keyEvent.ModAlt && keyEvent.ModCtrl)
                    {
                        switch (keyEvent.Key)
                        {
                        case Keys.Right:
                            if (keyEvent.ModShift)
                            {
                                CConfig.Config.Graphics.BorderLeft++;
                            }
                            else
                            {
                                CConfig.Config.Graphics.BorderRight--;
                            }
                            break;

                        case Keys.Left:
                            if (keyEvent.ModShift)
                            {
                                CConfig.Config.Graphics.BorderLeft--;
                            }
                            else
                            {
                                CConfig.Config.Graphics.BorderRight++;
                            }
                            break;

                        case Keys.Down:
                            if (keyEvent.ModShift)
                            {
                                CConfig.Config.Graphics.BorderTop++;
                            }
                            else
                            {
                                CConfig.Config.Graphics.BorderBottom--;
                            }
                            break;

                        case Keys.Up:
                            if (keyEvent.ModShift)
                            {
                                CConfig.Config.Graphics.BorderTop--;
                            }
                            else
                            {
                                CConfig.Config.Graphics.BorderBottom++;
                            }
                            break;

                        case Keys.D0:
                        case Keys.NumPad0:
                            CConfig.Config.Graphics.BorderLeft      =
                                CConfig.Config.Graphics.BorderRight = CConfig.Config.Graphics.BorderTop = CConfig.Config.Graphics.BorderBottom = 0;
                            break;

                        case Keys.Add:
                            switch (CConfig.Config.Graphics.ScreenAlignment)
                            {
                            case EGeneralAlignment.Middle:
                                CConfig.Config.Graphics.ScreenAlignment = EGeneralAlignment.End;
                                break;

                            case EGeneralAlignment.End:
                                CConfig.Config.Graphics.ScreenAlignment = EGeneralAlignment.Start;
                                break;

                            default:
                                CConfig.Config.Graphics.ScreenAlignment = EGeneralAlignment.Middle;
                                break;
                            }
                            break;
                        }
                        CConfig.SaveConfig();
                        break;
                    }
                }

                if (keyEvent.Key == Keys.F11)
                {
                    if (_CurrentPopupScreen == EPopupScreens.NoPopup)
                    {
                        ShowPopup(EPopupScreens.PopupServerQR);
                    }
                    else
                    {
                        HidePopup(EPopupScreens.PopupServerQR);
                    }
                }

                if (keyEvent.Key == Keys.F8)
                {
                    CLog.ShowLogAssistant("", null);
                }

                if (popupPlayerControlAllowed && keyEvent.Key == Keys.Tab)
                {
                    if (_CurrentPopupScreen == EPopupScreens.NoPopup && CConfig.Config.Sound.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_ON)
                    {
                        ShowPopup(EPopupScreens.PopupPlayerControl);
                    }
                    else
                    {
                        HidePopup(EPopupScreens.PopupPlayerControl);
                    }
                }

                if (popupPlayerControlAllowed && CConfig.Config.Sound.BackgroundMusic != EBackgroundMusicOffOn.TR_CONFIG_OFF)
                {
                    if (keyEvent.Key == Keys.MediaNextTrack)
                    {
                        CBackgroundMusic.Next();
                    }
                    else if (keyEvent.Key == Keys.MediaPreviousTrack)
                    {
                        CBackgroundMusic.Previous();
                    }
                    else if (keyEvent.Key == Keys.MediaPlayPause)
                    {
                        if (CBackgroundMusic.IsPlaying)
                        {
                            CBackgroundMusic.Pause();
                        }
                        else
                        {
                            CBackgroundMusic.Play();
                        }
                    }
                }

                if (keyEvent.ModShift && (keyEvent.Key == Keys.F1))
                {
                    CSettings.ProgramState = EProgramState.EditTheme;
                }
                else if (keyEvent.ModAlt && (keyEvent.Key == Keys.Enter))
                {
                    CConfig.Config.Graphics.FullScreen = (CConfig.Config.Graphics.FullScreen == EOffOn.TR_CONFIG_ON) ? EOffOn.TR_CONFIG_OFF : EOffOn.TR_CONFIG_ON;
                }
                else if (keyEvent.ModAlt && (keyEvent.Key == Keys.P))
                {
                    CDraw.MakeScreenShot();
                }
                else
                {
                    if (_Fading == null)
                    {
                        bool handled = false;
                        if (_CurrentPopupScreen != EPopupScreens.NoPopup)
                        {
                            handled = _PopupScreens[(int)_CurrentPopupScreen].HandleInput(keyEvent);
                            if (popupVolumeControlAllowed && _CurrentPopupScreen == EPopupScreens.PopupVolumeControl && handled)
                            {
                                _VolumePopupTimer.Restart();
                            }
                        }
                        else if (popupVolumeControlAllowed && _PopupScreens[(int)EPopupScreens.PopupVolumeControl].HandleInput(keyEvent))
                        {
                            ShowPopup(EPopupScreens.PopupVolumeControl);
                            _VolumePopupTimer.Restart();
                        }

                        if (!handled)
                        {
                            resume &= CurrentScreen.HandleInput(keyEvent);
                        }
                    }
                }

                if (!eventsAvailable)
                {
                    inputEventsAvailable = CController.PollKeyEvent(ref inputKeyEvent);
                }
            }

            inputEventsAvailable = CController.PollMouseEvent(ref inputMouseEvent);

            while ((eventsAvailable = mouse.PollEvent(ref mouseEvent)) || inputEventsAvailable)
            {
                if (!eventsAvailable)
                {
                    mouseEvent = inputMouseEvent;
                }

                if (mouseEvent.Wheel != 0)
                {
                    _Cursor.Activate();
                }

                _UpdateMousePosition(mouseEvent.X, mouseEvent.Y);

                bool isOverPopupPlayerControl = CHelper.IsInBounds(_PopupScreens[(int)EPopupScreens.PopupPlayerControl].ScreenArea, mouseEvent);
                if (popupPlayerControlAllowed && isOverPopupPlayerControl)
                {
                    if (_CurrentPopupScreen == EPopupScreens.NoPopup && CConfig.Config.Sound.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_ON)
                    {
                        ShowPopup(EPopupScreens.PopupPlayerControl);
                    }
                }

                if (!isOverPopupPlayerControl && _CurrentPopupScreen == EPopupScreens.PopupPlayerControl)
                {
                    HidePopup(EPopupScreens.PopupPlayerControl);
                }

                bool isOverPopupVolumeControl = CHelper.IsInBounds(_PopupScreens[(int)EPopupScreens.PopupVolumeControl].ScreenArea, mouseEvent);
                if (popupVolumeControlAllowed && isOverPopupVolumeControl)
                {
                    if (_CurrentPopupScreen == EPopupScreens.NoPopup)
                    {
                        ShowPopup(EPopupScreens.PopupVolumeControl);
                        _VolumePopupTimer.Reset();
                        _VolumePopupTimer.Start();
                    }
                }

                if (_CursorOverVolumeControl && !isOverPopupVolumeControl)
                {
                    if (_CurrentPopupScreen == EPopupScreens.PopupVolumeControl)
                    {
                        HidePopup(EPopupScreens.PopupVolumeControl);
                        _VolumePopupTimer.Reset();
                    }
                }
                _CursorOverVolumeControl = isOverPopupVolumeControl;


                bool handled = false;
                if (_CurrentPopupScreen != EPopupScreens.NoPopup)
                {
                    handled = _PopupScreens[(int)_CurrentPopupScreen].HandleMouse(mouseEvent);
                }

                if (!handled && _Fading == null && (_Cursor.IsActive || mouseEvent.LB || mouseEvent.RB || mouseEvent.MB))
                {
                    resume &= CurrentScreen.HandleMouse(mouseEvent);
                }

                if (!eventsAvailable)
                {
                    inputEventsAvailable = CController.PollMouseEvent(ref inputMouseEvent);
                }
            }
            return(resume);
        }