2.2.0-beta4

- added Marie Piontek as a project contributor
- added launcher icon
- made background picture caching
- made automatical patch downloading
- added social media buttons from the official launcher

Thanks Maroxy for all these enhancements
+ pull request #6
This commit is contained in:
Observer KRypt0n_ 2021-10-22 15:03:17 +02:00
parent 2015b831b0
commit 9801cf90df
No known key found for this signature in database
GPG key ID: DC5D4EC1303465DA
9 changed files with 72 additions and 68 deletions

View file

@ -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
* <s>Fix AppImage builds</s>
* <s>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))</s>
* <s>Fix AppImage builds</s> *(beta 3)*
* <s>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))</s> *(beta 3)*
* <s>Update launcher logo</s> *(beta 4)*
* <s>Cache launcher background picture ([pull request #6](https://notabug.org/nobody/an-anime-game-launcher/pulls/6))</s> *(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
<br>

View file

@ -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();
}

View file

@ -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 <marie@mxy.gg> (https://marie.omg.lol)"],
"author": "Nikita Podvirnyy <suimin.tu.mu.ga.mi@gmail.com>",
"contributors": [
"Marie Piontek <marie@mxy.gg> (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": [
{

BIN
public/images/icon256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 20 KiB

27
src/ts/GIJSON.d.ts vendored
View file

@ -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;

View file

@ -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<any>
{
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,

View file

@ -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 => {