TasClipboardEntry, move some logic to Tastudio, fix filename, and move to Client.Common
This commit is contained in:
parent
8e70bece16
commit
8d6cb7685e
|
@ -0,0 +1,16 @@
|
|||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public class TasClipboardEntry
|
||||
{
|
||||
public TasClipboardEntry(int frame, IController controllerState)
|
||||
{
|
||||
Frame = frame;
|
||||
ControllerState = controllerState;
|
||||
}
|
||||
|
||||
public int Frame { get; }
|
||||
public IController ControllerState { get; }
|
||||
}
|
||||
}
|
|
@ -481,7 +481,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
_tasClipboard.Clear();
|
||||
for (int i = 0; i < lines.Length - 1; i++)
|
||||
{
|
||||
var line = TasClipboardEntry.SetFromMnemonicStr(lines[i]);
|
||||
var line = ControllerFromMnemonicStr(lines[i]);
|
||||
if (line == null)
|
||||
{
|
||||
return;
|
||||
|
@ -521,7 +521,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
_tasClipboard.Clear();
|
||||
for (int i = 0; i < lines.Length - 1; i++)
|
||||
{
|
||||
var line = TasClipboardEntry.SetFromMnemonicStr(lines[i]);
|
||||
var line = ControllerFromMnemonicStr(lines[i]);
|
||||
if (line == null)
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -1262,5 +1262,21 @@ namespace BizHawk.Client.EmuHawk
|
|||
TasView.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private IMovieController ControllerFromMnemonicStr(string inputLogEntry)
|
||||
{
|
||||
try
|
||||
{
|
||||
var controller = MovieSession.GenerateMovieController();
|
||||
controller.SetFromMnemonic(inputLogEntry);
|
||||
|
||||
return controller;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show($"Invalid mnemonic string: {inputLogEntry}", "Paste Input failed!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public class TasClipboardEntry
|
||||
{
|
||||
public TasClipboardEntry(int frame, IController controllerState)
|
||||
{
|
||||
Frame = frame;
|
||||
ControllerState = controllerState;
|
||||
}
|
||||
|
||||
public int Frame { get; }
|
||||
public IController ControllerState { get; }
|
||||
|
||||
public static IMovieController SetFromMnemonicStr(string inputLogEntry)
|
||||
{
|
||||
try
|
||||
{
|
||||
var controller = GlobalWin.MovieSession.GenerateMovieController();
|
||||
controller.SetFromMnemonic(inputLogEntry);
|
||||
|
||||
foreach (var button in controller.Definition.BoolButtons)
|
||||
{
|
||||
GlobalWin.InputManager.ButtonOverrideAdapter.SetButton(button, controller.IsPressed(button));
|
||||
}
|
||||
|
||||
foreach (var axisName in controller.Definition.Axes.Keys)
|
||||
{
|
||||
GlobalWin.InputManager.ButtonOverrideAdapter.SetAxis(axisName, controller.AxisValue(axisName));
|
||||
}
|
||||
|
||||
return controller;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show($"Invalid mnemonic string: {inputLogEntry}", "Paste Input failed!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue