From 43d9f77fd68cb7b3b09b7b20392ef1e5afa47be0 Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 1 Aug 2014 01:34:40 +0000 Subject: [PATCH] this is mostly a hack, but fixes loading a rom when a movie is still running --- BizHawk.Client.EmuHawk/MainForm.Events.cs | 4 ++-- BizHawk.Client.EmuHawk/MainForm.Movie.cs | 2 +- BizHawk.Client.EmuHawk/MainForm.cs | 19 +++++++++++++++---- BizHawk.Client.EmuHawk/Program.cs | 2 +- .../tools/GB/DualGBXMLCreator.cs | 2 +- .../Lua/Libraries/EmuLuaLibrary.Client.cs | 2 +- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index f9b0fc9f4f..751dab4108 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -2377,7 +2377,7 @@ namespace BizHawk.Client.EmuHawk } else { - LoadRom(CurrentlyOpenRom); + StopMovieThenLoadRom(CurrentlyOpenRom); } string errorMsg; @@ -2399,7 +2399,7 @@ namespace BizHawk.Client.EmuHawk } else { - LoadRom(filePaths[0]); + StopMovieThenLoadRom(filePaths[0]); } } diff --git a/BizHawk.Client.EmuHawk/MainForm.Movie.cs b/BizHawk.Client.EmuHawk/MainForm.Movie.cs index b642273b98..ca6f6f69a5 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Movie.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Movie.cs @@ -158,7 +158,7 @@ namespace BizHawk.Client.EmuHawk { if (Global.MovieSession.Movie.IsActive) { - LoadRom(CurrentlyOpenRom); + StopMovieThenLoadRom(CurrentlyOpenRom); if (Global.MovieSession.Movie.StartsFromSavestate) { // TODO: why does this code exist twice?? diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index 6e4cf54834..41159613dd 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -262,7 +262,7 @@ namespace BizHawk.Client.EmuHawk if (cmdRom != null) { // Commandline should always override auto-load - LoadRom(cmdRom); + StopMovieThenLoadRom(cmdRom); if (Global.Game == null) { MessageBox.Show("Failed to load " + cmdRom + " specified on commandline"); @@ -818,7 +818,7 @@ namespace BizHawk.Client.EmuHawk public void RebootCore() { - LoadRom(CurrentlyOpenRom); + StopMovieThenLoadRom(CurrentlyOpenRom); } public void PauseEmulator() @@ -1569,7 +1569,7 @@ namespace BizHawk.Client.EmuHawk private void LoadRomFromRecent(string rom) { - if (!LoadRom(rom)) + if (!StopMovieThenLoadRom(rom)) { Global.Config.RecentRoms.HandleLoadError(rom); } @@ -1830,7 +1830,7 @@ namespace BizHawk.Client.EmuHawk var file = new FileInfo(ofd.FileName); Global.Config.LastRomPath = file.DirectoryName; _lastOpenRomFilter = ofd.FilterIndex; - LoadRom(file.FullName); + StopMovieThenLoadRom(file.FullName); } private void CoreSyncSettings(object sender, RomLoader.SettingsLoadArgs e) @@ -3061,6 +3061,17 @@ namespace BizHawk.Client.EmuHawk return platformChooser.PlatformChoice; } + // TODO: a better name for this method, but this is the one that should be called, in general + public bool StopMovieThenLoadRom(string path, bool? deterministicemulation = null) + { + if (Global.MovieSession.Movie.IsActive) + { + Global.MovieSession.Movie.Stop(); + } + + return LoadRom(path, deterministicemulation); + } + // Still needs a good bit of refactoring public bool LoadRom(string path, bool? deterministicemulation = null) { diff --git a/BizHawk.Client.EmuHawk/Program.cs b/BizHawk.Client.EmuHawk/Program.cs index eee0a7c8b9..d260029cee 100644 --- a/BizHawk.Client.EmuHawk/Program.cs +++ b/BizHawk.Client.EmuHawk/Program.cs @@ -233,7 +233,7 @@ namespace BizHawk.Client.EmuHawk void this_StartupNextInstance(object sender, StartupNextInstanceEventArgs e) { - (MainForm as MainForm).LoadRom(e.CommandLine[0]); + (MainForm as MainForm).StopMovieThenLoadRom(e.CommandLine[0]); } protected override void OnCreateMainForm() diff --git a/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.cs b/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.cs index e16bf5a50b..73033db095 100644 --- a/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.cs +++ b/BizHawk.Client.EmuHawk/tools/GB/DualGBXMLCreator.cs @@ -169,7 +169,7 @@ namespace BizHawk.Client.EmuHawk DialogResult = DialogResult.OK; Close(); - GlobalWin.MainForm.LoadRom(textBoxOutputDir.Text); + GlobalWin.MainForm.StopMovieThenLoadRom(textBoxOutputDir.Text); } } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs index 9c34491791..d979fb3d6c 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs @@ -140,7 +140,7 @@ namespace BizHawk.Client.EmuHawk )] public static void OpenRom(string path) { - GlobalWin.MainForm.LoadRom(path); + GlobalWin.MainForm.StopMovieThenLoadRom(path); } [LuaMethodAttributes(