tastudio: paste from OS clipboard if _tasClipboard is empty

This commit is contained in:
feos 2016-10-01 20:12:50 +03:00
parent fc66ec1b02
commit 5ed5613826
2 changed files with 76 additions and 0 deletions

View File

@ -413,6 +413,31 @@ namespace BizHawk.Client.EmuHawk
RefreshDialog();
}
}
else
{
// copypaste from PasteInsertMenuItem_Click!
IDataObject data = Clipboard.GetDataObject();
if (data.GetDataPresent(DataFormats.StringFormat))
{
string input = (string)data.GetData(DataFormats.StringFormat);
if (!string.IsNullOrWhiteSpace(input))
{
string[] lines = input.Split('\n');
if (lines.Length > 0)
{
for (int i = 0; i < lines.Length; i++)
{
var line = TasClipboardEntry.SetFromMnemonicStr(lines[i]);
if (line == null)
return;
else
_tasClipboard.Add(new TasClipboardEntry(i, line));
}
PasteMenuItem_Click(sender, e); // pseudo recursion
}
}
}
}
}
private void PasteInsertMenuItem_Click(object sender, EventArgs e)
@ -442,6 +467,31 @@ namespace BizHawk.Client.EmuHawk
RefreshDialog();
}
}
else
{
// copypaste from PasteMenuItem_Click!
IDataObject data = Clipboard.GetDataObject();
if (data.GetDataPresent(DataFormats.StringFormat))
{
string input = (string)data.GetData(DataFormats.StringFormat);
if (!string.IsNullOrWhiteSpace(input))
{
string[] lines = input.Split('\n');
if (lines.Length > 0)
{
for (int i = 0; i < lines.Length; i++)
{
var line = TasClipboardEntry.SetFromMnemonicStr(lines[i]);
if (line == null)
return;
else
_tasClipboard.Add(new TasClipboardEntry(i, line));
}
PasteInsertMenuItem_Click(sender, e); // pseudo recursion
}
}
}
}
}
private void CutMenuItem_Click(object sender, EventArgs e)

View File

@ -19,5 +19,31 @@ namespace BizHawk.Client.EmuHawk
var lg = Global.MovieSession.Movie.LogGeneratorInstance();
return lg.GenerateLogEntry();
}
public static IMovieController SetFromMnemonicStr(string inputLogEntry)
{
try
{
var lg = Global.MovieSession.MovieControllerInstance();
lg.SetControllersAsMnemonic(inputLogEntry);
foreach (var button in lg.Type.BoolButtons)
{
Global.LuaAndAdaptor.SetButton(button, lg.IsPressed(button));
}
foreach (var floatButton in lg.Type.FloatControls)
{
Global.LuaAndAdaptor.SetFloat(floatButton, lg.GetFloat(floatButton));
}
return lg;
}
catch (System.Exception)
{
System.Windows.Forms.MessageBox.Show("Invalid mnemonic string: " + inputLogEntry, "Paste Input failed!");
return null;
}
}
}
}