Clean up MainForm.LoadRom overloads
This commit is contained in:
parent
a1aaabe8d5
commit
4315bf8a2b
|
@ -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(new OpenAdvanced_OpenRom(path)));
|
=> _mainForm.LoadRom(new LoadRomArgs(new OpenAdvanced_OpenRom(path)));
|
||||||
|
|
||||||
public void Pause() => _mainForm.PauseEmulator();
|
public void Pause() => _mainForm.PauseEmulator();
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace BizHawk.Client.Common
|
||||||
bool LoadQuickSave(int slot, bool suppressOSD = false);
|
bool LoadQuickSave(int slot, bool suppressOSD = false);
|
||||||
|
|
||||||
/// <remarks>only referenced from <c>EmuClientApi</c></remarks>
|
/// <remarks>only referenced from <c>EmuClientApi</c></remarks>
|
||||||
bool LoadRom(string path, LoadRomArgs args);
|
bool LoadRom(LoadRomArgs args);
|
||||||
|
|
||||||
bool LoadState(string path, string userFriendlyStateName, bool suppressOSD = false);
|
bool LoadState(string path, string userFriendlyStateName, bool suppressOSD = false);
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
bool LoadQuickSave(int slot, bool suppressOSD = false);
|
bool LoadQuickSave(int slot, bool suppressOSD = false);
|
||||||
|
|
||||||
/// <remarks>only referenced from <see cref="MultiDiskBundler"/></remarks>
|
/// <remarks>only referenced from <see cref="MultiDiskBundler"/></remarks>
|
||||||
bool LoadRom(string path, LoadRomArgs args);
|
bool LoadRom(LoadRomArgs args);
|
||||||
|
|
||||||
/// <remarks>only referenced from <see cref="BookmarksBranchesBox"/></remarks>
|
/// <remarks>only referenced from <see cref="BookmarksBranchesBox"/></remarks>
|
||||||
BitmapBuffer MakeScreenshotImage();
|
BitmapBuffer MakeScreenshotImage();
|
||||||
|
|
|
@ -97,7 +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)));
|
=> LoadRom(new LoadRomArgs(new OpenAdvanced_OpenRom(filename)));
|
||||||
|
|
||||||
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));
|
||||||
|
|
|
@ -631,7 +631,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
// Commandline should always override auto-load
|
// Commandline should always override auto-load
|
||||||
OpenAdvanced_OpenRom ioa = new(_argParser.cmdRom);
|
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
|
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));
|
_ = LoadRom(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");
|
||||||
|
@ -1268,11 +1268,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
tool.RebootCore();
|
tool.RebootCore();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
if (CurrentlyOpenRomArgs is null) return true;
|
||||||
{
|
return LoadRom(CurrentlyOpenRomArgs);
|
||||||
if (CurrentlyOpenRomArgs == null) return true;
|
|
||||||
return LoadRom(CurrentlyOpenRomArgs.OpenAdvanced.SimplePath, CurrentlyOpenRomArgs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PauseEmulator()
|
public void PauseEmulator()
|
||||||
|
@ -2078,13 +2075,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
var ioa = OpenAdvancedSerializer.ParseWithLegacy(rom);
|
var ioa = OpenAdvancedSerializer.ParseWithLegacy(rom);
|
||||||
|
|
||||||
// if(ioa is this or that) - for more complex behaviour
|
// if(ioa is this or that) - for more complex behaviour
|
||||||
string romPath = ioa.SimplePath;
|
|
||||||
|
|
||||||
if (!LoadRom(romPath, new LoadRomArgs(ioa), out var failureIsFromAskSave))
|
if (!LoadRom(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(ioa.SimplePath)) AddOnScreenMessage("ROM loading failed");
|
||||||
else Config.RecentRoms.HandleLoadError(this, romPath, rom);
|
else Config.RecentRoms.HandleLoadError(this, ioa.SimplePath, rom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2314,8 +2310,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
filterIndex: ref _lastOpenRomFilter,
|
filterIndex: ref _lastOpenRomFilter,
|
||||||
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;
|
_ = LoadRom(new LoadRomArgs(new OpenAdvanced_OpenRom(new FileInfo(result).FullName)));
|
||||||
_ = LoadRom(filePath, new LoadRomArgs(new OpenAdvanced_OpenRom(filePath)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CoreSyncSettings(object sender, RomLoader.SettingsLoadArgs e)
|
private void CoreSyncSettings(object sender, RomLoader.SettingsLoadArgs e)
|
||||||
|
@ -3538,9 +3533,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
private LoadRomArgs _currentLoadRomArgs;
|
private LoadRomArgs _currentLoadRomArgs;
|
||||||
private bool _isLoadingRom;
|
private bool _isLoadingRom;
|
||||||
|
|
||||||
public bool LoadRom(string path, LoadRomArgs args) => LoadRom(path, args, out _);
|
private bool LoadRom(string path, LoadRomArgs args, out bool failureIsFromAskSave)
|
||||||
|
|
||||||
public bool LoadRom(string path, LoadRomArgs args, out bool failureIsFromAskSave)
|
|
||||||
{
|
{
|
||||||
if (!LoadRomInternal(path, args, out failureIsFromAskSave))
|
if (!LoadRomInternal(path, args, out failureIsFromAskSave))
|
||||||
return false;
|
return false;
|
||||||
|
@ -3555,6 +3548,15 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool LoadRom(string path, LoadRomArgs args)
|
||||||
|
=> LoadRom(path, args, out _);
|
||||||
|
|
||||||
|
private bool LoadRom(LoadRomArgs args, out bool failureIsFromAskSave)
|
||||||
|
=> LoadRom(args.OpenAdvanced.SimplePath, args, out failureIsFromAskSave);
|
||||||
|
|
||||||
|
public bool LoadRom(LoadRomArgs args)
|
||||||
|
=> LoadRom(args, out _);
|
||||||
|
|
||||||
// Still needs a good bit of refactoring
|
// Still needs a good bit of refactoring
|
||||||
private bool LoadRomInternal(string path, LoadRomArgs args, out bool failureIsFromAskSave)
|
private bool LoadRomInternal(string path, LoadRomArgs args, out bool failureIsFromAskSave)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
SettingsAdapter GetSettingsAdapterForLoadedCoreUntyped();
|
SettingsAdapter GetSettingsAdapterForLoadedCoreUntyped();
|
||||||
|
|
||||||
bool LoadRom(string path, LoadRomArgs args);
|
bool LoadRom(LoadRomArgs args);
|
||||||
|
|
||||||
void PauseEmulator();
|
void PauseEmulator();
|
||||||
|
|
||||||
|
|
|
@ -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 LoadRomArgs(new OpenAdvanced_OpenRom(path)));
|
_loadROM = path => _ = _mainForm.LoadRom(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,7 +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)));
|
_ = MainForm.LoadRom(new LoadRomArgs(new OpenAdvanced_OpenRom(fileInfo.FullName)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddButton_Click(object sender, EventArgs e)
|
private void AddButton_Click(object sender, EventArgs e)
|
||||||
|
|
Loading…
Reference in New Issue