tastudio - more fixes to startup logic, still convolted, buggy and wrong, but better!

This commit is contained in:
adelikat 2014-07-08 13:46:59 +00:00
parent 863d6f09ee
commit 7e39e67b1f
4 changed files with 57 additions and 42 deletions

View File

@ -1,4 +1,8 @@
namespace BizHawk.Client.Common.MovieConversionExtensions
using System;
using BizHawk.Common.ReflectionExtensions;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.Common.MovieConversionExtensions
{
public static class MovieConversionExtensions
{
@ -73,5 +77,47 @@
return bk2;
}
// TODO: This doesn't really belong here, but not sure where to put it
public static void PopulateWithDefaultHeaderValues(this IMovie movie, string author = null)
{
movie.Author = author ?? Global.Config.DefaultAuthor;
movie.EmulatorVersion = VersionInfo.GetEmuVersion();
movie.Platform = Global.Game.System;
movie.SyncSettingsJson = ConfigService.SaveWithType(Global.Emulator.GetSyncSettings());
if (Global.Game != null)
{
movie.GameName = PathManager.FilesystemSafeName(Global.Game);
movie.Hash = Global.Game.Hash;
if (Global.Game.FirmwareHash != null)
{
movie.FirmwareHash = Global.Game.FirmwareHash;
}
}
else
{
movie.GameName = "NULL";
}
if (Global.Emulator.BoardName != null)
{
movie.BoardName = Global.Emulator.BoardName;
}
if (Global.Emulator.HasPublicProperty("DisplayType"))
{
var region = Global.Emulator.GetPropertyValue("DisplayType");
if ((DisplayType)region == DisplayType.PAL)
{
movie.HeaderEntries.Add(HeaderKeys.PAL, "1");
}
}
movie.Core = ((CoreAttributes)Attribute
.GetCustomAttribute(Global.Emulator.GetType(), typeof(CoreAttributes)))
.CoreName;
}
}
}

View File

@ -20,7 +20,7 @@ namespace BizHawk.Client.EmuHawk
//If a movie is already loaded, save it before starting a new movie
if (Global.MovieSession.Movie.IsActive)
if (Global.MovieSession.Movie.IsActive && !string.IsNullOrEmpty(Global.MovieSession.Movie.Filename))
{
Global.MovieSession.Movie.Save();
}

View File

@ -3,8 +3,9 @@ using System.IO;
using System.Windows.Forms;
using BizHawk.Common.ReflectionExtensions;
using BizHawk.Client.Common;
using BizHawk.Emulation.Common;
using BizHawk.Client.Common;
using BizHawk.Client.Common.MovieConversionExtensions;
namespace BizHawk.Client.EmuHawk
{
@ -85,44 +86,7 @@ namespace BizHawk.Client.EmuHawk
}
// Header
movieToRecord.Author = AuthorBox.Text;
movieToRecord.EmulatorVersion = VersionInfo.GetEmuVersion();
movieToRecord.Platform = Global.Game.System;
movieToRecord.SyncSettingsJson = ConfigService.SaveWithType(Global.Emulator.GetSyncSettings());
if (Global.Game != null)
{
movieToRecord.GameName = PathManager.FilesystemSafeName(Global.Game);
movieToRecord.Hash = Global.Game.Hash;
if (Global.Game.FirmwareHash != null)
{
movieToRecord.FirmwareHash = Global.Game.FirmwareHash;
}
}
else
{
movieToRecord.GameName = "NULL";
}
if (Global.Emulator.BoardName != null)
{
movieToRecord.BoardName = Global.Emulator.BoardName;
}
if (Global.Emulator.HasPublicProperty("DisplayType"))
{
var region = Global.Emulator.GetPropertyValue("DisplayType");
if ((DisplayType)region == DisplayType.PAL)
{
movieToRecord.HeaderEntries.Add(HeaderKeys.PAL, "1");
}
}
movieToRecord.Core = ((CoreAttributes)Attribute
.GetCustomAttribute(Global.Emulator.GetType(), typeof(CoreAttributes)))
.CoreName;
movieToRecord.PopulateWithDefaultHeaderValues(AuthorBox.Text);
movieToRecord.Save();
GlobalWin.MainForm.StartNewMovie(movieToRecord, true);

View File

@ -225,7 +225,13 @@ namespace BizHawk.Client.EmuHawk
private void EngageTasStudio(TasMovie newMovie = null)
{
GlobalWin.OSD.AddMessage("TAStudio engaged");
Global.MovieSession.Movie = newMovie ?? new TasMovie();
if (newMovie == null)
{
Global.MovieSession.Movie.PopulateWithDefaultHeaderValues();
}
_tas = Global.MovieSession.Movie as TasMovie;
StartNewSession();
}
@ -234,7 +240,6 @@ namespace BizHawk.Client.EmuHawk
{
if (AskSave())
{
_tas.StartNewRecording();
GlobalWin.MainForm.StartNewMovie(_tas, record: true);
TasView.ItemCount = _tas.InputLogLength;
}