From a80399860d69da36624ef3b1310cda189d0129aa Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Fri, 28 Mar 2025 04:33:05 +1000 Subject: [PATCH] Merge `--gdi` handling into `ArgParser` (resolves #4201) funny story, the `--gdi` handler didn't remove it from the `args` array, so it's always been parsed as a rom filename and obviously failing, but before bd58bde07 it was failing silently --- src/BizHawk.Client.Common/ArgParser.cs | 4 ++++ src/BizHawk.Client.Common/ParsedCLIFlags.cs | 4 ++++ src/BizHawk.Client.EmuHawk/Program.cs | 7 +------ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/BizHawk.Client.Common/ArgParser.cs b/src/BizHawk.Client.Common/ArgParser.cs index 7e18e9e233..ef95276925 100644 --- a/src/BizHawk.Client.Common/ArgParser.cs +++ b/src/BizHawk.Client.Common/ArgParser.cs @@ -48,6 +48,8 @@ namespace BizHawk.Client.Common private static readonly BespokeOption OptionConfigFilePath = new(name: "--config", description: "path of config file to use"); + private static readonly BespokeOption OptionGDIPlus = new(name: "--gdi", description: "pass to use the GDI+ display method rather than whatever preference is set in the config file"); + private static readonly BespokeOption OptionHTTPClientURIGET = new(aliases: [ "--url-get", "--url_get" ], description: "string; URI to use for HTTP 'GET' IPC (Lua `comm.http*Get*`)"); private static readonly BespokeOption OptionHTTPClientURIPOST = new(aliases: [ "--url-post", "--url_post" ], description: "string; URI to use for HTTP 'POST' IPC (Lua `comm.http*Post*`)"); @@ -105,6 +107,7 @@ namespace BizHawk.Client.Common root.Add(/* --dump-name */ OptionAVDumpName); root.Add(/* --dump-type */ OptionAVDumpType); root.Add(/* --fullscreen */ OptionLaunchFullscreen); + root.Add(/* --gdi */ OptionGDIPlus); root.Add(/* --load-slot */ OptionLoadQuicksaveSlot); root.Add(/* --load-state */ OptionLoadSavestateFilePath); root.Add(/* --lua */ OptionLuaFilePath); @@ -219,6 +222,7 @@ namespace BizHawk.Client.Common autoCloseOnDump: result.GetValueForOption(OptionAVDumpQuitWhenDone), chromeless: result.GetValueForOption(OptionLaunchChromeless), startFullscreen: result.GetValueForOption(OptionLaunchFullscreen), + gdiPlusRequested: result.GetValueForOption(OptionGDIPlus), luaScript: luaScript, luaConsole: luaConsole, socketAddress: socketAddress, diff --git a/src/BizHawk.Client.Common/ParsedCLIFlags.cs b/src/BizHawk.Client.Common/ParsedCLIFlags.cs index 489585ea29..bf98c55771 100644 --- a/src/BizHawk.Client.Common/ParsedCLIFlags.cs +++ b/src/BizHawk.Client.Common/ParsedCLIFlags.cs @@ -31,6 +31,8 @@ namespace BizHawk.Client.Common public readonly bool startFullscreen; + public readonly bool GDIPlusRequested; + public readonly string? luaScript; public readonly bool luaConsole; @@ -64,6 +66,7 @@ namespace BizHawk.Client.Common bool autoCloseOnDump, bool chromeless, bool startFullscreen, + bool gdiPlusRequested, string? luaScript, bool luaConsole, (string IP, ushort Port)? socketAddress, @@ -87,6 +90,7 @@ namespace BizHawk.Client.Common _autoCloseOnDump = autoCloseOnDump; _chromeless = chromeless; this.startFullscreen = startFullscreen; + GDIPlusRequested = gdiPlusRequested; this.luaScript = luaScript; this.luaConsole = luaConsole; SocketAddress = socketAddress; diff --git a/src/BizHawk.Client.EmuHawk/Program.cs b/src/BizHawk.Client.EmuHawk/Program.cs index ce5706f24f..348e4cde03 100644 --- a/src/BizHawk.Client.EmuHawk/Program.cs +++ b/src/BizHawk.Client.EmuHawk/Program.cs @@ -220,6 +220,7 @@ namespace BizHawk.Client.EmuHawk initialConfig = ConfigService.Load(configPath); } initialConfig.ResolveDefaults(); + if (cliFlags.GDIPlusRequested) initialConfig.DispMethod = EDispMethod.GdiPlus; if (initialConfig.SaveSlot is 0) initialConfig.SaveSlot = 10; //TODO remove after a while // initialConfig should really be globalConfig as it's mutable @@ -307,12 +308,6 @@ namespace BizHawk.Client.EmuHawk } } - // super hacky! this needs to be done first. still not worth the trouble to make this system fully proper - if (Array.Exists(args, static arg => arg.StartsWithIgnoreCase("--gdi"))) - { - initialConfig.DispMethod = EDispMethod.GdiPlus; - } - var workingGL = TryInitIGL(initialConfig.DispMethod); Sound globalSound = null;