From a8b0d42a1aa2857edcf1f475730b2b6c9bbf7a06 Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 2 Jun 2020 17:18:39 -0500 Subject: [PATCH] pass in PreferredCores into MovieSession to manage the core switcheroo, instead of using Global.Config --- src/BizHawk.Client.Common/movie/MovieSession.cs | 16 ++++++++-------- .../movie/interfaces/IMovieSession.cs | 7 ++++--- src/BizHawk.Client.EmuHawk/MainForm.Movie.cs | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/BizHawk.Client.Common/movie/MovieSession.cs b/src/BizHawk.Client.Common/movie/MovieSession.cs index b81e386a9b..7ef28a0c31 100644 --- a/src/BizHawk.Client.Common/movie/MovieSession.cs +++ b/src/BizHawk.Client.Common/movie/MovieSession.cs @@ -227,7 +227,7 @@ namespace BizHawk.Client.Common } /// is and . does not match . - public void QueueNewMovie(IMovie movie, bool record, string systemId) + public void QueueNewMovie(IMovie movie, bool record, string systemId, IDictionary preferredCores) { if (movie.IsActive() && movie.Changes) { @@ -251,20 +251,20 @@ namespace BizHawk.Client.Common if (!record) { - if (Global.Config.PreferredCores.ContainsKey(systemId)) + if (preferredCores.ContainsKey(systemId)) { - string movieCore = Global.Config.PreferredCores[systemId]; + string movieCore = preferredCores[systemId]; if (string.IsNullOrWhiteSpace(movie.Core)) { - PopupMessage($"No core specified in the movie file, using the preferred core {Global.Config.PreferredCores[systemId]} instead."); + PopupMessage($"No core specified in the movie file, using the preferred core {preferredCores[systemId]} instead."); } else { movieCore = movie.Core; } - _preferredCores[systemId] = Global.Config.PreferredCores[systemId]; - Global.Config.PreferredCores[systemId] = movieCore; + _preferredCores[systemId] = preferredCores[systemId]; + preferredCores[systemId] = movieCore; } } @@ -280,12 +280,12 @@ namespace BizHawk.Client.Common _queuedMovie = movie; } - public void RunQueuedMovie(bool recordMode, IEmulator emulator) + public void RunQueuedMovie(bool recordMode, IEmulator emulator, IDictionary preferredCores) { _queuedMovie.Attach(this, emulator); foreach (var previousPref in _preferredCores) { - Global.Config.PreferredCores[previousPref.Key] = previousPref.Value; + preferredCores[previousPref.Key] = previousPref.Value; } Movie = _queuedMovie; diff --git a/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs b/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs index f97ae43240..3595e00a2d 100644 --- a/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs +++ b/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs @@ -1,4 +1,5 @@ -using System.IO; +using System.Collections.Generic; +using System.IO; using BizHawk.Emulation.Common; namespace BizHawk.Client.Common @@ -54,12 +55,12 @@ namespace BizHawk.Client.Common /// When initializing a movie, it will be stored until Rom loading processes have been completed, then it will be moved to the Movie property /// If an existing movie is still active, it will remain in the Movie property while the new movie is queued /// - void QueueNewMovie(IMovie movie, bool record, string systemId); + void QueueNewMovie(IMovie movie, bool record, string systemId, IDictionary preferredCores); /// /// Sets the Movie property with the QueuedMovie, clears the queued movie, and starts the new movie /// - void RunQueuedMovie(bool recordMode, IEmulator emulator); + void RunQueuedMovie(bool recordMode, IEmulator emulator, IDictionary preferredCores); void ToggleMultitrack(); diff --git a/src/BizHawk.Client.EmuHawk/MainForm.Movie.cs b/src/BizHawk.Client.EmuHawk/MainForm.Movie.cs index 65980eb420..26a64cacaf 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.Movie.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.Movie.cs @@ -17,7 +17,7 @@ namespace BizHawk.Client.EmuHawk try { - MovieSession.QueueNewMovie(movie, record, Emulator.SystemId); + MovieSession.QueueNewMovie(movie, record, Emulator.SystemId, Config.PreferredCores); } catch (MoviePlatformMismatchException ex) { @@ -30,7 +30,7 @@ namespace BizHawk.Client.EmuHawk Config.RecentMovies.Add(movie.Filename); - MovieSession.RunQueuedMovie(record, Emulator); + MovieSession.RunQueuedMovie(record, Emulator, Config.PreferredCores); SetMainformMovieInfo();