Exemple #1
0
        private static bool HandleInputs(CKeys keys, CMouse Mouse)
        {
            KeyEvent   KeyEvent        = new KeyEvent();
            MouseEvent MouseEvent      = new MouseEvent();
            KeyEvent   InputKeyEvent   = new KeyEvent();
            MouseEvent InputMouseEvent = new MouseEvent();

            bool PopupPlayerControlAllowed = _CurrentScreen != EScreens.ScreenOptionsRecord && _CurrentScreen != EScreens.ScreenSing &&
                                             _CurrentScreen != EScreens.ScreenSong && _CurrentScreen != EScreens.ScreenCredits;

            bool PopupVolumeControlAllowed = _CurrentScreen != EScreens.ScreenCredits;

            bool Resume               = true;
            bool EventsAvailable      = false;
            bool InputEventsAvailable = CInput.PollKeyEvent(ref InputKeyEvent);

            while ((EventsAvailable = keys.PollEvent(ref KeyEvent)) || InputEventsAvailable)
            {
                if (!EventsAvailable)
                {
                    KeyEvent = InputKeyEvent;
                }

                if (KeyEvent.Key == Keys.Left || KeyEvent.Key == Keys.Right || KeyEvent.Key == Keys.Up || KeyEvent.Key == Keys.Down)
                {
                    CSettings.MouseInactive();
                    _Cursor.FadeOut();
                }

                if (PopupPlayerControlAllowed && KeyEvent.Key == Keys.Tab)
                {
                    if (_CurrentPopupScreen == EPopupScreens.NoPopup && CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON)
                    {
                        ShowPopup(EPopupScreens.PopupPlayerControl);
                    }
                    else
                    {
                        HidePopup(EPopupScreens.PopupPlayerControl);
                    }
                }

                if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.F1))
                {
                    CSettings.GameState = EGameState.EditTheme;
                }
                else if (KeyEvent.ModALT && (KeyEvent.Key == Keys.Enter))
                {
                    CSettings.bFullScreen = !CSettings.bFullScreen;
                }
                else if (KeyEvent.ModALT && (KeyEvent.Key == Keys.P))
                {
                    CDraw.MakeScreenShot();
                }
                else
                {
                    if (!_Fading)
                    {
                        bool handled = false;
                        if (_CurrentPopupScreen != EPopupScreens.NoPopup)
                        {
                            handled = _PopupScreens[(int)_CurrentPopupScreen].HandleInput(KeyEvent);
                        }

                        if (!handled)
                        {
                            Resume &= _Screens[(int)_CurrentScreen].HandleInput(KeyEvent);
                        }
                    }
                }

                if (!EventsAvailable)
                {
                    InputEventsAvailable = CInput.PollKeyEvent(ref InputKeyEvent);
                }
            }

            InputEventsAvailable = CInput.PollMouseEvent(ref InputMouseEvent);

            while ((EventsAvailable = Mouse.PollEvent(ref MouseEvent)) || InputEventsAvailable)
            {
                if (!EventsAvailable)
                {
                    MouseEvent = InputMouseEvent;
                }

                if (MouseEvent.Wheel != 0)
                {
                    CSettings.MouseActive();
                    _Cursor.FadeIn();
                }

                UpdateMousePosition(MouseEvent.X, MouseEvent.Y);

                bool isOverPopupPlayerControl = CHelper.IsInBounds(_PopupScreens[(int)EPopupScreens.PopupPlayerControl].ScreenArea, MouseEvent);
                if (PopupPlayerControlAllowed && isOverPopupPlayerControl)
                {
                    if (_CurrentPopupScreen == EPopupScreens.NoPopup && CConfig.BackgroundMusic == EOffOn.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();
                    }
                }

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

                bool handled = false;
                if (_CurrentPopupScreen != EPopupScreens.NoPopup)
                {
                    handled = _PopupScreens[(int)_CurrentPopupScreen].HandleMouse(MouseEvent);
                }
                if (handled && _CurrentPopupScreen == EPopupScreens.PopupVolumeControl)
                {
                    _Screens[(int)_CurrentScreen].ApplyVolume();
                }


                if (!handled && !_Fading && (_Cursor.IsActive || MouseEvent.LB || MouseEvent.RB || MouseEvent.MB))
                {
                    Resume &= _Screens[(int)_CurrentScreen].HandleMouse(MouseEvent);
                }

                if (!EventsAvailable)
                {
                    InputEventsAvailable = CInput.PollMouseEvent(ref InputMouseEvent);
                }
            }
            return(Resume);
        }