Beispiel #1
0
        public void ExecuteShortcut(EmulatorShortcut shortcut)
        {
            Func <bool> isActionEnabled;

            if (_actionEnabledFuncs.TryGetValue(shortcut, out isActionEnabled))
            {
                isActionEnabled = _actionEnabledFuncs[shortcut];
                if (isActionEnabled != null && !isActionEnabled())
                {
                    //Action disabled
                    return;
                }
            }

            bool restoreFullscreen = _displayManager.ExclusiveFullscreen;

            switch (shortcut)
            {
            case EmulatorShortcut.Pause: TogglePause(); break;

            case EmulatorShortcut.Reset: EmuApi.Reset(); break;

            case EmulatorShortcut.PowerCycle: EmuApi.PowerCycle(); break;

            case EmulatorShortcut.ReloadRom: Task.Run(() => EmuApi.ReloadRom()); break;

            case EmulatorShortcut.PowerOff: Task.Run(() => EmuApi.Stop()); restoreFullscreen = false; break;

            case EmulatorShortcut.Exit: frmMain.Instance.Close(); restoreFullscreen = false; break;

            case EmulatorShortcut.ToggleAudio: ToggleAudio(); break;

            case EmulatorShortcut.IncreaseVolume: IncreaseVolume(); break;

            case EmulatorShortcut.DecreaseVolume: DecreaseVolume(); break;

            case EmulatorShortcut.ToggleFps: ToggleFps(); break;

            case EmulatorShortcut.ToggleGameTimer: ToggleGameTimer(); break;

            case EmulatorShortcut.ToggleFrameCounter: ToggleFrameCounter(); break;

            case EmulatorShortcut.ToggleOsd: ToggleOsd(); break;

            case EmulatorShortcut.ToggleAlwaysOnTop: ToggleAlwaysOnTop(); break;

            case EmulatorShortcut.ToggleDebugInfo: ToggleDebugInfo(); break;

            case EmulatorShortcut.ToggleCheats: ToggleCheats(); break;

            case EmulatorShortcut.MaxSpeed: ToggleMaxSpeed(); break;

            case EmulatorShortcut.ToggleFullscreen: _displayManager.ToggleFullscreen(); restoreFullscreen = false; break;

            case EmulatorShortcut.OpenFile: OpenFile(); break;

            case EmulatorShortcut.IncreaseSpeed: IncreaseEmulationSpeed(); break;

            case EmulatorShortcut.DecreaseSpeed: DecreaseEmulationSpeed(); break;

            case EmulatorShortcut.LoadRandomGame: RandomGameHelper.LoadRandomGame(); break;

            case EmulatorShortcut.SetScale1x: _displayManager.SetScale(1, true); break;

            case EmulatorShortcut.SetScale2x: _displayManager.SetScale(2, true); break;

            case EmulatorShortcut.SetScale3x: _displayManager.SetScale(3, true); break;

            case EmulatorShortcut.SetScale4x: _displayManager.SetScale(4, true); break;

            case EmulatorShortcut.SetScale5x: _displayManager.SetScale(5, true); break;

            case EmulatorShortcut.SetScale6x: _displayManager.SetScale(6, true); break;

            case EmulatorShortcut.ToggleBgLayer0: ToggleBgLayer0(); break;

            case EmulatorShortcut.ToggleBgLayer1: ToggleBgLayer1(); break;

            case EmulatorShortcut.ToggleBgLayer2: ToggleBgLayer2(); break;

            case EmulatorShortcut.ToggleBgLayer3: ToggleBgLayer3(); break;

            case EmulatorShortcut.ToggleSprites: ToggleSprites(); break;

            case EmulatorShortcut.EnableAllLayers: EnableAllLayers(); break;

            case EmulatorShortcut.ToggleRecordVideo: ToggleRecordVideo(); break;

            case EmulatorShortcut.ToggleRecordAudio: ToggleRecordAudio(); break;

            case EmulatorShortcut.ToggleRecordMovie: ToggleRecordMovie(); break;

            case EmulatorShortcut.TakeScreenshot: EmuApi.TakeScreenshot(); break;

            case EmulatorShortcut.LoadStateFromFile: SaveStateManager.LoadStateFromFile(); break;

            case EmulatorShortcut.SaveStateToFile: SaveStateManager.SaveStateToFile(); break;

            case EmulatorShortcut.SaveStateSlot1: SaveStateManager.SaveState(1); break;

            case EmulatorShortcut.SaveStateSlot2: SaveStateManager.SaveState(2); break;

            case EmulatorShortcut.SaveStateSlot3: SaveStateManager.SaveState(3); break;

            case EmulatorShortcut.SaveStateSlot4: SaveStateManager.SaveState(4); break;

            case EmulatorShortcut.SaveStateSlot5: SaveStateManager.SaveState(5); break;

            case EmulatorShortcut.SaveStateSlot6: SaveStateManager.SaveState(6); break;

            case EmulatorShortcut.SaveStateSlot7: SaveStateManager.SaveState(7); break;

            case EmulatorShortcut.SaveStateSlot8: SaveStateManager.SaveState(8); break;

            case EmulatorShortcut.SaveStateSlot9: SaveStateManager.SaveState(9); break;

            case EmulatorShortcut.SaveStateSlot10: SaveStateManager.SaveState(10); break;

            case EmulatorShortcut.LoadStateSlot1: SaveStateManager.LoadState(1); break;

            case EmulatorShortcut.LoadStateSlot2: SaveStateManager.LoadState(2); break;

            case EmulatorShortcut.LoadStateSlot3: SaveStateManager.LoadState(3); break;

            case EmulatorShortcut.LoadStateSlot4: SaveStateManager.LoadState(4); break;

            case EmulatorShortcut.LoadStateSlot5: SaveStateManager.LoadState(5); break;

            case EmulatorShortcut.LoadStateSlot6: SaveStateManager.LoadState(6); break;

            case EmulatorShortcut.LoadStateSlot7: SaveStateManager.LoadState(7); break;

            case EmulatorShortcut.LoadStateSlot8: SaveStateManager.LoadState(8); break;

            case EmulatorShortcut.LoadStateSlot9: SaveStateManager.LoadState(9); break;

            case EmulatorShortcut.LoadStateSlot10: SaveStateManager.LoadState(10); break;

            case EmulatorShortcut.LoadStateSlotAuto: SaveStateManager.LoadState(11); break;

            case EmulatorShortcut.LoadStateDialog:
                if (_displayManager.ExclusiveFullscreen)
                {
                    _displayManager.SetFullscreenState(false);
                    restoreFullscreen = false;
                }
                frmMain.Instance.ShowGameScreen(GameScreenMode.LoadState);
                break;

            case EmulatorShortcut.SaveStateDialog:
                if (_displayManager.ExclusiveFullscreen)
                {
                    _displayManager.SetFullscreenState(false);
                    restoreFullscreen = false;
                }
                frmMain.Instance.ShowGameScreen(GameScreenMode.SaveState);
                break;
            }

            if (restoreFullscreen && !_displayManager.ExclusiveFullscreen)
            {
                //Need to restore fullscreen mode after showing a dialog
                _displayManager.SetFullscreenState(true);
            }
        }
