From 268ab96ae99b7ab3fa25b0a10888e72ce8a489ab Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 13 Jun 2020 09:49:25 -0500 Subject: [PATCH] remove built-in multitrack movie recorder, justification: tastudio is a much better alternative, it isn't used, and it's causing strain on better movie architecture, also this logic is easily done via lua script. It could be built from scratch one day in a way that plays nice with better movie architecture, if there's demand, but we need to remove this to keep moving forward --- src/BizHawk.Client.Common/config/Binding.cs | 5 -- .../movie/MovieSession.cs | 63 +------------- .../movie/bk2/Bk2Controller.cs | 30 ------- .../movie/bk2/Bk2Movie.InputLog.cs | 73 +++++----------- .../movie/bk2/Bk2Movie.cs | 10 +-- .../movie/interfaces/IMovieController.cs | 5 -- .../movie/interfaces/IMovieSession.cs | 3 - .../movie/multitrack/ButtonNameParser.cs | 37 --------- .../movie/multitrack/MultitrackRecorder.cs | 83 ------------------- .../MultitrackRewiringControllerAdapter.cs | 55 ------------ .../DisplayManager/OSDManager.cs | 6 -- src/BizHawk.Client.EmuHawk/MainForm.Events.cs | 1 - src/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs | 15 ---- 13 files changed, 24 insertions(+), 362 deletions(-) delete mode 100644 src/BizHawk.Client.Common/movie/multitrack/ButtonNameParser.cs delete mode 100644 src/BizHawk.Client.Common/movie/multitrack/MultitrackRecorder.cs delete mode 100644 src/BizHawk.Client.Common/movie/multitrack/MultitrackRewiringControllerAdapter.cs diff --git a/src/BizHawk.Client.Common/config/Binding.cs b/src/BizHawk.Client.Common/config/Binding.cs index 239575bb67c..e13b724db1e 100644 --- a/src/BizHawk.Client.Common/config/Binding.cs +++ b/src/BizHawk.Client.Common/config/Binding.cs @@ -186,11 +186,6 @@ public static List DefaultValues Bind("Movie", "Stop Movie"), Bind("Movie", "Play from beginning"), Bind("Movie", "Save Movie"), - Bind("Movie", "Toggle MultiTrack"), - Bind("Movie", "MT Select All"), - Bind("Movie", "MT Select None"), - Bind("Movie", "MT Increment Player"), - Bind("Movie", "MT Decrement Player"), Bind("Tools", "RAM Watch"), Bind("Tools", "RAM Search"), diff --git a/src/BizHawk.Client.Common/movie/MovieSession.cs b/src/BizHawk.Client.Common/movie/MovieSession.cs index 89f2bce039e..dad14e64442 100644 --- a/src/BizHawk.Client.Common/movie/MovieSession.cs +++ b/src/BizHawk.Client.Common/movie/MovieSession.cs @@ -38,8 +38,6 @@ public MovieSession( ?? throw new ArgumentNullException($"{nameof(pauseCallback)} cannot be null."); _modeChangedCallback = modeChangedCallback ?? throw new ArgumentNullException($"{nameof(modeChangedCallback)} CannotUnloadAppDomainException be null."); - - MultiTrack.RewiringAdapter.Source = MovieIn; } public IMovieConfig Settings { get; } @@ -57,8 +55,6 @@ public MovieSession( public IMovieController MovieController { get; private set; } = new Bk2Controller("", NullController.Instance.Definition); - public MultitrackRecorder MultiTrack { get; } = new MultitrackRecorder(); - public IMovieController GenerateMovieController(ControllerDefinition definition = null) { // TODO: expose Movie.LogKey and pass in here @@ -242,7 +238,6 @@ public void RunQueuedMovie(bool recordMode, IEmulator emulator, IDictionary Movie.Emulator.Frame) - { - var input = Movie.GetInputState(Movie.Emulator.Frame); - MovieController.SetFrom(input); - } - - MovieController.SetPlayerFrom(rewiredSource, MultiTrack.CurrentPlayer); - } - } - private void LatchInputToUser() { MovieOut.Source = MovieIn; @@ -439,14 +385,7 @@ private void HandleFrameLoopForRecordMode() } else { - if (MultiTrack.IsActive) - { - LatchInputToMultitrackUser(); - } - else - { - LatchInputToUser(); - } + LatchInputToUser(); } Movie.RecordFrame(Movie.Emulator.Frame, MovieController); diff --git a/src/BizHawk.Client.Common/movie/bk2/Bk2Controller.cs b/src/BizHawk.Client.Common/movie/bk2/Bk2Controller.cs index 92a8acb5e1e..166e4487bc7 100644 --- a/src/BizHawk.Client.Common/movie/bk2/Bk2Controller.cs +++ b/src/BizHawk.Client.Common/movie/bk2/Bk2Controller.cs @@ -59,36 +59,6 @@ public void SetFrom(IController source) } } - public void SetPlayerFrom(IController playerSource, int controllerNum) - { - foreach (var button in playerSource.Definition.BoolButtons) - { - var bnp = ButtonNameParser.Parse(button); - - if (bnp?.PlayerNum != controllerNum) - { - continue; - } - - var val = playerSource.IsPressed(button); - _myBoolButtons[button] = val; - } - - foreach (var button in Definition.AxisControls) - { - var bnp = ButtonNameParser.Parse(button); - - if (bnp?.PlayerNum != controllerNum) - { - continue; - } - - var val = playerSource.AxisValue(button); - - _myAxisControls[button] = val; - } - } - public void SetFromSticky(IStickyController controller) { foreach (var button in Definition.BoolButtons) diff --git a/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs b/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs index 9b9a38966e4..2b712d291cf 100644 --- a/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs +++ b/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs @@ -38,69 +38,36 @@ public virtual bool ExtractInputLog(TextReader reader, out string errorMessage) int? stateFrame = null; // We are in record mode so replace the movie log with the one from the savestate - if (!Session.MultiTrack.IsActive) + if (Session.Settings.EnableBackupMovies && MakeBackup && Log.Count != 0) { - if (Session.Settings.EnableBackupMovies && MakeBackup && Log.Count != 0) + SaveBackup(); + MakeBackup = false; + } + + Log.Clear(); + string line; + while ((line = reader.ReadLine()) != null) + { + if (line.StartsWith("|")) { - SaveBackup(); - MakeBackup = false; + Log.Add(line); } - - Log.Clear(); - string line; - while ((line = reader.ReadLine()) != null) + else if (line.StartsWith("Frame ")) { - if (line.StartsWith("|")) - { - Log.Add(line); - } - else if (line.StartsWith("Frame ")) + var strs = line.Split(' '); + try { - var strs = line.Split(' '); - try - { - stateFrame = int.Parse(strs[1]); - } - catch - { - errorMessage = "Savestate Frame number failed to parse"; - return false; - } + stateFrame = int.Parse(strs[1]); } - else if (line.StartsWith("LogKey:")) + catch { - LogKey = line.Replace("LogKey:", ""); + errorMessage = "Savestate Frame number failed to parse"; + return false; } } - } - else - { - var i = 0; - string line; - while ((line = reader.ReadLine()) != null) + else if (line.StartsWith("LogKey:")) { - if (line.StartsWith("|")) - { - SetFrameAt(i, line); - i++; - } - else if (line.StartsWith("Frame ")) - { - var strs = line.Split(' '); - try - { - stateFrame = int.Parse(strs[1]); - } - catch - { - errorMessage = "Savestate Frame number failed to parse"; - return false; - } - } - else if (line.StartsWith("LogKey:")) - { - LogKey = line.Replace("LogKey:", ""); - } + LogKey = line.Replace("LogKey:", ""); } } diff --git a/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.cs b/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.cs index 60813ab618b..b73cae23007 100644 --- a/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.cs +++ b/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.cs @@ -130,14 +130,10 @@ public virtual void RecordFrame(int frame, IController source) public virtual void Truncate(int frame) { // This is a bad way to do multitrack logic, pass the info in instead of going to the global - // and it is weird for Truncate to possibly not truncate - if (!Session.MultiTrack.IsActive) + if (frame < Log.Count) { - if (frame < Log.Count) - { - Log.RemoveRange(frame, Log.Count - frame); - Changes = true; - } + Log.RemoveRange(frame, Log.Count - frame); + Changes = true; } } diff --git a/src/BizHawk.Client.Common/movie/interfaces/IMovieController.cs b/src/BizHawk.Client.Common/movie/interfaces/IMovieController.cs index d6c2a278375..ed18577de18 100644 --- a/src/BizHawk.Client.Common/movie/interfaces/IMovieController.cs +++ b/src/BizHawk.Client.Common/movie/interfaces/IMovieController.cs @@ -9,11 +9,6 @@ public interface IMovieController : IController /// void SetFrom(IController source); - /// - /// Latches to only the buttons in the given for the given controller - /// - void SetPlayerFrom(IController playerSource, int controllerNum); - /// /// Latches to the given /// For buttons it latches autohold state, for analogs it latches mid value. diff --git a/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs b/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs index df96bf8ad35..6778d4d4e0d 100644 --- a/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs +++ b/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs @@ -21,7 +21,6 @@ public interface IMovieSession string QueuedSyncSettings { get; } IMovieController MovieController { get; } - MultitrackRecorder MultiTrack { get; } /// /// Provides a source for sticky controls ot use when recording @@ -69,8 +68,6 @@ public interface IMovieSession /// void RunQueuedMovie(bool recordMode, IEmulator emulator, IDictionary preferredCores); - void ToggleMultitrack(); - void StopMovie(bool saveChanges = true); /// diff --git a/src/BizHawk.Client.Common/movie/multitrack/ButtonNameParser.cs b/src/BizHawk.Client.Common/movie/multitrack/ButtonNameParser.cs deleted file mode 100644 index 946a8805328..00000000000 --- a/src/BizHawk.Client.Common/movie/multitrack/ButtonNameParser.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace BizHawk.Client.Common -{ - internal class ButtonNameParser - { - public static ButtonNameParser Parse(string button) - { - // See if we're being asked for a button that we know how to rewire - var parts = button.Split(' '); - - if (parts.Length < 2) - { - return null; - } - - if (parts[0][0] != 'P') - { - return null; - } - - if (!int.TryParse(parts[0].Substring(1), out var player)) - { - return null; - } - - return new ButtonNameParser - { - PlayerNum = player, - ButtonPart = button.Substring(parts[0].Length + 1) - }; - } - - public int PlayerNum { get; set; } - public string ButtonPart { get; private set; } - - public override string ToString() => $"P{PlayerNum} {ButtonPart}"; - } -} diff --git a/src/BizHawk.Client.Common/movie/multitrack/MultitrackRecorder.cs b/src/BizHawk.Client.Common/movie/multitrack/MultitrackRecorder.cs deleted file mode 100644 index 295284aaa1c..00000000000 --- a/src/BizHawk.Client.Common/movie/multitrack/MultitrackRecorder.cs +++ /dev/null @@ -1,83 +0,0 @@ -namespace BizHawk.Client.Common -{ - public class MultitrackRecorder - { - public MultitrackRecorder() - { - Restart(1); - } - - internal MultitrackRewiringControllerAdapter RewiringAdapter { get; } = new MultitrackRewiringControllerAdapter(); - - public bool IsActive { get; set; } - public int CurrentPlayer { get; private set; } - public int PlayerCount { get; private set; } - public bool RecordAll { get; private set; } - - /// - /// Gets a user friendly multi-track status - /// - public string Status - { - get - { - if (!IsActive) - { - return ""; - } - - if (RecordAll) - { - return "Recording All"; - } - - if (CurrentPlayer == 0) - { - return "Recording None"; - } - - return $"Recording Player {CurrentPlayer}"; - } - } - - public void Restart(int playerCount) - { - PlayerCount = playerCount; - IsActive = false; - CurrentPlayer = 0; - RecordAll = false; - } - - public void SelectAll() - { - CurrentPlayer = 0; - RecordAll = true; - } - - public void SelectNone() - { - RecordAll = false; - CurrentPlayer = 0; - } - - public void Increment() - { - RecordAll = false; - CurrentPlayer++; - if (CurrentPlayer > PlayerCount) - { - CurrentPlayer = 1; - } - } - - public void Decrement() - { - RecordAll = false; - CurrentPlayer--; - if (CurrentPlayer < 1) - { - CurrentPlayer = PlayerCount; - } - } - } -} diff --git a/src/BizHawk.Client.Common/movie/multitrack/MultitrackRewiringControllerAdapter.cs b/src/BizHawk.Client.Common/movie/multitrack/MultitrackRewiringControllerAdapter.cs deleted file mode 100644 index 7e4655345a9..00000000000 --- a/src/BizHawk.Client.Common/movie/multitrack/MultitrackRewiringControllerAdapter.cs +++ /dev/null @@ -1,55 +0,0 @@ -using BizHawk.Emulation.Common; - -namespace BizHawk.Client.Common -{ - /// - /// rewires player1 controls to playerN - /// - internal class MultitrackRewiringControllerAdapter : IInputAdapter - { - public IController Source { get; set; } - public int PlayerSource { get; set; } = -1; - public int PlayerTargetMask { get; set; } - - public ControllerDefinition Definition => Source.Definition; - - public bool IsPressed(string button) - { - return Source.IsPressed(RemapButtonName(button)); - } - - public int AxisValue(string name) - { - return Source.AxisValue(RemapButtonName(name)); - } - - private string RemapButtonName(string button) - { - // Do we even have a source? - if (PlayerSource == -1) - { - return button; - } - - // See if we're being asked for a button that we know how to rewire - var bnp = ButtonNameParser.Parse(button); - - if (bnp == null) - { - return button; - } - - // Ok, this looks like a normal `P1 Button` type thing. we can handle it - // Were we supposed to replace this one? - int foundPlayerMask = 1 << bnp.PlayerNum; - if ((PlayerTargetMask & foundPlayerMask) == 0) - { - return button; - } - - // Ok, we were. swap out the source player and then grab his button - bnp.PlayerNum = PlayerSource; - return bnp.ToString(); - } - } -} diff --git a/src/BizHawk.Client.EmuHawk/DisplayManager/OSDManager.cs b/src/BizHawk.Client.EmuHawk/DisplayManager/OSDManager.cs index df2e847b1ac..fee485cda7b 100644 --- a/src/BizHawk.Client.EmuHawk/DisplayManager/OSDManager.cs +++ b/src/BizHawk.Client.EmuHawk/DisplayManager/OSDManager.cs @@ -320,12 +320,6 @@ public void DrawScreenInfo(IBlitter g) } } - if (GlobalWin.MovieSession.MultiTrack.IsActive) - { - var point = GetCoordinates(g, GlobalWin.Config.MultitrackRecorder, GlobalWin.MovieSession.MultiTrack.Status); - DrawOsdMessage(g, GlobalWin.MovieSession.MultiTrack.Status, FixedMessagesColor, point.X, point.Y); - } - if (GlobalWin.Config.DisplayFps && Fps != null) { var point = GetCoordinates(g, GlobalWin.Config.Fps, Fps); diff --git a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs index 5c9058eed49..fa0eb2c7bfc 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -231,7 +231,6 @@ private void SaveRamSubMenu_DropDownOpened(object sender, EventArgs e) private void MovieSubMenu_DropDownOpened(object sender, EventArgs e) { - FullMovieLoadstatesMenuItem.Enabled = !MovieSession.MultiTrack.IsActive; StopMovieWithoutSavingMenuItem.Enabled = MovieSession.Movie.IsActive() && MovieSession.Movie.Changes; StopMovieMenuItem.Enabled = SaveMovieMenuItem.Enabled diff --git a/src/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs b/src/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs index bdaa25e747b..48dabcdfa23 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs @@ -299,21 +299,6 @@ private bool CheckHotkey(string trigger) case "Save Movie": SaveMovie(); break; - case "Toggle MultiTrack": - MovieSession.ToggleMultitrack(); - break; - case "MT Select All": - MovieSession.MultiTrack.SelectAll(); - break; - case "MT Select None": - MovieSession.MultiTrack.SelectNone(); - break; - case "MT Increment Player": - MovieSession.MultiTrack.Increment(); - break; - case "MT Decrement Player": - MovieSession.MultiTrack.Decrement(); - break; // Tools case "RAM Watch":