TAStudio - implement clone frame feature, and some UI and Movie object cleanup

This commit is contained in:
adelikat 2012-08-17 02:18:25 +00:00
parent e900a5b1ba
commit 9baf1b8f28
4 changed files with 159 additions and 34 deletions

View File

@ -175,6 +175,34 @@ namespace BizHawk.MultiClient
return ret; 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() public string GetControllersAsMnemonic()
{ {
if (Global.Emulator.SystemId == "NULL" || ControlType == "Null Controller") if (Global.Emulator.SystemId == "NULL" || ControlType == "Null Controller")

View File

@ -245,8 +245,12 @@ namespace BizHawk.MultiClient
public void InsertFrame(string record, int frame) public void InsertFrame(string record, int frame)
{ {
Log.AddFrameAt(record,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() public void WriteMovie()

View File

@ -52,7 +52,11 @@
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editToolStripMenuItem = 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.insertFrameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.insertNumFramesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
this.clearVirtualPadsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.clearVirtualPadsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.settingsToolStripMenuItem = 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.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.ContextMenu_Insert = new System.Windows.Forms.ToolStripMenuItem(); this.ContextMenu_Insert = new System.Windows.Forms.ToolStripMenuItem();
this.cloneToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.ContextMenu_Delete = new System.Windows.Forms.ToolStripMenuItem(); this.ContextMenu_Delete = new System.Windows.Forms.ToolStripMenuItem();
this.SelectAll = new System.Windows.Forms.ToolStripMenuItem(); this.SelectAll = new System.Windows.Forms.ToolStripMenuItem();
this.ControllerBox = new System.Windows.Forms.GroupBox(); this.ControllerBox = new System.Windows.Forms.GroupBox();
@ -202,7 +207,11 @@
// editToolStripMenuItem // editToolStripMenuItem
// //
this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.clearToolStripMenuItem2,
this.deleteFramesToolStripMenuItem,
this.cloneToolStripMenuItem,
this.insertFrameToolStripMenuItem, this.insertFrameToolStripMenuItem,
this.insertNumFramesToolStripMenuItem,
this.toolStripSeparator7, this.toolStripSeparator7,
this.clearVirtualPadsToolStripMenuItem}); this.clearVirtualPadsToolStripMenuItem});
this.editToolStripMenuItem.Name = "editToolStripMenuItem"; this.editToolStripMenuItem.Name = "editToolStripMenuItem";
@ -210,25 +219,53 @@
this.editToolStripMenuItem.Text = "&Edit"; this.editToolStripMenuItem.Text = "&Edit";
this.editToolStripMenuItem.DropDownOpened += new System.EventHandler(this.editToolStripMenuItem_DropDownOpened); 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 // insertFrameToolStripMenuItem
// //
this.insertFrameToolStripMenuItem.Name = "insertFrameToolStripMenuItem"; this.insertFrameToolStripMenuItem.Name = "insertFrameToolStripMenuItem";
this.insertFrameToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) this.insertFrameToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.Insert))); | System.Windows.Forms.Keys.Insert)));
this.insertFrameToolStripMenuItem.Size = new System.Drawing.Size(247, 22); this.insertFrameToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
this.insertFrameToolStripMenuItem.Text = "Insert New Frame"; this.insertFrameToolStripMenuItem.Text = "&Insert";
this.insertFrameToolStripMenuItem.Click += new System.EventHandler(this.insertFrameToolStripMenuItem_Click); 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 // toolStripSeparator7
// //
this.toolStripSeparator7.Name = "toolStripSeparator7"; this.toolStripSeparator7.Name = "toolStripSeparator7";
this.toolStripSeparator7.Size = new System.Drawing.Size(244, 6); this.toolStripSeparator7.Size = new System.Drawing.Size(184, 6);
// //
// clearVirtualPadsToolStripMenuItem // clearVirtualPadsToolStripMenuItem
// //
this.clearVirtualPadsToolStripMenuItem.Name = "clearVirtualPadsToolStripMenuItem"; this.clearVirtualPadsToolStripMenuItem.Name = "clearVirtualPadsToolStripMenuItem";
this.clearVirtualPadsToolStripMenuItem.Size = new System.Drawing.Size(247, 22); this.clearVirtualPadsToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
this.clearVirtualPadsToolStripMenuItem.Text = "&Clear Controller Holds"; this.clearVirtualPadsToolStripMenuItem.Text = "Clear controller &holds";
this.clearVirtualPadsToolStripMenuItem.Click += new System.EventHandler(this.clearVirtualPadsToolStripMenuItem_Click); this.clearVirtualPadsToolStripMenuItem.Click += new System.EventHandler(this.clearVirtualPadsToolStripMenuItem_Click);
// //
// settingsToolStripMenuItem // settingsToolStripMenuItem
@ -296,32 +333,42 @@
// //
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ContextMenu_Insert, this.ContextMenu_Insert,
this.cloneToolStripMenuItem1,
this.ContextMenu_Delete, this.ContextMenu_Delete,
this.SelectAll}); this.SelectAll});
this.contextMenuStrip1.Name = "contextMenuStrip1"; 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); this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening);
// //
// ContextMenu_Insert // ContextMenu_Insert
// //
this.ContextMenu_Insert.Name = "ContextMenu_Insert"; this.ContextMenu_Insert.Name = "ContextMenu_Insert";
this.ContextMenu_Insert.ShortcutKeyDisplayString = "Ctrl+Shift+Ins"; this.ContextMenu_Insert.ShortcutKeyDisplayString = "Ctrl+Shift+Ins";
this.ContextMenu_Insert.Size = new System.Drawing.Size(247, 22); this.ContextMenu_Insert.Size = new System.Drawing.Size(231, 22);
this.ContextMenu_Insert.Text = "Insert New Frame"; this.ContextMenu_Insert.Text = "Insert frame(s)";
this.ContextMenu_Insert.Click += new System.EventHandler(this.Insert_Click); 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 // ContextMenu_Delete
// //
this.ContextMenu_Delete.Name = "ContextMenu_Delete"; this.ContextMenu_Delete.Name = "ContextMenu_Delete";
this.ContextMenu_Delete.Size = new System.Drawing.Size(247, 22); this.ContextMenu_Delete.ShortcutKeyDisplayString = "Ctrl+Del";
this.ContextMenu_Delete.Text = "Delete Frame(s)"; 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); this.ContextMenu_Delete.Click += new System.EventHandler(this.Delete_Click);
// //
// SelectAll // SelectAll
// //
this.SelectAll.Enabled = false; this.SelectAll.Enabled = false;
this.SelectAll.Name = "SelectAll"; 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"; this.SelectAll.Text = "Select All";
// //
// ControllerBox // ControllerBox
@ -568,5 +615,10 @@
private System.Windows.Forms.ToolStripButton FastForward; private System.Windows.Forms.ToolStripButton FastForward;
private System.Windows.Forms.ToolStripButton TurboFastForward; private System.Windows.Forms.ToolStripButton TurboFastForward;
private System.Windows.Forms.ToolStripMenuItem ContextMenu_Delete; 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;
} }
} }

