From 0d794f2b12b4efc7c6c6e1569309778faa0024be Mon Sep 17 00:00:00 2001 From: adelikat Date: Wed, 15 Apr 2020 18:06:31 -0500 Subject: [PATCH] refactor MultitrackRecording to keep up with PlayerCount rather than use Globals --- BizHawk.Client.Common/movie/MovieSession.cs | 4 ++-- .../movie/MultitrackRecording.cs | 24 +++++++------------ 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/BizHawk.Client.Common/movie/MovieSession.cs b/BizHawk.Client.Common/movie/MovieSession.cs index 7855904823..9ba5e0c394 100644 --- a/BizHawk.Client.Common/movie/MovieSession.cs +++ b/BizHawk.Client.Common/movie/MovieSession.cs @@ -329,7 +329,7 @@ namespace BizHawk.Client.Common { Movie = QueuedMovie; QueuedMovie = null; - MultiTrack.Restart(); + MultiTrack.Restart(Global.Emulator.ControllerDefinition.PlayerCount); if (recordMode) { @@ -389,7 +389,7 @@ namespace BizHawk.Client.Common ReadOnly = true; } - MultiTrack.Restart(); + MultiTrack.Restart(Global.Emulator.ControllerDefinition.PlayerCount); ModeChangedCallback(); } diff --git a/BizHawk.Client.Common/movie/MultitrackRecording.cs b/BizHawk.Client.Common/movie/MultitrackRecording.cs index 00c189789e..01744c86aa 100644 --- a/BizHawk.Client.Common/movie/MultitrackRecording.cs +++ b/BizHawk.Client.Common/movie/MultitrackRecording.cs @@ -6,11 +6,12 @@ namespace BizHawk.Client.Common { public MultitrackRecorder() { - Restart(); + Restart(1); } public bool IsActive { get; set; } public int CurrentPlayer { get; private set; } + public int PlayerCount { get; private set; } public bool RecordAll { get; private set; } /// @@ -39,8 +40,9 @@ namespace BizHawk.Client.Common } } - public void Restart() + public void Restart(int playerCount) { + PlayerCount = playerCount; IsActive = false; CurrentPlayer = 0; RecordAll = false; @@ -62,7 +64,7 @@ namespace BizHawk.Client.Common { RecordAll = false; CurrentPlayer++; - if (CurrentPlayer > Global.Emulator.ControllerDefinition.PlayerCount) + if (CurrentPlayer > PlayerCount) { CurrentPlayer = 1; } @@ -74,7 +76,7 @@ namespace BizHawk.Client.Common CurrentPlayer--; if (CurrentPlayer < 1) { - CurrentPlayer = Global.Emulator.ControllerDefinition.PlayerCount; + CurrentPlayer = PlayerCount; } } } @@ -84,19 +86,12 @@ namespace BizHawk.Client.Common /// public class MultitrackRewiringControllerAdapter : IController { - public MultitrackRewiringControllerAdapter() - { - PlayerSource = 1; - } - public IController Source { get; set; } - public int PlayerSource { get; set; } + public int PlayerSource { get; set; } = 1; public int PlayerTargetMask { get; set; } public ControllerDefinition Definition => Source.Definition; - public bool this[string button] => IsPressed(button); - public bool IsPressed(string button) { return Source.IsPressed(RemapButtonName(button)); @@ -169,9 +164,6 @@ namespace BizHawk.Client.Common public int PlayerNum { get; set; } public string ButtonPart { get; private set; } - public override string ToString() - { - return $"P{PlayerNum} {ButtonPart}"; - } + public override string ToString() => $"P{PlayerNum} {ButtonPart}"; } }