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.outputInterval = null;
|
||||||
process.runningInterval = null;
|
process.runningInterval = null;
|
||||||
|
|
||||||
|
process.kill();
|
||||||
|
|
||||||
debugThread.log({ message: info });
|
debugThread.log({ message: info });
|
||||||
|
|
||||||
resolve(info);
|
resolve(info);
|
||||||
|
|
|
@ -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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue