diff --git a/BizHawk.Client.Common/Api/Classes/MovieApi.cs b/BizHawk.Client.Common/Api/Classes/MovieApi.cs index c1369b1257..7042dbcf05 100644 --- a/BizHawk.Client.Common/Api/Classes/MovieApi.cs +++ b/BizHawk.Client.Common/Api/Classes/MovieApi.cs @@ -44,8 +44,9 @@ namespace BizHawk.Client.Common { return string.Empty; } - var lg = Global.MovieSession.LogGeneratorInstance(); - lg.SetSource(Global.MovieSession.Movie.GetInputState(frame)); + + var lg = Global.MovieSession.LogGeneratorInstance( + Global.MovieSession.Movie.GetInputState(frame)); return lg.GenerateLogEntry(); } diff --git a/BizHawk.Client.Common/movie/MovieSession.cs b/BizHawk.Client.Common/movie/MovieSession.cs index 1e11de9603..d22236380b 100644 --- a/BizHawk.Client.Common/movie/MovieSession.cs +++ b/BizHawk.Client.Common/movie/MovieSession.cs @@ -50,9 +50,11 @@ namespace BizHawk.Client.Common /// /// Simply shortens the verbosity necessary otherwise /// - public ILogEntryGenerator LogGeneratorInstance() + public ILogEntryGenerator LogGeneratorInstance(IController source) { - return Movie.LogGeneratorInstance(); + var lg = Movie.LogGeneratorInstance(); + lg.SetSource(source); + return lg; } public IMovieController MovieControllerInstance() diff --git a/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs b/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs index a0e63ed756..69fb2b5bd8 100644 --- a/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs +++ b/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs @@ -30,7 +30,7 @@ namespace BizHawk.Client.Common bool CheckSavestateTimeline(TextReader reader); bool HandleMovieLoadState(TextReader reader); - ILogEntryGenerator LogGeneratorInstance(); + ILogEntryGenerator LogGeneratorInstance(IController source); void QueueNewMovie(IMovie movie, bool record, IEmulator emulator); void RunQueuedMovie(bool recordMode); diff --git a/BizHawk.Client.EmuHawk/DisplayManager/OSDManager.cs b/BizHawk.Client.EmuHawk/DisplayManager/OSDManager.cs index 662eda0cfe..c7565db935 100644 --- a/BizHawk.Client.EmuHawk/DisplayManager/OSDManager.cs +++ b/BizHawk.Client.EmuHawk/DisplayManager/OSDManager.cs @@ -188,30 +188,22 @@ namespace BizHawk.Client.EmuHawk public string InputStrMovie() { - var lg = Global.MovieSession.LogGeneratorInstance(); - lg.SetSource(Global.MovieSession.MovieControllerAdapter); - - return lg.GenerateInputDisplay(); + return MakeStringFor(Global.MovieSession.MovieControllerAdapter); } public string InputStrImmediate() { - var lg = Global.MovieSession.LogGeneratorInstance(); - lg.SetSource(Global.InputManager.AutofireStickyXorAdapter); - - return lg.GenerateInputDisplay(); + return MakeStringFor(Global.InputManager.AutofireStickyXorAdapter); } public string InputPrevious() { if (Global.MovieSession.Movie.IsPlayingOrRecording()) { - var lg = Global.MovieSession.LogGeneratorInstance(); var state = Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1); if (state != null) { - lg.SetSource(state); - return lg.GenerateInputDisplay(); + return MakeStringFor(state); } } @@ -224,17 +216,12 @@ namespace BizHawk.Client.EmuHawk ? Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1) : Global.MovieSession.MovieControllerInstance(); - var lg = Global.MovieSession.LogGeneratorInstance(); - - lg.SetSource(Global.InputManager.AutofireStickyXorAdapter.Or(m)); - return lg.GenerateInputDisplay(); + return MakeStringFor(Global.InputManager.AutofireStickyXorAdapter.Or(m)); } private string MakeStringFor(IController controller) { - var lg = Global.MovieSession.LogGeneratorInstance(); - lg.SetSource(controller); - return lg.GenerateInputDisplay(); + return Global.MovieSession.LogGeneratorInstance(controller).GenerateInputDisplay(); } public string MakeIntersectImmediatePrevious() @@ -245,9 +232,7 @@ namespace BizHawk.Client.EmuHawk ? Global.MovieSession.Movie.GetInputState(Global.Emulator.Frame - 1) : Global.MovieSession.MovieControllerInstance(); - var lg = Global.MovieSession.LogGeneratorInstance(); - lg.SetSource(Global.InputManager.AutofireStickyXorAdapter.And(m)); - return lg.GenerateInputDisplay(); + return MakeStringFor(Global.InputManager.AutofireStickyXorAdapter.And(m)); } return ""; diff --git a/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs b/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs index f8a02a3988..1d9209259d 100644 --- a/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs +++ b/BizHawk.Client.EmuHawk/tools/BasicBot/BasicBot.cs @@ -976,8 +976,7 @@ namespace BizHawk.Client.EmuHawk UpdateBotStatusIcon(); MessageLabel.Text = "Running..."; _cachedControlProbabilities = ControlProbabilities; - _logGenerator = Global.MovieSession.LogGeneratorInstance(); - _logGenerator.SetSource(Global.InputManager.ClickyVirtualPadController); + _logGenerator = Global.MovieSession.LogGeneratorInstance(Global.InputManager.ClickyVirtualPadController); } private string CanStart() diff --git a/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.ButtonSelect.cs b/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.ButtonSelect.cs index 5f23b16438..5b0dfdea64 100644 --- a/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.ButtonSelect.cs +++ b/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.ButtonSelect.cs @@ -48,8 +48,7 @@ namespace BizHawk.Client.EmuHawk s.Refresh(); // Update the selected zone's key - var lg = Global.MovieSession.LogGeneratorInstance(); - lg.SetSource(Global.MovieSession.MovieControllerAdapter); + var lg = Global.MovieSession.LogGeneratorInstance(Global.MovieSession.MovieControllerAdapter); string key = lg.GenerateLogKey(); key = key.Replace("LogKey:", "").Replace("#", ""); diff --git a/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs b/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs index 6a2f008f31..5201319fb5 100644 --- a/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs +++ b/BizHawk.Client.EmuHawk/tools/Macros/MovieZone.cs @@ -229,8 +229,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 = Global.MovieSession.LogGeneratorInstance(); - lg.SetSource(Global.MovieSession.MovieControllerAdapter); + var lg = Global.MovieSession.LogGeneratorInstance(Global.MovieSession.MovieControllerAdapter); string key = lg.GenerateLogKey(); key = key.Replace("LogKey:", "").Replace("#", ""); key = key.Substring(0, key.Length - 1); diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index a6b2bb5197..2a60f8cfb8 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -42,13 +42,6 @@ namespace BizHawk.Client.EmuHawk /// public int LastPositionFrame { get; private set; } - private Dictionary GenerateColumnNames() - { - var lg = Global.MovieSession.LogGeneratorInstance(); - lg.SetSource(Global.MovieSession.MovieControllerAdapter); - return lg.Map(); - } - [ConfigPersist] public TAStudioSettings Settings { get; set; } @@ -420,7 +413,10 @@ namespace BizHawk.Client.EmuHawk Rotatable = true }); - var columnNames = GenerateColumnNames(); + var columnNames = Global.MovieSession + .LogGeneratorInstance(Global.MovieSession.MovieControllerAdapter) + .Map(); + foreach (var kvp in columnNames) { ColumnType type;