refactor importers to pass in a config instance, instead of using Global.Config
This commit is contained in:
parent
ade678487a
commit
8c852c1b70
|
@ -7,7 +7,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public interface IMovieImport
|
||||
{
|
||||
ImportResult Import(string path);
|
||||
ImportResult Import(string path, Config config);
|
||||
}
|
||||
|
||||
internal abstract class MovieImporter : IMovieImport
|
||||
|
@ -16,9 +16,10 @@ namespace BizHawk.Client.Common
|
|||
protected const string Md5 = "MD5";
|
||||
protected const string MovieOrigin = "MovieOrigin";
|
||||
|
||||
public ImportResult Import(string path)
|
||||
public ImportResult Import(string path, Config config)
|
||||
{
|
||||
SourceFile = new FileInfo(path);
|
||||
Config = config;
|
||||
|
||||
if (!SourceFile.Exists)
|
||||
{
|
||||
|
@ -39,6 +40,8 @@ namespace BizHawk.Client.Common
|
|||
return Result;
|
||||
}
|
||||
|
||||
protected Config Config { get; private set; }
|
||||
|
||||
protected ImportResult Result { get; } = new ImportResult();
|
||||
|
||||
protected FileInfo SourceFile { get; private set; }
|
||||
|
|
|
@ -115,7 +115,7 @@ namespace BizHawk.Client.Common.movie.import
|
|||
case "sgb_ntsc":
|
||||
case "sgb_pal":
|
||||
platform = "SNES";
|
||||
Global.Config.GbAsSgb = true;
|
||||
Config.GbAsSgb = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ namespace BizHawk.Client.Common.movie.import
|
|||
|
||||
Result.Movie.HeaderEntries[HeaderKeys.Platform] = platform;
|
||||
Result.Movie.SyncSettingsJson = ConfigService.SaveWithType(ss);
|
||||
Global.Config.SnesInSnes9x = false; // This could be annoying to a user if they don't notice we set this preference, but the alternative is for the movie import to fail to load the movie
|
||||
Config.SnesInSnes9x = false; // TODO: convert to snes9x if user has set this to true
|
||||
}
|
||||
|
||||
private IController EmptyLmsvFrame()
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace BizHawk.Client.Common
|
|||
);
|
||||
|
||||
// Attempt to import another type of movie file into a movie object.
|
||||
public static ImportResult ImportFile(string path)
|
||||
public static ImportResult ImportFile(string path, Config config)
|
||||
{
|
||||
string ext = Path.GetExtension(path) ?? "";
|
||||
var importerType = ImporterForExtension(ext);
|
||||
|
@ -47,7 +47,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
return importer == null
|
||||
? ImportResult.Error($"No importer found for file type {ext}")
|
||||
: importer.Import(path);
|
||||
: importer.Import(path, config);
|
||||
}
|
||||
|
||||
private static Type ImporterForExtension(string ext)
|
||||
|
|
|
@ -313,7 +313,7 @@ namespace BizHawk.Client.Common.movie.import
|
|||
Result.Movie.AppendFrame(controllers);
|
||||
|
||||
Result.Movie.SyncSettingsJson = ConfigService.SaveWithType(ss);
|
||||
Global.Config.SnesInSnes9x = false;
|
||||
Config.SnesInSnes9x = false; // TODO: convert to snes9x if user has set this to true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,13 +274,13 @@ namespace BizHawk.Client.Common.movie.import
|
|||
|
||||
if (isGBA)
|
||||
{
|
||||
Global.Config.GbaUsemGba = true;
|
||||
Config.GbaUsemGba = true;
|
||||
var ss = new MGBAHawk.SyncSettings { SkipBios = true };
|
||||
Result.Movie.SyncSettingsJson = ConfigService.SaveWithType(ss);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Global.Config.GbUseGbHawk || Global.Config.UseSubGBHawk)
|
||||
if (Config.GbUseGbHawk || Config.UseSubGBHawk)
|
||||
{
|
||||
var tempSync = new GBHawk.GBSyncSettings();
|
||||
if (is_GBC) { tempSync.ConsoleMode = GBHawk.GBSyncSettings.ConsoleModeType.GBC; }
|
||||
|
|
|
@ -3976,7 +3976,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void ProcessMovieImport(string fn, bool start)
|
||||
{
|
||||
var result = MovieImport.ImportFile(fn);
|
||||
var result = MovieImport.ImportFile(fn, Config);
|
||||
|
||||
if (result.Errors.Any())
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue