Broaden usage of TAStudio-specific movie-loading. (#2411)

* Broaden usage of TAStudio-specific movie-loading.

fixes #2386

* TAStudio drag-drop: use LoadMovieFile for consistency
This commit is contained in:
RetroEdit 2020-09-19 01:08:49 +00:00 committed by GitHub
parent a5d166cf71
commit b1a64e2212
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 43 deletions

View File

@ -95,14 +95,20 @@ namespace BizHawk.Client.EmuHawk
if (Emulator.IsNull())
{
OpenRom();
if (Emulator.IsNull())
{
return;
}
}
if (Emulator.IsNull())
if (GlobalWin.Tools.IsLoaded<TAStudio>())
{
return;
Tools.TAStudio.LoadMovieFile(filename);
}
else
{
StartNewMovie(MovieSession.Get(filename), false);
}
StartNewMovie(MovieSession.Get(filename), false);
}
private void LoadRom(string filename, string archive = null)

View File

@ -92,6 +92,9 @@ namespace BizHawk.Client.EmuHawk
}
}
/// <summary>
/// Ask whether changes should be saved. Returns false if cancelled, else true.
/// </summary>
public override bool AskSaveChanges()
{
if (_suppressAskSave)

View File

@ -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);
}
}
}
/// <summary>
/// Load the movie with the given filename within TAStudio.
/// </summary>
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();

View File

@ -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)