Several changes

- `Patch/Stream`'s `patchFinish()` callback now have `result: boolean` argument
  which indicates whether the patch was successfully applied
- `Patch/Stream` now also logs patch script output
- if the patch wasn't successfully applied - then `ApplyPatch` script
  will show user a notification about it
- also was fixed notification icon in telemetry checking
This commit is contained in:
Observer KRypt0n_ 2022-01-07 15:22:32 +02:00
parent a0e38c825b
commit 3fa259ec64
No known key found for this signature in database
GPG key ID: DC5D4EC1303465DA
4 changed files with 30 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View file

@ -16,9 +16,10 @@ declare const Neutralino;
class Stream extends AbstractInstaller
{
protected userUnpackFinishCallback?: () => void;
protected onPatchFinish?: () => void;
protected onPatchFinish?: (result: boolean) => void;
protected patchFinished: boolean = false;
protected patchResult: boolean = false;
public constructor(uri: string, version: string|null = null)
{
@ -84,11 +85,21 @@ class Stream extends AbstractInstaller
});
// When all the things above are done
pipeline.then(() => {
pipeline.then((outputs) => {
this.patchFinished = true;
Debug.log({
function: 'Patch/Stream',
message: [
'Patch script output:',
...outputs[5].stdOut.split(/\r\n|\r|\n/)
]
});
this.patchResult = outputs[5].stdOut.includes('==> Patch applied! Enjoy the game');
if (this.onPatchFinish)
this.onPatchFinish();
this.onPatchFinish(this.patchResult);
});
};
}
@ -104,12 +115,12 @@ class Stream extends AbstractInstaller
/**
* Specify event that will be called when the patch will be applied
*/
public patchFinish(callback: () => void)
public patchFinish(callback: (result: boolean) => void)
{
this.onPatchFinish = callback;
if (this.patchFinished)
callback();
callback(this.patchResult);
}
}

View file

@ -1,6 +1,8 @@
import type Launcher from '../../Launcher';
import Patch from '../../Patch';
import Notifications from '../../core/Notifications';
import constants from '../../Constants';
export default (launcher: Launcher): Promise<void> => {
return new Promise(async (resolve) => {
@ -56,9 +58,19 @@ export default (launcher: Launcher): Promise<void> => {
});
});
stream.patchFinish(() => {
stream.patchFinish((result) => {
launcher.progressBar?.hide();
// If for some reasons patch wasn't applied successfully
if (!result)
{
Notifications.show({
title: 'An Anime Game Launcher',
body: 'Patch wasn\'t applied successfully. Please, check your log file to find a reason of it, or ask someone in our discord server',
icon: `${constants.paths.appDir}/public/images/baal64-transparent.png`
});
}
resolve();
});
}

View file

@ -9,8 +9,6 @@ import Game from '../../Game';
import Process from '../../neutralino/Process';
import Window from '../../neutralino/Window';
import Baal from '../../../assets/images/baal64-transparent.png';
declare const Neutralino;
export default (launcher: Launcher): Promise<void> => {
@ -25,7 +23,7 @@ export default (launcher: Launcher): Promise<void> => {
Notifications.show({
title: 'An Anime Game Launcher',
body: 'Telemetry servers are not disabled',
icon: Baal,
icon: `${constants.paths.appDir}/public/images/baal64-transparent.png`,
importance: 'critical'
});