From d9da3cfa605daebda3f178705e8fbf3e73f2b204 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Sun, 5 Jan 2025 22:39:44 +1000 Subject: [PATCH] Set game name for Libretro when available resolves #4144 --- src/BizHawk.Client.Common/RomLoader.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/BizHawk.Client.Common/RomLoader.cs b/src/BizHawk.Client.Common/RomLoader.cs index d8d9dbd2ce..2a8f48877f 100644 --- a/src/BizHawk.Client.Common/RomLoader.cs +++ b/src/BizHawk.Client.Common/RomLoader.cs @@ -302,9 +302,14 @@ Exception NoCoreForSystem(string sysID) return game; } + private Disc/*?*/ InstantiateDiscFor(string path) + => DiscExtensions.CreateAnyType( + path, + str => DoLoadErrorCallback(message: str, systemId: "???"/*TODO we should NOT be doing this, even if it's just for error display*/, LoadErrorType.DiscError)); + private bool LoadDisc(string path, CoreComm nextComm, HawkFile file, string ext, string forcedCoreName, out IEmulator nextEmulator, out GameInfo game) { - var disc = DiscExtensions.CreateAnyType(path, str => DoLoadErrorCallback(str, "???", LoadErrorType.DiscError)); + var disc = InstantiateDiscFor(path); if (disc == null) { game = null; @@ -826,6 +831,12 @@ public bool LoadRom(string path, CoreComm nextComm, string launchLibretroCore, s retro.Dispose(); return false; } + // else success; update game name + var ext = file.Extension; + var gi = Disc.IsValidExtension(ext) + ? MakeGameFromDisc(InstantiateDiscFor(path), ext: ext, name: Path.GetFileNameWithoutExtension(file.Name)) + : new RomGame(file).GameInfo; + Game.Name = $"{gi.Name} [{Game.Name/* core name */}]"; } } else