diff --git a/README.md b/README.md index 453b8c0..45589f1 100644 --- a/README.md +++ b/README.md @@ -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 * ToS Violation Window *(2.1.0)* * Add `latest.log` file generation *(2.1.2)* * Add an option to show terminal with the wine's log of the game *(7375c743, released in 2.1.3)* -* Statistics window -* Add Chinese game's version support (due to changes in the Krock's patch) +* Add analytics window *(e0a09323)* +* Add Chinese game's version support (due to changes in the Krock's patch) *(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 diff --git a/public/locales/de-de.yaml b/public/locales/de-de.yaml index ec7e4f1..1d6dc07 100644 --- a/public/locales/de-de.yaml +++ b/public/locales/de-de.yaml @@ -95,6 +95,7 @@ settings: hu-hu: Magyar id-id: Bahasa Indonesia nb-no: Norsk + zh-cn: 简体中文 uwu: Engwish # Spiel sprachpaket auswahl diff --git a/public/locales/en-us.yaml b/public/locales/en-us.yaml index 2b826de..db47d05 100644 --- a/public/locales/en-us.yaml +++ b/public/locales/en-us.yaml @@ -95,6 +95,7 @@ settings: hu-hu: Magyar id-id: Bahasa Indonesia nb-no: Norsk + zh-cn: 简体中文 uwu: Engwish # Game voice pack language diff --git a/public/locales/es-es.yaml b/public/locales/es-es.yaml index 4927063..e3e6324 100644 --- a/public/locales/es-es.yaml +++ b/public/locales/es-es.yaml @@ -95,6 +95,7 @@ settings: hu-hu: Magyar id-id: Bahasa Indonesia nb-no: Norsk + zh-cn: 简体中文 uwu: Engwish # Idioma del paquete de voz diff --git a/public/locales/fr-fr.yaml b/public/locales/fr-fr.yaml index 1410e3d..0deaa55 100644 --- a/public/locales/fr-fr.yaml +++ b/public/locales/fr-fr.yaml @@ -98,6 +98,7 @@ settings: hu-hu: Magyar id-id: Bahasa Indonesia nb-no: Norsk + zh-cn: 简体中文 uwu: Engwish # Game voice pack language diff --git a/public/locales/hu-hu.yaml b/public/locales/hu-hu.yaml index 5e71482..4cb7db2 100644 --- a/public/locales/hu-hu.yaml +++ b/public/locales/hu-hu.yaml @@ -95,6 +95,7 @@ settings: hu-hu: Magyar id-id: Bahasa Indonesia nb-no: Norsk + zh-cn: 简体中文 uwu: Engwish # Game voice pack language diff --git a/public/locales/id-id.yaml b/public/locales/id-id.yaml index a0f06b2..a55592c 100644 --- a/public/locales/id-id.yaml +++ b/public/locales/id-id.yaml @@ -95,6 +95,7 @@ settings: hu-hu: Magyar id-id: Bahasa Indonesia nb-no: Norsk + zh-cn: 简体中文 uwu: Engwish # Game voice pack language diff --git a/public/locales/it-it.yaml b/public/locales/it-it.yaml index 3ab7497..c7b8039 100644 --- a/public/locales/it-it.yaml +++ b/public/locales/it-it.yaml @@ -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 \ No newline at end of file + participate: Partecipa + skip: Rifiuta + skip_forever: Rifiuta e non chiedere più \ No newline at end of file diff --git a/public/locales/nb-no.yaml b/public/locales/nb-no.yaml index d4e2cbb..cde7263 100644 --- a/public/locales/nb-no.yaml +++ b/public/locales/nb-no.yaml @@ -95,6 +95,7 @@ settings: hu-hu: Magyar id-id: Bahasa Indonesia nb-no: Norsk + zh-cn: 简体中文 uwu: Engwish # Game voice pack language diff --git a/public/locales/ru-ru.yaml b/public/locales/ru-ru.yaml index fedd125..e192dbc 100644 --- a/public/locales/ru-ru.yaml +++ b/public/locales/ru-ru.yaml @@ -95,6 +95,7 @@ settings: hu-hu: Magyar id-id: Bahasa Indonesia nb-no: Norsk + zh-cn: 简体中文 uwu: Engwish # Язык озвучки в игре diff --git a/public/locales/uwu.yaml b/public/locales/uwu.yaml index 9c659c0..b9eee62 100644 --- a/public/locales/uwu.yaml +++ b/public/locales/uwu.yaml @@ -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 \ No newline at end of file + participate: pawticipate + skip: skip + skip_forever: skip and don't ask again \ No newline at end of file diff --git a/public/locales/zh-cn.yaml b/public/locales/zh-cn.yaml new file mode 100644 index 0000000..ef44af5 --- /dev/null +++ b/public/locales/zh-cn.yaml @@ -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: 跳过并不再询问 \ No newline at end of file diff --git a/src/defaultSettings.ts b/src/defaultSettings.ts index 5aa7baf..47d511e 100644 --- a/src/defaultSettings.ts +++ b/src/defaultSettings.ts @@ -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(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 diff --git a/src/i18n.ts b/src/i18n.ts index db473c1..76965ac 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -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) => { diff --git a/src/splash.svelte b/src/splash.svelte index e392381..a1d8040 100644 --- a/src/splash.svelte +++ b/src/splash.svelte @@ -62,7 +62,7 @@

{$_(`splash.phrases.${phrase}`, { values: { // Required by de-de locale - game: constants.placeholders.uppercase.full + game: constants.placeholders.uppercase.full.global } })}

diff --git a/src/tos-violation.svelte b/src/tos-violation.svelte index 23c8958..0fa8f6c 100644 --- a/src/tos-violation.svelte +++ b/src/tos-violation.svelte @@ -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 } })}

diff --git a/src/ts/Constants.ts b/src/ts/Constants.ts index 59ed46a..f45a5dd 100644 --- a/src/ts/Constants.ts +++ b/src/ts/Constants.ts @@ -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 { - 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}`; + } } diff --git a/src/ts/Game.ts b/src/ts/Game.ts index 18c8578..b03b153 100644 --- a/src/ts/Game.ts +++ b/src/ts/Game.ts @@ -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 { 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)); }); diff --git a/src/ts/Launcher.ts b/src/ts/Launcher.ts index bd2f2de..d09a4dc 100644 --- a/src/ts/Launcher.ts +++ b/src/ts/Launcher.ts @@ -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 { diff --git a/src/ts/Patch.ts b/src/ts/Patch.ts index 4a06bdc..216bbe5 100644 --- a/src/ts/Patch.ts +++ b/src/ts/Patch.ts @@ -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)); }); diff --git a/src/ts/launcher/Background.ts b/src/ts/launcher/Background.ts index 1f2a0d1..48dcdd0 100644 --- a/src/ts/launcher/Background.ts +++ b/src/ts/launcher/Background.ts @@ -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 + public static get(): Promise { 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 => { + 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); }); } diff --git a/src/ts/launcher/Locales.ts b/src/ts/launcher/Locales.ts index 1e13624..1de0c30 100644 --- a/src/ts/launcher/Locales.ts +++ b/src/ts/launcher/Locales.ts @@ -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' ]; /** diff --git a/src/ts/launcher/states/Launch.ts b/src/ts/launcher/states/Launch.ts index 9175067..b488e8a 100644 --- a/src/ts/launcher/states/Launch.ts +++ b/src/ts/launcher/states/Launch.ts @@ -247,7 +247,7 @@ export default (launcher: Launcher): Promise => { // Game was closed else { - const stopTime = Date.now(); + // const stopTime = Date.now(); Windows.current.show(); Windows.current.center(1280, 700); diff --git a/src/ts/types/Patch.d.ts b/src/ts/types/Patch.d.ts index b66fd3c..1ee339d 100644 --- a/src/ts/types/Patch.d.ts +++ b/src/ts/types/Patch.d.ts @@ -19,6 +19,11 @@ type PatchInfo = { * Source where this info was got from */ source?: 'origin' | 'additional'; + + /** + * Used game server + */ + server: 'global' | 'cn'; }; export type {