From db1130a8a30380835c2e4c480aa17bd95d50e3fa Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 25 Jul 2015 21:56:24 -0400 Subject: [PATCH] Tastudio branches - ability to update a branch --- .../TAStudio/BookmarksBranchesBox.Designer.cs | 92 ++++++++++--------- .../tools/TAStudio/BookmarksBranchesBox.cs | 35 +++++-- 2 files changed, 80 insertions(+), 47 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.Designer.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.Designer.cs index fda70a44a9..29c8519730 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.Designer.cs @@ -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; } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs index 372571bd6b..1f858029e8 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs @@ -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(); + } } }