Change the ToBk2() method to receive an IMovie instead of Bkm, and write a ToTasMovie() method similarly. Tastudio - remove code that warns the user if they open it with a movie already active, instead ask and autoconvert the current movie to a tasproj file

This commit is contained in:
adelikat 2014-07-06 21:20:43 +00:00
parent b9bb1635a1
commit a02888344b
3 changed files with 67 additions and 20 deletions

View File

@ -2,36 +2,72 @@
{
public static class MovieConversionExtensions
{
public static Bk2Movie ToBk2(this BkmMovie bkm)
public static TasMovie ToTasMovie(this IMovie old)
{
var newFilename = bkm.Filename + "." + Bk2Movie.Extension;
var newFilename = old.Filename + "." + TasMovie.Extension;
var tas = new TasMovie(newFilename);
tas.HeaderEntries.Clear();
foreach (var kvp in old.HeaderEntries)
{
tas.HeaderEntries[kvp.Key] = kvp.Value;
}
tas.SyncSettingsJson = old.SyncSettingsJson;
tas.Comments.Clear();
foreach (var comment in old.Comments)
{
tas.Comments.Add(comment);
}
tas.Subtitles.Clear();
foreach (var sub in old.Subtitles)
{
tas.Subtitles.Add(sub);
}
tas.TextSavestate = old.TextSavestate;
tas.BinarySavestate = old.BinarySavestate;
for (var i = 0; i < old.InputLogLength; i++)
{
var input = old.GetInputState(i);
tas.AppendFrame(input);
}
return tas;
}
public static Bk2Movie ToBk2(this IMovie old)
{
var newFilename = old.Filename + "." + Bk2Movie.Extension;
var bk2 = new Bk2Movie(newFilename);
bk2.HeaderEntries.Clear();
foreach(var kvp in bkm.HeaderEntries)
foreach(var kvp in old.HeaderEntries)
{
bk2.HeaderEntries[kvp.Key] = kvp.Value;
}
bk2.SyncSettingsJson = bkm.SyncSettingsJson;
bk2.SyncSettingsJson = old.SyncSettingsJson;
bk2.Comments.Clear();
foreach(var comment in bkm.Comments)
foreach(var comment in old.Comments)
{
bk2.Comments.Add(comment);
}
bk2.Subtitles.Clear();
foreach(var sub in bkm.Subtitles)
foreach(var sub in old.Subtitles)
{
bk2.Subtitles.Add(sub);
}
bk2.TextSavestate = bkm.TextSavestate;
bk2.BinarySavestate = bkm.BinarySavestate;
bk2.TextSavestate = old.TextSavestate;
bk2.BinarySavestate = old.BinarySavestate;
for (var i = 0; i < bkm.InputLogLength; i++)
for (var i = 0; i < old.InputLogLength; i++)
{
var input = bkm.GetInputState(i);
var input = old.GetInputState(i);
bk2.AppendFrame(input);
}

View File

@ -650,8 +650,8 @@ namespace BizHawk.Client.EmuHawk
protected override void OnDeactivate(EventArgs e)
{
base.OnDeactivate(e);
Input.Instance.ControlInputFocus(this, Input.InputFocus.Mouse, false);
base.OnDeactivate(e);
}
public void ProcessInput()

View File

@ -6,6 +6,7 @@ using System.Linq;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Client.Common.MovieConversionExtensions;
namespace BizHawk.Client.EmuHawk
{
@ -163,17 +164,27 @@ namespace BizHawk.Client.EmuHawk
private void Tastudio_Load(object sender, EventArgs e)
{
if (Global.MovieSession.Movie.IsActive)
if (Global.MovieSession.Movie.IsActive && !(Global.MovieSession.Movie is TasMovie))
{
var result = MessageBox.Show("Warning, Tastudio doesn't support regular movie files at this time, opening this will cause you to lose your work, proceed? If you have unsaved changes you should cancel this, and savebefore opening TAStudio", "Unsupported movie", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
if (result != DialogResult.Yes)
var result = MessageBox.Show("In order to use Tastudio, a new project must be created from the current movie\nThe current movie will be saved and closed, and a new project file will be created\nProceed?", "Convert movie", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (result == DialogResult.OK)
{
Global.MovieSession.Movie.Save();
var newMovie = Global.MovieSession.Movie.ToTasMovie();
Global.MovieSession.Movie.Stop();
EngageTasStudio(newMovie);
}
else
{
Close();
return;
}
}
if (Global.Config.AutoloadTAStudioProject)
else if (Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie is TasMovie)
{
_tas = Global.MovieSession.Movie as TasMovie;
}
else if (Global.Config.AutoloadTAStudioProject)
{
Global.MovieSession.Movie = new TasMovie();
_tas = Global.MovieSession.Movie as TasMovie;
@ -184,14 +195,14 @@ namespace BizHawk.Client.EmuHawk
EngageTasStudio();
}
SetUpColumns();
LoadConfigSettings();
//SetUpColumns();
//LoadConfigSettings();
}
private void EngageTasStudio()
private void EngageTasStudio(TasMovie newMovie = null)
{
GlobalWin.OSD.AddMessage("TAStudio engaged");
Global.MovieSession.Movie = new TasMovie();
Global.MovieSession.Movie = newMovie ?? new TasMovie();
_tas = Global.MovieSession.Movie as TasMovie;
_tas.StartNewRecording();