Tastudio branches - ability to update a branch

This commit is contained in:
adelikat 2015-07-25 21:56:24 -04:00
parent a2edd3a018
commit db1130a8a3
2 changed files with 80 additions and 47 deletions

View File

@ -30,12 +30,13 @@
{
this.components = new System.ComponentModel.Container();
this.BookmarksBranchesGroupBox = new System.Windows.Forms.GroupBox();
this.BranchView = new BizHawk.Client.EmuHawk.InputRoll();
this.BranchesContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
this.LoadBranchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.AddContextMenu = new System.Windows.Forms.ToolStripMenuItem();
this.RemoveBranchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.BranchView = new BizHawk.Client.EmuHawk.InputRoll();
this.UpdateBranchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.BookmarksBranchesGroupBox.SuspendLayout();
this.BranchesContextMenu.SuspendLayout();
this.SuspendLayout();
@ -53,46 +54,6 @@
this.BookmarksBranchesGroupBox.TabStop = false;
this.BookmarksBranchesGroupBox.Text = "Bookmarks / Branches";
//
// BranchesContextMenu
//
this.BranchesContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.LoadBranchContextMenuItem,
this.toolStripSeparator1,
this.AddContextMenu,
this.RemoveBranchContextMenuItem});
this.BranchesContextMenu.Name = "BranchesContextMenu";
this.BranchesContextMenu.Size = new System.Drawing.Size(118, 76);
this.BranchesContextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.BranchesContextMenu_Opening);
//
// LoadBranchContextMenuItem
//
this.LoadBranchContextMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Debugger;
this.LoadBranchContextMenuItem.Name = "LoadBranchContextMenuItem";
this.LoadBranchContextMenuItem.Size = new System.Drawing.Size(117, 22);
this.LoadBranchContextMenuItem.Text = "Load";
this.LoadBranchContextMenuItem.Click += new System.EventHandler(this.LoadBranchContextMenuItem_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(114, 6);
//
// AddContextMenu
//
this.AddContextMenu.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.add;
this.AddContextMenu.Name = "AddContextMenu";
this.AddContextMenu.Size = new System.Drawing.Size(117, 22);
this.AddContextMenu.Text = "Add";
this.AddContextMenu.Click += new System.EventHandler(this.AddContextMenu_Click);
//
// RemoveBranchContextMenuItem
//
this.RemoveBranchContextMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Delete;
this.RemoveBranchContextMenuItem.Name = "RemoveBranchContextMenuItem";
this.RemoveBranchContextMenuItem.Size = new System.Drawing.Size(117, 22);
this.RemoveBranchContextMenuItem.Text = "Remove";
this.RemoveBranchContextMenuItem.Click += new System.EventHandler(this.RemoveBranchContextMenuItem_Click);
//
// BranchView
//
this.BranchView.AllowColumnReorder = false;
@ -121,6 +82,54 @@
this.BranchView.MouseLeave += new System.EventHandler(this.BranchView_MouseLeave);
this.BranchView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.BranchView_MouseMove);
//
// BranchesContextMenu
//
this.BranchesContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.LoadBranchContextMenuItem,
this.toolStripSeparator1,
this.UpdateBranchContextMenuItem,
this.AddContextMenu,
this.RemoveBranchContextMenuItem});
this.BranchesContextMenu.Name = "BranchesContextMenu";
this.BranchesContextMenu.Size = new System.Drawing.Size(153, 120);
this.BranchesContextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.BranchesContextMenu_Opening);
//
// LoadBranchContextMenuItem
//
this.LoadBranchContextMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Debugger;
this.LoadBranchContextMenuItem.Name = "LoadBranchContextMenuItem";
this.LoadBranchContextMenuItem.Size = new System.Drawing.Size(152, 22);
this.LoadBranchContextMenuItem.Text = "Load";
this.LoadBranchContextMenuItem.Click += new System.EventHandler(this.LoadBranchContextMenuItem_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(149, 6);
//
// AddContextMenu
//
this.AddContextMenu.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.add;
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.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Delete;
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);
//
// UpdateBranchContextMenuItem
//
this.UpdateBranchContextMenuItem.Name = "UpdateBranchContextMenuItem";
this.UpdateBranchContextMenuItem.Size = new System.Drawing.Size(152, 22);
this.UpdateBranchContextMenuItem.Text = "&Update";
this.UpdateBranchContextMenuItem.Click += new System.EventHandler(this.UpdateBranchContextMenuItem_Click);
//
// BookmarksBranchesBox
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
@ -142,5 +151,6 @@
private System.Windows.Forms.ToolStripMenuItem RemoveBranchContextMenuItem;
private System.Windows.Forms.ToolStripMenuItem LoadBranchContextMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem UpdateBranchContextMenuItem;
}
}

View File

@ -137,6 +137,7 @@ namespace BizHawk.Client.EmuHawk
private void BranchesContextMenu_Opening(object sender, CancelEventArgs e)
{
UpdateBranchContextMenuItem.Enabled =
RemoveBranchContextMenuItem.Enabled =
LoadBranchContextMenuItem.Enabled =
SelectedBranch != null;
@ -218,22 +219,25 @@ namespace BizHawk.Client.EmuHawk
}
public void Branch()
{
var branch = CreateBranch();
Branches.Add(branch);
BranchView.RowCount = Branches.Count;
BranchView.Refresh();
}
private TasBranch CreateBranch()
{
// TODO: don't use Global.Emulator
TasBranch branch = new TasBranch
return new TasBranch
{
Frame = Global.Emulator.Frame,
CoreData = (byte[])((Global.Emulator as IStatable).SaveStateBinary().Clone()),
InputLog = Tastudio.CurrentTasMovie.InputLog.ToList(),
OSDFrameBuffer = GlobalWin.MainForm.CaptureOSD(),
//OSDFrameBuffer = (int[])(Global.Emulator.VideoProvider().GetVideoBuffer().Clone()),
LagLog = Tastudio.CurrentTasMovie.TasLagLog.Clone(),
ChangeLog = new TasMovieChangeLog(Tastudio.CurrentTasMovie)
};
Branches.Add(branch);
BranchView.RowCount = Branches.Count;
BranchView.Refresh();
}
private void BranchView_CellHovered(object sender, InputRoll.CellEventArgs e)
@ -291,5 +295,24 @@ namespace BizHawk.Client.EmuHawk
Tastudio.ScreenshotControl.Branch = branch;
Tastudio.ScreenshotControl.Refresh();
}
private void UpdateBranchContextMenuItem_Click(object sender, EventArgs e)
{
if (SelectedBranch != null)
{
UpdateBranch(SelectedBranch);
}
}
private void UpdateBranch(TasBranch branch)
{
var index = Branches.IndexOf(branch);
var newbranch = CreateBranch();
Branches.Insert(index, newbranch);
Branches.Remove(branch);
BranchView.Refresh();
}
}
}