From d8ded66c3579d1e28bfdf6b5abcdfb210e48841f Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 6 Jun 2020 14:29:33 -0500 Subject: [PATCH] don't use Global.Config in bk2movies, this solution is a bit of shenanigans but it's the least shenanigans I could come up with --- src/BizHawk.Client.Common/movie/MovieSession.cs | 4 ++++ src/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs | 3 +-- src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs | 2 ++ src/BizHawk.Client.EmuHawk/MainForm.cs | 5 +++-- src/BizHawk.Client.EmuHawk/config/PathConfig.cs | 2 ++ 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/BizHawk.Client.Common/movie/MovieSession.cs b/src/BizHawk.Client.Common/movie/MovieSession.cs index b29aa5105e..5ff58ba290 100644 --- a/src/BizHawk.Client.Common/movie/MovieSession.cs +++ b/src/BizHawk.Client.Common/movie/MovieSession.cs @@ -25,12 +25,14 @@ namespace BizHawk.Client.Common public MovieSession( IMovieConfig settings, + string backDirectory, Action messageCallback, Action popupCallback, Action pauseCallback, Action modeChangedCallback) { Settings = settings; + BackupDirectory = backDirectory; _messageCallback = messageCallback; _popupCallback = popupCallback; _pauseCallback = pauseCallback @@ -41,6 +43,8 @@ namespace BizHawk.Client.Common public IMovieConfig Settings { get; } + public string BackupDirectory { get; set; } + public IMovie Movie { get; private set; } public bool ReadOnly { get; set; } = true; public bool NewMovieQueued => _queuedMovie != null; diff --git a/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs b/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs index 6a17cb2bac..890477e6de 100644 --- a/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs +++ b/src/BizHawk.Client.Common/movie/bk2/Bk2Movie.IO.cs @@ -20,10 +20,9 @@ namespace BizHawk.Client.Common return; } - var backupDir = Global.Config.PathEntries.MovieBackupsAbsolutePath(); var backupName = Filename; backupName = backupName.Insert(Filename.LastIndexOf("."), $".{DateTime.Now:yyyy-MM-dd HH.mm.ss}"); - backupName = Path.Combine(backupDir, Path.GetFileName(backupName)); + backupName = Path.Combine(Session.BackupDirectory, Path.GetFileName(backupName)); Write(backupName, isBackup: true); } diff --git a/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs b/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs index c854d49101..6f9445572b 100644 --- a/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs +++ b/src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs @@ -66,5 +66,7 @@ namespace BizHawk.Client.Common void ConvertToTasProj(); IMovie Get(string path); + + string BackupDirectory { get; set; } } } diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index feda49ab8c..517a70ace7 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -282,6 +282,7 @@ namespace BizHawk.Client.EmuHawk Global.FirmwareManager = new FirmwareManager(); MovieSession = new MovieSession( Config.Movies, + Config.PathEntries.MovieBackupsAbsolutePath(), AddOnScreenMessage, ShowMessageCoreComm, PauseEmulator, @@ -881,10 +882,10 @@ namespace BizHawk.Client.EmuHawk private ToolManager Tools => GlobalWin.Tools; private DisplayManager DisplayManager => GlobalWin.DisplayManager; - private IMovieSession MovieSession + public IMovieSession MovieSession { get => Global. MovieSession; - set => Global.MovieSession = value; + private set => Global.MovieSession = value; } private GameInfo Game diff --git a/src/BizHawk.Client.EmuHawk/config/PathConfig.cs b/src/BizHawk.Client.EmuHawk/config/PathConfig.cs index 36b6e5d54e..4672aa51aa 100644 --- a/src/BizHawk.Client.EmuHawk/config/PathConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/PathConfig.cs @@ -254,6 +254,8 @@ namespace BizHawk.Client.EmuHawk var pathEntry = _config.PathEntries.First(p => p.System == t.Parent.Name && p.Type == t.Name); pathEntry.Path = t.Text; } + + _mainForm.MovieSession.BackupDirectory = _config.PathEntries.MovieBackupsAbsolutePath(); } private void DoRomToggle()