Skip to content

Fix LaunchAndFocus and ship AppLauncher keys in the default retrobat.ini - #50

Open
goldorakiller wants to merge 2 commits into
RetroBat-Official:mainfrom
goldorakiller:fix/launch-and-focus-splash-and-return
Open

Fix LaunchAndFocus and ship AppLauncher keys in the default retrobat.ini#50
goldorakiller wants to merge 2 commits into
RetroBat-Official:mainfrom
goldorakiller:fix/launch-and-focus-splash-and-return

Conversation

@goldorakiller

@goldorakiller goldorakiller commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

This PR groups two related follow-ups on the launcher. It started as the LaunchAndFocus fix alone and now also carries the AppLauncher ini fix.

1. LaunchAndFocus (review feedback from @Tartifless)

  • The black splash could stay on screen indefinitely. SplashVideo.CloseBlackSplash() was only called on the success path (esHandle != IntPtr.Zero && !isExternalLauncher). When the window handle was never obtained — exclusive fullscreen, or EmulationStation exiting early — it was never closed there. It is now closed unconditionally right after the wait loop, which is bounded by maxWaitMs and therefore always reached, with a finally as a safety net in case an exception is thrown earlier.

  • Missing return false in the catch. return true sat after the try/catch, so a failure to start EmulationStation was logged and then reported as a success. return true moved to the end of the try, return false added to the catch, and the XML doc updated to match the new contract.

2. AppLauncher missing from a generated retrobat.ini

The option was documented but never showed up in a freshly generated retrobat.ini. It was written as AppLauncher= with an empty value, and IniFile.ToString() skips entries whose value is empty, so the line was dropped as soon as the file was saved. Users had to add the key by hand to discover the feature.

  • The default ini now ships AppLauncher="" and AppLauncher2="" as real keys. "" is not an empty string, so the lines survive every rewrite, and an empty value still means "disabled" as documented.
  • The number of supported entries is now a single constant (MaxAppLaunchers) shared with the ini comment, instead of a magic 20 duplicated in both places.
  • An entry with no path is skipped silently, since that is the state every default install ships with. An entry whose path is set but does not exist is still logged as a warning.

Reading the configuration never writes to retrobat.ini: entries are read with GetValue, so absent keys stay absent. A key manually emptied down to AppLauncher= is therefore still dropped on the next save, which is pre-existing IniFile behaviour and simply leaves the feature disabled.

Generated [RetroBat] section

; Path to an additional application to launch in parallel with RetroBat (.exe, .bat, .cmd...). Leave empty to disable. Use quotes if the path contains spaces.
; Add -nowindow at the end to start it without a visible window (e.g. AppLauncher="C:\tools\app.exe" -nowindow). Without -nowindow, it starts normally.
; Up to 20 applications can be launched: fill in AppLauncher below, then add AppLauncher2, AppLauncher3... up to AppLauncher20.
AppLauncher=""
AppLauncher2=""

Testing

Release build passes with no warnings. The ini behaviour was checked with a standalone harness driving IniFile + RetroBatConfigLoader over three scenarios: fresh generation, a full rewrite triggered by a missing key, and a real path set by the user. The AppLauncher lines and their values survive in all three, and loading the configuration leaves the file untouched.Follow-up to review feedback on #48.

  • The black splash was only closed inside the success branch (esHandle != IntPtr.Zero && !isExternalLauncher). When the main window handle was never obtained - exclusive fullscreen, or EmulationStation exiting early - it stayed on screen for the whole wait. It is now closed unconditionally right after the (bounded) wait loop, with a finally block as a safety net if an exception is thrown earlier. CloseBlackSplash is idempotent, so the extra call is harmless.

  • The method returned true even when an exception was caught, so callers could not distinguish a successful launch from a failed one. The success return is now at the end of the try block and the catch returns false. The XML doc was updated to match the new contract.

Follow-up to review feedback on RetroBat-Official#48.

- The black splash was only closed inside the success branch
  (esHandle != IntPtr.Zero && !isExternalLauncher). When the main window
  handle was never obtained - exclusive fullscreen, or EmulationStation
  exiting early - it stayed on screen for the whole wait. It is now
  closed unconditionally right after the (bounded) wait loop, with a
  finally block as a safety net if an exception is thrown earlier.
  CloseBlackSplash is idempotent, so the extra call is harmless.

- The method returned true even when an exception was caught, so callers
  could not distinguish a successful launch from a failed one. The
  success return is now at the end of the try block and the catch
  returns false. The XML doc was updated to match the new contract.
The AppLauncher option was documented but never appeared in a freshly
generated retrobat.ini: it was written as "AppLauncher=" with an empty
value, and IniFile.ToString() skips entries whose value is empty, so the
line was dropped as soon as the file was saved. Users had to add the key
by hand to discover the feature.

- The default ini now ships AppLauncher="" and AppLauncher2="" as real
  keys. The value "" is not an empty string, so the lines survive every
  rewrite, and an empty value still means "disabled" as documented.
- The supported number of entries is now a single constant
  (MaxAppLaunchers) shared with the ini comment, instead of a magic 20
  duplicated in both places.
- An entry with no path is skipped silently, since that is the state
  every default install ships with; an entry whose path is set but does
  not exist is still logged as a warning.

Reading the configuration never writes to retrobat.ini: entries are read
with GetValue, so absent keys stay absent. As a result, a key manually
emptied down to "AppLauncher=" is still dropped on the next save, which
is the pre-existing IniFile behaviour and leaves the feature disabled.
@goldorakiller
goldorakiller force-pushed the fix/launch-and-focus-splash-and-return branch from e950912 to 36bba0c Compare August 26, 2026 19:19
@goldorakiller goldorakiller changed the title Fix LaunchAndFocus: always close splash, return false on failure Fix LaunchAndFocus and ship AppLauncher keys in the default retrobat.ini Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant