From 01290d2e5998e4936fa02b1c2b18bb5452cfb8ef Mon Sep 17 00:00:00 2001 From: Suuper Date: Wed, 22 Jul 2015 15:08:50 -0500 Subject: [PATCH] -Allow creating savestate-anchored movie from savestate-anchored movie -Fix marker placement in savestate-anchored movies --- .../conversions/MovieConversionExtensions.cs | 18 +++++++++++------- .../movie/tasproj/TasMovie.cs | 6 ++---- .../tools/TAStudio/TAStudio.Designer.cs | 16 ++++++++-------- .../tools/TAStudio/TAStudio.MenuItems.cs | 6 ++---- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs b/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs index 55037d36df..81d3644e67 100644 --- a/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs +++ b/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Linq; +using System.Collections.Generic; using BizHawk.Common.ReflectionExtensions; using BizHawk.Emulation.Common; @@ -136,16 +137,21 @@ namespace BizHawk.Client.Common.MovieConversionExtensions } } - var tas = new TasMovie(newFilename, true); + TasMovie tas = new TasMovie(newFilename, true); tas.BinarySavestate = savestate; tas.TasStateManager.Clear(); tas.ClearLagLog(); - var entries = old.GetLogEntries(); + List entries = old.GetLogEntries(); tas.CopyLog(entries.Skip(frame)); + tas.CopyVerificationLog(old.VerificationLog); tas.CopyVerificationLog(entries.Take(frame)); + // States: TODO + + // Lag Log: TODO + tas.HeaderEntries.Clear(); foreach (var kvp in old.HeaderEntries) { @@ -167,12 +173,10 @@ namespace BizHawk.Client.Common.MovieConversionExtensions tas.Subtitles.Add(sub); } - foreach(var marker in old.Markers) + foreach(TasMovieMarker marker in old.Markers) { - if (marker.Frame > 0) - { - tas.Markers.Add(marker); - } + if (marker.Frame > frame) + tas.Markers.Add(new TasMovieMarker(marker.Frame - frame, marker.Message)); } tas.TasStateManager.Settings = old.TasStateManager.Settings; diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs index dabaefa9f2..45d8b4a0bc 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs @@ -20,7 +20,7 @@ namespace BizHawk.Client.Common private readonly TasStateManager StateManager; private readonly TasLagLog LagLog = new TasLagLog(); private readonly Dictionary InputStateCache = new Dictionary(); - private readonly List VerificationLog = new List(); // For movies that do not begin with power-on, this is the input required to get into the initial state + public readonly List VerificationLog = new List(); // For movies that do not begin with power-on, this is the input required to get into the initial state private readonly TasBranchCollection Branches = new TasBranchCollection(); @@ -284,8 +284,7 @@ namespace BizHawk.Client.Common public void CopyVerificationLog(IEnumerable log) { - VerificationLog.Clear(); - foreach (var entry in log) + foreach (string entry in log) { VerificationLog.Add(entry); } @@ -458,7 +457,6 @@ namespace BizHawk.Client.Common public void LoadBranch(TasBranch branch) { - // TODO: undo? _log = branch.InputLog; _changes = true; StateManager.ClearStateHistory(); diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs index 2b461a8491..f2bf3f8196 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs @@ -168,11 +168,11 @@ namespace BizHawk.Client.EmuHawk this.InsertNumFramesContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator18 = new System.Windows.Forms.ToolStripSeparator(); this.TruncateContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.BranchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.StartFromNowSeparator = new System.Windows.Forms.ToolStripSeparator(); this.StartNewProjectFromNowMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.BookMarkControl = new BizHawk.Client.EmuHawk.BookmarksBranchesBox(); - this.BranchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.TASMenu.SuspendLayout(); this.TasStatusStrip.SuspendLayout(); this.MarkerContextMenu.SuspendLayout(); @@ -1325,6 +1325,13 @@ namespace BizHawk.Client.EmuHawk this.TruncateContextMenuItem.Text = "Truncate Movie"; this.TruncateContextMenuItem.Click += new System.EventHandler(this.TruncateMenuItem_Click); // + // BranchContextMenuItem + // + this.BranchContextMenuItem.Name = "BranchContextMenuItem"; + this.BranchContextMenuItem.Size = new System.Drawing.Size(272, 22); + this.BranchContextMenuItem.Text = "&Branch"; + this.BranchContextMenuItem.Click += new System.EventHandler(this.BranchContextMenuItem_Click); + // // StartFromNowSeparator // this.StartFromNowSeparator.Name = "StartFromNowSeparator"; @@ -1358,13 +1365,6 @@ namespace BizHawk.Client.EmuHawk this.BookMarkControl.TabIndex = 8; this.BookMarkControl.Tastudio = null; // - // BranchContextMenuItem - // - this.BranchContextMenuItem.Name = "BranchContextMenuItem"; - this.BranchContextMenuItem.Size = new System.Drawing.Size(272, 22); - this.BranchContextMenuItem.Text = "&Branch"; - this.BranchContextMenuItem.Click += new System.EventHandler(this.BranchContextMenuItem_Click); - // // TAStudio // this.AllowDrop = true; diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs index b3a03505de..d236da2856 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs @@ -973,8 +973,7 @@ namespace BizHawk.Client.EmuHawk StartFromNowSeparator.Visible = StartNewProjectFromNowMenuItem.Visible = - TasView.SelectedRows.Count() == 1 && - !CurrentTasMovie.StartsFromSavestate; + TasView.SelectedRows.Count() == 1; RemoveMarkersContextMenuItem.Enabled = CurrentTasMovie.Markers.Any(m => TasView.SelectedRows.Contains(m.Frame)); // Disable the option to remove markers if no markers are selected (FCEUX does this). @@ -1005,8 +1004,7 @@ namespace BizHawk.Client.EmuHawk GoToFrame(index); TasMovie newProject = CurrentTasMovie.ConvertToSavestateAnchoredMovie( - index, - (byte[])StatableEmulator.SaveStateBinary().Clone()); + index, (byte[])StatableEmulator.SaveStateBinary().Clone()); GlobalWin.MainForm.PauseEmulator(); LoadFile(new FileInfo(newProject.Filename));