diff --git a/src/BizHawk.Client.Common/movie/tasproj/TasClipboardEntry.cs b/src/BizHawk.Client.Common/movie/tasproj/TasClipboardEntry.cs new file mode 100644 index 0000000000..2a9bf3bc6b --- /dev/null +++ b/src/BizHawk.Client.Common/movie/tasproj/TasClipboardEntry.cs @@ -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; } + } +} diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs index 3ab829d5d3..7250e63fbb 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs @@ -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; diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 7426239495..da3402eaf5 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -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; + } + } } } diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudioClipboard.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudioClipboard.cs deleted file mode 100644 index d081eef1cb..0000000000 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudioClipboard.cs +++ /dev/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; - } - } - } -}