From c5c8b6bdd92741edd969f6e70911c8f0cd707fce Mon Sep 17 00:00:00 2001 From: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com> Date: Wed, 11 Dec 2024 19:33:33 -0800 Subject: [PATCH] Don't open choose file from archive dialog when trying to fallback to a different core for a MAME ROM The fallback is intended in cases where there is a misdetection for MAME ROMs, since it just goes off the archive's filename against a db. MAME ROMs will not have any sensical ROM extensions in them, and will most likely just have multiple files in it. As such, if this is actually a MAME ROM, they're pretty much guaranteed to show the choose file in archive dialog, which would confuse users. If it's not a MAME ROM, it most likely will not show this dialog and will just be loaded by the appropriate core (of course in practice this likely doesn't occur anyways, since most users likely just have their ROMs named with dat names like No-Intro etc which never match MAME's names). --- src/BizHawk.Client.Common/RomLoader.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/BizHawk.Client.Common/RomLoader.cs b/src/BizHawk.Client.Common/RomLoader.cs index 7c59501a540..25c00094f0c 100644 --- a/src/BizHawk.Client.Common/RomLoader.cs +++ b/src/BizHawk.Client.Common/RomLoader.cs @@ -194,7 +194,7 @@ private void DoLoadErrorCallback(string message, string systemId, string path, b public IOpenAdvanced OpenAdvanced { get; set; } - private bool HandleArchiveBinding(HawkFile file) + private bool HandleArchiveBinding(HawkFile file, bool showDialog = true) { // try binding normal rom extensions first if (!file.IsBound) @@ -213,7 +213,7 @@ private bool HandleArchiveBinding(HawkFile file) // if we have an archive and need to bind something, then pop the dialog if (file.IsArchive && !file.IsBound) { - int? result = HandleArchive(file); + var result = showDialog ? HandleArchive(file) : null; if (result.HasValue) { file.BindArchiveMember(result.Value); @@ -627,7 +627,10 @@ private void LoadMAME( try { using var f = new HawkFile(path, allowArchives: true); - if (!HandleArchiveBinding(f)) throw; + // we want to avoid opening up the choose file from archive dialog + // as it is very likely in this case this is actually a MAME ROM + // which case, we do want the error to be shown immediately, other cores won't load this + if (!HandleArchiveBinding(f, showDialog: false)) throw; LoadOther(nextComm, f, ext: ext, forcedCoreName: null, out nextEmulator, out rom, out game, out cancel); } catch (Exception oex)