Merge branch 'main' into marie/integrity

This commit is contained in:
Maroxy 2022-02-20 13:39:48 +01:00
commit 836faa38ec
No known key found for this signature in database
GPG key ID: F4B27EADB21E3021
24 changed files with 529 additions and 69 deletions

View file

@ -48,6 +48,16 @@ flatpak install launcher.moe com.gitlab.KRypt0n_.an-anime-game-launcher
Some additional configuration is possible when using the flatpak. For info about this, see [this page](https://gitlab.com/lane__/an-anime-game-launcher-flatpak/-/blob/master/README.md)
## Chinese version
To use Chinese version of the game make sure that you have
```yaml
server: cn
```
field in your `config.yaml` file (settings -> launcher folder). If your system uses the Chinese language - then it should be selected automatically. If not, then close the launcher, replace `server: global` with `server: cn`, and run it again. After that launcher will download the Chinese version of the game and the patch
# Status
| Game version | Launcher version | Patch version |
@ -159,10 +169,10 @@ This is our current roadmap goals. You can find older ones [here](repository/pag
* <s>ToS Violation Window</s> *(2.1.0)*
* <s>Add `latest.log` file generation</s> *(2.1.2)*
* <s>Add an option to show terminal with the wine's log of the game</s> *(7375c743, released in 2.1.3)*
* <s>Statistics window</s>
* Add Chinese game's version support (due to changes in the Krock's patch)
* <s>Add analytics window</s> *(e0a09323)*
* <s>Add Chinese game's version support (due to changes in the Krock's patch)</s> *(75f2ad66)*
* Implement manual config flushing functionality from the Empathize's API
* Add analytics window
* Game statistics window
* Dark progress bar design
* Changelog window
* Screenshots explorer

View file

@ -95,6 +95,7 @@ settings:
hu-hu: Magyar
id-id: Bahasa Indonesia
nb-no: Norsk
zh-cn: 简体中文
uwu: Engwish
# Spiel sprachpaket auswahl

View file

@ -95,6 +95,7 @@ settings:
hu-hu: Magyar
id-id: Bahasa Indonesia
nb-no: Norsk
zh-cn: 简体中文
uwu: Engwish
# Game voice pack language

View file

@ -95,6 +95,7 @@ settings:
hu-hu: Magyar
id-id: Bahasa Indonesia
nb-no: Norsk
zh-cn: 简体中文
uwu: Engwish
# Idioma del paquete de voz

View file

@ -98,6 +98,7 @@ settings:
hu-hu: Magyar
id-id: Bahasa Indonesia
nb-no: Norsk
zh-cn: 简体中文
uwu: Engwish
# Game voice pack language

View file

@ -95,6 +95,7 @@ settings:
hu-hu: Magyar
id-id: Bahasa Indonesia
nb-no: Norsk
zh-cn: 简体中文
uwu: Engwish
# Game voice pack language

View file

@ -95,6 +95,7 @@ settings:
hu-hu: Magyar
id-id: Bahasa Indonesia
nb-no: Norsk
zh-cn: 简体中文
uwu: Engwish
# Game voice pack language

View file

