NScumm.Scumm.ScummEngine.ProcessInput C# (CSharp) Метод

ProcessInput() защищенный Метод

protected ProcessInput ( ) : void
Результат void
        internal protected virtual void ProcessInput()
        {
            //
            // Determine the mouse button state.
            //
            mouseAndKeyboardStat = 0;

            if (_leftBtnPressed.HasFlag(MouseButtonStatus.Clicked) && _rightBtnPressed.HasFlag(MouseButtonStatus.Clicked))
            {
                // Pressing both mouse buttons is treated as if you pressed
                // the cutscene exit key (ESC) in V4+ games. That mimicks
                // the behavior of the original engine where pressing both
                // mouse buttons also skips the current cutscene.
                mouseAndKeyboardStat = 0;
//                lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE);
            }
            else if (_rightBtnPressed.HasFlag(MouseButtonStatus.Clicked) && (Game.Version <= 3 && Game.GameId != GameId.Loom))
            {
                // Pressing right mouse button is treated as if you pressed
                // the cutscene exit key (ESC) in V0-V3 games. That mimicks
                // the behavior of the original engine where pressing right
                // mouse button also skips the current cutscene.
                mouseAndKeyboardStat = 0;
//                lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE);
            }
            else if (_leftBtnPressed.HasFlag(MouseButtonStatus.Clicked))
            {
                mouseAndKeyboardStat = (KeyCode)ScummMouseButtonState.LeftClick;
            }
            else if (_rightBtnPressed.HasFlag(MouseButtonStatus.Clicked))
            {
                mouseAndKeyboardStat = (KeyCode)ScummMouseButtonState.RightClick;
            }

            if (Game.Version >= 6)
            {
                Variables[VariableLeftButtonHold.Value] = _leftBtnPressed.HasFlag(MouseButtonStatus.Down) ? 1 : 0;
                Variables[VariableRightButtonHold.Value] = _rightBtnPressed.HasFlag(MouseButtonStatus.Down) ? 1 : 0;

                // scumm7: left/right button down
                if (Game.Version >= 7)
                {
                    Variables[VariableLeftButtonDown.Value] = _leftBtnPressed.HasFlag(MouseButtonStatus.Clicked) ? 1 : 0;
                    Variables[VariableRightButtonDown.Value] = _rightBtnPressed.HasFlag(MouseButtonStatus.Clicked) ? 1 : 0;
                }
            }

            _leftBtnPressed &= ~MouseButtonStatus.Clicked;
            _rightBtnPressed &= ~MouseButtonStatus.Clicked;

            var cutsceneExitKeyEnabled = (!VariableCutSceneExitKey.HasValue || Variables[VariableCutSceneExitKey.Value] != 0);
            var mainmenuKeyEnabled = !VariableMainMenu.HasValue || _variables[VariableMainMenu.Value] != 0;

            // For games which use VAR_MAINMENU_KEY, disable the mainmenu key if
            // requested by the scripts. We make an exception for COMI (i.e.
            // forcefully always enable it there), as that always disables it.
            if (Game.GameId == GameId.CurseOfMonkeyIsland)
                mainmenuKeyEnabled = true;

            if (cutsceneExitKeyEnabled && _inputState.IsKeyDown(KeyCode.Escape))
            {
                AbortCutscene();
                // VAR_CUTSCENEEXIT_KEY doesn't exist in SCUMM0
                if (VariableCutSceneExitKey.HasValue)
                {
                    mouseAndKeyboardStat = (KeyCode)Variables[VariableCutSceneExitKey.Value];
                }
            }

            if (mainmenuKeyEnabled && _inputState.IsKeyDown(KeyCode.F5))
            {
                if (VariableSaveLoadScript.HasValue && _currentRoom != 0)
                {
                    RunScript(Variables[VariableSaveLoadScript.Value], false, false, new int[0]);
                }

                ShowMenu();

                if (VariableSaveLoadScript2.HasValue && _currentRoom != 0)
                {
                    RunScript(Variables[VariableSaveLoadScript2.Value], false, false, new int[0]);
                }
            }

            for (var i = KeyCode.A; i <= KeyCode.Z; i++)
            {
                if (_inputState.IsKeyDown(i))
                {
                    mouseAndKeyboardStat = i;
                }
            }
            for (var i = KeyCode.F1; i <= KeyCode.F9; i++)
            {
                if (_inputState.IsKeyDown(i))
                {
                    mouseAndKeyboardStat = i;
                }
            }

            if (_inputState.IsKeyDown(KeyCode.Return))
            {
                mouseAndKeyboardStat = KeyCode.Return;
            }
            if (_inputState.IsKeyDown(KeyCode.Backspace))
            {
                mouseAndKeyboardStat = KeyCode.Backspace;
            }
            if (_inputState.IsKeyDown(KeyCode.Tab))
            {
                mouseAndKeyboardStat = KeyCode.Tab;
            }
            if (_inputState.IsKeyDown(KeyCode.Space))
            {
                mouseAndKeyboardStat = KeyCode.Space;
            }

            if ((Game.GameId == Scumm.IO.GameId.Indy4 || Game.GameId == Scumm.IO.GameId.Pass))
            {
                var numpad = new int[]
                {
                    '0',
                    335, 336, 337,
                    331, 332, 333,
                    327, 328, 329
                };

                for (var i = KeyCode.D0; i <= KeyCode.D9; i++)
                {
                    if (_inputState.IsKeyDown(i))
                    {
                        mouseAndKeyboardStat = (KeyCode)numpad[i - KeyCode.D0];
                    }
                }
            }
            else
            {
                for (var i = KeyCode.D0; i <= KeyCode.D9; i++)
                {
                    if (_inputState.IsKeyDown(i))
                    {
                        mouseAndKeyboardStat = i - (int)KeyCode.D0 + '0';
                    }
                }
            }

            _mousePos = _inputManager.GetMousePosition();
            if (_mousePos.X < 0)
                _mousePos.X = 0;
            if (_mousePos.X > ScreenWidth - 1)
                _mousePos.X = (short)(ScreenWidth - 1);
            if (_mousePos.Y < 0)
                _mousePos.Y = 0;
            if (_mousePos.Y > ScreenHeight - 1)
                _mousePos.Y = (short)(ScreenHeight - 1);

            var mouseX = (ScreenStartStrip * 8) + _mousePos.X;
            var mouseY = _mousePos.Y - MainVirtScreen.TopLine + ((_game.Version >= 7) ? ScreenTop : 0);

            if (Game.Version >= 3)
            {
                Variables[VariableMouseX.Value] = _mousePos.X;
                Variables[VariableMouseY.Value] = _mousePos.Y;
                Variables[VariableVirtualMouseX.Value] = mouseX;
                Variables[VariableVirtualMouseY.Value] = mouseY;
            
            }
            else if (Game.Version >= 1)
            {
                // We use shifts below instead of dividing by V12_X_MULTIPLIER resp.
                // V12_Y_MULTIPLIER to handle negative coordinates correctly.
                // This fixes e.g. bugs #1328131 and #1537595.
                Variables[VariableVirtualMouseX.Value] = mouseX >> V12_X_SHIFT;
                Variables[VariableVirtualMouseY.Value] = mouseY >> V12_Y_SHIFT;

                // Adjust mouse coordinates as narrow rooms in NES are centered
//                if (_game.platform == Common::kPlatformNES && _NESStartStrip > 0)
//                {
//                    VAR(VAR_VIRT_MOUSE_X) -= 2;
//                    if (VAR(VAR_VIRT_MOUSE_X) < 0)
//                        VAR(VAR_VIRT_MOUSE_X) = 0;
//                }
            }
        }
ScummEngine