Beispiel #2
0
        public void ExecuteShortcut(EmulatorShortcut shortcut)
        {
            Func <bool> isActionEnabled;

            if (_actionEnabledFuncs.TryGetValue(shortcut, out isActionEnabled))
            {
                isActionEnabled = _actionEnabledFuncs[shortcut];
                if (isActionEnabled != null && !isActionEnabled())
                {
                    //Action disabled
                    return;
                }
            }

            bool restoreFullscreen = _displayManager.ExclusiveFullscreen;

            switch (shortcut)
            {
            case EmulatorShortcut.Pause: TogglePause(); break;

            case EmulatorShortcut.Reset: EmuApi.Reset(); break;

            case EmulatorShortcut.PowerCycle: EmuApi.PowerCycle(); break;

            case EmulatorShortcut.PowerOff: Task.Run(() => EmuApi.Stop()); restoreFullscreen = false; break;

            case EmulatorShortcut.Exit: Application.OpenForms[0].Close(); restoreFullscreen = false; break;

            case EmulatorShortcut.ToggleAudio: ToggleAudio(); break;

            case EmulatorShortcut.ToggleFps: ToggleFps(); break;

            case EmulatorShortcut.ToggleGameTimer: ToggleGameTimer(); break;

            case EmulatorShortcut.ToggleFrameCounter: ToggleFrameCounter(); break;

            case EmulatorShortcut.ToggleOsd: ToggleOsd(); break;

            case EmulatorShortcut.ToggleAlwaysOnTop: ToggleAlwaysOnTop(); break;

            case EmulatorShortcut.ToggleDebugInfo: ToggleDebugInfo(); break;

            case EmulatorShortcut.MaxSpeed: ToggleMaxSpeed(); break;

            case EmulatorShortcut.ToggleFullscreen: _displayManager.ToggleFullscreen(); restoreFullscreen = false; break;

            case EmulatorShortcut.OpenFile: OpenFile(); break;

            case EmulatorShortcut.IncreaseSpeed: IncreaseEmulationSpeed(); break;

            case EmulatorShortcut.DecreaseSpeed: DecreaseEmulationSpeed(); break;

            case EmulatorShortcut.SetScale1x: _displayManager.SetScale(1, true); break;

            case EmulatorShortcut.SetScale2x: _displayManager.SetScale(2, true); break;

            case EmulatorShortcut.SetScale3x: _displayManager.SetScale(3, true); break;

            case EmulatorShortcut.SetScale4x: _displayManager.SetScale(4, true); break;

            case EmulatorShortcut.SetScale5x: _displayManager.SetScale(5, true); break;

            case EmulatorShortcut.SetScale6x: _displayManager.SetScale(6, true); break;

            case EmulatorShortcut.TakeScreenshot: EmuApi.TakeScreenshot(); break;

            case EmulatorShortcut.LoadStateFromFile: SaveStateManager.LoadStateFromFile(); break;

            case EmulatorShortcut.SaveStateToFile: SaveStateManager.SaveStateToFile(); break;

            case EmulatorShortcut.SaveStateSlot1: SaveStateManager.SaveState(1); break;

            case EmulatorShortcut.SaveStateSlot2: SaveStateManager.SaveState(2); break;

            case EmulatorShortcut.SaveStateSlot3: SaveStateManager.SaveState(3); break;

            case EmulatorShortcut.SaveStateSlot4: SaveStateManager.SaveState(4); break;

            case EmulatorShortcut.SaveStateSlot5: SaveStateManager.SaveState(5); break;

            case EmulatorShortcut.SaveStateSlot6: SaveStateManager.SaveState(6); break;

            case EmulatorShortcut.SaveStateSlot7: SaveStateManager.SaveState(7); break;

            case EmulatorShortcut.SaveStateSlot8: SaveStateManager.SaveState(8); break;

            case EmulatorShortcut.SaveStateSlot9: SaveStateManager.SaveState(9); break;

            case EmulatorShortcut.SaveStateSlot10: SaveStateManager.SaveState(10); break;

            case EmulatorShortcut.LoadStateSlot1: SaveStateManager.LoadState(1); break;

            case EmulatorShortcut.LoadStateSlot2: SaveStateManager.LoadState(2); break;

            case EmulatorShortcut.LoadStateSlot3: SaveStateManager.LoadState(3); break;

            case EmulatorShortcut.LoadStateSlot4: SaveStateManager.LoadState(4); break;

            case EmulatorShortcut.LoadStateSlot5: SaveStateManager.LoadState(5); break;

            case EmulatorShortcut.LoadStateSlot6: SaveStateManager.LoadState(6); break;

            case EmulatorShortcut.LoadStateSlot7: SaveStateManager.LoadState(7); break;

            case EmulatorShortcut.LoadStateSlot8: SaveStateManager.LoadState(8); break;

            case EmulatorShortcut.LoadStateSlot9: SaveStateManager.LoadState(9); break;

            case EmulatorShortcut.LoadStateSlot10: SaveStateManager.LoadState(10); break;

            case EmulatorShortcut.LoadStateSlotAuto: SaveStateManager.LoadState(11); break;
            }

            if (restoreFullscreen && !_displayManager.ExclusiveFullscreen)
            {
                //Need to restore fullscreen mode after showing a dialog
                _displayManager.SetFullscreenState(true);
            }
        }