move Bk2 -> TasMovie conversion logic from Tastudio to MovieSession, fix crashing when loading .bk2 movies from the tastudio menu

This commit is contained in:
adelikat 2020-04-18 14:50:21 -05:00
parent d946aa6145
commit 4e3aa0eb15
5 changed files with 26 additions and 7 deletions

View File

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using BizHawk.Client.Common.MovieConversionExtensions;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
@ -355,6 +355,14 @@ namespace BizHawk.Client.Common
Movie = MovieService.DefaultInstance;
}
public void ConvertToTasProj()
{
Movie.Save();
Movie = Movie.ToTasMovie();
Movie.Save();
Movie.SwitchToPlay();
}
private void ClearFrame()
{
if (Movie.IsPlaying())

View File

@ -64,5 +64,10 @@ namespace BizHawk.Client.Common
void ToggleMultitrack();
void StopMovie(bool saveChanges = true);
/// <summary>
/// If a movie is active, it will be converted to a <see cref="TasMovie" />
/// </summary>
void ConvertToTasProj();
}
}

View File

@ -1,4 +1,5 @@
using System.Windows.Forms;
using System;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Emulation.Common;
@ -9,6 +10,11 @@ namespace BizHawk.Client.EmuHawk
{
public bool StartNewMovie(IMovie movie, bool record)
{
if (movie == null)
{
throw new ArgumentNullException($"{nameof(movie)} cannot be null.");
}
try
{
MovieSession.QueueNewMovie(movie, record, Emulator);

View File

@ -121,10 +121,12 @@ namespace BizHawk.Client.EmuHawk
else if (ofd.FileName.EndsWith(Bk2Movie.Extension))
{
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 == DialogResult.OK)
if (result1.IsOk())
{
_initializing = true; // Starting a new movie causes a core reboot
MainForm.StartNewMovie(MovieService.Get(ofd.FileName), false);
ConvertCurrentMovieToTasproj();
_initialized = false;
StartNewMovieWrapper(false);
SetUpColumns();
SetTextProperty();

View File

@ -615,11 +615,9 @@ namespace BizHawk.Client.EmuHawk
private void ConvertCurrentMovieToTasproj()
{
MovieSession.Movie.Save();
MovieSession.Movie = MovieSession.Movie.ToTasMovie();
MovieSession.Movie.Save();
MovieSession.Movie.SwitchToPlay();
MovieSession.ConvertToTasProj();
Settings.RecentTas.Add(MovieSession.Movie.Filename);
MainForm.SetMainformMovieInfo();
}
private bool LoadFile(FileInfo file, bool startsFromSavestate = false, int gotoFrame = 0)