TAStudio - implement the Cut menu item
This commit is contained in:
parent
0f6dbd5570
commit
76fc763715
|
@ -47,5 +47,20 @@ namespace BizHawk.Client.Common
|
|||
LagLog.RemoveRange(frame + 1, LagLog.Count - frame - 1);
|
||||
StateManager.Invalidate(frame + 1);
|
||||
}
|
||||
|
||||
public void RemoveFrames(int[] frames)
|
||||
{
|
||||
if (frames.Any())
|
||||
{
|
||||
var truncateStatesTo = frames.Min(x => x);
|
||||
foreach (var frame in frames.OrderByDescending(x => x)) // Removin them in reverse order allows us to remove by index;
|
||||
{
|
||||
_log.RemoveAt(frame);
|
||||
}
|
||||
|
||||
StateManager.Invalidate(truncateStatesTo);
|
||||
Changes = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -347,11 +347,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
//
|
||||
// CutMenuItem
|
||||
//
|
||||
this.CutMenuItem.Enabled = false;
|
||||
this.CutMenuItem.Name = "CutMenuItem";
|
||||
this.CutMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X)));
|
||||
this.CutMenuItem.Size = new System.Drawing.Size(240, 22);
|
||||
this.CutMenuItem.Text = "&Cut";
|
||||
this.CutMenuItem.Click += new System.EventHandler(this.CutMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator8
|
||||
//
|
||||
|
|
|
@ -400,6 +400,30 @@ namespace BizHawk.Client.EmuHawk
|
|||
SetSplicer();
|
||||
}
|
||||
|
||||
private void CutMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_tasClipboard.Clear();
|
||||
var list = TasView.SelectedIndices
|
||||
.OfType<int>()
|
||||
.ToArray();
|
||||
var sb = new StringBuilder();
|
||||
for (var i = 0; i < list.Length; i++)
|
||||
{
|
||||
var input = _tas.GetInputState(i);
|
||||
_tasClipboard.Add(new TasClipboardEntry(list[i], input));
|
||||
var lg = _tas.LogGeneratorInstance();
|
||||
lg.SetSource(input);
|
||||
sb.AppendLine(lg.GenerateLogEntry());
|
||||
}
|
||||
|
||||
Clipboard.SetDataObject(sb.ToString());
|
||||
|
||||
_tas.RemoveFrames(list);
|
||||
|
||||
SetSplicer();
|
||||
RefreshDialog();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Config
|
||||
|
|
Loading…
Reference in New Issue