Skip to content

Commit

Permalink
AppUI: Fix launching Chocobo World on FF8 2000
Browse files Browse the repository at this point in the history
  • Loading branch information
julianxhokaxhiu committed Dec 12, 2024
1 parent 5557c71 commit de6bc91
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions AppUI/Classes/GameLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,11 @@ internal static async Task<bool> LaunchChocoboExe()
Process.Start(startInfo);

// Wait for game process
await waitForProcess(Path.GetFileNameWithoutExtension(chocoboExe));
Process game = await waitForProcess(Path.GetFileNameWithoutExtension(chocoboExe));
if (game != null)
{
ff8Proc = game;
}

// Delete signal file
File.Delete(ticket);
Expand All @@ -882,9 +886,29 @@ internal static async Task<bool> LaunchChocoboExe()
WorkingDirectory = Path.GetDirectoryName(chocoboExe),
UseShellExecute = true,
};
Process.Start(startInfo);
ff8Proc = Process.Start(startInfo);
}

ff8Proc.EnableRaisingEvents = true;
ff8Proc.Exited += (o, e) =>
{
try
{
if (!IsChocoboRunning() && Instance._controllerInterceptor != null)
{
// stop polling for input once all ff8 procs are closed (could be multiple instances open)
Instance._controllerInterceptor.PollingInput = false;
}

// cleanup
DeleteJ8WrapperDlls();
}
catch (Exception ex)
{
Logger.Error(ex);
}
};

return true;
}
catch (Exception ex)
Expand Down Expand Up @@ -1334,6 +1358,21 @@ public static bool IsFF8Running()
return ret;
}

public static bool IsChocoboRunning()
{
bool ret = false;

string fileName = Sys.Settings.FF8InstalledVersion == FF8Version.Steam ? "chocobo_en" : "chocobo";
ret = Process.GetProcessesByName(fileName).Length > 0;

if (!ret && Sys.Settings.FF8InstalledVersion == FF8Version.Steam)
{
ret = Process.GetProcessesByName("FF8_Launcher").Length > 0;
}

return ret;
}

private static bool ForceKillFF8()
{
string fileName = Path.GetFileNameWithoutExtension(Sys.Settings.FF8Exe);
Expand Down

0 comments on commit de6bc91

Please sign in to comment.