View File

@ -12,6 +12,7 @@ namespace BizHawk.MultiClient
public partial class TAStudio : Form public partial class TAStudio : Form
{ {
//TODO: //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 //If null emulator do a base virtualpad so getmnemonic doesn't fail
//Right-click - Go to current frame //Right-click - Go to current frame
//Clicking a frame should go there //Clicking a frame should go there
@ -409,13 +410,23 @@ namespace BizHawk.MultiClient
private void editToolStripMenuItem_DropDownOpened(object sender, EventArgs e) 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; insertFrameToolStripMenuItem.Enabled = false;
insertNumFramesToolStripMenuItem.Enabled = false;
} }
else else
{ {
clearToolStripMenuItem.Enabled = true;
deleteFramesToolStripMenuItem.Enabled = true;
cloneToolStripMenuItem.Enabled = true;
insertFrameToolStripMenuItem.Enabled = true; insertFrameToolStripMenuItem.Enabled = true;
insertNumFramesToolStripMenuItem.Enabled = true;
} }
} }
@ -427,7 +438,7 @@ namespace BizHawk.MultiClient
} }
else else
{ {
InsertNewFrame(); InsertFrames();
} }
} }
@ -515,30 +526,12 @@ namespace BizHawk.MultiClient
private void Insert_Click(object sender, EventArgs e) private void Insert_Click(object sender, EventArgs e)
{ {
InsertNewFrame(); InsertFrames();
}
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]);
}
} }
private void Delete_Click(object sender, EventArgs e) private void Delete_Click(object sender, EventArgs e)
{ {
DeleteFrame(); DeleteFrames();
}
private void DeleteFrame()
{
ListView.SelectedIndexCollection list = TASView.SelectedIndices;
for (int index = 0; index < list.Count; index++)
{
Global.MovieSession.Movie.DeleteFrame(list[index]);
}
} }
private static string SaveRecordingAs() private static string SaveRecordingAs()
@ -590,5 +583,53 @@ namespace BizHawk.MultiClient
ContextMenu_Delete.Enabled = true; 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();
}
} }
} }