mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2025-03-19 22:50:09 +03:00
Merge remote-tracking branch 'original/main' into term
This commit is contained in:
commit
15472d64df
14 changed files with 333 additions and 150 deletions
|
@ -10,11 +10,11 @@
|
|||
|
||||
| Game version | Launcher version | Patch version |
|
||||
| :---: | :---: | :---: |
|
||||
| 2.2.0 | 2.2.0-beta5 ⚠️ | 2.2.0-stable ✅ |
|
||||
| 2.2.0 | 2.2.0-beta6 ⚠️ | 2.2.0-stable ✅ |
|
||||
|
||||
Download from [Releases](https://notabug.org/nobody/an-anime-game-launcher/releases)
|
||||
|
||||
> ⚠️ Launcher is currently in development
|
||||
> ⚠️ Launcher is currently in development, but you already can use it
|
||||
|
||||
# Requirements
|
||||
|
||||
|
@ -50,9 +50,11 @@ To 2.2.0-release1
|
|||
* <s>Cache launcher background picture ([pull request #6](https://notabug.org/nobody/an-anime-game-launcher/pulls/6))</s> *(beta 4)*
|
||||
* <s>Make Proton-GE default compatibility tool and fix game input issues</s> (added runners manager) *(beta 5)*
|
||||
* <s>Add preferences menu</s> *(beta 5)*
|
||||
* Add additional telemetry checking
|
||||
* <s>Add additional telemetry checking</s> *(beta 6)*
|
||||
* <s>Add DXVK downloading in settings</s> *(beta 6)*
|
||||
* Add launcher updates notifications
|
||||
* Make automatical patch state parsing
|
||||
* Add outdated files deletion when new game's update releases
|
||||
|
||||
And don't forget to change the patch's URI when it will be changed
|
||||
|
||||
|
|
46
dxvks.json
Normal file
46
dxvks.json
Normal file
|
@ -0,0 +1,46 @@
|
|||
[
|
||||
{
|
||||
"version": "1.9.2",
|
||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.9.2/dxvk-1.9.2.tar.gz"
|
||||
},
|
||||
{
|
||||
"version": "1.9.1",
|
||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.9.1/dxvk-1.9.1.tar.gz"
|
||||
},
|
||||
{
|
||||
"version": "1.9",
|
||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.9/dxvk-1.9.tar.gz"
|
||||
},
|
||||
{
|
||||
"version": "1.8.1",
|
||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.8.1/dxvk-1.8.1.tar.gz"
|
||||
},
|
||||
{
|
||||
"version": "1.8",
|
||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.8/dxvk-1.8.tar.gz"
|
||||
},
|
||||
{
|
||||
"version": "1.7.3",
|
||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.7.3/dxvk-1.7.3.tar.gz"
|
||||
},
|
||||
{
|
||||
"version": "1.7.2",
|
||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.7.2/dxvk-1.7.2.tar.gz"
|
||||
},
|
||||
{
|
||||
"version": "1.7.1",
|
||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.7.1/dxvk-1.7.1.tar.gz"
|
||||
},
|
||||
{
|
||||
"version": "1.7",
|
||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.7/dxvk-1.7.tar.gz"
|
||||
},
|
||||
{
|
||||
"version": "1.6.1",
|
||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.6.1/dxvk-1.6.1.tar.gz"
|
||||
},
|
||||
{
|
||||
"version": "1.6",
|
||||
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.6/dxvk-1.6.tar.gz"
|
||||
}
|
||||
]
|
19
entry.js
19
entry.js
|
@ -1,5 +1,12 @@
|
|||
const { app, BrowserWindow, ipcMain, Notification, shell } = require('electron');
|
||||
const { Genshinlib } = require('./public/js/Genshinlib');
|
||||
const {
|
||||
app,
|
||||
BrowserWindow,
|
||||
ipcMain,
|
||||
Notification,
|
||||
shell,
|
||||
nativeImage
|
||||
} = require('electron');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
let mainWindow;
|
||||
|
@ -8,10 +15,10 @@ ipcMain.handle('hide-window', () => mainWindow.hide());
|
|||
ipcMain.handle('show-window', () => mainWindow.show());
|
||||
|
||||
ipcMain.on('notification', (event, args) => {
|
||||
new Notification({
|
||||
title: args.title,
|
||||
body: args.content
|
||||
}).show();
|
||||
if (args.icon !== undefined)
|
||||
args.icon = nativeImage.createFromPath(args.icon);
|
||||
|
||||
new Notification(args).show();
|
||||
});
|
||||
|
||||
ipcMain.handle('open-settings', () => {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "an-anime-game-linux-launcher",
|
||||
"version": "2.2.0-beta5",
|
||||
"version": "2.2.0-beta6",
|
||||
"description": "An Anime Game Linux Launcher",
|
||||
"author": "Nikita Podvirnyy <suimin.tu.mu.ga.mi@gmail.com>",
|
||||
"contributors": [
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<div class="menu">
|
||||
<div class="menu-item menu-item-active" anchor="general" i18id="GeneralSettings">General</div>
|
||||
<div class="menu-item" anchor="runners" i18id="Runners">Runners</div>
|
||||
<div class="menu-item" anchor="dxvks">DXVK</div>
|
||||
</div>
|
||||
|
||||
<div class="settings">
|
||||
|
@ -59,6 +60,12 @@
|
|||
|
||||
<div class="list" id="runners-list"></div>
|
||||
</div>
|
||||
|
||||
<div class="settings-item" id="dxvks">
|
||||
<h2>DXVK</h2>
|
||||
|
||||
<div class="list" id="dxvk-list"></div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
BIN
public/images/baal-transparent.png
Normal file
BIN
public/images/baal-transparent.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 274 KiB |
BIN
public/images/baal.png
Normal file
BIN
public/images/baal.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 257 KiB |
BIN
public/images/baal64-transparent.png
Normal file
BIN
public/images/baal64-transparent.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
public/images/baal64.png
Normal file
BIN
public/images/baal64.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
159
runners.json
159
runners.json
|
@ -1,4 +1,72 @@
|
|||
[
|
||||
{
|
||||
"title": "Lutris",
|
||||
"runners": [
|
||||
{
|
||||
"name": "Lutris 6.14-4",
|
||||
"version": "6.14-4",
|
||||
"uri": "https://github.com/lutris/wine/releases/download/lutris-6.14-4/wine-lutris-6.14-4-x86_64.tar.xz",
|
||||
"archive": "tar",
|
||||
"folder": "lutris-6.14-4-x86_64",
|
||||
"makeFolder": false,
|
||||
"executable": "bin/wine64"
|
||||
},
|
||||
{
|
||||
"name": "Lutris 6.14-3",
|
||||
"version": "6.14-3",
|
||||
"uri": "https://github.com/lutris/wine/releases/download/lutris-6.14-3/wine-lutris-6.14-3-x86_64.tar.xz",
|
||||
"archive": "tar",
|
||||
"folder": "lutris-6.14-3-x86_64",
|
||||
"makeFolder": false,
|
||||
"executable": "bin/wine64"
|
||||
},
|
||||
{
|
||||
"name": "Lutris 6.14-2",
|
||||
"version": "6.14-2",
|
||||
"uri": "https://github.com/lutris/wine/releases/download/lutris-6.14-2/wine-lutris-6.14-2-x86_64.tar.xz",
|
||||
"archive": "tar",
|
||||
"folder": "lutris-6.14-2-x86_64",
|
||||
"makeFolder": false,
|
||||
"executable": "bin/wine64"
|
||||
},
|
||||
{
|
||||
"name": "Lutris 6.14",
|
||||
"version": "6.14",
|
||||
"uri": "https://github.com/lutris/wine/releases/download/lutris-6.14/wine-lutris-6.14-x86_64.tar.xz",
|
||||
"archive": "tar",
|
||||
"folder": "lutris-6.14-x86_64",
|
||||
"makeFolder": false,
|
||||
"executable": "bin/wine64"
|
||||
},
|
||||
{
|
||||
"name": "Lutris 6.13-3",
|
||||
"version": "6.13-3",
|
||||
"uri": "https://github.com/lutris/wine/releases/download/lutris-6.13-3/wine-lutris-6.13-3-x86_64.tar.xz",
|
||||
"archive": "tar",
|
||||
"folder": "lutris-6.13-3-x86_64",
|
||||
"makeFolder": false,
|
||||
"executable": "bin/wine64"
|
||||
},
|
||||
{
|
||||
"name": "Lutris 6.13-2",
|
||||
"version": "6.13-2",
|
||||
"uri": "https://github.com/lutris/wine/releases/download/lutris-6.13-2/wine-lutris-6.13-2-x86_64.tar.xz",
|
||||
"archive": "tar",
|
||||
"folder": "lutris-6.13-2-x86_64",
|
||||
"makeFolder": false,
|
||||
"executable": "bin/wine64"
|
||||
},
|
||||
{
|
||||
"name": "Lutris 6.13",
|
||||
"version": "6.13",
|
||||
"uri": "https://github.com/lutris/wine/releases/download/lutris-6.13/wine-lutris-6.13-x86_64.tar.xz",
|
||||
"archive": "tar",
|
||||
"folder": "lutris-6.13-x86_64",
|
||||
"makeFolder": false,
|
||||
"executable": "bin/wine64"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Proton-GE",
|
||||
"runners": [
|
||||
|
@ -93,96 +161,5 @@
|
|||
"executable": "files/bin/wine64"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Lutris",
|
||||
"runners": [
|
||||
{
|
||||
"name": "Lutris 6.14-4",
|
||||
"version": "6.14-4",
|
||||
"uri": "https://github.com/lutris/wine/releases/download/lutris-6.14-4/wine-lutris-6.14-4-x86_64.tar.xz",
|
||||
"archive": "tar",
|
||||
"folder": "lutris-6.14-4-x86_64",
|
||||
"makeFolder": false,
|
||||
"executable": "bin/wine64"
|
||||
},
|
||||
{
|
||||
"name": "Lutris 6.14-3",
|
||||
"version": "6.14-3",
|
||||
"uri": "https://github.com/lutris/wine/releases/download/lutris-6.14-3/wine-lutris-6.14-3-x86_64.tar.xz",
|
||||
"archive": "tar",
|
||||
"folder": "lutris-6.14-3-x86_64",
|
||||
"makeFolder": false,
|
||||
"executable": "bin/wine64"
|
||||
},
|
||||
{
|
||||
"name": "Lutris 6.14-2",
|
||||
"version": "6.14-2",
|
||||
"uri": "https://github.com/lutris/wine/releases/download/lutris-6.14-2/wine-lutris-6.14-2-x86_64.tar.xz",
|
||||
"archive": "tar",
|
||||
"folder": "lutris-6.14-2-x86_64",
|
||||
"makeFolder": false,
|
||||
"executable": "bin/wine64"
|
||||
},
|
||||
{
|
||||
"name": "Lutris 6.14",
|
||||
"version": "6.14",
|
||||
"uri": "https://github.com/lutris/wine/releases/download/lutris-6.14/wine-lutris-6.14-x86_64.tar.xz",
|
||||
"archive": "tar",
|
||||
"folder": "lutris-6.14-x86_64",
|
||||
"makeFolder": false,
|
||||
"executable": "bin/wine64"
|
||||
},
|
||||
{
|
||||
"name": "Lutris 6.10-2",
|
||||
"version": "6.10-2",
|
||||
"uri": "https://github.com/lutris/wine/releases/download/lutris-6.10-2/wine-lutris-6.10-2-x86_64.tar.xz",
|
||||
"archive": "tar",
|
||||
"folder": "lutris-6.10-2-x86_64",
|
||||
"makeFolder": false,
|
||||
"executable": "bin/wine64"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Lutris-fshack",
|
||||
"runners": [
|
||||
{
|
||||
"name": "Lutris-fshack 6.14-4",
|
||||
"version": "6.14-4-fshack",
|
||||
"uri": "https://github.com/lutris/wine/releases/download/lutris-6.14-4/wine-lutris-fshack-6.14-4-x86_64.tar.xz",
|
||||
"archive": "tar",
|
||||
"folder": "lutris-fshack-6.14-4-x86_64",
|
||||
"makeFolder": false,
|
||||
"executable": "bin/wine64"
|
||||
},
|
||||
{
|
||||
"name": "Lutris-fshack 6.14-3",
|
||||
"version": "6.14-3-fshack",
|
||||
"uri": "https://github.com/lutris/wine/releases/download/lutris-6.14-3/wine-lutris-fshack-6.14-3-x86_64.tar.xz",
|
||||
"archive": "tar",
|
||||
"folder": "lutris-fshack-6.14-3-x86_64",
|
||||
"makeFolder": false,
|
||||
"executable": "bin/wine64"
|
||||
},
|
||||
{
|
||||
"name": "Lutris-fshack 6.14-2",
|
||||
"version": "6.14-2-fshack",
|
||||
"uri": "https://github.com/lutris/wine/releases/download/lutris-6.14-2/wine-lutris-fshack-6.14-2-x86_64.tar.xz",
|
||||
"archive": "tar",
|
||||
"folder": "lutris-fshack-6.14-2-x86_64",
|
||||
"makeFolder": false,
|
||||
"executable": "bin/wine64"
|
||||
},
|
||||
{
|
||||
"name": "Lutris-fshack 6.14",
|
||||
"version": "6.14-fshack",
|
||||
"uri": "https://github.com/lutris/wine/releases/download/lutris-6.14/wine-lutris-fshack-6.14-x86_64.tar.xz",
|
||||
"archive": "tar",
|
||||
"folder": "lutris-fshack-6.14-x86_64",
|
||||
"makeFolder": false,
|
||||
"executable": "bin/wine64"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -71,8 +71,9 @@ body
|
|||
cursor: pointer
|
||||
|
||||
> div
|
||||
width: 52px
|
||||
width: auto
|
||||
height: 52px
|
||||
min-width: 52px
|
||||
|
||||
margin-left: auto
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ const fs = require('fs');
|
|||
const path = require('path');
|
||||
const os = require('os');
|
||||
const { spawn, exec } = require('child_process');
|
||||
const dns = require('dns');
|
||||
|
||||
type Runner = {
|
||||
name: string, // Runner title which will be showed in the list
|
||||
|
@ -17,6 +18,11 @@ type Runner = {
|
|||
executable: string // Path to wine executable inside folder
|
||||
};
|
||||
|
||||
type DXVK = {
|
||||
version: string,
|
||||
uri: string
|
||||
};
|
||||
|
||||
type Config = {
|
||||
lang: {
|
||||
launcher: 'en-us' | 'ru-ru' | 'fr-fr' | 'id-id' | 'de-de' | 'es-es' | 'pt-pt' | 'th-th' | 'vi-vn' | 'ko-kr' | 'ja-jp' | 'zh-tw' | 'zh-cn',
|
||||
|
@ -36,7 +42,8 @@ type Config = {
|
|||
folder: string,
|
||||
executable: string
|
||||
},
|
||||
rpc: boolean
|
||||
rpc: boolean,
|
||||
dxvk: string|null
|
||||
};
|
||||
|
||||
export class Genshinlib
|
||||
|
@ -54,11 +61,13 @@ export class Genshinlib
|
|||
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');
|
||||
public static readonly runnersDir: string = path.join(this.launcherDir, 'runners');
|
||||
public static readonly dxvksDir: string = path.join(this.launcherDir, 'dxvks');
|
||||
|
||||
protected static readonly versionsUri: string = 'https://sdk-os-static.mihoyo.com/hk4e_global/mdk/launcher/api/resource?key=gcStgarh&launcher_id=10';
|
||||
protected static readonly backgroundUri: string = 'https://sdk-os-static.mihoyo.com/hk4e_global/mdk/launcher/api/content?filter_adv=true&launcher_id=10&language=';
|
||||
protected static readonly patchUri: string = 'https://notabug.org/Krock/GI-on-Linux/archive/master.zip';
|
||||
protected static readonly runnersUri: string = 'https://notabug.org/nobody/an-anime-game-launcher/raw/main/runners.json';
|
||||
protected static readonly dxvksUri: string = 'https://notabug.org/nobody/an-anime-game-launcher/raw/main/dxvks.json';
|
||||
|
||||
public static get version(): Config['version']
|
||||
{
|
||||
|
@ -81,6 +90,17 @@ export class Genshinlib
|
|||
// return JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'runners.json')));
|
||||
}
|
||||
|
||||
public static getDXVKs (): Promise<DXVK[]>
|
||||
{
|
||||
return new Promise((resolve, reject) => {
|
||||
fetch(this.runnersUri)
|
||||
.then(response => response.json())
|
||||
.then(runners => resolve(runners));
|
||||
});
|
||||
|
||||
// return new Promise(resolve => resolve(JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'dxvks.json')))));
|
||||
}
|
||||
|
||||
public static getConfig (): Config
|
||||
{
|
||||
if (!fs.existsSync(this.launcherJson))
|
||||
|
@ -178,6 +198,36 @@ export class Genshinlib
|
|||
return JSON.parse(fs.readFileSync(this.patchJson));
|
||||
}
|
||||
|
||||
/**
|
||||
* 0.0.0.0 log-upload-os.mihoyo.com
|
||||
* 0.0.0.0 overseauspider.yuanshen.com
|
||||
*/
|
||||
public static isTelemetryDisabled (): Promise<boolean>
|
||||
{
|
||||
return new Promise((resolve, reject) => {
|
||||
dns.lookup('log-upload-os.mihoyo.com', (error: any, address: string, family: any) => {
|
||||
if (error)
|
||||
reject(error);
|
||||
|
||||
else
|
||||
{
|
||||
if (address != '0.0.0.0')
|
||||
resolve(false);
|
||||
|
||||
else
|
||||
{
|
||||
dns.lookup('log-upload-os.mihoyo.com', (error: any, address: string, family: any) => {
|
||||
if (error)
|
||||
reject(error);
|
||||
|
||||
else resolve(address == '0.0.0.0');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static async downloadFile (uri: string, savePath: string, progress: (current: number, total: number, difference: number) => void): Promise<void|Error>
|
||||
{
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
|
@ -207,27 +207,40 @@ $(() => {
|
|||
{
|
||||
console.log(`%c> Starting the game...`, 'font-size: 16px');
|
||||
|
||||
let wineExeutable = 'wine';
|
||||
|
||||
if (Genshinlib.getConfig().runner !== null)
|
||||
if (!await Genshinlib.isTelemetryDisabled())
|
||||
{
|
||||
wineExeutable = path.join(
|
||||
Genshinlib.runnersDir,
|
||||
Genshinlib.getConfig().runner?.folder,
|
||||
Genshinlib.getConfig().runner?.executable
|
||||
);
|
||||
console.log('miHoYo\'s telemetry servers doesn\'t disabled!');
|
||||
|
||||
if (!fs.existsSync(wineExeutable))
|
||||
{
|
||||
wineExeutable = 'wine';
|
||||
|
||||
Genshinlib.updateConfig({
|
||||
runner: null
|
||||
});
|
||||
}
|
||||
ipcRenderer.send('notification', {
|
||||
title: document.title,
|
||||
body: 'miHoYo\'s telemetry servers doesn\'t disabled!',
|
||||
icon: path.join(__dirname, '..', 'images', 'baal64-transparent.png')
|
||||
});
|
||||
}
|
||||
|
||||
console.log(`Wine executable: ${wineExeutable}`);
|
||||
else
|
||||
{
|
||||
let wineExeutable = 'wine';
|
||||
|
||||
if (Genshinlib.getConfig().runner !== null)
|
||||
{
|
||||
wineExeutable = path.join(
|
||||
Genshinlib.runnersDir,
|
||||
Genshinlib.getConfig().runner?.folder,
|
||||
Genshinlib.getConfig().runner?.executable
|
||||
);
|
||||
|
||||
if (!fs.existsSync(wineExeutable))
|
||||
{
|
||||
wineExeutable = 'wine';
|
||||
|
||||
Genshinlib.updateConfig({
|
||||
runner: null
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Wine executable: ${wineExeutable}`);
|
||||
|
||||
if (rpc)
|
||||
rpc.setActivity({
|
||||
|
@ -247,7 +260,7 @@ $(() => {
|
|||
}, (err: any, stdout: any, stderr: any) => {
|
||||
console.log(`%c> Game closed`, 'font-size: 16px');
|
||||
|
||||
ipcRenderer.invoke('show-window');
|
||||
ipcRenderer.invoke('show-window');
|
||||
|
||||
if (rpc)
|
||||
rpc.setActivity({
|
||||
|
@ -262,7 +275,8 @@ $(() => {
|
|||
console.log(stderr);
|
||||
});
|
||||
|
||||
ipcRenderer.invoke('hide-window');
|
||||
ipcRenderer.invoke('hide-window');
|
||||
}
|
||||
}
|
||||
|
||||
// Apply test patch
|
||||
|
@ -377,7 +391,7 @@ $(() => {
|
|||
|
||||
ipcRenderer.send('notification', {
|
||||
title: document.title,
|
||||
content: i18n.translate('GameDownloaded')
|
||||
body: i18n.translate('GameDownloaded')
|
||||
});
|
||||
}, (data) => console.log(data.toString()));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { ipcRenderer } = require('electron');
|
||||
const { exec } = require('child_process');
|
||||
|
||||
import $ from 'cash-dom';
|
||||
import i18n from './i18n';
|
||||
|
@ -13,7 +14,7 @@ $(() => {
|
|||
});
|
||||
|
||||
$('.menu-item').on('click', (e) => {
|
||||
$('.settings')[0]!.scrollTop = $(`#${e.target.getAttribute('anchor')}`).offset()!.top - $('.settings').offset()!.top - 16;
|
||||
$('.settings')[0]!.scrollTop = document.getElementById(e.target.getAttribute('anchor'))!.offsetTop - 16;
|
||||
|
||||
$('.menu-item').removeClass('menu-item-active');
|
||||
$(e.target).addClass('menu-item-active');
|
||||
|
@ -104,18 +105,90 @@ $(() => {
|
|||
|
||||
let activeRunner = Genshinlib.getConfig().runner;
|
||||
|
||||
Genshinlib.getRunners().then(runners => runners.forEach(category => {
|
||||
$(`<h3>${category.title}</h3>`).appendTo('#runners-list');
|
||||
Genshinlib.getRunners().then(runners => {
|
||||
runners.forEach(category => {
|
||||
$(`<h3>${category.title}</h3>`).appendTo('#runners-list');
|
||||
|
||||
category.runners.forEach(runner => {
|
||||
let item = $(`<div class="list-item">${runner.name}<div><img src="../images/download.png"></div></div>`).appendTo('#runners-list');
|
||||
|
||||
if (fs.existsSync(path.join(Genshinlib.runnersDir, runner.folder)))
|
||||
category.runners.forEach(runner => {
|
||||
let item = $(`<div class="list-item">${runner.name}<div><img src="../images/download.png"></div></div>`).appendTo('#runners-list');
|
||||
|
||||
if (fs.existsSync(path.join(Genshinlib.runnersDir, runner.folder)))
|
||||
{
|
||||
item.find('div').css('display', 'none');
|
||||
|
||||
// I think we shouldn't set runner as active if it is not installed
|
||||
if (runner.name == activeRunner?.name)
|
||||
item.addClass('list-item-active');
|
||||
}
|
||||
|
||||
item.find('div').on('click', () => {
|
||||
if (!item.hasClass('list-item-disabled'))
|
||||
{
|
||||
item.addClass('list-item-disabled');
|
||||
|
||||
let div = item.find('div');
|
||||
|
||||
Genshinlib.downloadFile(runner.uri, path.join(Genshinlib.launcherDir, runner.name), (current: number, total: number, difference: number) => {
|
||||
div.text(`${ Math.round(current / total * 100) }%`);
|
||||
}).then(() => {
|
||||
let unpacker = runner.archive === 'tar' ?
|
||||
Genshinlib.untar : Genshinlib.unzip;
|
||||
|
||||
unpacker(
|
||||
path.join(Genshinlib.launcherDir, runner.name),
|
||||
runner.makeFolder ?
|
||||
path.join(Genshinlib.runnersDir, runner.folder) :
|
||||
Genshinlib.runnersDir,
|
||||
(current: number, total: number, difference: number) => {
|
||||
div.text(`${ Math.round(current / total * 100) }%`);
|
||||
}
|
||||
).then(() => {
|
||||
fs.unlinkSync(path.join(Genshinlib.launcherDir, runner.name));
|
||||
|
||||
item.removeClass('list-item-disabled');
|
||||
div.css('display', 'none');
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
item.on('click', () => {
|
||||
if (!item.hasClass('list-item-disabled'))
|
||||
{
|
||||
while (!item.hasClass('list-item'))
|
||||
item = item.parent();
|
||||
|
||||
if (item.find('div').css('display') === 'none')
|
||||
{
|
||||
Genshinlib.updateConfig({
|
||||
runner: {
|
||||
name: runner.name,
|
||||
folder: runner.folder,
|
||||
executable: runner.executable
|
||||
}
|
||||
});
|
||||
|
||||
$('#runners-list > .list-item').removeClass('list-item-active');
|
||||
item.addClass('list-item-active');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
let activeDXVK = Genshinlib.getConfig().dxvk;
|
||||
|
||||
Genshinlib.getDXVKs().then(dxvks => {
|
||||
dxvks.forEach(dxvk => {
|
||||
let item = $(`<div class="list-item">${dxvk.version}<div><img src="../images/download.png"></div></div>`).appendTo('#dxvk-list');
|
||||
|
||||
if (fs.existsSync(path.join(Genshinlib.dxvksDir, 'dxvk-' + dxvk.version)))
|
||||
{
|
||||
item.find('div').css('display', 'none');
|
||||
|
||||
// I think we shouldn't set runner as active if it is not installed
|
||||
if (runner.name == activeRunner?.name)
|
||||
// I think we shouldn't set DXVK as active if it is not installed
|
||||
if (dxvk.version == activeDXVK)
|
||||
item.addClass('list-item-active');
|
||||
}
|
||||
|
||||
|
@ -126,22 +199,17 @@ $(() => {
|
|||
|
||||
let div = item.find('div');
|
||||
|
||||
Genshinlib.downloadFile(runner.uri, path.join(Genshinlib.launcherDir, runner.name), (current: number, total: number, difference: number) => {
|
||||
Genshinlib.downloadFile(dxvk.uri, path.join(Genshinlib.launcherDir, 'dxvk-' + dxvk.version), (current: number, total: number, difference: number) => {
|
||||
div.text(`${ Math.round(current / total * 100) }%`);
|
||||
}).then(() => {
|
||||
let unpacker = runner.archive === 'tar' ?
|
||||
Genshinlib.untar : Genshinlib.unzip;
|
||||
|
||||
unpacker(
|
||||
path.join(Genshinlib.launcherDir, runner.name),
|
||||
runner.makeFolder ?
|
||||
path.join(Genshinlib.runnersDir, runner.folder) :
|
||||
Genshinlib.runnersDir,
|
||||
Genshinlib.untar(
|
||||
path.join(Genshinlib.launcherDir, 'dxvk-' + dxvk.version),
|
||||
Genshinlib.dxvksDir,
|
||||
(current: number, total: number, difference: number) => {
|
||||
div.text(`${ Math.round(current / total * 100) }%`);
|
||||
}
|
||||
).then(() => {
|
||||
fs.unlinkSync(path.join(Genshinlib.launcherDir, runner.name));
|
||||
fs.unlinkSync(path.join(Genshinlib.launcherDir, 'dxvk-' + dxvk.version));
|
||||
|
||||
item.removeClass('list-item-disabled');
|
||||
div.css('display', 'none');
|
||||
|
@ -158,19 +226,30 @@ $(() => {
|
|||
|
||||
if (item.find('div').css('display') === 'none')
|
||||
{
|
||||
Genshinlib.updateConfig({
|
||||
runner: {
|
||||
name: runner.name,
|
||||
folder: runner.folder,
|
||||
executable: runner.executable
|
||||
item.find('div')
|
||||
.css('display', 'flex')
|
||||
.text('Applying...');
|
||||
|
||||
let installer = exec('./setup_dxvk.sh install', {
|
||||
cwd: path.join(Genshinlib.dxvksDir, 'dxvk-' + dxvk.version),
|
||||
env: {
|
||||
...process.env,
|
||||
WINEPREFIX: Genshinlib.prefixDir
|
||||
}
|
||||
});
|
||||
|
||||
$('#runners-list > .list-item').removeClass('list-item-active');
|
||||
item.addClass('list-item-active');
|
||||
installer.on('close', () => {
|
||||
Genshinlib.updateConfig({
|
||||
dxvk: dxvk.version
|
||||
});
|
||||
|
||||
$('#dxvk-list > .list-item').removeClass('list-item-active');
|
||||
item.addClass('list-item-active');
|
||||
item.find('div').css('display', 'none');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue