diff --git a/src/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs b/src/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs index 7c57e4dae7..41b2576ebb 100644 --- a/src/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs +++ b/src/BizHawk.Client.Common/movie/bk2/Bk2LogEntryGenerator.cs @@ -51,11 +51,11 @@ namespace BizHawk.Client.Common /// documentation of the meaning of the mnemonics and not to be used to /// enforce the mnemonic values /// - public string GenerateLogKey() + public static string GenerateLogKey(ControllerDefinition definition) { var sb = new StringBuilder(); - foreach (var group in _source.Definition.ControlsOrdered.Where(static c => c.Count is not 0)) + foreach (var group in definition.ControlsOrdered.Where(static c => c.Count is not 0)) { sb.Append('#'); foreach (var button in group) diff --git a/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs b/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs index 8cd9a167ec..12b8db5eac 100644 --- a/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs +++ b/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs @@ -14,7 +14,7 @@ namespace BizHawk.Client.Common { writer.WriteLine("[Input]"); writer.Write("LogKey:"); - writer.WriteLine(string.IsNullOrEmpty(LogKey) ? LogGeneratorInstance(Session.MovieController).GenerateLogKey() : LogKey); + writer.WriteLine(string.IsNullOrEmpty(LogKey) ? Bk2LogEntryGenerator.GenerateLogKey(Session.MovieController.Definition) : LogKey); foreach (var record in Log) { diff --git a/src/BizHawk.Client.Common/movie/import/LsmvImport.cs b/src/BizHawk.Client.Common/movie/import/LsmvImport.cs index 4d9f11c5bd..a863a1369a 100644 --- a/src/BizHawk.Client.Common/movie/import/LsmvImport.cs +++ b/src/BizHawk.Client.Common/movie/import/LsmvImport.cs @@ -90,7 +90,7 @@ namespace BizHawk.Client.Common.movie.import _controller = new SimpleController(controllerDefinition); _playerCount = controllerDefinition.PlayerCount; - Result.Movie.LogKey = new Bk2LogEntryGenerator(VSystemID.Raw.SNES, new Bk2Controller(controllerDefinition)).GenerateLogKey(); + Result.Movie.LogKey = Bk2LogEntryGenerator.GenerateLogKey(controllerDefinition); foreach (var item in zip.Entries) { diff --git a/src/BizHawk.Client.Common/movie/import/SmvImport.cs b/src/BizHawk.Client.Common/movie/import/SmvImport.cs index 28980fde54..10c10821e0 100644 --- a/src/BizHawk.Client.Common/movie/import/SmvImport.cs +++ b/src/BizHawk.Client.Common/movie/import/SmvImport.cs @@ -193,7 +193,7 @@ namespace BizHawk.Client.Common.movie.import ControllerDefinition definition = new Snes9xControllers(ss).ControllerDefinition; SimpleController controllers = new(definition); - Result.Movie.LogKey = new Bk2LogEntryGenerator(VSystemID.Raw.SNES, new Bk2Controller(definition)).GenerateLogKey(); + Result.Movie.LogKey = Bk2LogEntryGenerator.GenerateLogKey(definition); r.BaseStream.Position = firstFrameOffset; /* diff --git a/src/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.ButtonSelect.cs b/src/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.ButtonSelect.cs index fc7e1cdf1b..07a32d580a 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.ButtonSelect.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.ButtonSelect.cs @@ -2,6 +2,8 @@ using System.Drawing; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.Client.EmuHawk { public partial class MacroInputTool @@ -47,8 +49,7 @@ namespace BizHawk.Client.EmuHawk s.Refresh(); // Update the selected zone's key - var lg = MovieSession.Movie.LogGeneratorInstance(MovieSession.MovieController); - string key = lg.GenerateLogKey(); + string key = Bk2LogEntryGenerator.GenerateLogKey(MovieSession.MovieController.Definition); key = key.Replace("#", ""); foreach (var box in _buttonBoxes) diff --git a/src/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs b/src/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs index 626ca548fa..6406f5879e 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs @@ -20,11 +20,9 @@ namespace BizHawk.Client.EmuHawk public MovieZone(IEmulator emulator, ToolManager tools, IMovieSession movieSession, int start, int length, string key = "") : this(emulator, tools, movieSession) { - var lg = movieSession.Movie.LogGeneratorInstance(movieSession.MovieController); - if (key == "") { - key = lg.GenerateLogKey(); + key = Bk2LogEntryGenerator.GenerateLogKey(movieSession.MovieController.Definition); } key = key.Replace("#", ""); @@ -38,9 +36,8 @@ namespace BizHawk.Client.EmuHawk InitController(_inputKey); var logGenerator = movieSession.Movie.LogGeneratorInstance(_controller); - logGenerator.GenerateLogEntry(); // Reference and create all buttons. - string movieKey = logGenerator.GenerateLogKey().Replace("#", ""); + string movieKey = Bk2LogEntryGenerator.GenerateLogKey(_controller.Definition).Replace("#", ""); movieKey = movieKey.Substring(startIndex: 0, length: movieKey.Length - 1); // drop last char if (key == movieKey) { @@ -236,8 +233,7 @@ namespace BizHawk.Client.EmuHawk // If the LogKey contains buttons/controls not accepted by the emulator, // tell the user and display the macro's controller name and player count _inputKey = readText[0]; - var lg = _movieSession.Movie.LogGeneratorInstance(_movieSession.MovieController); - string key = lg.GenerateLogKey(); + string key = Bk2LogEntryGenerator.GenerateLogKey(_movieSession.MovieController.Definition); key = key.Replace("#", ""); key = key.Substring(startIndex: 0, length: key.Length - 1); // drop last char string[] emuKeys = key.Split('|');