Added proper launched game closing handling

This commit is contained in:
Observer KRypt0n_ 2022-01-05 14:39:24 +02:00
parent bb6d68bec0
commit e5375dabff
No known key found for this signature in database
GPG key ID: DC5D4EC1303465DA
3 changed files with 26 additions and 6 deletions

View file

@ -26,6 +26,8 @@ export default class Domain
process.outputInterval = null; process.outputInterval = null;
process.runningInterval = null; process.runningInterval = null;
process.kill();
debugThread.log({ message: info }); debugThread.log({ message: info });
resolve(info); resolve(info);

View file

@ -126,17 +126,33 @@ export default (launcher: Launcher): Promise<void> => {
cwd: await constants.paths.gameDir cwd: await constants.paths.gameDir
}); });
// Game closed event // Game was started by the launcher.bat file
// so we just need to wait until GenshinImpact process
// will be closed
process.finish(() => { process.finish(() => {
const stopTime = Date.now(); const waiter = async () => {
const processes: string = (await Neutralino.os.execCommand('ps -A')).stdOut;
Window.current.show(); // Game is still running
if (processes.includes('GenshinImpact'))
setTimeout(waiter, 3000);
launcher.updateDiscordRPC('in-launcher'); // Game was closed
else
{
const stopTime = Date.now();
// TODO Window.current.show();
resolve(); launcher.updateDiscordRPC('in-launcher');
// TODO
resolve();
}
};
setTimeout(waiter, 5000);
}); });
} }
}); });

View file

@ -170,6 +170,8 @@ class Process
*/ */
public kill(forced: boolean = false): Promise<void> public kill(forced: boolean = false): Promise<void>
{ {
Neutralino.filesystem.removeFile(this.outputFile);
return Process.kill(this.id, forced); return Process.kill(this.id, forced);
} }