From fa552cab813baa0e17b581c24be96dc74e88b22f Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 18 Apr 2020 12:05:16 -0500 Subject: [PATCH] restrict access to IMovieSession.QueuedMovie --- BizHawk.Client.Common/movie/MovieSession.cs | 13 +++++++------ .../movie/interfaces/IMovieSession.cs | 18 ++++++++++-------- BizHawk.Client.EmuHawk/MainForm.cs | 4 ++-- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/BizHawk.Client.Common/movie/MovieSession.cs b/BizHawk.Client.Common/movie/MovieSession.cs index 5070077eff..7a50f64619 100644 --- a/BizHawk.Client.Common/movie/MovieSession.cs +++ b/BizHawk.Client.Common/movie/MovieSession.cs @@ -16,6 +16,8 @@ namespace BizHawk.Client.Common private readonly Action _messageCallback; private readonly Action _popupCallback; + private IMovie _queuedMovie; + // Previous saved core preferences. Stored here so that when a movie // overrides the values, they can be restored to user preferences private readonly IDictionary _preferredCores = new Dictionary(); @@ -37,10 +39,9 @@ namespace BizHawk.Client.Common } public IMovie Movie { get; set; } - public IMovie QueuedMovie { get; private set; } - - public bool MovieIsQueued => QueuedMovie != null; public bool ReadOnly { get; set; } = true; + public bool MovieIsQueued => _queuedMovie != null; + public string QueuedSyncSettings => _queuedMovie.SyncSettingsJson; public IMovieController MovieController { get; set; } = new Bk2Controller("", NullController.Instance.Definition); @@ -274,7 +275,7 @@ namespace BizHawk.Client.Common movie.SwitchToPlay(); } - QueuedMovie = movie; + _queuedMovie = movie; } public void RunQueuedMovie(bool recordMode) @@ -284,8 +285,8 @@ namespace BizHawk.Client.Common Global.Config.PreferredCores[previousPref.Key] = previousPref.Value; } - Movie = QueuedMovie; - QueuedMovie = null; + Movie = _queuedMovie; + _queuedMovie = null; MultiTrack.Restart(Global.Emulator.ControllerDefinition.PlayerCount); Movie.ProcessSavestate(Global.Emulator); diff --git a/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs b/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs index 9a03ecddc3..c87c3dccc0 100644 --- a/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs +++ b/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs @@ -6,17 +6,14 @@ namespace BizHawk.Client.Common public interface IMovieSession { IMovie Movie { get; set; } - - /// - /// Gets the queued movie - /// When initializing a movie, it will be stored here until Rom 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 - /// - IMovie QueuedMovie { get; } + bool ReadOnly { get; set; } bool MovieIsQueued { get; } - bool ReadOnly { get; set; } + /// + /// Gets the sync settings from a queued movie, if a movie is queued + /// + string QueuedSyncSettings { get; } IMovieController MovieController { get; } MultitrackRecorder MultiTrack { get; } @@ -49,6 +46,11 @@ namespace BizHawk.Client.Common bool CheckSavestateTimeline(TextReader reader); bool HandleLoadState(TextReader reader); + /// + /// Queues up a movie for loading + /// 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, IEmulator emulator); /// diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index 9a184c7f8b..2cc6073134 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -2271,9 +2271,9 @@ namespace BizHawk.Client.EmuHawk { if (MovieSession.MovieIsQueued) { - if (!string.IsNullOrWhiteSpace(MovieSession.QueuedMovie.SyncSettingsJson)) + if (!string.IsNullOrWhiteSpace(MovieSession.QueuedSyncSettings)) { - e.Settings = ConfigService.LoadWithType(MovieSession.QueuedMovie.SyncSettingsJson); + e.Settings = ConfigService.LoadWithType(MovieSession.QueuedSyncSettings); } else {