diff --git a/src/BizHawk.Client.EmuHawk/MainForm.FileLoader.cs b/src/BizHawk.Client.EmuHawk/MainForm.FileLoader.cs index 3ab451bcb2..5b9b666f0e 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.FileLoader.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.FileLoader.cs @@ -95,14 +95,20 @@ namespace BizHawk.Client.EmuHawk if (Emulator.IsNull()) { OpenRom(); + if (Emulator.IsNull()) + { + return; + } } - if (Emulator.IsNull()) + if (GlobalWin.Tools.IsLoaded()) { - return; + Tools.TAStudio.LoadMovieFile(filename); + } + else + { + StartNewMovie(MovieSession.Get(filename), false); } - - StartNewMovie(MovieSession.Get(filename), false); } private void LoadRom(string filename, string archive = null) diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs index ad15853fed..36f38453e1 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs @@ -92,6 +92,9 @@ namespace BizHawk.Client.EmuHawk } } + /// + /// Ask whether changes should be saved. Returns false if cancelled, else true. + /// public override bool AskSaveChanges() { if (_suppressAskSave) diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs index 56eaca2217..53b34c4b7e 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs @@ -111,36 +111,49 @@ namespace BizHawk.Client.EmuHawk var result = ofd.ShowHawkDialog(); if (result.IsOk()) { - if (ofd.FileName.EndsWith(MovieService.TasMovieExtension)) - { - LoadFileWithFallback(ofd.FileName); - } - else if (ofd.FileName.EndsWith(MovieService.StandardMovieExtension)) - { - var result1 = MessageBox.Show("This is a regular movie, a new project must be created from it, in order to use in TAStudio\nProceed?", "Convert movie", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); - if (result1.IsOk()) - { - _initializing = true; // Starting a new movie causes a core reboot - WantsToControlReboot = false; - _engaged = false; - MainForm.StartNewMovie(MovieSession.Get(ofd.FileName), false); - ConvertCurrentMovieToTasproj(); - _initializing = false; - StartNewMovieWrapper(CurrentTasMovie); - _engaged = true; - WantsToControlReboot = true; - SetUpColumns(); - UpdateWindowTitle(); - } - } - else - { - MessageBox.Show("This is not a BizHawk movie!", "Movie load error", MessageBoxButtons.OK, MessageBoxIcon.Error); - } + LoadMovieFile(ofd.FileName, false); } } } + /// + /// Load the movie with the given filename within TAStudio. + /// + public void LoadMovieFile(string filename, bool askToSave = true) + { + if (askToSave && !AskSaveChanges()) + { + return; + } + + if (filename.EndsWith(MovieService.TasMovieExtension)) + { + LoadFileWithFallback(filename); + } + else if (filename.EndsWith(MovieService.StandardMovieExtension)) + { + var result1 = MessageBox.Show("This is a regular movie, a new project must be created from it to use in TAStudio\nProceed?", "Convert movie", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); + if (result1.IsOk()) + { + _initializing = true; // Starting a new movie causes a core reboot + WantsToControlReboot = false; + _engaged = false; + MainForm.StartNewMovie(MovieSession.Get(filename), false); + ConvertCurrentMovieToTasproj(); + _initializing = false; + StartNewMovieWrapper(CurrentTasMovie); + _engaged = true; + WantsToControlReboot = true; + SetUpColumns(); + UpdateWindowTitle(); + } + } + else + { + MessageBox.Show("This is not a BizHawk movie!", "Movie load error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void SaveTasMenuItem_Click(object sender, EventArgs e) { SaveTas(); diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 8dd6d7ae88..9bdaad3416 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -1129,20 +1129,11 @@ namespace BizHawk.Client.EmuHawk private void TAStudio_DragDrop(object sender, DragEventArgs e) { - if (!AskSaveChanges()) - { - return; - } - + // TODO: Maybe this should call Mainform's DragDrop method, + // since that can file types that are not movies, + // and it can process multiple files sequentially var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); - if (Path.GetExtension(filePaths[0]) == $".{MovieService.TasMovieExtension}") - { - FileInfo file = new FileInfo(filePaths[0]); - if (file.Exists) - { - LoadFile(file); - } - } + LoadMovieFile(filePaths[0]); } private void TAStudio_MouseLeave(object sender, EventArgs e)