mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-12-20 17:01:47 +03:00
Several changes
- `cache.json` file was renamed to `.cache.json` - `Patch.fetchTimeout` was increased up to 5 seconds from 3 seconds - fixed *possible* issue with `Locales.default()` method: before, if you've been passing there a language to set as default, it wasn't returning properly - added notification when all the patch repos are not available
This commit is contained in:
parent
673c9b70d9
commit
a7afc472c1
4 changed files with 42 additions and 21 deletions
|
@ -104,7 +104,7 @@ class Paths
|
||||||
*/
|
*/
|
||||||
public static get cache(): Promise<string>
|
public static get cache(): Promise<string>
|
||||||
{
|
{
|
||||||
return new Promise(async (resolve) => resolve(`${await this.launcherDir}/cache.json`));
|
return new Promise(async (resolve) => resolve(`${await this.launcherDir}/.cache.json`));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly prefix = Prefix;
|
public static readonly prefix = Prefix;
|
||||||
|
|
|
@ -126,7 +126,7 @@ class Stream extends AbstractInstaller
|
||||||
|
|
||||||
export default class Patch
|
export default class Patch
|
||||||
{
|
{
|
||||||
public static fetchTimeout: number|null = 3000;
|
public static fetchTimeout: number|null = 5000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get information about latest available patch
|
* Get information about latest available patch
|
||||||
|
|
|
@ -32,9 +32,13 @@ export default class Locales
|
||||||
public static default(lang: AvailableLocales|null = null): Promise<AvailableLocales>
|
public static default(lang: AvailableLocales|null = null): Promise<AvailableLocales>
|
||||||
{
|
{
|
||||||
if (lang !== null)
|
if (lang !== null)
|
||||||
|
{
|
||||||
Configs.set('lang.launcher', lang);
|
Configs.set('lang.launcher', lang);
|
||||||
|
|
||||||
return Configs.get('lang.launcher') as Promise<AvailableLocales>;
|
return Promise.resolve(lang);
|
||||||
|
}
|
||||||
|
|
||||||
|
else return Configs.get('lang.launcher') as Promise<AvailableLocales>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -368,28 +368,45 @@ export default class State
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const patch = await Patch.latest;
|
try
|
||||||
|
|
||||||
// If the latest game version is, for example, 2.3.0
|
|
||||||
// and the patch is 2.4.0 preparation, it means that
|
|
||||||
// 2.4.0 will be released soon, but since it's still not released
|
|
||||||
// we shouldn't show something about it to user and just let him play the game
|
|
||||||
if (gameLatest.game.latest.version === patch.version && !patch.applied)
|
|
||||||
{
|
{
|
||||||
state = patch.state == 'preparation' ?
|
const patch = await Patch.latest;
|
||||||
'patch-unavailable' : (patch.state == 'testing' ?
|
|
||||||
'test-patch-available' : 'patch-available');
|
// If the latest game version is, for example, 2.3.0
|
||||||
|
// and the patch is 2.4.0 preparation, it means that
|
||||||
|
// 2.4.0 will be released soon, but since it's still not released
|
||||||
|
// we shouldn't show something about it to user and just let him play the game
|
||||||
|
if (gameLatest.game.latest.version === patch.version && !patch.applied)
|
||||||
|
{
|
||||||
|
state = patch.state == 'preparation' ?
|
||||||
|
'patch-unavailable' : (patch.state == 'testing' ?
|
||||||
|
'test-patch-available' : 'patch-available');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Patch is more important than game pre-downloading
|
||||||
|
// because otherwise we will not be able to play the game
|
||||||
|
else if (gameLatest.pre_download_game && !await Game.isUpdatePredownloaded())
|
||||||
|
state = 'game-pre-installation-available';
|
||||||
|
|
||||||
|
else if (gameLatest.pre_download_game && !await Voice.isUpdatePredownloaded(await Voice.selected))
|
||||||
|
state = 'game-voice-pre-installation-available';
|
||||||
|
|
||||||
|
else state = 'game-launch-available';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Patch is more important than game pre-downloading
|
// Patch.latest can throw an error if all of patch's servers
|
||||||
// because otherwise we will not be able to play the game
|
// are not available, and we must notify user about that
|
||||||
else if (gameLatest.pre_download_game && !await Game.isUpdatePredownloaded())
|
catch
|
||||||
state = 'game-pre-installation-available';
|
{
|
||||||
|
state = 'game-launch-available';
|
||||||
|
|
||||||
else if (gameLatest.pre_download_game && !await Voice.isUpdatePredownloaded(await Voice.selected))
|
Notifications.show({
|
||||||
state = 'game-voice-pre-installation-available';
|
title: 'An Anime Game Launcher',
|
||||||
|
body: 'All the patch repositories are not available. You\'ll be able to run the game, but launcher can\'t be sure is it patched properly',
|
||||||
else state = 'game-launch-available';
|
icon: `${constants.paths.appDir}/public/images/baal64-transparent.png`,
|
||||||
|
importance: 'critical'
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue