mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-12-30 05:28:15 +03:00
Added proper launched game closing handling
This commit is contained in:
parent
bb6d68bec0
commit
e5375dabff
3 changed files with 26 additions and 6 deletions
|
@ -26,6 +26,8 @@ export default class Domain
|
|||
process.outputInterval = null;
|
||||
process.runningInterval = null;
|
||||
|
||||
process.kill();
|
||||
|
||||
debugThread.log({ message: info });
|
||||
|
||||
resolve(info);
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -170,6 +170,8 @@ class Process
|
|||
*/
|
||||
public kill(forced: boolean = false): Promise<void>
|
||||
{
|
||||
Neutralino.filesystem.removeFile(this.outputFile);
|
||||
|
||||
return Process.kill(this.id, forced);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue