Replace direct `CoreComm` usage in `RomLoader` w/ `IDialogParent`
resolves #4208
partially reverts ddd14d527
This commit is contained in:
parent
c0f93b05fc
commit
bba93b33d6
|
@ -58,11 +58,17 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
private readonly Config _config;
|
private readonly Config _config;
|
||||||
|
|
||||||
public RomLoader(Config config)
|
private readonly IDialogParent _dialogParent;
|
||||||
|
|
||||||
|
public RomLoader(Config config, IDialogParent dialogParent)
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config;
|
||||||
|
_dialogParent = dialogParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool? Question(string text)
|
||||||
|
=> _dialogParent.ModalMessageBox3(icon: EMsgBoxIcon.Question, caption: "ROM loader", text: text);
|
||||||
|
|
||||||
public enum LoadErrorType
|
public enum LoadErrorType
|
||||||
{
|
{
|
||||||
Unknown,
|
Unknown,
|
||||||
|
@ -591,7 +597,7 @@ namespace BizHawk.Client.Common
|
||||||
HawkFile hfMatching = new(binFilePath.RemoveSuffix(".bin") + ".cue");
|
HawkFile hfMatching = new(binFilePath.RemoveSuffix(".bin") + ".cue");
|
||||||
if (hfMatching.Exists)
|
if (hfMatching.Exists)
|
||||||
{
|
{
|
||||||
var result = nextComm.Question(string.Format(FMT_STR_ASK, hfMatching.Name));
|
var result = Question(string.Format(FMT_STR_ASK, hfMatching.Name));
|
||||||
if (result is null)
|
if (result is null)
|
||||||
{
|
{
|
||||||
cancel = true;
|
cancel = true;
|
||||||
|
@ -612,7 +618,7 @@ namespace BizHawk.Client.Common
|
||||||
HawkFile hfSoleSibling = soleCueSiblingPath is null ? null : new(soleCueSiblingPath);
|
HawkFile hfSoleSibling = soleCueSiblingPath is null ? null : new(soleCueSiblingPath);
|
||||||
if (hfSoleSibling is { Exists: true })
|
if (hfSoleSibling is { Exists: true })
|
||||||
{
|
{
|
||||||
var result = nextComm.Question(string.Format(FMT_STR_ASK, hfSoleSibling.Name));
|
var result = Question(string.Format(FMT_STR_ASK, hfSoleSibling.Name));
|
||||||
if (result is null)
|
if (result is null)
|
||||||
{
|
{
|
||||||
cancel = true;
|
cancel = true;
|
||||||
|
|
|
@ -306,7 +306,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return new CoreComm(
|
return new CoreComm(
|
||||||
message => this.ModalMessageBox(message, "Warning", EMsgBoxIcon.Warning),
|
message => this.ModalMessageBox(message, "Warning", EMsgBoxIcon.Warning),
|
||||||
AddOnScreenMessage,
|
AddOnScreenMessage,
|
||||||
text => this.ModalMessageBox3(icon: EMsgBoxIcon.Question, caption: "ROM loader", text: text),
|
|
||||||
cfp,
|
cfp,
|
||||||
prefs,
|
prefs,
|
||||||
new OpenGLProvider());
|
new OpenGLProvider());
|
||||||
|
@ -3773,7 +3772,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var loader = new RomLoader(Config)
|
var loader = new RomLoader(Config, this)
|
||||||
{
|
{
|
||||||
ChooseArchive = LoadArchiveChooser,
|
ChooseArchive = LoadArchiveChooser,
|
||||||
ChoosePlatform = ChoosePlatformForRom,
|
ChoosePlatform = ChoosePlatformForRom,
|
||||||
|
|
|
@ -94,7 +94,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var pp = (Tuple<int, List<string>>)o;
|
var pp = (Tuple<int, List<string>>)o;
|
||||||
BatchRunner br = new BatchRunner(_config, _createCoreComm(), pp.Item2, pp.Item1);
|
BatchRunner br = new(_createCoreComm(), _config, this, pp.Item2, pp.Item1);
|
||||||
br.OnProgress += BrOnProgress;
|
br.OnProgress += BrOnProgress;
|
||||||
var results = br.Run();
|
var results = br.Run();
|
||||||
this.Invoke(() => { label3.Text = "Status: Finished!"; _mostRecentResults = results; });
|
this.Invoke(() => { label3.Text = "Status: Finished!"; _mostRecentResults = results; });
|
||||||
|
|
|
@ -63,12 +63,17 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BatchRunner(Config config, CoreComm comm, IEnumerable<string> files, int numFrames)
|
public BatchRunner(
|
||||||
|
CoreComm comm,
|
||||||
|
Config config,
|
||||||
|
IDialogParent dialogParent,
|
||||||
|
IEnumerable<string> files,
|
||||||
|
int numFrames)
|
||||||
{
|
{
|
||||||
_files = new List<string>(files);
|
_files = new List<string>(files);
|
||||||
_numFrames = numFrames;
|
_numFrames = numFrames;
|
||||||
|
|
||||||
_ldr = new RomLoader(config);
|
_ldr = new RomLoader(config, dialogParent);
|
||||||
_ldr.OnLoadError += OnLoadError;
|
_ldr.OnLoadError += OnLoadError;
|
||||||
_ldr.ChooseArchive = ChooseArchive;
|
_ldr.ChooseArchive = ChooseArchive;
|
||||||
_comm = comm;
|
_comm = comm;
|
||||||
|
|
|
@ -8,12 +8,9 @@ namespace BizHawk.Emulation.Common
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CoreComm
|
public class CoreComm
|
||||||
{
|
{
|
||||||
public readonly Func<string, bool?> Question;
|
|
||||||
|
|
||||||
public CoreComm(
|
public CoreComm(
|
||||||
Action<string> showMessage,
|
Action<string> showMessage,
|
||||||
Action<string, int?> notifyMessage,
|
Action<string, int?> notifyMessage,
|
||||||
Func<string, bool?> question,
|
|
||||||
ICoreFileProvider coreFileProvider,
|
ICoreFileProvider coreFileProvider,
|
||||||
CorePreferencesFlags prefs,
|
CorePreferencesFlags prefs,
|
||||||
IOpenGLProvider oglProvider
|
IOpenGLProvider oglProvider
|
||||||
|
@ -21,7 +18,6 @@ namespace BizHawk.Emulation.Common
|
||||||
{
|
{
|
||||||
ShowMessage = showMessage;
|
ShowMessage = showMessage;
|
||||||
Notify = notifyMessage;
|
Notify = notifyMessage;
|
||||||
Question = question;
|
|
||||||
CoreFileProvider = coreFileProvider;
|
CoreFileProvider = coreFileProvider;
|
||||||
CorePreferences = prefs;
|
CorePreferences = prefs;
|
||||||
OpenGLProvider = oglProvider;
|
OpenGLProvider = oglProvider;
|
||||||
|
|
Loading…
Reference in New Issue