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.runningInterval = null;
process.kill();
debugThread.log({ message: info });
resolve(info);

View file

@ -126,8 +126,20 @@ export default (launcher: Launcher): Promise<void> => {
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(() => {
const waiter = async () => {
const processes: string = (await Neutralino.os.execCommand('ps -A')).stdOut;
// Game is still running
if (processes.includes('GenshinImpact'))
setTimeout(waiter, 3000);
// Game was closed
else
{
const stopTime = Date.now();
Window.current.show();
@ -137,6 +149,10 @@ export default (launcher: Launcher): Promise<void> => {
// TODO
resolve();
}
};
setTimeout(waiter, 5000);
});
}
});

View file

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