@ -23,7 +23,7 @@ launcher:
game:
downloading: Scaricando il gioco...
unpacking: Decomprimendo il gioco...
applying_changes: Applying changes...
applying_changes: Applicando i cambiamenti...
deleting_outdated: Cancellando file vecchi...
integrity_check: Verifying Files...
download_mismatch_files: Downloading mismatched files...
@ -44,12 +44,12 @@ launcher:
update: Aggiorna
apply_changes:
title: Apply changes
hint: Apply hdiff changes to the game files
title: Applica cambiamenti
hint: Applica i cambiamenti di hdiff ai file di gioco
remove_outdated:
title: Remove outdated
hint: Remove outdated game files
title: Elimina file vecchi
hint: Elimina file di gioco vecchi
# When the game should be patched
patching:
@ -95,6 +95,7 @@ settings:
hu-hu: Magyar
id-id: Bahasa Indonesia
nb-no: Norsk
zh-cn: 简体中文
uwu: Engwish
# Game voice pack language
@ -304,8 +305,8 @@ notifications:
# HDiffPatch couldn't successfully apply game files changes
game_changes_applying_error:
title: An error occurred during game updating
body: '{files} files couldn''t be updated by the hdiff patch'
title: Si è verificato un errore nell'aggiornamento del gioco
body: '{files} files non sono stati aggiornati dalla patch hdiff
# ToS violation warning window
tos_violation:
@ -327,18 +328,19 @@ tos_violation:
# Analytics window
analytics:
title: Yanfei's commission...
header: Participate in anonymous data collection
title: La commissione di Yanfei...
header: Partecipa nella collezione di dati anonimi
body:
- To count the active user base for Linux, Yanfei would like to collect your IP address everytime the game updates
- The IP address will be hashed for security purpose
- Per contare il numero di giocatori attivi su Linux, Yanfei vorrebbe collezionare il tuo indirizzo IP ogni volta che il gioco si aggiorna
- L'indirizzo IP sarà hashato per motivi di sicurezza
actions:
share_country:
title: Share country
hint: Allow Yanfei to store the country your IP address registered in to make statistics more detailed. No other data than the country will be stored
title: Condividi paese
hint: Permetti a Yanfei di registrare lo stato del tuo indirizzo IP per raccogliere statistiche più dettagliate.
Nessun''altro dato oltre al paese verrà registrato.
participate: Participate
skip: Skip
skip_forever: Skip and don't ask again
participate: Partecipa
skip: Rifiuta
skip_forever: Rifiuta e non chiedere più

View file

@ -95,6 +95,7 @@ settings:
hu-hu: Magyar
id-id: Bahasa Indonesia
nb-no: Norsk
zh-cn: 简体中文
uwu: Engwish
# Game voice pack language

View file

@ -95,6 +95,7 @@ settings:
hu-hu: Magyar
id-id: Bahasa Indonesia
nb-no: Norsk
zh-cn: 简体中文
uwu: Engwish
# Язык озвучки в игре

View file

@ -95,6 +95,7 @@ settings:
hu-hu: Magyar
id-id: Bahasa Indonesia
nb-no: Norsk
zh-cn: 简体中文
uwu: Engwish
# Game voice pack language
@ -328,18 +329,18 @@ tos_violation:
# Analytics window
analytics:
title: Yanfei's commission...
header: Participate in anonymous data collection
title: Yanfei's commission... (≧◡≦)
header: pawticipate in a-anonymous data cowwection
body:
- To count the active user base for Linux, Yanfei would like to collect your IP address everytime the game updates
- The IP address will be hashed for security purpose
- to count the active u-user base fow winux, yanfei wouwd wike to c-cowwect youw ip addwess evewytime the g-game updates
- the ip addwess will be hashed f-fow secuwity puwpose
actions:
share_country:
title: Share country
hint: Allow Yanfei to store the country your IP address registered in to make statistics more detailed. No other data than the country will be stored
title: share countwy
hint: awwow yanfei t-to store the countwy y-youw ip addwess w-wegistewed in to make statistics more detaiwed (* ^ ω ^) n-no other data than the countwy will be stowed
participate: Participate
skip: Skip
skip_forever: Skip and don't ask again
participate: pawticipate
skip: skip
skip_forever: skip and don't ask again

343
public/locales/zh-cn.yaml Normal file
View file

@ -0,0 +1,343 @@
# Splash window
splash:
title: 启动器加载中
phrases:
- 一些重要的事情...
- 抽神子...
- 捡材料...
- 凹深渊...
- 收集成就...
- 培养武神七七...
- 为五星献祭...
- 寻找联机好友...
# Launcher window
launcher:
# Progress bar
progress:
pause: 暂停
resume: 恢复
# Game installation
game:
downloading: 下载游戏中...
unpacking: 解压游戏中...
applying_changes: 应用更改...
deleting_outdated: 删除过期文件...
# Voice packages installation
voice:
deleting: 删除语音包...
downloading: 下载 {voice} 语音包中...
unpacking: 解压 {voice} 语音包中...
# Launcher states
states:
# When the game should be installed or updated
installation:
install_wine: 安装 Wine
install_dxvk: 安装 DXVK
install: 安装
update: 更新
apply_changes:
title: 应用更改
hint: 对游戏文件应用 hdiff 更改
remove_outdated:
title: 移除过期
hint: 移除过期的游戏文件
# When the game should be patched
patching:
# Patch unavailable
unavailable:
title: 补丁不可用
hint: 这个游戏版本还没有反作弊补丁。
请稍等几天,会有稳定或者测试版本的补丁
# Patch is in testing
test:
title: 应用测试版补丁
hint: 这个游戏版本有一个实验性的反作弊补丁。
你可以在它稳定之前等上几天,或者自担风险地应用测试补丁
# Patch is stable
stable: 应用补丁
# When the game is ready for playing
ready:
launch: 启动
predownload: 预下载更新
# Settings window
settings:
# General
general:
title: 通用
items:
# Language selection
lang:
# Launcher language
launcher:
title: 启动器
items:
en-us: English (US)
ru-ru: Русский
es-es: Español
de-de: Deutsch
fr-fr: Français
it-it: Italiano
hu-hu: Magyar
id-id: Bahasa Indonesia
nb-no: Norsk
zh-cn: 简体中文
uwu: Engwish
# Game voice pack language
voice:
title: 语音包
tooltip: 你只能在游戏中手动选择新的语音包
items:
en-us: 英语(美国)
ja-jp: 日语
ko-kr: 汉语
zh-cn: 中文
# Launcher theme
theme:
title: 主题
items:
system: 跟随系统
light: 明亮
dark: 暗色
# Discord RPC
discord:
title: Discord RPC
settings:
title: Discord RPC 设置
items:
timer: 显示预估耗时
in-launcher: 启动器内文本
in-game: 游戏内文本
selectIcon: 选择图标
# Some buttons
buttons:
winetricks: winetricks
winecfg: winecfg
launcher: 启动器文件夹
game: 游戏文件夹
# Enhancements
enhancements:
title: 增强功能
# Enhancements related to the wine
wine:
title: Wine
items:
# HUD
hud:
title: HUD
items:
none:
dxvk: DXVK
mangohud: MangoHUD
# Wine synchronization
winesync:
title: Wine 同步
tooltip: ESync 是一种同步多线程操作的机制。它可以提高你的游戏性能。
FSync 是 ESync 的改进版,可用于特定的内核版本
items:
none:
esync: ESync
fsync: FSync
futex2: Futex2
# AMD FSR
fsr:
title: 开启 AMD FSR
tooltip: 这个选项开启 AMD FidelityFX Super Resolution (FSR)
它可以在不掉帧的情况下提高游戏分辨率
# Wine Virtual Desktop
winevd:
title: 虚拟桌面
settings:
title: 虚拟桌面设置
items:
width:
height:
# Enhancements related to the game
game:
title: 游戏
items:
# GameMode
gamemode:
title: 使用 GameMode
tooltip:
enabled: 这是一个能够提高游戏性能的软件
disabled: ⚠️ 你没有安装 gamemode 软件包
# Borderless Window
borderless_window:
title: 允许无边框窗口
tooltip: 移除窗口模式下的窗口边框。
To play in a fullscreen borderless window, press alt+enter when playing on fullscreen
# Unlock FPS
fps_unlocker:
title: 解锁帧率
tooltip: 这个选项将会解锁最高 60 帧的限制
# Use separate terminal window to run the game
use_terminal:
title: 使用终端
tooltip: 启用该选项后,启动器将在一个单独的终端窗口中运行 wine 命令
# Enhancements related to the launcher
launcher:
title: 启动器
items:
# Delete logs
purge_logs:
# Game logs (DXVK)
game:
title: 删除 DXVK 日志
tooltip: 启用该选项后,您的启动器将自动
删除 DXVK 日志文件。
# Launcher logs
launcher:
title: 删除启动器日志
tooltip: 日志保留时间
items:
1d: 1
3d: 3
5d: 5
7d: 1
14d: 2
never: 永久
# Runners
runners:
title: Wine 版本
items:
recommended:
title: 只显示推荐
tooltip: 这个选项会隐藏不能正常游玩的 wine 版本
# DXVKs
dxvks:
title: DXVK
items:
recommended:
title: 只显示推荐
tooltip: 这个选先会隐藏老的 DXVK 版本
# Shaders
shaders:
title: 着色器
items:
shaders:
title: 着色器
tooltip: 在游戏中使用 HOME 键切换着色器
items:
none:
custom: 自定义
author: '作者:{author}'
no_images: 无图片
not_installed: 你还没有安装 vkBasalt 和 reshade-shaders 库
# Environmantal variables manager
environment:
title: 环境变量
items:
# Table rows
table:
name:
value:
# Table buttons
buttons:
add: 添加
delete: 删除
# Notifications
notifications:
# Launcher update
launcher_update_available:
title: '启动器更新可用:{from} -> {to}'
body: 你可以从位于 {repository} 的项目仓库下载新版本的启动器
# Before telemetry check when iputils is not downloaded
iputils_package_required:
title: 二次元游戏启动器
body: 为了检查遥测服务的状态你必须安装 iputils
# When telemetry servers are not disabled
telemetry_not_disabled:
title: 二次元游戏启动器
body: 遥测服务未禁用
# Before patch applying when xdelta3 package is not downloaded
xdelta3_package_required:
title: 二次元游戏启动器
body: 为了应用补丁你必须安装 xdelta3
# If patch wasn't applied because of some error
patch_applying_error:
title: 二次元游戏启动器
body: 补丁安装失败。请检查日志以找到原因,或者在我们的 discord 服务器上获取帮助
# Patch repositories are not available
patch_repos_unavailable:
title: 二次元游戏启动器
body: 没有可用的补丁仓库。你可以运行游戏,但启动器不能确定它是否打了补丁。
# HDiffPatch couldn't successfully apply game files changes
game_changes_applying_error:
title: 游戏更新中发生了一个错误
body: '{files} 文件没有被 hdiff 不补丁更新'
# ToS violation warning window
tos_violation:
title: 违反服务条款警告
heading: ⚠️ 请注意
body: 这个启动器是一个非官方工具,与 {company} 和 {company_alterego} 无关。
设计这个工具是为了在 Linux 上更方便的游玩 {game}
构建它的唯一目的是减少安装和运行游戏中的麻烦。
它通过结合现有的项目并简化用户操作来达到上述目标。
然而,这里使用的一些组件可能违反了 {company} 对于 {game} 的服务条款。
如果你使用这个启动器, 你的游戏帐号可能被 {company}/{company_alterego} 认定为违反服务条款。
如果发生这种情况,因为你违反了服务条款, {company}/{company_alterego} 可以采取任何他们认为合适的措施, 包括封禁帐号。
如果你理解使用非官方客户端游玩的风险, 按下确定来探索提瓦特吧!
buttons:
ok:
title: 我理解风险
tooltip: 你真的应该阅读上述文字。这很重要
cancel: 取消
discord: 我们的 discord 服务器
# Analytics window
analytics:
title: 烟绯的委托...
header: 参与匿名数据收集
body:
- 为了统计 Linux 的用户活跃数据,烟绯想在每次游戏更新时收集你的 IP 地址。
- 安全起见, IP 地址将被加密。
actions:
share_country:
title: 分享地区
hint: 为使统计数据更加详细,允许烟绯存储你的 IP 地址注册国家。除了国家之外,没有其他数据会被存储
participate: 加入
skip: 跳过
skip_forever: 跳过并不再询问

