Add ctors to `LoadRomArgs` and `OpenAdvanced_OpenRom`
This commit is contained in:
parent
12310befff
commit
a1aaabe8d5
|
@ -140,7 +140,7 @@ namespace BizHawk.Client.Common
|
||||||
suppressOSD: false);
|
suppressOSD: false);
|
||||||
|
|
||||||
public bool OpenRom(string path)
|
public bool OpenRom(string path)
|
||||||
=> _mainForm.LoadRom(path, new LoadRomArgs { OpenAdvanced = new OpenAdvanced_OpenRom { Path = path } });
|
=> _mainForm.LoadRom(path, new LoadRomArgs(new OpenAdvanced_OpenRom(path)));
|
||||||
|
|
||||||
public void Pause() => _mainForm.PauseEmulator();
|
public void Pause() => _mainForm.PauseEmulator();
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
namespace BizHawk.Client.Common
|
namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
public class LoadRomArgs
|
public sealed class LoadRomArgs(IOpenAdvanced ioa, bool? deterministic = null)
|
||||||
{
|
{
|
||||||
public bool? Deterministic { get; set; }
|
public readonly bool? Deterministic = deterministic;
|
||||||
public IOpenAdvanced OpenAdvanced { get; set; }
|
|
||||||
|
public readonly IOpenAdvanced OpenAdvanced = ioa;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
return text.StartsWith('*')
|
return text.StartsWith('*')
|
||||||
? Deserialize(text.Substring(1))
|
? Deserialize(text.Substring(1))
|
||||||
: new OpenAdvanced_OpenRom { Path = text };
|
: new OpenAdvanced_OpenRom(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IOpenAdvanced Deserialize(string text)
|
private static IOpenAdvanced Deserialize(string text)
|
||||||
|
@ -151,6 +151,12 @@ namespace BizHawk.Client.Common
|
||||||
public string DisplayName => Path;
|
public string DisplayName => Path;
|
||||||
public string SimplePath => Path;
|
public string SimplePath => Path;
|
||||||
|
|
||||||
|
public OpenAdvanced_OpenRom() {}
|
||||||
|
|
||||||
|
public OpenAdvanced_OpenRom(string path)
|
||||||
|
: this()
|
||||||
|
=> Path = path;
|
||||||
|
|
||||||
public void Deserialize(string str)
|
public void Deserialize(string str)
|
||||||
{
|
{
|
||||||
Path = str;
|
Path = str;
|
||||||
|
|
|
@ -239,30 +239,25 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
if (oac.Result == AdvancedRomLoaderType.LibretroLaunchNoGame)
|
if (oac.Result == AdvancedRomLoaderType.LibretroLaunchNoGame)
|
||||||
{
|
{
|
||||||
var argsNoGame = new LoadRomArgs
|
_ = LoadRom(string.Empty, new LoadRomArgs(new OpenAdvanced_LibretroNoGame(Config.LibretroCore)));
|
||||||
{
|
|
||||||
OpenAdvanced = new OpenAdvanced_LibretroNoGame(Config.LibretroCore)
|
|
||||||
};
|
|
||||||
_ = LoadRom(string.Empty, argsNoGame);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var args = new LoadRomArgs();
|
IOpenAdvanced ioa;
|
||||||
|
FilesystemFilterSet filter;
|
||||||
var filter = RomLoader.RomFilter;
|
|
||||||
|
|
||||||
if (oac.Result == AdvancedRomLoaderType.LibretroLaunchGame)
|
if (oac.Result == AdvancedRomLoaderType.LibretroLaunchGame)
|
||||||
{
|
{
|
||||||
args.OpenAdvanced = new OpenAdvanced_Libretro();
|
ioa = new OpenAdvanced_Libretro();
|
||||||
filter = oac.SuggestedExtensionFilter!;
|
filter = oac.SuggestedExtensionFilter!;
|
||||||
}
|
}
|
||||||
else if (oac.Result == AdvancedRomLoaderType.ClassicLaunchGame)
|
else if (oac.Result == AdvancedRomLoaderType.ClassicLaunchGame)
|
||||||
{
|
{
|
||||||
args.OpenAdvanced = new OpenAdvanced_OpenRom();
|
ioa = new OpenAdvanced_OpenRom();
|
||||||
|
filter = RomLoader.RomFilter;
|
||||||
}
|
}
|
||||||
else if (oac.Result == AdvancedRomLoaderType.MameLaunchGame)
|
else if (oac.Result == AdvancedRomLoaderType.MameLaunchGame)
|
||||||
{
|
{
|
||||||
args.OpenAdvanced = new OpenAdvanced_MAME();
|
ioa = new OpenAdvanced_MAME();
|
||||||
filter = MAMERomsFSFilterSet;
|
filter = MAMERomsFSFilterSet;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -277,7 +272,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (result is null) return;
|
if (result is null) return;
|
||||||
FileInfo file = new(result);
|
FileInfo file = new(result);
|
||||||
Config.PathEntries.LastRomPath = file.DirectoryName;
|
Config.PathEntries.LastRomPath = file.DirectoryName;
|
||||||
_ = LoadRom(file.FullName, args);
|
_ = LoadRom(file.FullName, new LoadRomArgs(ioa));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CloseRomMenuItem_Click(object sender, EventArgs e)
|
private void CloseRomMenuItem_Click(object sender, EventArgs e)
|
||||||
|
|
|
@ -97,13 +97,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool LoadRom(string filename, string archive = null)
|
private bool LoadRom(string filename, string archive = null)
|
||||||
{
|
=> LoadRom(filename, new LoadRomArgs(new OpenAdvanced_OpenRom(filename)));
|
||||||
var args = new LoadRomArgs
|
|
||||||
{
|
|
||||||
OpenAdvanced = new OpenAdvanced_OpenRom {Path = filename}
|
|
||||||
};
|
|
||||||
return LoadRom(filename, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool LoadStateFile(string filename, string archive = null)
|
private bool LoadStateFile(string filename, string archive = null)
|
||||||
=> LoadState(path: filename, userFriendlyStateName: Path.GetFileName(filename));
|
=> LoadState(path: filename, userFriendlyStateName: Path.GetFileName(filename));
|
||||||
|
|
|
@ -629,9 +629,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (_argParser.cmdRom != null)
|
if (_argParser.cmdRom != null)
|
||||||
{
|
{
|
||||||
// Commandline should always override auto-load
|
// Commandline should always override auto-load
|
||||||
OpenAdvanced_OpenRom ioa = new() { Path = _argParser.cmdRom };
|
OpenAdvanced_OpenRom ioa = new(_argParser.cmdRom);
|
||||||
if (ioa is OpenAdvanced_OpenRom oaor) ioa = new OpenAdvanced_OpenRom { Path = oaor.Path.MakeAbsolute() }; // fixes #3224; should this be done for all the IOpenAdvanced types? --yoshi
|
if (ioa is OpenAdvanced_OpenRom oaor) ioa = new(oaor.Path.MakeAbsolute()); // fixes #3224; should this be done for all the IOpenAdvanced types? --yoshi
|
||||||
_ = LoadRom(ioa.SimplePath, new LoadRomArgs { OpenAdvanced = ioa });
|
_ = LoadRom(ioa.SimplePath, new LoadRomArgs(ioa));
|
||||||
if (Game.IsNullInstance())
|
if (Game.IsNullInstance())
|
||||||
{
|
{
|
||||||
ShowMessageBox(owner: null, $"Failed to load {_argParser.cmdRom} specified on commandline");
|
ShowMessageBox(owner: null, $"Failed to load {_argParser.cmdRom} specified on commandline");
|
||||||
|
@ -2077,15 +2077,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
var ioa = OpenAdvancedSerializer.ParseWithLegacy(rom);
|
var ioa = OpenAdvancedSerializer.ParseWithLegacy(rom);
|
||||||
|
|
||||||
var args = new LoadRomArgs
|
|
||||||
{
|
|
||||||
OpenAdvanced = ioa
|
|
||||||
};
|
|
||||||
|
|
||||||
// if(ioa is this or that) - for more complex behaviour
|
// if(ioa is this or that) - for more complex behaviour
|
||||||
string romPath = ioa.SimplePath;
|
string romPath = ioa.SimplePath;
|
||||||
|
|
||||||
if (!LoadRom(romPath, args, out var failureIsFromAskSave))
|
if (!LoadRom(romPath, new LoadRomArgs(ioa), out var failureIsFromAskSave))
|
||||||
{
|
{
|
||||||
if (failureIsFromAskSave) AddOnScreenMessage("ROM loading cancelled; a tool had unsaved changes");
|
if (failureIsFromAskSave) AddOnScreenMessage("ROM loading cancelled; a tool had unsaved changes");
|
||||||
else if (ioa is OpenAdvanced_LibretroNoGame || File.Exists(romPath)) AddOnScreenMessage("ROM loading failed");
|
else if (ioa is OpenAdvanced_LibretroNoGame || File.Exists(romPath)) AddOnScreenMessage("ROM loading failed");
|
||||||
|
@ -2320,7 +2315,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
initDir: Config.PathEntries.RomAbsolutePath(Emulator.SystemId));
|
initDir: Config.PathEntries.RomAbsolutePath(Emulator.SystemId));
|
||||||
if (result is null) return;
|
if (result is null) return;
|
||||||
var filePath = new FileInfo(result).FullName;
|
var filePath = new FileInfo(result).FullName;
|
||||||
_ = LoadRom(filePath, new LoadRomArgs { OpenAdvanced = new OpenAdvanced_OpenRom { Path = filePath } });
|
_ = LoadRom(filePath, new LoadRomArgs(new OpenAdvanced_OpenRom(filePath)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CoreSyncSettings(object sender, RomLoader.SettingsLoadArgs e)
|
private void CoreSyncSettings(object sender, RomLoader.SettingsLoadArgs e)
|
||||||
|
|
|
@ -142,7 +142,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
Marshal.Copy(name, 0, buffer, Math.Min(name.Length, 256));
|
Marshal.Copy(name, 0, buffer, Math.Min(name.Length, 256));
|
||||||
};
|
};
|
||||||
_resetEmulator = () => _mainForm.RebootCore();
|
_resetEmulator = () => _mainForm.RebootCore();
|
||||||
_loadROM = path => _ = _mainForm.LoadRom(path, new() { OpenAdvanced = new OpenAdvanced_OpenRom { Path = path } });
|
_loadROM = path => _ = _mainForm.LoadRom(path, new LoadRomArgs(new OpenAdvanced_OpenRom(path)));
|
||||||
|
|
||||||
RA.InstallSharedFunctionsExt(_isActive, _unpause, _pause, _rebuildMenu, _estimateTitle, _resetEmulator, _loadROM);
|
RA.InstallSharedFunctionsExt(_isActive, _unpause, _pause, _rebuildMenu, _estimateTitle, _resetEmulator, _loadROM);
|
||||||
|
|
||||||
|
|
|
@ -165,9 +165,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
Close();
|
Close();
|
||||||
|
_ = MainForm.LoadRom(fileInfo.FullName, new LoadRomArgs(new OpenAdvanced_OpenRom(fileInfo.FullName)));
|
||||||
var lra = new LoadRomArgs { OpenAdvanced = new OpenAdvanced_OpenRom { Path = fileInfo.FullName } };
|
|
||||||
_ = MainForm.LoadRom(fileInfo.FullName, lra);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddButton_Click(object sender, EventArgs e)
|
private void AddButton_Click(object sender, EventArgs e)
|
||||||
|
|
Loading…
Reference in New Issue