From dbf89440f6cdb2337aaaa196bee5ab9c25b9deb2 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 29 Jun 2014 02:12:23 +0000 Subject: [PATCH] Simplify some movie related client code --- BizHawk.Client.EmuHawk/MainForm.Events.cs | 51 +++++++++++++++++-- BizHawk.Client.EmuHawk/MainForm.Hotkey.cs | 8 +-- BizHawk.Client.EmuHawk/MainForm.Movie.cs | 60 +---------------------- 3 files changed, 53 insertions(+), 66 deletions(-) diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index d52ef0e0d9..6a3a6cf077 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -14,6 +14,7 @@ using BizHawk.Emulation.Cores.PCEngine; using BizHawk.Emulation.Cores.Sega.MasterSystem; using BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES; using BizHawk.Client.EmuHawk.config.NES; +using BizHawk.Emulation.Common.IEmulatorExtensions; namespace BizHawk.Client.EmuHawk { @@ -374,12 +375,56 @@ namespace BizHawk.Client.EmuHawk private void RecordMovieMenuItem_Click(object sender, EventArgs e) { - LoadRecordMovieDialog(); + if (!Global.Emulator.Attributes().Released) + { + var result = MessageBox.Show + (this, "Thanks for using Bizhawk! The emulation core you have selected " + + "is currently BETA-status. We appreciate your help in testing Bizhawk. " + + "You can record a movie on this core if you'd like to, but expect to " + + "encounter bugs and sync problems. Continue?", "BizHawk", MessageBoxButtons.YesNo); + + if (result != DialogResult.Yes) + { + return; + } + } + else if (Global.Emulator is LibsnesCore) + { + var ss = (LibsnesCore.SnesSyncSettings)Global.Emulator.GetSyncSettings(); + if (ss.Profile == "Performance" && !Global.Config.DontAskPerformanceCoreRecordingNag) + { + var box = new MsgBox( + "While the performance core is faster, it is recommended that you use the Compatibility profile when recording movies for better accuracy and stability\n\nSwitch to Compatibility?", + "Stability Warning", + MessageBoxIcon.Warning); + + box.SetButtons( + new[] { "Switch", "Continue", "Cancel" }, + new[] { DialogResult.Yes, DialogResult.No, DialogResult.Cancel }); + box.SetCheckbox("Don't ask me again"); + box.MaximumSize = new Size(450, 350); + box.SetMessageToAutoSize(); + var result = box.ShowDialog(); + Global.Config.DontAskPerformanceCoreRecordingNag = box.CheckboxChecked; + + if (result == DialogResult.Yes) + { + ss.Profile = "Compatibility"; + Global.Emulator.PutSyncSettings(ss); + } + else if (result == DialogResult.Cancel) + { + return; + } + } + } + + new RecordMovie().ShowDialog(); } private void PlayMovieMenuItem_Click(object sender, EventArgs e) { - LoadPlayMovieDialog(); + new PlayMovie().ShowDialog(); } private void StopMovieMenuItem_Click(object sender, EventArgs e) @@ -1061,7 +1106,7 @@ namespace BizHawk.Client.EmuHawk using (var dlg = new DualGBXMLCreator()) { var result = dlg.ShowDialog(this); - if (result == System.Windows.Forms.DialogResult.OK) + if (result == DialogResult.OK) { GlobalWin.OSD.AddMessage("XML File saved"); } diff --git a/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs b/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs index 90fb7ca4a7..41cae8c820 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs @@ -243,11 +243,11 @@ namespace BizHawk.Client.EmuHawk case "Toggle read-only": ToggleReadOnly(); break; - case "Play Movie": - LoadPlayMovieDialog(); + case "Play Movie": + PlayMovieMenuItem_Click(null, null); break; - case "Record Movie": - LoadRecordMovieDialog(); + case "Record Movie": + RecordMovieMenuItem_Click(null, null); break; case "Stop Movie": StopMovie(); diff --git a/BizHawk.Client.EmuHawk/MainForm.Movie.cs b/BizHawk.Client.EmuHawk/MainForm.Movie.cs index 6960617edb..c42ebf75c0 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Movie.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Movie.cs @@ -1,14 +1,10 @@ using System; -using System.Drawing; using System.IO; -using System.Windows.Forms; using BizHawk.Client.Common; using BizHawk.Emulation.Common; -using BizHawk.Emulation.Common.IEmulatorExtensions; using BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES; using BizHawk.Emulation.Cores.Nintendo.NES; -using BizHawk.Emulation.Cores.Nintendo.SNES; namespace BizHawk.Client.EmuHawk { @@ -54,7 +50,7 @@ namespace BizHawk.Client.EmuHawk } } - string s = Global.MovieSession.Movie.SyncSettingsJson; + var s = Global.MovieSession.Movie.SyncSettingsJson; if (!string.IsNullOrWhiteSpace(s)) { _syncSettingsHack = ConfigService.LoadWithType(s); @@ -135,60 +131,6 @@ namespace BizHawk.Client.EmuHawk } } - public void LoadPlayMovieDialog() - { - new PlayMovie().ShowDialog(); - } - - public void LoadRecordMovieDialog() - { - if (!Global.Emulator.Attributes().Released) - { - var result = MessageBox.Show - (this, "Thanks for using Bizhawk! The emulation core you have selected " + - "is currently BETA-status. We appreciate your help in testing Bizhawk. " + - "You can record a movie on this core if you'd like to, but expect to " + - "encounter bugs and sync problems. Continue?", "BizHawk", MessageBoxButtons.YesNo); - - if (result != DialogResult.Yes) - { - return; - } - } - else if (Global.Emulator is LibsnesCore) - { - var ss = (LibsnesCore.SnesSyncSettings)Global.Emulator.GetSyncSettings(); - if (ss.Profile == "Performance" && !Global.Config.DontAskPerformanceCoreRecordingNag) - { - var box = new MsgBox( - "While the performance core is faster, it is recommended that you use the Compatibility profile when recording movies for better accuracy and stability\n\nSwitch to Compatibility?", - "Stability Warning", - MessageBoxIcon.Warning); - - box.SetButtons( - new [] {"Switch", "Continue", "Cancel" }, - new DialogResult[] { DialogResult.Yes, DialogResult.No, DialogResult.Cancel }); - box.SetCheckbox("Don't ask me again"); - box.MaximumSize = new Size(450, 350); - box.SetMessageToAutoSize(); - var result = box.ShowDialog(); - Global.Config.DontAskPerformanceCoreRecordingNag = box.CheckboxChecked; - - if (result == DialogResult.Yes) - { - ss.Profile = "Compatibility"; - Global.Emulator.PutSyncSettings(ss); - } - else if (result == DialogResult.Cancel) - { - return; - } - } - } - - new RecordMovie().ShowDialog(); - } - public void RestartMovie() { if (Global.MovieSession.Movie.IsActive)