View file

@ -1,17 +1,26 @@
import { Configs, promisify } from './empathize';
import { Configs } from './empathize';
import constants from './ts/Constants';
import Locales from './ts/launcher/Locales';
export default new Promise<void>(async (resolve) => {
const systemLocale = await Locales.system();
await Configs.defaults({
lang: {
launcher: await Locales.system(),
launcher: systemLocale,
voice: [
'en-us'
]
},
/**
* Game server
*
* Available options: "global" and "cn"
*/
server: systemLocale === 'zh-cn' ? 'cn' : 'global',
folders: {
/**
* Path to wine prefix

View file

@ -11,6 +11,7 @@ register('it-it', () => Locales.get('it-it'));
register('hu-hu', () => Locales.get('hu-hu'));
register('id-id', () => Locales.get('id-id'));
register('nb-no', () => Locales.get('nb-no'));
register('zh-cn', () => Locales.get('zh-cn'));
register('uwu', () => Locales.get('uwu'));
Locales.default().then((locale) => {

View file

@ -62,7 +62,7 @@
<p>{$_(`splash.phrases.${phrase}`, {
values: {
// Required by de-de locale
game: constants.placeholders.uppercase.full
game: constants.placeholders.uppercase.full.global
}
})}</p>
</main>

View file

@ -58,7 +58,7 @@
values: {
company: constants.placeholders.uppercase.company,
company_alterego: constants.placeholders.uppercase.company_alterego,
game: constants.placeholders.uppercase.full
game: constants.placeholders.uppercase.full.global
}
})}</p>

View file

@ -1,5 +1,9 @@
import type { AvailableLocales } from './launcher/Locales';
import { Configs } from '../empathize';
import Game from './Game';
declare const Neutralino;
declare const NL_CWD;
@ -142,7 +146,13 @@ class Paths
*/
public static get gameDataDir(): Promise<string>
{
return new Promise(async (resolve) => resolve(`${await this.gameDir}/${constants.placeholders.uppercase.first + constants.placeholders.uppercase.second}_Data`));
return new Promise(async (resolve) => {
const folder = await Game.server === 'global' ?
constants.placeholders.uppercase.first + constants.placeholders.uppercase.second :
constants.placeholders.uppercase.full.cn;
resolve(`${await this.gameDir}/${folder}_Data`);
});
}
/**
@ -188,7 +198,10 @@ export default class constants
/**
* Anime Game
*/
full: atob('R2Vuc2hpbiBJbXBhY3Q='),
full: {
global: atob('R2Vuc2hpbiBJbXBhY3Q='),
cn: atob('WXVhblNoZW4=')
},
/**
* anAnimeCompany
@ -215,35 +228,55 @@ export default class constants
}
};
protected static readonly api = {
key: {
global: 'gcStgarh',
cn: 'eYd89JmJ'
},
launcher_id: {
global: 10,
cn: 18
}
};
public static readonly uri = {
api: `https://sdk-os-static.${this.placeholders.lowercase.company}.com/hk4e_global/mdk/launcher/api`,
api: {
global: `https://sdk-os-static.${this.placeholders.lowercase.company}.com/hk4e_global/mdk/launcher/api`,
cn: `https://sdk-static.${this.placeholders.lowercase.company}.com/hk4e_cn/mdk/launcher/api`
},
patch: {
origin: 'https://notabug.org/Krock/dawn',
additional: 'https://dev.kaifa.ch/Maroxy/dawn'
},
launcher: 'https://gitlab.com/KRypt0n_/an-anime-game-launcher',
discord: 'https://discord.gg/ck37X6UWBp',
telemetry: [
atob('bG9nLXVwbG9hZC1vcy5taWhveW8uY29t'),
atob('b3ZlcnNlYXVzcGlkZXIueXVhbnNoZW4uY29t')
],
telemetry: {
global: [
atob('bG9nLXVwbG9hZC1vcy5taWhveW8uY29t'),
atob('b3ZlcnNlYXVzcGlkZXIueXVhbnNoZW4uY29t')
],
cn: [
atob('bG9nLXVwbG9hZC5taWhveW8uY29t'),
atob('dXNwaWRlci55dWFuc2hlbi5jb20=')
]
},
winetricks: 'https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks',
fpsunlock: {
unlocker: `https://github.com/34736384/${this.placeholders.lowercase.first}-fps-unlock/releases/download/v1.4.2/unlockfps.exe`,
bat: 'https://dev.kaifa.ch/Maroxy/an-anime-game-aur/raw/branch/fpsunlock/fpsunlock.bat'
},
launcher: 'https://gitlab.com/KRypt0n_/an-anime-game-launcher',
discord: 'https://discord.gg/ck37X6UWBp',
analytics: 'https://aagl.launcher.moe/stat/'
};
// TODO: cache drops at that dates instead of the 7 days period
/*public static readonly cacheDropDates = [
new Date('November 24, 2021').getTime(), // 2.3.0 half 1 release
new Date('December 15, 2021').getTime(), // 2.3.0 half 2 release
new Date('January 5, 2022').getTime() // 2.4.0 half 1 release
];*/
public static readonly paths = Paths;
public static readonly versionsUri: string = `${this.uri.api}/resource?key=gcStgarh&launcher_id=10`;
public static readonly backgroundUri: string = `${this.uri.api}/content?filter_adv=true&launcher_id=10&key=gcStgarh&language=`;
public static versionsUri(server: 'global' | 'cn'): string
{
return `${this.uri.api[server]}/resource?key=${this.api.key[server]}&launcher_id=${this.api.launcher_id[server]}`;
}
public static backgroundUri(server: 'global' | 'cn', lang: AvailableLocales): string
{
return `${this.uri.api[server]}/content?filter_adv=true&key=${this.api.key[server]}&launcher_id=${this.api.launcher_id[server]}&language=${lang}`;
}
}

View file

@ -7,7 +7,7 @@ import type {
import type { Stream as DownloadingStream } from '@empathize/framework/dist/network/Downloader';
import { fetch, Domain, promisify, Downloader, Cache, Debug, Package } from '../empathize';
import { fetch, Domain, promisify, Downloader, Cache, Debug, Package, Configs } from '../empathize';
import { DebugThread } from '@empathize/framework/dist/meta/Debug';
import constants from './Constants';
@ -25,6 +25,18 @@ class Stream extends AbstractInstaller
export default class Game
{
protected static _server: 'global' | 'cn' | null = null;
public static get server(): Promise<'global' | 'cn'>
{
return new Promise(async (resolve) => {
if (!this._server)
this._server = (await Configs.get('server')) as 'global' | 'cn';
resolve(this._server);
})
}
/**
* Get current installed game version
*
@ -64,7 +76,7 @@ export default class Game
public static getLatestData(): Promise<Data>
{
return new Promise(async (resolve, reject) => {
const response = await fetch(constants.versionsUri);
const response = await fetch(constants.versionsUri(await this.server));
if (response.ok)
{
@ -266,7 +278,7 @@ export default class Game
else
{
const pipeline = promisify({
callbacks: await constants.uri.telemetry.map((domain) => {
callbacks: await constants.uri.telemetry[await this.server].map((domain) => {
return new Promise((resolve) => {
Domain.getInfo(domain).then((info) => resolve(info.available));
});

View file

@ -112,7 +112,11 @@ export default class Launcher
{
locale.set(record.pop().data.locale);
Background.get().then((uri) => document.getElementsByClassName('background')[0]!.setAttribute('src', uri));
Background.get().then((uri) => {
if (uri)
document.getElementsByClassName('background')[0]!.setAttribute('src', uri);
});
this.getSocial().then((uri) => document.getElementById('social-iframe')!.setAttribute('src', uri));
}
}
@ -140,6 +144,8 @@ export default class Launcher
/**
* Get launcher social buttons uri
*
* TODO: Chinese URI
*/
public getSocial(): Promise<string>
{

View file

@ -343,7 +343,7 @@ export default class Patch
else
{
fetch(`${patchUri}/raw/master/${version.replaceAll('.', '')}/patch_files/unityplayer_patch_os.vcdiff`, this.fetchTimeout)
.then((response) => {
.then(async (response) => {
// Return an error if patch's server is unavailable
if (response.status === null)
rejectOutput(new Error(`${source} patch repository is unreachable`));
@ -356,7 +356,8 @@ export default class Patch
version: version,
state: 'preparation',
applied: false,
source: source
source: source,
server: await Game.server
});
}
@ -370,7 +371,7 @@ export default class Patch
rejectOutput(new Error(`${source} patch repository is unreachable`));
else patcherResponse.body(this.fetchTimeout)
.then((response) => {
.then(async (response) => {
// Return an error if patch's server is unavailable
if (response === '')
rejectOutput(new Error(`${source} patch repository is unreachable`));
@ -386,22 +387,28 @@ export default class Patch
version: version,
state: response.includes(stableMark) ? 'stable' : 'testing',
applied: false,
source: source
source: source,
server: await Game.server
};
const originalPlayer = /if \[ "\${sum}" == "([a-z0-9]{32})" \]; then/mg.exec(response);
const hashesMatches = [...response.matchAll(/if \[ "\${sum}" == "([a-z0-9]{32})" \]; then/mg)];
// If we could get original UnityPlayer.dll hash - then we can
// compare it with actual UnityPlayer.dll hash and say whether the patch
// was applied or not
if (originalPlayer !== null)
if (hashesMatches.length === 2)
{
const originalPlayer = {
global: hashesMatches[0][1],
cn: hashesMatches[1][1]
}[patchInfo.server];
constants.paths.gameDir.then((gameDir) => {
Neutralino.filesystem.readBinaryFile(`${gameDir}/UnityPlayer.dll`)
.then((currPlayer: ArrayBuffer) => {
patchInfo.applied = md5(currPlayer) != originalPlayer[1];
patchInfo.applied = md5(currPlayer) != originalPlayer;
resolveOutput(patchInfo, originalPlayer[1]);
resolveOutput(patchInfo, originalPlayer);
})
.catch(() => resolveOutput(patchInfo));
});

View file

@ -2,19 +2,41 @@ import { fetch } from '../../empathize';
import constants from '../Constants';
import Locales from './Locales';
import Game from '../Game';
export default class Background
{
/**
* Get background uri
*
* @return null if uri is not available
*/
public static get(): Promise<string>
public static get(): Promise<string|null>
{
return new Promise(async (resolve) => {
fetch(constants.backgroundUri + Locales.fallback((await Locales.default()) ?? 'en-us'))
.then((header) => header.body().then((body) => {
resolve(JSON.parse(body).data.adv.background);
}));
const server = await Game.server;
const locale = Locales.fallback((await Locales.default()) ?? 'en-us');
const tryToFetch = (server: 'global' | 'cn'): Promise<string|null> => {
return new Promise((resolve) => {
fetch(constants.backgroundUri(server, locale))
.then((header) => header.body().then((body) => {
const data = JSON.parse(body);
if (data.message !== 'OK' || data.data.adv === null)
{
if (server === 'global')
resolve(null);
else tryToFetch('global').then(resolve);
}
else resolve(data.data.adv.background);
}));
});
};
tryToFetch(server).then(resolve);
});
}

View file

@ -11,6 +11,7 @@ type AvailableLocales =
// Supported by the game's API
| 'en-us' | 'ru-ru' | 'es-es'
| 'de-de' | 'fr-fr' | 'id-id'
| 'zh-cn'
// Unsupported by the game's API
| 'it-it' | 'hu-hu' | 'uwu'
@ -24,7 +25,7 @@ export default class Locales
* List of locales supported by the game's API
*/
public static readonly supportedLocales: AvailableLocales[] = [
'en-us', 'ru-ru', 'es-es', 'de-de', 'fr-fr', 'id-id'
'en-us', 'ru-ru', 'es-es', 'de-de', 'fr-fr', 'id-id', 'zh-cn'
];
/**

View file

@ -247,7 +247,7 @@ export default (launcher: Launcher): Promise<void> => {
// Game was closed
else
{
const stopTime = Date.now();
// const stopTime = Date.now();
Windows.current.show();
Windows.current.center(1280, 700);

View file

@ -19,6 +19,11 @@ type PatchInfo = {
* Source where this info was got from
*/
source?: 'origin' | 'additional';
/**
* Used game server
*/
server: 'global' | 'cn';
};
export type {