private static void ToggleRecordMovie() { if (!EmuApi.IsRunning()) { return; } if (!RecordApi.MoviePlaying() && !NetplayApi.IsConnected()) { if (RecordApi.MovieRecording()) { RecordApi.MovieStop(); } else { RecordMovieOptions options = new RecordMovieOptions( GetOutputFilename(ConfigManager.MovieFolder, ".msm"), ConfigManager.Config.MovieRecord.Author, ConfigManager.Config.MovieRecord.Description, ConfigManager.Config.MovieRecord.RecordFrom ); RecordApi.MovieRecord(ref options); } } }
private void mnuFile_DropDownOpening(object sender, EventArgs e) { mnuLoadState.Enabled = !NetplayApi.IsConnected(); mnuRecentFiles.DropDownItems.Clear(); mnuRecentFiles.DropDownItems.AddRange(ConfigManager.Config.RecentFiles.GetMenuItems().ToArray()); mnuRecentFiles.Enabled = ConfigManager.Config.RecentFiles.Items.Count > 0; }
private void InitNetPlayMenus() { mnuConnect.Click += (s, e) => { NetPlayHelper.Connect(); }; mnuStartServer.Click += (s, e) => { NetPlayHelper.ToggleServer(); }; mnuProfile.Click += (s, e) => { using (frmPlayerProfile frm = new frmPlayerProfile()) { frm.ShowDialog(mnuProfile, this); } }; mnuNetPlayPlayer1.Click += (s, e) => { NetplayApi.NetPlaySelectController(0); }; mnuNetPlayPlayer2.Click += (s, e) => { NetplayApi.NetPlaySelectController(1); }; mnuNetPlayPlayer3.Click += (s, e) => { NetplayApi.NetPlaySelectController(2); }; mnuNetPlayPlayer4.Click += (s, e) => { NetplayApi.NetPlaySelectController(3); }; mnuNetPlayPlayer5.Click += (s, e) => { NetplayApi.NetPlaySelectController(4); }; mnuNetPlaySpectator.Click += (s, e) => { NetplayApi.NetPlaySelectController(0xFF); }; mnuNetPlay.DropDownOpening += (s, e) => { bool runAheadDisabled = ConfigManager.Config.Emulation.RunAheadFrames == 0; bool isClient = NetplayApi.IsConnected(); bool isServer = NetplayApi.IsServerRunning(); mnuConnect.Text = ResourceHelper.GetMessage(isClient ? "Disconnect" : "ConnectToServer"); mnuConnect.Enabled = runAheadDisabled && !isServer; mnuStartServer.Text = ResourceHelper.GetMessage(isServer ? "StopServer" : "StartServer"); mnuStartServer.Enabled = runAheadDisabled && !isClient; mnuNetPlaySelectController.Enabled = isClient || isServer; }; mnuNetPlaySelectController.DropDownOpening += (s, e) => { int availableControllers = NetplayApi.NetPlayGetAvailableControllers(); int currentControllerPort = NetplayApi.NetPlayGetControllerPort(); mnuNetPlayPlayer1.Enabled = (availableControllers & 0x01) == 0x01; mnuNetPlayPlayer2.Enabled = (availableControllers & 0x02) == 0x02; mnuNetPlayPlayer3.Enabled = (availableControllers & 0x04) == 0x04; mnuNetPlayPlayer4.Enabled = (availableControllers & 0x08) == 0x08; mnuNetPlayPlayer5.Enabled = (availableControllers & 0x10) == 0x10; Func <int, string> getControllerName = (int port) => { ControllerType type = ConfigApi.GetControllerType(port); if (type == ControllerType.Multitap) { type = ControllerType.SnesController; } return(ResourceHelper.GetEnumText(type)); }; mnuNetPlayPlayer1.Text = ResourceHelper.GetMessage("PlayerNumber", "1") + " (" + getControllerName(0) + ")"; mnuNetPlayPlayer2.Text = ResourceHelper.GetMessage("PlayerNumber", "2") + " (" + getControllerName(1) + ")"; mnuNetPlayPlayer3.Text = ResourceHelper.GetMessage("PlayerNumber", "3") + " (" + getControllerName(2) + ")"; mnuNetPlayPlayer4.Text = ResourceHelper.GetMessage("PlayerNumber", "4") + " (" + getControllerName(3) + ")"; mnuNetPlayPlayer5.Text = ResourceHelper.GetMessage("PlayerNumber", "5") + " (" + getControllerName(4) + ")"; mnuNetPlayPlayer1.Checked = (currentControllerPort == 0); mnuNetPlayPlayer2.Checked = (currentControllerPort == 1); mnuNetPlayPlayer3.Checked = (currentControllerPort == 2); mnuNetPlayPlayer4.Checked = (currentControllerPort == 3); mnuNetPlayPlayer5.Checked = (currentControllerPort == 4); mnuNetPlaySpectator.Checked = (currentControllerPort == 0xFF); }; }
public static void Connect() { if (NetplayApi.IsConnected()) { Task.Run(() => NetplayApi.Disconnect()); } else { using (frmClientConfig frm = new frmClientConfig()) { if (frm.ShowDialog(frmMain.Instance) == DialogResult.OK) { NetplayConfig cfg = ConfigManager.Config.Netplay; Task.Run(() => { NetplayApi.Connect(cfg.Host, cfg.Port, cfg.Password, cfg.PlayerName, false); }); } } } }
private void mnuTools_DropDownOpening(object sender, EventArgs e) { bool isClient = NetplayApi.IsConnected(); mnuMovies.Enabled = EmuRunner.IsRunning(); mnuPlayMovie.Enabled = EmuRunner.IsRunning() && !RecordApi.MoviePlaying() && !RecordApi.MovieRecording() && !isClient; mnuRecordMovie.Enabled = EmuRunner.IsRunning() && !RecordApi.MoviePlaying() && !RecordApi.MovieRecording(); mnuStopMovie.Enabled = EmuRunner.IsRunning() && (RecordApi.MoviePlaying() || RecordApi.MovieRecording()); mnuSoundRecorder.Enabled = EmuRunner.IsRunning(); mnuWaveRecord.Enabled = EmuRunner.IsRunning() && !RecordApi.WaveIsRecording(); mnuWaveStop.Enabled = EmuRunner.IsRunning() && RecordApi.WaveIsRecording(); mnuVideoRecorder.Enabled = EmuRunner.IsRunning(); mnuAviRecord.Enabled = EmuRunner.IsRunning() && !RecordApi.AviIsRecording(); mnuAviStop.Enabled = EmuRunner.IsRunning() && RecordApi.AviIsRecording(); mnuCheats.Enabled = EmuRunner.IsRunning() && !isClient; }
private void mnuTools_DropDownOpening(object sender, EventArgs e) { bool isClient = NetplayApi.IsConnected(); bool runAheadDisabled = ConfigManager.Config.Emulation.RunAheadFrames == 0; bool isGameboyMode = EmuApi.GetRomInfo().CoprocessorType == CoprocessorType.Gameboy; mnuNetPlay.Enabled = runAheadDisabled && !isGameboyMode; mnuMovies.Enabled = runAheadDisabled && EmuRunner.IsRunning(); mnuPlayMovie.Enabled = runAheadDisabled && EmuRunner.IsRunning() && !RecordApi.MoviePlaying() && !RecordApi.MovieRecording() && !isClient; mnuRecordMovie.Enabled = runAheadDisabled && EmuRunner.IsRunning() && !RecordApi.MoviePlaying() && !RecordApi.MovieRecording(); mnuStopMovie.Enabled = runAheadDisabled && EmuRunner.IsRunning() && (RecordApi.MoviePlaying() || RecordApi.MovieRecording()); mnuSoundRecorder.Enabled = EmuRunner.IsRunning(); mnuWaveRecord.Enabled = EmuRunner.IsRunning() && !RecordApi.WaveIsRecording(); mnuWaveStop.Enabled = EmuRunner.IsRunning() && RecordApi.WaveIsRecording(); mnuVideoRecorder.Enabled = EmuRunner.IsRunning(); mnuAviRecord.Enabled = EmuRunner.IsRunning() && !RecordApi.AviIsRecording(); mnuAviStop.Enabled = EmuRunner.IsRunning() && RecordApi.AviIsRecording(); mnuCheats.Enabled = EmuRunner.IsRunning() && !isClient && !isGameboyMode; }
private void BindShortcuts() { Func <bool> notClient = () => { return(!NetplayApi.IsConnected()); }; Func <bool> running = () => { return(EmuRunner.IsRunning()); }; Func <bool> runningNotClient = () => { return(EmuRunner.IsRunning() && !NetplayApi.IsConnected()); }; Func <bool> runningNotClientNotMovie = () => { return(EmuRunner.IsRunning() && !NetplayApi.IsConnected() && !RecordApi.MoviePlaying()); }; _shortcuts.BindShortcut(mnuOpen, EmulatorShortcut.OpenFile); _shortcuts.BindShortcut(mnuReloadRom, EmulatorShortcut.ReloadRom, runningNotClientNotMovie); _shortcuts.BindShortcut(mnuExit, EmulatorShortcut.Exit); _shortcuts.BindShortcut(mnuIncreaseSpeed, EmulatorShortcut.IncreaseSpeed, notClient); _shortcuts.BindShortcut(mnuDecreaseSpeed, EmulatorShortcut.DecreaseSpeed, notClient); _shortcuts.BindShortcut(mnuEmuSpeedMaximumSpeed, EmulatorShortcut.MaxSpeed, notClient); _shortcuts.BindShortcut(mnuPause, EmulatorShortcut.Pause, runningNotClient); _shortcuts.BindShortcut(mnuReset, EmulatorShortcut.Reset, runningNotClientNotMovie); _shortcuts.BindShortcut(mnuPowerCycle, EmulatorShortcut.PowerCycle, runningNotClientNotMovie); _shortcuts.BindShortcut(mnuPowerOff, EmulatorShortcut.PowerOff, runningNotClient); _shortcuts.BindShortcut(mnuShowFPS, EmulatorShortcut.ToggleFps); _shortcuts.BindShortcut(mnuScale1x, EmulatorShortcut.SetScale1x); _shortcuts.BindShortcut(mnuScale2x, EmulatorShortcut.SetScale2x); _shortcuts.BindShortcut(mnuScale3x, EmulatorShortcut.SetScale3x); _shortcuts.BindShortcut(mnuScale4x, EmulatorShortcut.SetScale4x); _shortcuts.BindShortcut(mnuScale5x, EmulatorShortcut.SetScale5x); _shortcuts.BindShortcut(mnuScale6x, EmulatorShortcut.SetScale6x); _shortcuts.BindShortcut(mnuFullscreen, EmulatorShortcut.ToggleFullscreen); _shortcuts.BindShortcut(mnuTakeScreenshot, EmulatorShortcut.TakeScreenshot, running); _shortcuts.BindShortcut(mnuRandomGame, EmulatorShortcut.LoadRandomGame); mnuDebugger.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenDebugger)); mnuSpcDebugger.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenSpcDebugger)); mnuSa1Debugger.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenSa1Debugger)); mnuGsuDebugger.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenGsuDebugger)); mnuNecDspDebugger.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenNecDspDebugger)); mnuCx4Debugger.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenCx4Debugger)); mnuGbDebugger.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenGameboyDebugger)); mnuMemoryTools.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenMemoryTools)); mnuEventViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenEventViewer)); mnuTilemapViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenTilemapViewer)); mnuTileViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenTileViewer)); mnuSpriteViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenSpriteViewer)); mnuPaletteViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenPaletteViewer)); mnuTraceLogger.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenTraceLogger)); mnuScriptWindow.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenScriptWindow)); mnuRegisterViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenRegisterViewer)); mnuProfiler.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenProfiler)); mnuAssembler.InitShortcut(this, nameof(DebuggerShortcutsConfig.OpenAssembler)); mnuNoneFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.None); }; mnuNtscFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.NTSC); }; mnuHQ2xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.HQ2x); }; mnuHQ3xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.HQ3x); }; mnuHQ4xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.HQ4x); }; mnuPrescale2xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Prescale2x); }; mnuPrescale3xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Prescale3x); }; mnuPrescale4xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Prescale4x); }; mnuPrescale6xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Prescale6x); }; mnuPrescale8xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Prescale8x); }; mnuPrescale10xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Prescale10x); }; mnuScale2xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Scale2x); }; mnuScale3xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Scale3x); }; mnuScale4xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Scale4x); }; mnu2xSaiFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType._2xSai); }; mnuSuper2xSaiFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.Super2xSai); }; mnuSuperEagleFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.SuperEagle); }; mnuXBRZ2xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.xBRZ2x); }; mnuXBRZ3xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.xBRZ3x); }; mnuXBRZ4xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.xBRZ4x); }; mnuXBRZ5xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.xBRZ5x); }; mnuXBRZ6xFilter.Click += (s, e) => { _shortcuts.SetVideoFilter(VideoFilterType.xBRZ6x); }; mnuBilinearInterpolation.Click += (s, e) => { _shortcuts.ToggleBilinearInterpolation(); }; mnuBlendHighResolutionModes.Click += (s, e) => { _shortcuts.ToggleBlendHighResolutionModes(); }; mnuRegionAuto.Click += (s, e) => { _shortcuts.SetRegion(ConsoleRegion.Auto); }; mnuRegionNtsc.Click += (s, e) => { _shortcuts.SetRegion(ConsoleRegion.Ntsc); }; mnuRegionPal.Click += (s, e) => { _shortcuts.SetRegion(ConsoleRegion.Pal); }; mnuCheats.Click += (s, e) => { frmCheatList.ShowWindow(); }; mnuOptions.DropDownOpening += (s, e) => { bool isConnected = NetplayApi.IsConnected(); mnuRegion.Enabled = !isConnected; mnuInputConfig.Enabled = !isConnected; mnuEmulationConfig.Enabled = !isConnected; }; InitNetPlayMenus(); mnuDebugger.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.Debugger); }; mnuSpcDebugger.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.SpcDebugger); }; mnuSa1Debugger.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.Sa1Debugger); }; mnuGsuDebugger.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.GsuDebugger); }; mnuNecDspDebugger.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.NecDspDebugger); }; mnuCx4Debugger.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.Cx4Debugger); }; mnuGbDebugger.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.GbDebugger); }; mnuTraceLogger.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.TraceLogger); }; mnuMemoryTools.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.MemoryTools); }; mnuTilemapViewer.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.TilemapViewer); }; mnuTileViewer.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.TileViewer); }; mnuSpriteViewer.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.SpriteViewer); }; mnuPaletteViewer.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.PaletteViewer); }; mnuEventViewer.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.EventViewer); }; mnuScriptWindow.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.ScriptWindow); }; mnuRegisterViewer.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.RegisterViewer); }; mnuProfiler.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.Profiler); }; mnuAssembler.Click += (s, e) => { DebugWindowManager.OpenDebugWindow(DebugWindow.Assembler); }; mnuTestRun.Click += (s, e) => { RomTestHelper.RunTest(); }; mnuTestRecord.Click += (s, e) => { RomTestHelper.RecordTest(); }; mnuTestStop.Click += (s, e) => { RomTestHelper.StopRecording(); }; mnuRunAllTests.Click += (s, e) => { RomTestHelper.RunAllTests(); }; UpdateDebuggerMenu(); }
public static void InitializeStateMenu(ToolStripMenuItem menu, bool forSave, ShortcutHandler shortcutHandler) { Action <uint> addSaveStateInfo = (i) => { ToolStripMenuItem item = new ToolStripMenuItem(); menu.DropDownItems.Add(item); if (forSave) { shortcutHandler.BindShortcut(item, (EmulatorShortcut)((int)EmulatorShortcut.SaveStateSlot1 + i - 1)); } else { shortcutHandler.BindShortcut(item, (EmulatorShortcut)((int)EmulatorShortcut.LoadStateSlot1 + i - 1)); } }; for (uint i = 1; i <= NumberOfSaveSlots; i++) { addSaveStateInfo(i); } if (!forSave) { menu.DropDownItems.Add("-"); addSaveStateInfo(NumberOfSaveSlots + 1); menu.DropDownItems.Add("-"); ToolStripMenuItem loadDialog = new ToolStripMenuItem(ResourceHelper.GetMessage("LoadStateDialog"), Resources.SplitView); menu.DropDownItems.Add(loadDialog); shortcutHandler.BindShortcut(loadDialog, EmulatorShortcut.LoadStateDialog, () => EmuRunner.IsRunning() && !NetplayApi.IsConnected()); ToolStripMenuItem loadFromFile = new ToolStripMenuItem(ResourceHelper.GetMessage("LoadFromFile"), Resources.Folder); menu.DropDownItems.Add(loadFromFile); shortcutHandler.BindShortcut(loadFromFile, EmulatorShortcut.LoadStateFromFile); } else { menu.DropDownItems.Add("-"); ToolStripMenuItem saveDialog = new ToolStripMenuItem(ResourceHelper.GetMessage("SaveStateDialog"), Resources.SplitView); menu.DropDownItems.Add(saveDialog); shortcutHandler.BindShortcut(saveDialog, EmulatorShortcut.SaveStateDialog, () => EmuRunner.IsRunning() && !NetplayApi.IsConnected()); ToolStripMenuItem saveToFile = new ToolStripMenuItem(ResourceHelper.GetMessage("SaveToFile"), Resources.SaveFloppy); menu.DropDownItems.Add(saveToFile); shortcutHandler.BindShortcut(saveToFile, EmulatorShortcut.SaveStateToFile); } }