TAStudio - implement paste and paste insert
This commit is contained in:
parent
e8f821117b
commit
e49754b705
|
@ -70,6 +70,35 @@ namespace BizHawk.Client.Common
|
|||
InvalidateAfter(frame);
|
||||
}
|
||||
|
||||
public void InsertInput(int frame, IEnumerable<IController> inputStates)
|
||||
{
|
||||
var lg = LogGeneratorInstance();
|
||||
|
||||
var inputLog = new List<string>();
|
||||
|
||||
foreach (var input in inputStates)
|
||||
{
|
||||
lg.SetSource(input);
|
||||
inputLog.Add(lg.GenerateLogEntry());
|
||||
}
|
||||
|
||||
InsertInput(frame, inputLog);
|
||||
}
|
||||
|
||||
public void CopyOverInput(int frame, IEnumerable<IController> inputStates)
|
||||
{
|
||||
var lg = LogGeneratorInstance();
|
||||
var states = inputStates.ToList();
|
||||
for (int i = 0; i < states.Count; i++)
|
||||
{
|
||||
lg.SetSource(states[i]);
|
||||
_log[frame + i] = lg.GenerateLogEntry();
|
||||
}
|
||||
|
||||
Changes = true;
|
||||
InvalidateAfter(frame);
|
||||
}
|
||||
|
||||
public void InsertEmptyFrame(int frame)
|
||||
{
|
||||
var lg = LogGeneratorInstance();
|
||||
|
|
|
@ -330,20 +330,20 @@ namespace BizHawk.Client.EmuHawk
|
|||
//
|
||||
// PasteMenuItem
|
||||
//
|
||||
this.PasteMenuItem.Enabled = false;
|
||||
this.PasteMenuItem.Name = "PasteMenuItem";
|
||||
this.PasteMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V)));
|
||||
this.PasteMenuItem.Size = new System.Drawing.Size(240, 22);
|
||||
this.PasteMenuItem.Text = "&Paste";
|
||||
this.PasteMenuItem.Click += new System.EventHandler(this.PasteMenuItem_Click);
|
||||
//
|
||||
// PasteInsertMenuItem
|
||||
//
|
||||
this.PasteInsertMenuItem.Enabled = false;
|
||||
this.PasteInsertMenuItem.Name = "PasteInsertMenuItem";
|
||||
this.PasteInsertMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
|
||||
| System.Windows.Forms.Keys.V)));
|
||||
this.PasteInsertMenuItem.Size = new System.Drawing.Size(240, 22);
|
||||
this.PasteInsertMenuItem.Text = "&Paste Insert";
|
||||
this.PasteInsertMenuItem.Click += new System.EventHandler(this.PasteInsertMenuItem_Click);
|
||||
//
|
||||
// CutMenuItem
|
||||
//
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
|
@ -31,6 +32,39 @@ namespace BizHawk.Client.EmuHawk
|
|||
return (lg as Bk2LogEntryGenerator).Map();
|
||||
}
|
||||
|
||||
// Indices Helpers
|
||||
private int FirstSelectedIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return TasView.SelectedIndices
|
||||
.OfType<int>()
|
||||
.OrderBy(frame => frame)
|
||||
.First();
|
||||
}
|
||||
}
|
||||
|
||||
private int LastSelectedIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return TasView.SelectedIndices
|
||||
.OfType<int>()
|
||||
.OrderBy(frame => frame)
|
||||
.Last();
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable SelectedIndices
|
||||
{
|
||||
get
|
||||
{
|
||||
return TasView.SelectedIndices
|
||||
.OfType<int>()
|
||||
.OrderBy(frame => frame);
|
||||
}
|
||||
}
|
||||
|
||||
public TAStudio()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -388,7 +422,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
var sb = new StringBuilder();
|
||||
for (var i = 0; i < list.Count; i++)
|
||||
{
|
||||
var input = _tas.GetInputState(i);
|
||||
var input = _tas.GetInputState(list[i]);
|
||||
_tasClipboard.Add(new TasClipboardEntry(list[i], input));
|
||||
var lg = _tas.LogGeneratorInstance();
|
||||
lg.SetSource(input);
|
||||
|
@ -400,6 +434,30 @@ namespace BizHawk.Client.EmuHawk
|
|||
SetSplicer();
|
||||
}
|
||||
|
||||
private void PasteMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// TODO: if highlighting 2 rows and pasting 3, only paste 2 of them
|
||||
// FCEUX Taseditor does't do this, but I think it is the expected behavior in editor programs
|
||||
if (_tasClipboard.Any())
|
||||
{
|
||||
_tas.CopyOverInput(FirstSelectedIndex, _tasClipboard.Select(x => x.ControllerState));
|
||||
}
|
||||
|
||||
RefreshDialog();
|
||||
}
|
||||
|
||||
private void PasteInsertMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// TODO: if highlighting 2 rows and pasting 3, only paste 2 of them
|
||||
// FCEUX Taseditor does't do this, but I think it is the expected behavior in editor programs
|
||||
if (_tasClipboard.Any())
|
||||
{
|
||||
_tas.InsertInput(FirstSelectedIndex, _tasClipboard.Select(x => x.ControllerState));
|
||||
}
|
||||
|
||||
RefreshDialog();
|
||||
}
|
||||
|
||||
private void CutMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_tasClipboard.Clear();
|
||||
|
|
Loading…
Reference in New Issue