restrict access to IMovieSession.QueuedMovie

This commit is contained in:
adelikat 2020-04-18 12:05:16 -05:00
parent dc9fa1acf3
commit fa552cab81
3 changed files with 19 additions and 16 deletions

View File

@ -16,6 +16,8 @@ namespace BizHawk.Client.Common
private readonly Action<string> _messageCallback; private readonly Action<string> _messageCallback;
private readonly Action<string> _popupCallback; private readonly Action<string> _popupCallback;
private IMovie _queuedMovie;
// Previous saved core preferences. Stored here so that when a movie // Previous saved core preferences. Stored here so that when a movie
// overrides the values, they can be restored to user preferences // overrides the values, they can be restored to user preferences
private readonly IDictionary<string, string> _preferredCores = new Dictionary<string, string>(); private readonly IDictionary<string, string> _preferredCores = new Dictionary<string, string>();
@ -37,10 +39,9 @@ namespace BizHawk.Client.Common
} }
public IMovie Movie { get; set; } public IMovie Movie { get; set; }
public IMovie QueuedMovie { get; private set; }
public bool MovieIsQueued => QueuedMovie != null;
public bool ReadOnly { get; set; } = true; 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); public IMovieController MovieController { get; set; } = new Bk2Controller("", NullController.Instance.Definition);
@ -274,7 +275,7 @@ namespace BizHawk.Client.Common
movie.SwitchToPlay(); movie.SwitchToPlay();
} }
QueuedMovie = movie; _queuedMovie = movie;
} }
public void RunQueuedMovie(bool recordMode) public void RunQueuedMovie(bool recordMode)
@ -284,8 +285,8 @@ namespace BizHawk.Client.Common
Global.Config.PreferredCores[previousPref.Key] = previousPref.Value; Global.Config.PreferredCores[previousPref.Key] = previousPref.Value;
} }
Movie = QueuedMovie; Movie = _queuedMovie;
QueuedMovie = null; _queuedMovie = null;
MultiTrack.Restart(Global.Emulator.ControllerDefinition.PlayerCount); MultiTrack.Restart(Global.Emulator.ControllerDefinition.PlayerCount);
Movie.ProcessSavestate(Global.Emulator); Movie.ProcessSavestate(Global.Emulator);

View File

@ -6,17 +6,14 @@ namespace BizHawk.Client.Common
public interface IMovieSession public interface IMovieSession
{ {
IMovie Movie { get; set; } IMovie Movie { get; set; }
bool ReadOnly { get; set; }
/// <summary>
/// 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
/// </summary>
IMovie QueuedMovie { get; }
bool MovieIsQueued { get; } bool MovieIsQueued { get; }
bool ReadOnly { get; set; } /// <summary>
/// Gets the sync settings from a queued movie, if a movie is queued
/// </summary>
string QueuedSyncSettings { get; }
IMovieController MovieController { get; } IMovieController MovieController { get; }
MultitrackRecorder MultiTrack { get; } MultitrackRecorder MultiTrack { get; }
@ -49,6 +46,11 @@ namespace BizHawk.Client.Common
bool CheckSavestateTimeline(TextReader reader); bool CheckSavestateTimeline(TextReader reader);
bool HandleLoadState(TextReader reader); bool HandleLoadState(TextReader reader);
/// <summary>
/// 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
/// </summary>
void QueueNewMovie(IMovie movie, bool record, IEmulator emulator); void QueueNewMovie(IMovie movie, bool record, IEmulator emulator);
/// <summary> /// <summary>

View File

@ -2271,9 +2271,9 @@ namespace BizHawk.Client.EmuHawk
{ {
if (MovieSession.MovieIsQueued) 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 else
{ {