TAStudio - implement the Insert menu item
This commit is contained in:
parent
3ebad0cf49
commit
e8f821117b
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
|
@ -57,8 +58,26 @@ namespace BizHawk.Client.Common
|
|||
_log.RemoveAt(frame);
|
||||
}
|
||||
|
||||
Changes = true;
|
||||
InvalidateAfter(invalidateAfter);
|
||||
}
|
||||
}
|
||||
|
||||
public void InsertInput(int frame, IEnumerable<string> inputLog)
|
||||
{
|
||||
_log.InsertRange(frame, inputLog);
|
||||
Changes = true;
|
||||
InvalidateAfter(frame);
|
||||
}
|
||||
|
||||
public void InsertEmptyFrame(int frame)
|
||||
{
|
||||
var lg = LogGeneratorInstance();
|
||||
lg.SetSource(Global.MovieSession.MovieControllerInstance());
|
||||
_log.Insert(frame, lg.EmptyEntry);
|
||||
|
||||
Changes = true;
|
||||
InvalidateAfter(frame - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -377,20 +377,20 @@ namespace BizHawk.Client.EmuHawk
|
|||
//
|
||||
// CloneMenuItem
|
||||
//
|
||||
this.CloneMenuItem.Enabled = false;
|
||||
this.CloneMenuItem.Name = "CloneMenuItem";
|
||||
this.CloneMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Insert)));
|
||||
this.CloneMenuItem.Size = new System.Drawing.Size(240, 22);
|
||||
this.CloneMenuItem.Text = "&Clone";
|
||||
this.CloneMenuItem.Click += new System.EventHandler(this.CloneMenuItem_Click);
|
||||
//
|
||||
// InsertFrameMenuItem
|
||||
//
|
||||
this.InsertFrameMenuItem.Enabled = false;
|
||||
this.InsertFrameMenuItem.Name = "InsertFrameMenuItem";
|
||||
this.InsertFrameMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
|
||||
| System.Windows.Forms.Keys.Insert)));
|
||||
this.InsertFrameMenuItem.Size = new System.Drawing.Size(240, 22);
|
||||
this.InsertFrameMenuItem.Text = "&Insert";
|
||||
this.InsertFrameMenuItem.Click += new System.EventHandler(this.InsertFrameMenuItem_Click);
|
||||
//
|
||||
// InsertNumFramesMenuItem
|
||||
//
|
||||
|
|
|
@ -452,6 +452,37 @@ namespace BizHawk.Client.EmuHawk
|
|||
RefreshDialog();
|
||||
}
|
||||
|
||||
private void CloneMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var framesToInsert = TasView.SelectedIndices
|
||||
.OfType<int>()
|
||||
.OrderBy(frame => frame)
|
||||
.ToList();
|
||||
|
||||
var insertionFrame = framesToInsert.Last() + 1;
|
||||
|
||||
var inputLog = new List<string>();
|
||||
foreach (var frame in framesToInsert)
|
||||
{
|
||||
inputLog.Add(_tas.GetInput(frame));
|
||||
}
|
||||
|
||||
_tas.InsertInput(insertionFrame, inputLog);
|
||||
|
||||
RefreshDialog();
|
||||
}
|
||||
|
||||
private void InsertFrameMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var insertionFrame = TasView.SelectedIndices
|
||||
.OfType<int>()
|
||||
.Last() + 1;
|
||||
|
||||
_tas.InsertEmptyFrame(insertionFrame);
|
||||
|
||||
RefreshDialog();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Config
|
||||
|
|
Loading…
Reference in New Issue