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);
|
||||
|
||||
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();
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public class LoadRomArgs
|
||||
public sealed class LoadRomArgs(IOpenAdvanced ioa, bool? deterministic = null)
|
||||
{
|
||||
public bool? Deterministic { get; set; }
|
||||
public IOpenAdvanced OpenAdvanced { get; set; }
|
||||
public readonly bool? Deterministic = deterministic;
|
||||
|
||||
public readonly IOpenAdvanced OpenAdvanced = ioa;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
return text.StartsWith('*')
|
||||
? Deserialize(text.Substring(1))
|
||||
: new OpenAdvanced_OpenRom { Path = text };
|
||||
: new OpenAdvanced_OpenRom(text);
|
||||
}
|
||||
|
||||
private static IOpenAdvanced Deserialize(string text)
|
||||
|
@ -151,6 +151,12 @@ namespace BizHawk.Client.Common
|
|||
public string DisplayName => Path;
|
||||
public string SimplePath => Path;
|
||||
|
||||
public OpenAdvanced_OpenRom() {}
|
||||
|
||||
public OpenAdvanced_OpenRom(string path)
|
||||
: this()
|
||||
=> Path = path;
|
||||
|
||||
public void Deserialize(string str)
|
||||
{
|
||||
Path = str;
|
||||
|
|
|
@ -239,30 +239,25 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (oac.Result == AdvancedRomLoaderType.LibretroLaunchNoGame)
|
||||
{
|
||||
var argsNoGame = new LoadRomArgs
|
||||
{
|
||||
OpenAdvanced = new OpenAdvanced_LibretroNoGame(Config.LibretroCore)
|
||||
};
|
||||
_ = LoadRom(string.Empty, argsNoGame);
|
||||
_ = LoadRom(string.Empty, new LoadRomArgs(new OpenAdvanced_LibretroNoGame(Config.LibretroCore)));
|
||||
return;
|
||||
}
|
||||
|
||||
var args = new LoadRomArgs();
|
||||
|
||||
var filter = RomLoader.RomFilter;
|
||||
|
||||
IOpenAdvanced ioa;
|
||||
FilesystemFilterSet filter;
|
||||
if (oac.Result == AdvancedRomLoaderType.LibretroLaunchGame)
|
||||
{
|
||||
args.OpenAdvanced = new OpenAdvanced_Libretro();
|
||||
ioa = new OpenAdvanced_Libretro();
|
||||
filter = oac.SuggestedExtensionFilter!;
|
||||
}
|
||||
else if (oac.Result == AdvancedRomLoaderType.ClassicLaunchGame)
|
||||
{
|
||||
args.OpenAdvanced = new OpenAdvanced_OpenRom();
|
||||
ioa = new OpenAdvanced_OpenRom();
|
||||
filter = RomLoader.RomFilter;
|
||||
}
|
||||
else if (oac.Result == AdvancedRomLoaderType.MameLaunchGame)
|
||||
{
|
||||
args.OpenAdvanced = new OpenAdvanced_MAME();
|
||||
ioa = new OpenAdvanced_MAME();
|
||||
filter = MAMERomsFSFilterSet;
|
||||
}
|
||||
else
|
||||
|
@ -277,7 +272,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (result is null) return;
|
||||
FileInfo file = new(result);
|
||||
Config.PathEntries.LastRomPath = file.DirectoryName;
|
||||
_ = LoadRom(file.FullName, args);
|
||||
_ = LoadRom(file.FullName, new LoadRomArgs(ioa));
|
||||
}
|
||||
|
||||
private void CloseRomMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -97,13 +97,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
private bool LoadRom(string filename, string archive = null)
|
||||
{
|
||||
var args = new LoadRomArgs
|
||||
{
|
||||
OpenAdvanced = new OpenAdvanced_OpenRom {Path = filename}
|
||||
};
|
||||
return LoadRom(filename, args);
|
||||
}
|
||||
=> LoadRom(filename, new LoadRomArgs(new OpenAdvanced_OpenRom(filename)));
|
||||
|
||||
private bool LoadStateFile(string filename, string archive = null)
|
||||
=> LoadState(path: filename, userFriendlyStateName: Path.GetFileName(filename));
|
||||
|
|
|
@ -629,9 +629,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (_argParser.cmdRom != null)
|
||||
{
|
||||
// Commandline should always override auto-load
|
||||
OpenAdvanced_OpenRom ioa = new() { Path = _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
|
||||
_ = LoadRom(ioa.SimplePath, new LoadRomArgs { OpenAdvanced = ioa });
|
||||
OpenAdvanced_OpenRom ioa = new(_argParser.cmdRom);
|
||||
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(ioa));
|
||||
if (Game.IsNullInstance())
|
||||
{
|
||||
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 args = new LoadRomArgs
|
||||
{
|
||||
OpenAdvanced = ioa
|
||||
};
|
||||
|
||||
// if(ioa is this or that) - for more complex behaviour
|
||||
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");
|
||||
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));
|
||||
if (result is null) return;
|
||||
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)
|
||||
|
|
|
@ -142,7 +142,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Marshal.Copy(name, 0, buffer, Math.Min(name.Length, 256));
|
||||
};
|
||||
_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);
|
||||
|
||||
|
|
|
@ -165,9 +165,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
|
||||
var lra = new LoadRomArgs { OpenAdvanced = new OpenAdvanced_OpenRom { Path = fileInfo.FullName } };
|
||||
_ = MainForm.LoadRom(fileInfo.FullName, lra);
|
||||
_ = MainForm.LoadRom(fileInfo.FullName, new LoadRomArgs(new OpenAdvanced_OpenRom(fileInfo.FullName)));
|
||||
}
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
|
|
Loading…
Reference in New Issue