From 9baf1b8f283f7a8027dfeef1362939f68be3d0e0 Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 17 Aug 2012 02:18:25 +0000 Subject: [PATCH] TAStudio - implement clone frame feature, and some UI and Movie object cleanup --- BizHawk.MultiClient/movie/InputAdapters.cs | 28 ++++++ BizHawk.MultiClient/movie/Movie.cs | 6 +- .../tools/TAStudio.Designer.cs | 74 +++++++++++++--- BizHawk.MultiClient/tools/TAStudio.cs | 85 ++++++++++++++----- 4 files changed, 159 insertions(+), 34 deletions(-) diff --git a/BizHawk.MultiClient/movie/InputAdapters.cs b/BizHawk.MultiClient/movie/InputAdapters.cs index 2bd29cf9fc..e90ac2c18c 100644 --- a/BizHawk.MultiClient/movie/InputAdapters.cs +++ b/BizHawk.MultiClient/movie/InputAdapters.cs @@ -175,6 +175,34 @@ namespace BizHawk.MultiClient return ret; } + public string GetEmptyMnemonic() + { + switch (Global.Emulator.SystemId) + { + default: + case "NULL": + return "|.|"; + case "A26": + return "|..|.....|.....|"; + case "TI83": + return "|..................................................|.|"; + case "NES": + return "|.|........|........|........|........|"; + case "SMS": + case "GG": + case "SG": + return "|......|......|..|"; + case "GEN": + return "|.|........|........|"; + case "GB": + return "|.|........|"; + case "PCE": + case "PCECD": + case "SGX": + return "|.|........|........|........|........|........|"; + } + } + public string GetControllersAsMnemonic() { if (Global.Emulator.SystemId == "NULL" || ControlType == "Null Controller") diff --git a/BizHawk.MultiClient/movie/Movie.cs b/BizHawk.MultiClient/movie/Movie.cs index e6e90f42cc..0a52cac1b2 100644 --- a/BizHawk.MultiClient/movie/Movie.cs +++ b/BizHawk.MultiClient/movie/Movie.cs @@ -245,8 +245,12 @@ namespace BizHawk.MultiClient public void InsertFrame(string record, int frame) { Log.AddFrameAt(record,frame); + } - Global.MainForm.TAStudio1.UpdateValues(); + public void InsertBlankFrame(int frame) + { + MnemonicsGenerator mg = new MnemonicsGenerator(); + Log.AddFrameAt(mg.GetEmptyMnemonic(), frame); } public void WriteMovie() diff --git a/BizHawk.MultiClient/tools/TAStudio.Designer.cs b/BizHawk.MultiClient/tools/TAStudio.Designer.cs index 03ac1e3872..1cd3e2e2a1 100644 --- a/BizHawk.MultiClient/tools/TAStudio.Designer.cs +++ b/BizHawk.MultiClient/tools/TAStudio.Designer.cs @@ -52,7 +52,11 @@ this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.clearToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); + this.deleteFramesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.cloneToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.insertFrameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.insertNumFramesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); this.clearVirtualPadsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -65,6 +69,7 @@ this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); this.ContextMenu_Insert = new System.Windows.Forms.ToolStripMenuItem(); + this.cloneToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.ContextMenu_Delete = new System.Windows.Forms.ToolStripMenuItem(); this.SelectAll = new System.Windows.Forms.ToolStripMenuItem(); this.ControllerBox = new System.Windows.Forms.GroupBox(); @@ -202,7 +207,11 @@ // editToolStripMenuItem // this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.clearToolStripMenuItem2, + this.deleteFramesToolStripMenuItem, + this.cloneToolStripMenuItem, this.insertFrameToolStripMenuItem, + this.insertNumFramesToolStripMenuItem, this.toolStripSeparator7, this.clearVirtualPadsToolStripMenuItem}); this.editToolStripMenuItem.Name = "editToolStripMenuItem"; @@ -210,25 +219,53 @@ this.editToolStripMenuItem.Text = "&Edit"; this.editToolStripMenuItem.DropDownOpened += new System.EventHandler(this.editToolStripMenuItem_DropDownOpened); // + // clearToolStripMenuItem2 + // + this.clearToolStripMenuItem2.Name = "clearToolStripMenuItem2"; + this.clearToolStripMenuItem2.Size = new System.Drawing.Size(187, 22); + this.clearToolStripMenuItem2.Text = "Clear"; + // + // deleteFramesToolStripMenuItem + // + this.deleteFramesToolStripMenuItem.Name = "deleteFramesToolStripMenuItem"; + this.deleteFramesToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Delete))); + this.deleteFramesToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.deleteFramesToolStripMenuItem.Text = "&Delete"; + this.deleteFramesToolStripMenuItem.Click += new System.EventHandler(this.deleteFramesToolStripMenuItem_Click); + // + // cloneToolStripMenuItem + // + this.cloneToolStripMenuItem.Name = "cloneToolStripMenuItem"; + this.cloneToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Insert))); + this.cloneToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.cloneToolStripMenuItem.Text = "&Clone"; + this.cloneToolStripMenuItem.Click += new System.EventHandler(this.cloneToolStripMenuItem_Click); + // // insertFrameToolStripMenuItem // this.insertFrameToolStripMenuItem.Name = "insertFrameToolStripMenuItem"; this.insertFrameToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) | System.Windows.Forms.Keys.Insert))); - this.insertFrameToolStripMenuItem.Size = new System.Drawing.Size(247, 22); - this.insertFrameToolStripMenuItem.Text = "Insert New Frame"; + this.insertFrameToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.insertFrameToolStripMenuItem.Text = "&Insert"; this.insertFrameToolStripMenuItem.Click += new System.EventHandler(this.insertFrameToolStripMenuItem_Click); // + // insertNumFramesToolStripMenuItem + // + this.insertNumFramesToolStripMenuItem.Name = "insertNumFramesToolStripMenuItem"; + this.insertNumFramesToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.insertNumFramesToolStripMenuItem.Text = "Insert # of Frames"; + // // toolStripSeparator7 // this.toolStripSeparator7.Name = "toolStripSeparator7"; - this.toolStripSeparator7.Size = new System.Drawing.Size(244, 6); + this.toolStripSeparator7.Size = new System.Drawing.Size(184, 6); // // clearVirtualPadsToolStripMenuItem // this.clearVirtualPadsToolStripMenuItem.Name = "clearVirtualPadsToolStripMenuItem"; - this.clearVirtualPadsToolStripMenuItem.Size = new System.Drawing.Size(247, 22); - this.clearVirtualPadsToolStripMenuItem.Text = "&Clear Controller Holds"; + this.clearVirtualPadsToolStripMenuItem.Size = new System.Drawing.Size(187, 22); + this.clearVirtualPadsToolStripMenuItem.Text = "Clear controller &holds"; this.clearVirtualPadsToolStripMenuItem.Click += new System.EventHandler(this.clearVirtualPadsToolStripMenuItem_Click); // // settingsToolStripMenuItem @@ -296,32 +333,42 @@ // this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.ContextMenu_Insert, + this.cloneToolStripMenuItem1, this.ContextMenu_Delete, this.SelectAll}); this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(248, 70); + this.contextMenuStrip1.Size = new System.Drawing.Size(232, 114); this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening); // // ContextMenu_Insert // this.ContextMenu_Insert.Name = "ContextMenu_Insert"; this.ContextMenu_Insert.ShortcutKeyDisplayString = "Ctrl+Shift+Ins"; - this.ContextMenu_Insert.Size = new System.Drawing.Size(247, 22); - this.ContextMenu_Insert.Text = "Insert New Frame"; + this.ContextMenu_Insert.Size = new System.Drawing.Size(231, 22); + this.ContextMenu_Insert.Text = "Insert frame(s)"; this.ContextMenu_Insert.Click += new System.EventHandler(this.Insert_Click); // + // cloneToolStripMenuItem1 + // + this.cloneToolStripMenuItem1.Name = "cloneToolStripMenuItem1"; + this.cloneToolStripMenuItem1.ShortcutKeyDisplayString = "Ctrl+Ins"; + this.cloneToolStripMenuItem1.Size = new System.Drawing.Size(231, 22); + this.cloneToolStripMenuItem1.Text = "Clone"; + this.cloneToolStripMenuItem1.Click += new System.EventHandler(this.cloneToolStripMenuItem1_Click); + // // ContextMenu_Delete // this.ContextMenu_Delete.Name = "ContextMenu_Delete"; - this.ContextMenu_Delete.Size = new System.Drawing.Size(247, 22); - this.ContextMenu_Delete.Text = "Delete Frame(s)"; + this.ContextMenu_Delete.ShortcutKeyDisplayString = "Ctrl+Del"; + this.ContextMenu_Delete.Size = new System.Drawing.Size(231, 22); + this.ContextMenu_Delete.Text = "Delete frame(s)"; this.ContextMenu_Delete.Click += new System.EventHandler(this.Delete_Click); // // SelectAll // this.SelectAll.Enabled = false; this.SelectAll.Name = "SelectAll"; - this.SelectAll.Size = new System.Drawing.Size(247, 22); + this.SelectAll.Size = new System.Drawing.Size(231, 22); this.SelectAll.Text = "Select All"; // // ControllerBox @@ -568,5 +615,10 @@ private System.Windows.Forms.ToolStripButton FastForward; private System.Windows.Forms.ToolStripButton TurboFastForward; private System.Windows.Forms.ToolStripMenuItem ContextMenu_Delete; + private System.Windows.Forms.ToolStripMenuItem cloneToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem cloneToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem deleteFramesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem2; + private System.Windows.Forms.ToolStripMenuItem insertNumFramesToolStripMenuItem; } } \ No newline at end of file diff --git a/BizHawk.MultiClient/tools/TAStudio.cs b/BizHawk.MultiClient/tools/TAStudio.cs index 2cb72d32d3..21700035fa 100644 --- a/BizHawk.MultiClient/tools/TAStudio.cs +++ b/BizHawk.MultiClient/tools/TAStudio.cs @@ -12,6 +12,7 @@ namespace BizHawk.MultiClient public partial class TAStudio : Form { //TODO: + //When closing tastudio, don't write the movie file? AskSave() is acceptable however //If null emulator do a base virtualpad so getmnemonic doesn't fail //Right-click - Go to current frame //Clicking a frame should go there @@ -409,13 +410,23 @@ namespace BizHawk.MultiClient private void editToolStripMenuItem_DropDownOpened(object sender, EventArgs e) { - if (Global.MainForm.ReadOnly) + if (ReadOnlyCheckBox.Checked) { + + clearToolStripMenuItem.Enabled = false; + deleteFramesToolStripMenuItem.Enabled = false; + cloneToolStripMenuItem.Enabled = false; insertFrameToolStripMenuItem.Enabled = false; + insertNumFramesToolStripMenuItem.Enabled = false; + } else { + clearToolStripMenuItem.Enabled = true; + deleteFramesToolStripMenuItem.Enabled = true; + cloneToolStripMenuItem.Enabled = true; insertFrameToolStripMenuItem.Enabled = true; + insertNumFramesToolStripMenuItem.Enabled = true; } } @@ -427,7 +438,7 @@ namespace BizHawk.MultiClient } else { - InsertNewFrame(); + InsertFrames(); } } @@ -515,30 +526,12 @@ namespace BizHawk.MultiClient private void Insert_Click(object sender, EventArgs e) { - InsertNewFrame(); - } - - private void InsertNewFrame() - { - ListView.SelectedIndexCollection list = TASView.SelectedIndices; - for (int index = 0; index < list.Count; index++) - { - Global.MovieSession.Movie.InsertFrame(Global.MovieSession.Movie.GetInputFrame(list[index]), (int)list[index]); - } + InsertFrames(); } private void Delete_Click(object sender, EventArgs e) { - DeleteFrame(); - } - - private void DeleteFrame() - { - ListView.SelectedIndexCollection list = TASView.SelectedIndices; - for (int index = 0; index < list.Count; index++) - { - Global.MovieSession.Movie.DeleteFrame(list[index]); - } + DeleteFrames(); } private static string SaveRecordingAs() @@ -590,5 +583,53 @@ namespace BizHawk.MultiClient ContextMenu_Delete.Enabled = true; } } + + private void cloneToolStripMenuItem_Click(object sender, EventArgs e) + { + Clone(); + } + + private void cloneToolStripMenuItem1_Click(object sender, EventArgs e) + { + Clone(); + } + + private void deleteFramesToolStripMenuItem_Click(object sender, EventArgs e) + { + DeleteFrames(); + } + + private void InsertFrames() + { + ListView.SelectedIndexCollection list = TASView.SelectedIndices; + for (int index = 0; index < list.Count; index++) + { + Global.MovieSession.Movie.InsertBlankFrame(list[index]); + } + + UpdateValues(); + } + + private void DeleteFrames() + { + ListView.SelectedIndexCollection list = TASView.SelectedIndices; + for (int index = 0; index < list.Count; index++) + { + Global.MovieSession.Movie.DeleteFrame(list[index]); + } + + UpdateValues(); + } + + private void Clone() + { + ListView.SelectedIndexCollection list = TASView.SelectedIndices; + for (int index = 0; index < list.Count; index++) + { + Global.MovieSession.Movie.InsertFrame(Global.MovieSession.Movie.GetInputFrame(list[index]), list[index]); + } + + UpdateValues(); + } } }