pass in PreferredCores into MovieSession to manage the core switcheroo, instead of using Global.Config

This commit is contained in:
adelikat 2020-06-02 17:18:39 -05:00
parent 2dda13cdd1
commit a8b0d42a1a
3 changed files with 14 additions and 13 deletions

View File

@ -227,7 +227,7 @@ namespace BizHawk.Client.Common
}
/// <exception cref="MoviePlatformMismatchException"><paramref name="record"/> is <see langword="false"/> and <paramref name="movie"/>.<see cref="IMovie.SystemID"/> does not match <paramref name="systemId"/>.<see cref="IEmulator.SystemId"/></exception>
public void QueueNewMovie(IMovie movie, bool record, string systemId)
public void QueueNewMovie(IMovie movie, bool record, string systemId, IDictionary<string, string> 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<string, string> preferredCores)
{
_queuedMovie.Attach(this, emulator);
foreach (var previousPref in _preferredCores)
{
Global.Config.PreferredCores[previousPref.Key] = previousPref.Value;
preferredCores[previousPref.Key] = previousPref.Value;
}
Movie = _queuedMovie;

View File

@ -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
/// </summary>
void QueueNewMovie(IMovie movie, bool record, string systemId);
void QueueNewMovie(IMovie movie, bool record, string systemId, IDictionary<string, string> preferredCores);
/// <summary>
/// Sets the Movie property with the QueuedMovie, clears the queued movie, and starts the new movie
/// </summary>
void RunQueuedMovie(bool recordMode, IEmulator emulator);
void RunQueuedMovie(bool recordMode, IEmulator emulator, IDictionary<string, string> preferredCores);
void ToggleMultitrack();

View File

@ -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();