diff --git a/BizHawk.Client.Common/BinarySaveStates.cs b/BizHawk.Client.Common/BinarySaveStates.cs
index 50d05af7ac..f8dd794c08 100644
--- a/BizHawk.Client.Common/BinarySaveStates.cs
+++ b/BizHawk.Client.Common/BinarySaveStates.cs
@@ -29,6 +29,7 @@ namespace BizHawk.Client.Common
Markers,
ClientSettings,
VerificationLog,
+ Branches,
UserData
}
@@ -67,6 +68,7 @@ namespace BizHawk.Client.Common
AddLumpName(BinaryStateLump.ClientSettings, "ClientSettings.json");
AddLumpName(BinaryStateLump.VerificationLog, "VerificationLog.txt");
AddLumpName(BinaryStateLump.UserData, "UserData.txt");
+ AddLumpName(BinaryStateLump.Branches, "Branches");
}
public static string GetReadName(BinaryStateLump lump)
diff --git a/BizHawk.Client.Common/BizHawk.Client.Common.csproj b/BizHawk.Client.Common/BizHawk.Client.Common.csproj
index b2d30486cf..ee24a77606 100644
--- a/BizHawk.Client.Common/BizHawk.Client.Common.csproj
+++ b/BizHawk.Client.Common/BizHawk.Client.Common.csproj
@@ -156,6 +156,7 @@
Bk2Movie.cs
+
Bk2Movie.cs
diff --git a/BizHawk.Client.Common/movie/tasproj/TasBranch.cs b/BizHawk.Client.Common/movie/tasproj/TasBranch.cs
new file mode 100644
index 0000000000..72c3fa6068
--- /dev/null
+++ b/BizHawk.Client.Common/movie/tasproj/TasBranch.cs
@@ -0,0 +1,29 @@
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+
+namespace BizHawk.Client.Common
+{
+ public class TasBranch
+ {
+ public int Frame { get; set; }
+ public byte[] CoreData { get; set; }
+ public List InputLog { get; set; }
+ public byte[] OSDFrameBuffer { get; set; }
+ }
+
+ public class TasBranchCollection : List
+ {
+ private List Branches = new List();
+
+ public void Save(BinaryWriter bw)
+ {
+
+ }
+
+ public void Load(BinaryReader br, long length)
+ {
+
+ }
+ }
+}
diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs
index b6a286d7e5..63e2c7cb27 100644
--- a/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs
+++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.IO.cs
@@ -90,6 +90,12 @@ namespace BizHawk.Client.Common
{
bs.PutLump(BinaryStateLump.VerificationLog, tw => tw.WriteLine(InputLogToString(VerificationLog)));
}
+
+ if (Branches.Any())
+ {
+ bs.PutLump(BinaryStateLump.Branches, (BinaryWriter bw) => Branches.Save(bw));
+ }
+
ReportProgress(PROGRESS_STEP);
}
@@ -263,6 +269,14 @@ namespace BizHawk.Client.Common
}
});
}
+
+ if (bl.HasLump(BinaryStateLump.Branches))
+ {
+ bl.GetLump(BinaryStateLump.Branches, true, delegate(BinaryReader br, long length)
+ {
+ Branches.Load(br, length);
+ });
+ }
}
Changes = false;
diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs
index d7bdbc49df..6ce8d7302c 100644
--- a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs
+++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs
@@ -22,6 +22,8 @@ namespace BizHawk.Client.Common
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
+ private readonly TasBranchCollection Branches = new TasBranchCollection();
+
private BackgroundWorker _progressReportWorker = null;
public void NewBGWorker(BackgroundWorker newWorker)
{
@@ -75,7 +77,8 @@ namespace BizHawk.Client.Common
}
public TasLagLog TasLagLog { get { return LagLog; } }
-
+ public TasBranchCollection TasBranches { get { return Branches; } }
+ public List InputLog { get { return _log; } }
public TasMovieMarkerList Markers { get; set; }
public bool BindMarkersToInput { get; set; }
public bool UseInputCache { get; set; }
diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs
index 9ee2275cb6..ce3e4f6018 100644
--- a/BizHawk.Client.EmuHawk/MainForm.cs
+++ b/BizHawk.Client.EmuHawk/MainForm.cs
@@ -815,6 +815,18 @@ namespace BizHawk.Client.EmuHawk
}
}
+ public byte[] CurrentFrameBuffer(bool captureOSD)
+ {
+ using (var bb = captureOSD ? CaptureOSD() : MakeScreenshotImage())
+ {
+ using (var img = bb.ToSysdrawingBitmap())
+ {
+ ImageConverter converter = new ImageConverter();
+ return (byte[])converter.ConvertTo(img, typeof(byte[]));
+ }
+ }
+ }
+
public void TakeScreenshotToClipboard()
{
using (var bb = Global.Config.Screenshot_CaptureOSD ? CaptureOSD() : MakeScreenshotImage())
diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.Designer.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.Designer.cs
index cb55dbe127..874aef230f 100644
--- a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.Designer.cs
+++ b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.Designer.cs
@@ -28,12 +28,17 @@
///
private void InitializeComponent()
{
+ this.components = new System.ComponentModel.Container();
this.BookmarksBranchesGroupBox = new System.Windows.Forms.GroupBox();
+ this.BranchesContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
+ this.AddContextMenu = new System.Windows.Forms.ToolStripMenuItem();
+ this.RemoveBranchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.BranchView = new BizHawk.Client.EmuHawk.VirtualListView();
this.BranchNumberColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.FrameColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.TimeColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.BookmarksBranchesGroupBox.SuspendLayout();
+ this.BranchesContextMenu.SuspendLayout();
this.SuspendLayout();
//
// BookmarksBranchesGroupBox
@@ -49,6 +54,29 @@
this.BookmarksBranchesGroupBox.TabStop = false;
this.BookmarksBranchesGroupBox.Text = "Bookmarks / Branches";
//
+ // BranchesContextMenu
+ //
+ this.BranchesContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.AddContextMenu,
+ this.RemoveBranchContextMenuItem});
+ this.BranchesContextMenu.Name = "BranchesContextMenu";
+ this.BranchesContextMenu.Size = new System.Drawing.Size(153, 70);
+ this.BranchesContextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.BranchesContextMenu_Opening);
+ //
+ // AddContextMenu
+ //
+ this.AddContextMenu.Name = "AddContextMenu";
+ this.AddContextMenu.Size = new System.Drawing.Size(152, 22);
+ this.AddContextMenu.Text = "Add";
+ this.AddContextMenu.Click += new System.EventHandler(this.AddContextMenu_Click);
+ //
+ // RemoveBranchContextMenuItem
+ //
+ this.RemoveBranchContextMenuItem.Name = "RemoveBranchContextMenuItem";
+ this.RemoveBranchContextMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.RemoveBranchContextMenuItem.Text = "Remove";
+ this.RemoveBranchContextMenuItem.Click += new System.EventHandler(this.RemoveBranchContextMenuItem_Click);
+ //
// BranchView
//
this.BranchView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@@ -59,9 +87,12 @@
this.BranchNumberColumn,
this.FrameColumn,
this.TimeColumn});
+ this.BranchView.ContextMenuStrip = this.BranchesContextMenu;
+ this.BranchView.FullRowSelect = true;
this.BranchView.GridLines = true;
this.BranchView.ItemCount = 0;
this.BranchView.Location = new System.Drawing.Point(6, 19);
+ this.BranchView.MultiSelect = false;
this.BranchView.Name = "BranchView";
this.BranchView.SelectAllInProgress = false;
this.BranchView.selectedItem = -1;
@@ -70,6 +101,7 @@
this.BranchView.UseCompatibleStateImageBehavior = false;
this.BranchView.UseCustomBackground = true;
this.BranchView.View = System.Windows.Forms.View.Details;
+ this.BranchView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.BranchView_MouseDoubleClick);
//
// BranchNumberColumn
//
@@ -93,6 +125,7 @@
this.Name = "BookmarksBranchesBox";
this.Size = new System.Drawing.Size(204, 253);
this.BookmarksBranchesGroupBox.ResumeLayout(false);
+ this.BranchesContextMenu.ResumeLayout(false);
this.ResumeLayout(false);
}
@@ -104,5 +137,8 @@
private System.Windows.Forms.ColumnHeader BranchNumberColumn;
private System.Windows.Forms.ColumnHeader FrameColumn;
private System.Windows.Forms.ColumnHeader TimeColumn;
+ private System.Windows.Forms.ContextMenuStrip BranchesContextMenu;
+ private System.Windows.Forms.ToolStripMenuItem AddContextMenu;
+ private System.Windows.Forms.ToolStripMenuItem RemoveBranchContextMenuItem;
}
}
diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs
index e2449c4324..83a24969fe 100644
--- a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs
+++ b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs
@@ -7,12 +7,20 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
+using BizHawk.Emulation.Common;
+using BizHawk.Client.Common;
+
namespace BizHawk.Client.EmuHawk
{
public partial class BookmarksBranchesBox : UserControl
{
public TAStudio Tastudio { get; set; }
+ public TasBranchCollection Branches
+ {
+ get { return Tastudio.CurrentTasMovie.TasBranches; }
+ }
+
public BookmarksBranchesBox()
{
InitializeComponent();
@@ -20,14 +28,89 @@ namespace BizHawk.Client.EmuHawk
BranchView.QueryItemBkColor += QueryItemBkColor;
}
+ public TasBranch SelectedBranch
+ {
+ get
+ {
+ if (BranchView.SelectedIndices.Count > 0)
+ {
+ return Branches[BranchView.SelectedIndices[0]];
+ }
+
+ return null;
+ }
+ }
+
private void QueryItemText(int index, int column, out string text)
{
text = string.Empty;
+
+ var columnName = BranchView.Columns[column].Name;
+
+ if (index >= Tastudio.CurrentTasMovie.TasBranches.Count)
+ {
+ return;
+ }
+
+ switch (column)
+ {
+ case 0: // BranchNumberColumn
+ text = index.ToString();
+ break;
+ case 1: // FrameColumn
+ text = Branches[index].Frame.ToString();
+ break;
+ case 2: // TimeColumn
+ text = "TODO";
+ break;
+ }
}
private void QueryItemBkColor(int index, int column, ref Color color)
{
}
+
+ private void AddContextMenu_Click(object sender, EventArgs e)
+ {
+ // TODO: don't use Global.Emulator
+ var branch = new TasBranch
+ {
+ Frame = Global.Emulator.Frame,
+ CoreData = (Global.Emulator as IStatable).SaveStateBinary(),
+ InputLog = Tastudio.CurrentTasMovie.InputLog.ToList(),
+ OSDFrameBuffer = GlobalWin.MainForm.CurrentFrameBuffer(captureOSD: true)
+ };
+
+ Branches.Add(branch);
+ BranchView.ItemCount = Branches.Count;
+ }
+
+ private void BranchView_MouseDoubleClick(object sender, MouseEventArgs e)
+ {
+ if (SelectedBranch != null)
+ {
+ LoadBranch(SelectedBranch);
+ }
+ }
+
+ private void BranchesContextMenu_Opening(object sender, CancelEventArgs e)
+ {
+ RemoveBranchContextMenuItem.Enabled = SelectedBranch != null;
+ }
+
+ private void RemoveBranchContextMenuItem_Click(object sender, EventArgs e)
+ {
+ if (SelectedBranch != null)
+ {
+ Branches.Remove(SelectedBranch);
+ BranchView.ItemCount = Branches.Count;
+ }
+ }
+
+ private void LoadBranch(TasBranch branch)
+ {
+ MessageBox.Show("TODO: load this branch");
+ }
}
}
diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.resx b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.resx
index 29dcb1b3a3..82ceea8475 100644
--- a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.resx
+++ b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.resx
@@ -117,4 +117,7 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ 17, 17
+
\ No newline at end of file