diff --git a/README.md b/README.md index 36347db..6810ce4 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ | Game version | Launcher version | Patch version | | :---: | :---: | :---: | -| 2.2.0 | 2.2.0-beta3 ⚠️ | 2.2.0-stable ✅ | +| 2.2.0 | 2.2.0-beta4 ⚠️ | 2.2.0-stable ✅ | Download from [Releases](https://notabug.org/nobody/an-anime-game-launcher/releases) @@ -41,13 +41,17 @@ npm start To 2.2.0-release1 -* Fix AppImage builds -* Parse background banners from the game's API ([issue #1](https://notabug.org/nobody/an-anime-game-launcher/issues/1), [pull request #2](https://notabug.org/nobody/an-anime-game-launcher/pulls/2)) +* Fix AppImage builds *(beta 3)* +* Parse background banners from the game's API ([issue #1](https://notabug.org/nobody/an-anime-game-launcher/issues/1), [pull request #2](https://notabug.org/nobody/an-anime-game-launcher/pulls/2)) *(beta 3)* +* Update launcher logo *(beta 4)* +* Cache launcher background picture ([pull request #6](https://notabug.org/nobody/an-anime-game-launcher/pulls/6)) *(beta 4)* * Make Proton-GE default compatibility tool and fix game input issues * Add additional telemetry checking * Add preferences menu * Add launcher updates notifications -* Cache launcher background picture +* Make automatical patch state parsing + +And don't forget to change the patch's URI when it will be changed
diff --git a/entry.js b/entry.js index 4eb40f0..8f0006b 100644 --- a/entry.js +++ b/entry.js @@ -33,9 +33,9 @@ function createWindow () // open URLs in Browser instead of an pop-up in electron app. mainWindow.webContents.setWindowOpenHandler(({ url }) => { shell.openExternal(url); + return { action: 'deny' }; }); - // mainWindow.webContents.openDevTools(); } diff --git a/package.json b/package.json index 7a9e6a2..aaa2265 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,11 @@ { "name": "an-anime-game-linux-launcher", - "version": "2.2.0-beta3", + "version": "2.2.0-beta4", "description": "An Anime Game Linux Launcher", - "author": "Nikita Podvirnyy (https://notabug.org/nobody)", - "contributors": ["Marie Piontek (https://marie.omg.lol)"], + "author": "Nikita Podvirnyy ", + "contributors": [ + "Marie Piontek (https://marie.omg.lol)" + ], "license": "GPL-3.0", "main": "entry.js", "scripts": { @@ -23,7 +25,7 @@ "entry.js" ], "linux": { - "icon": "public/images/icon512.png", + "icon": "public/images/icon256.png", "category": "Utility", "target": [ { diff --git a/public/images/icon256.png b/public/images/icon256.png new file mode 100644 index 0000000..89738cd Binary files /dev/null and b/public/images/icon256.png differ diff --git a/public/images/icon512.png b/public/images/icon512.png deleted file mode 100644 index 300e309..0000000 Binary files a/public/images/icon512.png and /dev/null differ diff --git a/public/images/icon64.png b/public/images/icon64.png index 4163306..dae3e87 100644 Binary files a/public/images/icon64.png and b/public/images/icon64.png differ diff --git a/src/ts/GIJSON.d.ts b/src/ts/GIJSON.d.ts index 04ec4f0..51ca7d6 100644 --- a/src/ts/GIJSON.d.ts +++ b/src/ts/GIJSON.d.ts @@ -1,4 +1,5 @@ -interface VoicePack { +interface VoicePack +{ language: string; name: string; path: string; @@ -6,7 +7,8 @@ interface VoicePack { md5: string; } -interface Latest { +interface Latest +{ name: string; version: string; path: string; @@ -18,7 +20,8 @@ interface Latest { segments: any[]; } -interface Diff { +interface Diff +{ name: string; version: string; path: string; @@ -28,12 +31,14 @@ interface Diff { voice_packs: VoicePack[]; } -interface Game { +interface Game +{ latest: Latest; diffs: Diff[]; } -interface Plugins { +interface Plugins +{ name: string; version: string; path: string; @@ -42,17 +47,20 @@ interface Plugins { entry: string; } -interface Plugin { +interface Plugin +{ plugins: Plugins[]; version: string; } -interface DeprecatedPackage { +interface DeprecatedPackage +{ name: string; md5: string; } -interface Data { +interface Data +{ game: Game; plugin: Plugin; web_url: string; @@ -62,7 +70,8 @@ interface Data { sdk?: any; } -export default interface GIJSON { +export default interface GIJSON +{ retcode: number; message: string; data: Data; diff --git a/src/ts/Genshinlib.ts b/src/ts/Genshinlib.ts index 902f83f..8f0f7b0 100644 --- a/src/ts/Genshinlib.ts +++ b/src/ts/Genshinlib.ts @@ -1,4 +1,4 @@ -import GIJSON from "./GIJSON"; +import GIJSON from './GIJSON'; const https = require('https'); const fs = require('fs'); @@ -13,7 +13,7 @@ type Config = { }, background: { time: string|null, - name: string|null + file: string|null }, version: string|null, patch: { @@ -32,12 +32,13 @@ export class Genshinlib public static readonly launcherDir: string = path.join(os.homedir(), 'genshin-impact-launcher'); public static readonly launcherJson: string = path.join(this.launcherDir, 'launcher.json'); - public static readonly TMPpatchDir: string = path.join(this.launcherDir, 'gi-on-linux'); + public static readonly tmpPatchDir: string = path.join(this.launcherDir, 'gi-on-linux'); public static readonly prefixDir: string = path.join(this.launcherDir, 'game'); public static readonly gameDir: string = path.join(this.prefixDir, 'drive_c', 'Program Files', 'Genshin Impact'); - protected static uri: string = 'https://sdk-os-static.mihoyo.com/hk4e_global/mdk/launcher/api/resource?key=gcStgarh&launcher_id=10'; + protected static versionsUri: string = 'https://sdk-os-static.mihoyo.com/hk4e_global/mdk/launcher/api/resource?key=gcStgarh&launcher_id=10'; + protected static backgroundUri: string = 'https://sdk-os-static.mihoyo.com/hk4e_global/mdk/launcher/api/content?filter_adv=true&launcher_id=10&language='; public static get version(): Config['version'] { @@ -78,7 +79,7 @@ export class Genshinlib public static async getData (): Promise { return new Promise((resolve, reject) => { - https.get(this.uri, (response: any) => { + https.get(this.versionsUri, (response: any) => { let data = ''; response.on('data', (chunk: any) => data += chunk); @@ -100,36 +101,36 @@ export class Genshinlib if (!this.getConfig().background.time || new Date(new Date().setHours(0,0,0,0)).setDate(new Date(new Date().setHours(0,0,0,0)).getDate()).toString() >= this.getConfig().background.time!) { - await fetch(`https://sdk-os-static.mihoyo.com/hk4e_global/mdk/launcher/api/content?filter_adv=true&launcher_id=10&language=${this.lang.launcher}`) + await fetch(this.backgroundUri + this.lang.launcher) .then(res => res.json()) .then(async resdone => { - let oldbg = this.getConfig().background.name; + let oldbg = this.getConfig().background.file; this.setConfig({ ...this.getConfig(), background: { time: new Date(new Date().setHours(0,0,0,0)).setDate(new Date(new Date().setHours(0,0,0,0)).getDate() + 7).toString(), - name: resdone.data.adv.background.replace(/.*\//, '') + file: resdone.data.adv.background.replace(/.*\//, '') } }); - if (fs.existsSync(path.join(this.launcherDir, this.getConfig().background.name))) - { - bg = path.join(this.launcherDir, this.getConfig().background.name); - } + if (fs.existsSync(path.join(this.launcherDir, this.getConfig().background.file))) + bg = path.join(this.launcherDir, this.getConfig().background.file); + else { - await this.downloadFile(resdone.data.adv.background, path.join(this.launcherDir, this.getConfig().background.name), (current: number, total: number, difference: number) => null).then(() => { - !oldbg ? console.log('No Old Background Found.') : fs.unlinkSync(path.join(this.launcherDir, oldbg)); - bg = path.join(this.launcherDir, this.getConfig().background.name); + await this.downloadFile(resdone.data.adv.background, path.join(this.launcherDir, this.getConfig().background.file), (current: number, total: number, difference: number) => null).then(() => { + !oldbg ? + console.log('No old background found') : + fs.unlinkSync(path.join(this.launcherDir, oldbg)); + + bg = path.join(this.launcherDir, this.getConfig().background.file); }); }; }); } - else - { - bg = path.join(this.launcherDir, this.getConfig().background.name); - }; + + else bg = path.join(this.launcherDir, this.getConfig().background.file); return bg; } @@ -155,9 +156,7 @@ export class Genshinlib }); response.on('end', () => resolve()); - }).on('error', (err: Error) => { - reject(err); - }); + }).on('error', (err: Error) => reject(err)); }); } @@ -177,15 +176,13 @@ export class Genshinlib line = line.slice(0, -1); let matches = /^(\d+) [a-zA-Z\:]+[ ]+(\d+)[ ]+[0-9\-]+% [0-9\-]+ [0-9\:]+ [a-f0-9]{8} (.+)/.exec(line); - if (matches) { + + if (matches) return { path: matches[3], - compressedSize: parseInt(matches[2]), - uncompressedSize: parseInt(matches[1]) }; - }; }); let total = fs.statSync(zipPath)['size'], current = 0; @@ -268,21 +265,23 @@ export class Genshinlib return fs.existsSync(path.join(prefixPath, 'drive_c')); } - public static patchGame (version: string, onFinish: () => void, onData: (data: string) => void) { + public static patchGame (version: string, onFinish: () => void, onData: (data: string) => void) + { this.downloadFile('https://notabug.org/Krock/GI-on-Linux/archive/master.zip', path.join(this.launcherDir, 'krock.zip'), (current: number, total: number, difference: number) => null).then(() => { this.unzip(path.join(this.launcherDir, 'krock.zip'), this.launcherDir, (current: number, total: number, difference: number) => null).then(() => { // Delete zip file and assign patch directory. fs.unlinkSync(path.join(this.launcherDir, 'krock.zip')); - let patchdir: string = path.join(this.TMPpatchDir, version.replace(/\./g, '')); + + let patchDir: string = path.join(this.tmpPatchDir, version.replace(/\./g, '')); // Patch out the testing phase content from the shell files if active and make sure the shell files are executable. - exec(`cd ${patchdir} && sed -i '/^echo "If you would like to test this patch, modify this script and remove the line below this one."/,+5d' patch.sh`); - exec(`cd ${patchdir} && sed -i '/^echo " necessary afterwards (Friday?). If that's the case, comment the line below."/,+2d' patch_anti_logincrash.sh`); - exec(`chmod +x ${path.join(patchdir, 'patch.sh')}`); - exec(`chmod +x ${path.join(patchdir, 'patch_anti_logincrash.sh')}`); + exec(`cd ${patchDir} && sed -i '/^echo "If you would like to test this patch, modify this script and remove the line below this one."/,+5d' patch.sh`); + exec(`cd ${patchDir} && sed -i '/^echo " necessary afterwards (Friday?). If that's the case, comment the line below."/,+2d' patch_anti_logincrash.sh`); + exec(`chmod +x ${path.join(patchDir, 'patch.sh')}`); + exec(`chmod +x ${path.join(patchDir, 'patch_anti_logincrash.sh')}`); // Execute the patch file with "yes yes" in the beginning to agree to the choices. - let patcherProcess = exec(`yes yes | ${path.join(patchdir, 'patch.sh')}`, { + let patcherProcess = exec(`yes yes | ${path.join(patchDir, 'patch.sh')}`, { cwd: this.gameDir, env: { ...process.env, @@ -294,7 +293,7 @@ export class Genshinlib patcherProcess.on('close', () => { // Execute the patch file with "yes" in the beginning to agree to the choice. - let patcherAntiCrashProcess = exec(`yes | ${path.join(patchdir, 'patch_anti_logincrash.sh')}`, { + let patcherAntiCrashProcess = exec(`yes | ${path.join(patchDir, 'patch_anti_logincrash.sh')}`, { cwd: this.gameDir, env: { ...process.env, @@ -305,7 +304,7 @@ export class Genshinlib patcherAntiCrashProcess.stdout.on('data', (data: string) => onData(data)); patcherAntiCrashProcess.on('close', () => { - fs.rmSync(this.TMPpatchDir, { recursive: true }); + fs.rmSync(this.tmpPatchDir, { recursive: true }); onFinish(); }); @@ -313,8 +312,8 @@ export class Genshinlib }); }); } - /* - public static applyPatch (onFinish: () => void, onData: (data: string) => void) + + /*public static applyPatch (onFinish: () => void, onData: (data: string) => void) { let patcherProcess = spawn('bash', [Genshinlib.patchSh], { cwd: Genshinlib.gameDir, diff --git a/src/ts/index.ts b/src/ts/index.ts index 925598e..ea9c189 100644 --- a/src/ts/index.ts +++ b/src/ts/index.ts @@ -17,23 +17,13 @@ $(() => { Genshinlib.getBackgroundUri().then(uri => $('body').css('background-image', `url(${ uri })`)); - // Don't really think we need this, but maybe in future~~ - fetch(`https://genshin.mihoyo.com/launcher/10/${ Genshinlib.getConfig().lang.launcher }?api_url=https%3A%2F%2Fapi-os-takumi.mihoyo.com%2Fhk4e_global&prev=false`) .then(res => res.text()) .then(body => { - // Get the element which should have the launchers content. - let container = document.getElementById('launchcontent'); + $(body).find('#__layout').appendTo('#launchcontent'); - // Parse the HTML and append the HTML from the site to the div. - let parser = new DOMParser(); - let converted = parser.parseFromString(body, 'text/html'); - container!.appendChild(converted.getElementById('__layout')!); - - // Get the home container to remove the functions that don't work currently. - let home = container!.getElementsByClassName('home__main')[0]; - home.removeChild(home.getElementsByClassName('home-swiper-wrap')[0]); - home.removeChild(home.getElementsByClassName('home-news')[0]); + $('#launchcontent .home__main .home-swiper-wrap').remove(); + $('#launchcontent .home__main .home-news').remove(); }); Genshinlib.getData().then(data => {