mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-12-24 10:38:14 +03:00
Conspiracy update, part 2
- core class was renamed to the LauncherLib - added upper- and lowercased secret names variants
This commit is contained in:
parent
c3ed135a63
commit
36d130ead6
6 changed files with 93 additions and 81 deletions
|
@ -1,28 +1,28 @@
|
||||||
const { ipcRenderer } = require('electron');
|
const { ipcRenderer } = require('electron');
|
||||||
|
|
||||||
import $ from 'cash-dom';
|
import $ from 'cash-dom';
|
||||||
import { Genshinlib } from './lib/Genshinlib';
|
import { LauncherLib } from './lib/LauncherLib';
|
||||||
import { LauncherUI } from './lib/LauncherUI';
|
import { LauncherUI } from './lib/LauncherUI';
|
||||||
|
|
||||||
$(() => {
|
$(() => {
|
||||||
LauncherUI.updateLang(Genshinlib.getConfig('lang.launcher'));
|
LauncherUI.updateLang(LauncherLib.getConfig('lang.launcher'));
|
||||||
|
|
||||||
$('#participate').on('click', async () => {
|
$('#participate').on('click', async () => {
|
||||||
await fetch(`https://an-anime-game-launcher.000webhostapp.com${ !$('#share-country').hasClass('checkbox-active') ? '/?hide-geo' : '' }`);
|
await fetch(`https://an-anime-game-launcher.000webhostapp.com${ !$('#share-country').hasClass('checkbox-active') ? '/?hide-geo' : '' }`);
|
||||||
|
|
||||||
Genshinlib.updateConfig('analytics', Genshinlib.version);
|
LauncherLib.updateConfig('analytics', LauncherLib.version);
|
||||||
|
|
||||||
ipcRenderer.invoke('hide-analytics-participation');
|
ipcRenderer.invoke('hide-analytics-participation');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#skip').on('click', () => {
|
$('#skip').on('click', () => {
|
||||||
Genshinlib.updateConfig('analytics', Genshinlib.version);
|
LauncherLib.updateConfig('analytics', LauncherLib.version);
|
||||||
|
|
||||||
ipcRenderer.invoke('hide-analytics-participation');
|
ipcRenderer.invoke('hide-analytics-participation');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#skip-and-ignore').on('click', () => {
|
$('#skip-and-ignore').on('click', () => {
|
||||||
Genshinlib.updateConfig('analytics', null);
|
LauncherLib.updateConfig('analytics', null);
|
||||||
|
|
||||||
ipcRenderer.invoke('hide-analytics-participation');
|
ipcRenderer.invoke('hide-analytics-participation');
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,7 +8,7 @@ const semver = require('semver');
|
||||||
import $ from 'cash-dom';
|
import $ from 'cash-dom';
|
||||||
|
|
||||||
import { constants } from './lib/constants';
|
import { constants } from './lib/constants';
|
||||||
import { Genshinlib } from './lib/Genshinlib';
|
import { LauncherLib } from './lib/LauncherLib';
|
||||||
import { LauncherUI } from './lib/LauncherUI';
|
import { LauncherUI } from './lib/LauncherUI';
|
||||||
import { Tools } from './lib/Tools';
|
import { Tools } from './lib/Tools';
|
||||||
import { DiscordRPC } from './lib/DiscordRPC';
|
import { DiscordRPC } from './lib/DiscordRPC';
|
||||||
|
@ -25,11 +25,11 @@ if (!fs.existsSync(constants.dxvksDir))
|
||||||
fs.mkdirSync(constants.dxvksDir, { recursive: true });
|
fs.mkdirSync(constants.dxvksDir, { recursive: true });
|
||||||
|
|
||||||
$(() => {
|
$(() => {
|
||||||
if (Genshinlib.version !== null)
|
if (LauncherLib.version !== null)
|
||||||
document.title = `${constants.gamePlaceholder.full} Linux Launcher - ${Genshinlib.version}`;
|
document.title = `${constants.gamePlaceholder.uppercase.full} Linux Launcher - ${LauncherLib.version}`;
|
||||||
|
|
||||||
// On Start configuration of LauncherUI
|
// On Start configuration of LauncherUI
|
||||||
LauncherUI.updateLang(Genshinlib.getConfig('lang.launcher') ?? 'en-us');
|
LauncherUI.updateLang(LauncherLib.getConfig('lang.launcher') ?? 'en-us');
|
||||||
LauncherUI.setState('game-launch-available');
|
LauncherUI.setState('game-launch-available');
|
||||||
LauncherUI.updateBackground();
|
LauncherUI.updateBackground();
|
||||||
LauncherUI.updateSocial();
|
LauncherUI.updateSocial();
|
||||||
|
@ -40,7 +40,7 @@ $(() => {
|
||||||
LauncherUI.updateSocial();
|
LauncherUI.updateSocial();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Genshinlib.getConfig('rpc'))
|
if (LauncherLib.getConfig('rpc'))
|
||||||
DiscordRPC.init();
|
DiscordRPC.init();
|
||||||
|
|
||||||
ipcRenderer.on('rpc-toggle', () => {
|
ipcRenderer.on('rpc-toggle', () => {
|
||||||
|
@ -51,14 +51,14 @@ $(() => {
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
/*ipcRenderer.on('updateVP', (event: void, remotedata: any) => {
|
/*ipcRenderer.on('updateVP', (event: void, remotedata: any) => {
|
||||||
Genshinlib.getData().then(data => {
|
LauncherLib.getData().then(data => {
|
||||||
LauncherUI.initProgressBar();
|
LauncherUI.initProgressBar();
|
||||||
|
|
||||||
let voicePack = data.game.latest.voice_packs[1]; // en-us
|
let voicePack = data.game.latest.voice_packs[1]; // en-us
|
||||||
let old;
|
let old;
|
||||||
|
|
||||||
for (let i = 0; i < data.game.latest.voice_packs.length; ++i)
|
for (let i = 0; i < data.game.latest.voice_packs.length; ++i)
|
||||||
if (data.game.latest.voice_packs[i].language == Genshinlib.getConfig('lang.voice'))
|
if (data.game.latest.voice_packs[i].language == LauncherLib.getConfig('lang.voice'))
|
||||||
{
|
{
|
||||||
voicePack = data.game.latest.voice_packs[i];
|
voicePack = data.game.latest.voice_packs[i];
|
||||||
|
|
||||||
|
@ -76,26 +76,26 @@ $(() => {
|
||||||
let oldstring = old.name.replace(`_${data.game.latest.version}.zip`, '');
|
let oldstring = old.name.replace(`_${data.game.latest.version}.zip`, '');
|
||||||
|
|
||||||
// Check if the directory and file exists to prevent errors.
|
// Check if the directory and file exists to prevent errors.
|
||||||
if (fs.existsSync(path.join(Genshinlib.gameDir, oldstring + '_pkg_version')))
|
if (fs.existsSync(path.join(LauncherLib.gameDir, oldstring + '_pkg_version')))
|
||||||
fs.rmSync(path.join(Genshinlib.gameDir, oldstring + '_pkg_version'));
|
fs.rmSync(path.join(LauncherLib.gameDir, oldstring + '_pkg_version'));
|
||||||
|
|
||||||
if (fs.existsSync(path.join(Genshinlib.gameDir, 'GenshinImpact_Data', 'StreamingAssets', 'Audio', 'GeneratedSoundBanks', 'Windows', oldstring.replace('Audio_', ''))))
|
if (fs.existsSync(path.join(LauncherLib.gameDir, 'GenshinImpact_Data', 'StreamingAssets', 'Audio', 'GeneratedSoundBanks', 'Windows', oldstring.replace('Audio_', ''))))
|
||||||
fs.rmSync(path.join(Genshinlib.gameDir, 'GenshinImpact_Data', 'StreamingAssets', 'Audio', 'GeneratedSoundBanks', 'Windows', oldstring.replace('Audio_', '')), { recursive: true });
|
fs.rmSync(path.join(LauncherLib.gameDir, 'GenshinImpact_Data', 'StreamingAssets', 'Audio', 'GeneratedSoundBanks', 'Windows', oldstring.replace('Audio_', '')), { recursive: true });
|
||||||
|
|
||||||
console.log(`%c> Downloading voice data...`, 'font-size: 16px');
|
console.log(`%c> Downloading voice data...`, 'font-size: 16px');
|
||||||
|
|
||||||
// For some reason this keeps breaking and locking up most of the time.
|
// For some reason this keeps breaking and locking up most of the time.
|
||||||
Tools.downloadFile(voicePack.path, path.join(Genshinlib.launcherDir, voicePack.name), (current: number, total: number, difference: number) => {
|
Tools.downloadFile(voicePack.path, path.join(LauncherLib.launcherDir, voicePack.name), (current: number, total: number, difference: number) => {
|
||||||
LauncherUI.updateProgressBar(LauncherUI.i18n.translate('Downloading'), current, total, difference);
|
LauncherUI.updateProgressBar(LauncherUI.i18n.translate('Downloading'), current, total, difference);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
console.log(`%c> Unpacking voice data...`, 'font-size: 16px');
|
console.log(`%c> Unpacking voice data...`, 'font-size: 16px');
|
||||||
|
|
||||||
LauncherUI.initProgressBar();
|
LauncherUI.initProgressBar();
|
||||||
|
|
||||||
Tools.unzip(path.join(Genshinlib.launcherDir, voicePack.name), Genshinlib.gameDir, (current: number, total: number, difference: number) => {
|
Tools.unzip(path.join(LauncherLib.launcherDir, voicePack.name), LauncherLib.gameDir, (current: number, total: number, difference: number) => {
|
||||||
LauncherUI.updateProgressBar(LauncherUI.i18n.translate('Unpack'), current, total, difference);
|
LauncherUI.updateProgressBar(LauncherUI.i18n.translate('Unpack'), current, total, difference);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
fs.unlinkSync(path.join(Genshinlib.launcherDir, voicePack.name));
|
fs.unlinkSync(path.join(LauncherLib.launcherDir, voicePack.name));
|
||||||
LauncherUI.setState('game-launch-available');
|
LauncherUI.setState('game-launch-available');
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -113,18 +113,18 @@ $(() => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Genshinlib.getConfig('analytics') !== null && Genshinlib.getConfig('analytics') !== Genshinlib.version)
|
if (LauncherLib.getConfig('analytics') !== null && LauncherLib.getConfig('analytics') !== LauncherLib.version)
|
||||||
ipcRenderer.invoke('open-analytics-participation');
|
ipcRenderer.invoke('open-analytics-participation');
|
||||||
|
|
||||||
Genshinlib.getData().then(async data => {
|
LauncherLib.getData().then(async data => {
|
||||||
let patchInfo = await Genshinlib.getPatchInfo();
|
let patchInfo = await LauncherLib.getPatchInfo();
|
||||||
|
|
||||||
// Update available
|
// Update available
|
||||||
if (Genshinlib.version != data.game.latest.version)
|
if (LauncherLib.version != data.game.latest.version)
|
||||||
LauncherUI.setState(Genshinlib.version === null ? 'game-installation-available' : 'game-update-available');
|
LauncherUI.setState(LauncherLib.version === null ? 'game-installation-available' : 'game-update-available');
|
||||||
|
|
||||||
// Patch version is incorrect
|
// Patch version is incorrect
|
||||||
else if (Genshinlib.getConfig('patch') && Genshinlib.getConfig('patch.version') != patchInfo.version)
|
else if (LauncherLib.getConfig('patch') && LauncherLib.getConfig('patch.version') != patchInfo.version)
|
||||||
{
|
{
|
||||||
// Patch is not available
|
// Patch is not available
|
||||||
if (patchInfo.version !== data.game.latest.version)
|
if (patchInfo.version !== data.game.latest.version)
|
||||||
|
@ -140,7 +140,7 @@ $(() => {
|
||||||
|
|
||||||
LauncherUI.setState('patch-applying');
|
LauncherUI.setState('patch-applying');
|
||||||
|
|
||||||
Genshinlib.patchGame(() => {
|
LauncherLib.patchGame(() => {
|
||||||
LauncherUI.setState('game-launch-available');
|
LauncherUI.setState('game-launch-available');
|
||||||
}, data => console.log(data.toString()));
|
}, data => console.log(data.toString()));
|
||||||
}
|
}
|
||||||
|
@ -152,27 +152,27 @@ $(() => {
|
||||||
|
|
||||||
// Current patch is in testing phase,
|
// Current patch is in testing phase,
|
||||||
// but stable is available
|
// but stable is available
|
||||||
else if (Genshinlib.getConfig('patch') && Genshinlib.getConfig('patch.version') == patchInfo.version && Genshinlib.getConfig('patch.state') == 'testing' && patchInfo.state == 'stable')
|
else if (LauncherLib.getConfig('patch') && LauncherLib.getConfig('patch.version') == patchInfo.version && LauncherLib.getConfig('patch.state') == 'testing' && patchInfo.state == 'stable')
|
||||||
{
|
{
|
||||||
console.log(`%c> Applying patch...`, 'font-size: 16px');
|
console.log(`%c> Applying patch...`, 'font-size: 16px');
|
||||||
|
|
||||||
LauncherUI.setState('patch-applying');
|
LauncherUI.setState('patch-applying');
|
||||||
|
|
||||||
Genshinlib.patchGame(() => {
|
LauncherLib.patchGame(() => {
|
||||||
LauncherUI.setState('game-launch-available');
|
LauncherUI.setState('game-launch-available');
|
||||||
}, data => console.log(data.toString()));
|
}, data => console.log(data.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#launch').on('click', async () => {
|
$('#launch').on('click', async () => {
|
||||||
// Creating wine prefix
|
// Creating wine prefix
|
||||||
if (!Genshinlib.isPrefixInstalled(constants.prefixDir))
|
if (!LauncherLib.isPrefixInstalled(constants.prefixDir))
|
||||||
{
|
{
|
||||||
console.log(`%c> Creating wineprefix...`, 'font-size: 16px');
|
console.log(`%c> Creating wineprefix...`, 'font-size: 16px');
|
||||||
|
|
||||||
$('#launch').css('display', 'none');
|
$('#launch').css('display', 'none');
|
||||||
$('#downloader-panel').css('display', 'block');
|
$('#downloader-panel').css('display', 'block');
|
||||||
|
|
||||||
await Genshinlib.installPrefix(constants.prefixDir, (output: string, current: number, total: number) => {
|
await LauncherLib.installPrefix(constants.prefixDir, (output: string, current: number, total: number) => {
|
||||||
output = output.trim();
|
output = output.trim();
|
||||||
|
|
||||||
console.log(output);
|
console.log(output);
|
||||||
|
@ -192,7 +192,7 @@ $(() => {
|
||||||
{
|
{
|
||||||
console.log(`%c> Starting the game...`, 'font-size: 16px');
|
console.log(`%c> Starting the game...`, 'font-size: 16px');
|
||||||
|
|
||||||
if (!await Genshinlib.isTelemetryDisabled())
|
if (!await LauncherLib.isTelemetryDisabled())
|
||||||
{
|
{
|
||||||
console.log('miHoYo\'s telemetry servers doesn\'t disabled!');
|
console.log('miHoYo\'s telemetry servers doesn\'t disabled!');
|
||||||
|
|
||||||
|
@ -206,19 +206,19 @@ $(() => {
|
||||||
{
|
{
|
||||||
let wineExeutable = 'wine';
|
let wineExeutable = 'wine';
|
||||||
|
|
||||||
if (Genshinlib.getConfig('runner') !== null)
|
if (LauncherLib.getConfig('runner') !== null)
|
||||||
{
|
{
|
||||||
wineExeutable = path.join(
|
wineExeutable = path.join(
|
||||||
constants.runnersDir,
|
constants.runnersDir,
|
||||||
Genshinlib.getConfig('runner.folder'),
|
LauncherLib.getConfig('runner.folder'),
|
||||||
Genshinlib.getConfig('runner.executable')
|
LauncherLib.getConfig('runner.executable')
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!fs.existsSync(wineExeutable))
|
if (!fs.existsSync(wineExeutable))
|
||||||
{
|
{
|
||||||
wineExeutable = 'wine';
|
wineExeutable = 'wine';
|
||||||
|
|
||||||
Genshinlib.updateConfig('runner', null);
|
LauncherLib.updateConfig('runner', null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ $(() => {
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
WINEPREFIX: constants.prefixDir,
|
WINEPREFIX: constants.prefixDir,
|
||||||
...Genshinlib.getConfig('env')
|
...LauncherLib.getConfig('env')
|
||||||
}
|
}
|
||||||
}, (err: any, stdout: any, stderr: any) => {
|
}, (err: any, stdout: any, stderr: any) => {
|
||||||
console.log(`%c> Game closed`, 'font-size: 16px');
|
console.log(`%c> Game closed`, 'font-size: 16px');
|
||||||
|
@ -271,7 +271,7 @@ $(() => {
|
||||||
|
|
||||||
LauncherUI.setState('patch-applying');
|
LauncherUI.setState('patch-applying');
|
||||||
|
|
||||||
Genshinlib.patchGame(() => {
|
LauncherLib.patchGame(() => {
|
||||||
LauncherUI.setState('game-launch-available');
|
LauncherUI.setState('game-launch-available');
|
||||||
}, data => console.log(data.toString()));
|
}, data => console.log(data.toString()));
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ $(() => {
|
||||||
};
|
};
|
||||||
|
|
||||||
for (let i = 0; i < data.game.diffs.length; ++i)
|
for (let i = 0; i < data.game.diffs.length; ++i)
|
||||||
if (data.game.diffs[i].version == Genshinlib.version)
|
if (data.game.diffs[i].version == LauncherLib.version)
|
||||||
{
|
{
|
||||||
diff = data.game.diffs[i];
|
diff = data.game.diffs[i];
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ $(() => {
|
||||||
let voicePack = diff.voice_packs[1]; // en-us
|
let voicePack = diff.voice_packs[1]; // en-us
|
||||||
|
|
||||||
for (let i = 0; i < diff.voice_packs.length; ++i)
|
for (let i = 0; i < diff.voice_packs.length; ++i)
|
||||||
if (diff.voice_packs[i].language == Genshinlib.getConfig('lang.voice'))
|
if (diff.voice_packs[i].language == LauncherLib.getConfig('lang.voice'))
|
||||||
{
|
{
|
||||||
voicePack = diff.voice_packs[i];
|
voicePack = diff.voice_packs[i];
|
||||||
|
|
||||||
|
@ -367,7 +367,7 @@ $(() => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Genshinlib.updateConfig('version', data.game.latest.version);
|
LauncherLib.updateConfig('version', data.game.latest.version);
|
||||||
|
|
||||||
// Patch available
|
// Patch available
|
||||||
if (patchInfo.version === data.game.latest.version)
|
if (patchInfo.version === data.game.latest.version)
|
||||||
|
@ -381,7 +381,7 @@ $(() => {
|
||||||
$('#speed').text('');
|
$('#speed').text('');
|
||||||
$('#eta').text('');
|
$('#eta').text('');
|
||||||
|
|
||||||
Genshinlib.patchGame(() => {
|
LauncherLib.patchGame(() => {
|
||||||
LauncherUI.setState('game-launch-available');
|
LauncherUI.setState('game-launch-available');
|
||||||
|
|
||||||
ipcRenderer.send('notification', {
|
ipcRenderer.send('notification', {
|
||||||
|
|
|
@ -56,7 +56,7 @@ type DXVK = {
|
||||||
uri: string
|
uri: string
|
||||||
};
|
};
|
||||||
|
|
||||||
export class Genshinlib
|
export class LauncherLib
|
||||||
{
|
{
|
||||||
public static get version(): string|null
|
public static get version(): string|null
|
||||||
{
|
{
|
||||||
|
@ -225,7 +225,7 @@ export class Genshinlib
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// WINEPREFIX='/home/observer/genshin-impact-launcher/wineprefix' winetricks corefonts usetakefocus=n
|
// WINEPREFIX='...../wineprefix' winetricks corefonts usetakefocus=n
|
||||||
public static async installPrefix (prefixpath: string, progress: (output: string, current: number, total: number) => void): Promise<void>
|
public static async installPrefix (prefixpath: string, progress: (output: string, current: number, total: number) => void): Promise<void>
|
||||||
{
|
{
|
||||||
let installationSteps = [
|
let installationSteps = [
|
||||||
|
@ -282,7 +282,7 @@ export class Genshinlib
|
||||||
|
|
||||||
public static patchGame (onFinish: () => void, onData: (data: string) => void)
|
public static patchGame (onFinish: () => void, onData: (data: string) => void)
|
||||||
{
|
{
|
||||||
Genshinlib.getPatchInfo().then(pathInfo => {
|
this.getPatchInfo().then(pathInfo => {
|
||||||
Tools.downloadFile(constants.patchUri, path.join(constants.launcherDir, 'patch.zip'), (current: number, total: number, difference: number) => null).then(() => {
|
Tools.downloadFile(constants.patchUri, path.join(constants.launcherDir, 'patch.zip'), (current: number, total: number, difference: number) => null).then(() => {
|
||||||
Tools.unzip(path.join(constants.launcherDir, 'patch.zip'), constants.launcherDir, (current: number, total: number, difference: number) => null).then(() => {
|
Tools.unzip(path.join(constants.launcherDir, 'patch.zip'), constants.launcherDir, (current: number, total: number, difference: number) => null).then(() => {
|
||||||
// Delete zip file and assign patch directory.
|
// Delete zip file and assign patch directory.
|
||||||
|
@ -330,8 +330,8 @@ export class Genshinlib
|
||||||
patcherAntiCrashProcess.stdout.on('data', (data: string) => onData(data));
|
patcherAntiCrashProcess.stdout.on('data', (data: string) => onData(data));
|
||||||
|
|
||||||
patcherAntiCrashProcess.on('close', () => {
|
patcherAntiCrashProcess.on('close', () => {
|
||||||
Genshinlib.updateConfig('patch.version', pathInfo.version);
|
this.updateConfig('patch.version', pathInfo.version);
|
||||||
Genshinlib.updateConfig('patch.state', pathInfo.state);
|
this.updateConfig('patch.state', pathInfo.state);
|
||||||
|
|
||||||
fs.rmSync(path.join(constants.launcherDir, 'gi-on-linux'), { recursive: true });
|
fs.rmSync(path.join(constants.launcherDir, 'gi-on-linux'), { recursive: true });
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import $ from 'cash-dom';
|
import $ from 'cash-dom';
|
||||||
import { Genshinlib } from './Genshinlib';
|
|
||||||
|
import { constants } from './constants';
|
||||||
|
import { LauncherLib } from './LauncherLib';
|
||||||
import { i18n } from './i18n';
|
import { i18n } from './i18n';
|
||||||
|
|
||||||
type LauncherState =
|
type LauncherState =
|
||||||
|
@ -12,6 +14,8 @@ type LauncherState =
|
||||||
|
|
||||||
export class LauncherUI
|
export class LauncherUI
|
||||||
{
|
{
|
||||||
|
public static readonly socialUri = `https://${constants.gamePlaceholder.lowercase.first}.${constants.gamePlaceholder.lowercase.company}.com/launcher/10/${LauncherLib.getConfig('lang.launcher')}?api_url=https%3A%2F%2Fapi-os-takumi.${constants.gamePlaceholder.lowercase.company}.com%2Fhk4e_global&prev=false`;
|
||||||
|
|
||||||
protected static _launcherState: LauncherState = 'game-launch-available';
|
protected static _launcherState: LauncherState = 'game-launch-available';
|
||||||
protected static _i18n: any;
|
protected static _i18n: any;
|
||||||
|
|
||||||
|
@ -161,7 +165,7 @@ export class LauncherUI
|
||||||
|
|
||||||
public static updateBackground (): void
|
public static updateBackground (): void
|
||||||
{
|
{
|
||||||
Genshinlib.getBackgroundUri().then(uri => {
|
LauncherLib.getBackgroundUri().then(uri => {
|
||||||
uri = `url(${uri})`;
|
uri = `url(${uri})`;
|
||||||
|
|
||||||
if ($('body').css('background-image') != uri)
|
if ($('body').css('background-image') != uri)
|
||||||
|
@ -171,7 +175,7 @@ export class LauncherUI
|
||||||
|
|
||||||
public static updateSocial (): void
|
public static updateSocial (): void
|
||||||
{
|
{
|
||||||
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`)
|
fetch(this.socialUri)
|
||||||
.then(res => res.text())
|
.then(res => res.text())
|
||||||
.then(body => {
|
.then(body => {
|
||||||
$('#__layout').remove();
|
$('#__layout').remove();
|
||||||
|
|
|
@ -4,21 +4,29 @@ const os = require('os');
|
||||||
export class constants
|
export class constants
|
||||||
{
|
{
|
||||||
public static readonly gamePlaceholder = {
|
public static readonly gamePlaceholder = {
|
||||||
first: Buffer.from('R2Vuc2hpbg==', 'base64').toString(),
|
uppercase:
|
||||||
second: Buffer.from('SW1wYWN0', 'base64').toString(),
|
{
|
||||||
full: Buffer.from('R2Vuc2hpbiBJbXBhY3Q=', 'base64').toString(),
|
first: Buffer.from('R2Vuc2hpbg==', 'base64').toString(),
|
||||||
company: Buffer.from('bWlob3lv', 'base64').toString()
|
second: Buffer.from('SW1wYWN0', 'base64').toString(),
|
||||||
|
full: Buffer.from('R2Vuc2hpbiBJbXBhY3Q=', 'base64').toString()
|
||||||
|
},
|
||||||
|
|
||||||
|
lowercase:
|
||||||
|
{
|
||||||
|
first: Buffer.from('Z2Vuc2hpbg==', 'base64').toString(),
|
||||||
|
company: Buffer.from('bWlob3lv', 'base64').toString()
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static readonly launcherDir: string = path.join(os.homedir(), '.local', 'share', 'anime-game-launcher');
|
public static readonly launcherDir: string = path.join(os.homedir(), '.local', 'share', 'anime-game-launcher');
|
||||||
|
|
||||||
public static readonly prefixDir: string = path.join(this.launcherDir, 'game');
|
public static readonly prefixDir: string = path.join(this.launcherDir, 'game');
|
||||||
public static readonly gameDir: string = path.join(this.prefixDir, 'drive_c', 'Program Files', this.gamePlaceholder.full);
|
public static readonly gameDir: string = path.join(this.prefixDir, 'drive_c', 'Program Files', this.gamePlaceholder.uppercase.full);
|
||||||
public static readonly runnersDir: string = path.join(this.launcherDir, 'runners');
|
public static readonly runnersDir: string = path.join(this.launcherDir, 'runners');
|
||||||
public static readonly dxvksDir: string = path.join(this.launcherDir, 'dxvks');
|
public static readonly dxvksDir: string = path.join(this.launcherDir, 'dxvks');
|
||||||
|
|
||||||
public static readonly versionsUri: string = `https://sdk-os-static.${this.gamePlaceholder.company}.com/hk4e_global/mdk/launcher/api/resource?key=gcStgarh&launcher_id=10`;
|
public static readonly versionsUri: string = `https://sdk-os-static.${this.gamePlaceholder.lowercase.company}.com/hk4e_global/mdk/launcher/api/resource?key=gcStgarh&launcher_id=10`;
|
||||||
public static readonly backgroundUri: string = `https://sdk-os-static.${this.gamePlaceholder.company}.com/hk4e_global/mdk/launcher/api/content?filter_adv=true&launcher_id=10&language=`;
|
public static readonly backgroundUri: string = `https://sdk-os-static.${this.gamePlaceholder.lowercase.company}.com/hk4e_global/mdk/launcher/api/content?filter_adv=true&launcher_id=10&language=`;
|
||||||
|
|
||||||
public static readonly patchUri: string = 'https://notabug.org/Krock/GI-on-Linux/archive/master.zip';
|
public static readonly patchUri: string = 'https://notabug.org/Krock/GI-on-Linux/archive/master.zip';
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,13 @@ const { exec } = require('child_process');
|
||||||
import $ from 'cash-dom';
|
import $ from 'cash-dom';
|
||||||
|
|
||||||
import { constants } from './lib/constants';
|
import { constants } from './lib/constants';
|
||||||
import { Genshinlib } from './lib/Genshinlib';
|
import { LauncherLib } from './lib/LauncherLib';
|
||||||
import { LauncherUI } from './lib/LauncherUI';
|
import { LauncherUI } from './lib/LauncherUI';
|
||||||
import { Tools } from './lib/Tools';
|
import { Tools } from './lib/Tools';
|
||||||
|
|
||||||
$(() => {
|
$(() => {
|
||||||
// Make sure settings is shown in correct language.
|
// Make sure settings is shown in correct language.
|
||||||
LauncherUI.updateLang(Genshinlib.getConfig('lang.launcher') ?? 'en-us');
|
LauncherUI.updateLang(LauncherLib.getConfig('lang.launcher') ?? 'en-us');
|
||||||
|
|
||||||
$('.menu-item').on('click', (e) => {
|
$('.menu-item').on('click', (e) => {
|
||||||
$('.settings')[0]!.scrollTop = document.getElementById(e.target.getAttribute('anchor'))!.offsetTop - 16;
|
$('.settings')[0]!.scrollTop = document.getElementById(e.target.getAttribute('anchor'))!.offsetTop - 16;
|
||||||
|
@ -29,12 +29,12 @@ $(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#language').on('selectionChanged', (e, data: any) => {
|
$('#language').on('selectionChanged', (e, data: any) => {
|
||||||
let activeLang = Genshinlib.getConfig('lang.launcher');
|
let activeLang = LauncherLib.getConfig('lang.launcher');
|
||||||
|
|
||||||
if (activeLang != data.value)
|
if (activeLang != data.value)
|
||||||
{
|
{
|
||||||
Genshinlib.updateConfig('lang.launcher', data.value);
|
LauncherLib.updateConfig('lang.launcher', data.value);
|
||||||
Genshinlib.updateConfig('background.time', null);
|
LauncherLib.updateConfig('background.time', null);
|
||||||
|
|
||||||
LauncherUI.updateLang(data.value);
|
LauncherUI.updateLang(data.value);
|
||||||
|
|
||||||
|
@ -44,26 +44,26 @@ $(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Select the saved options in launcher.json on load
|
// Select the saved options in launcher.json on load
|
||||||
// $(`#voice-list option[value="${Genshinlib.getConfig('lang.voice')}"]`).prop('selected', true);
|
// $(`#voice-list option[value="${LauncherLib.getConfig('lang.voice')}"]`).prop('selected', true);
|
||||||
|
|
||||||
$(`#language li[value=${Genshinlib.getConfig('lang.launcher')}]`).addClass('selected');
|
$(`#language li[value=${LauncherLib.getConfig('lang.launcher')}]`).addClass('selected');
|
||||||
$('#language .selected-item span').text($(`#language li[value=${Genshinlib.getConfig('lang.launcher')}]`).text());
|
$('#language .selected-item span').text($(`#language li[value=${LauncherLib.getConfig('lang.launcher')}]`).text());
|
||||||
|
|
||||||
if (Genshinlib.getConfig('rpc'))
|
if (LauncherLib.getConfig('rpc'))
|
||||||
$('#discord-rpc').addClass('checkbox-active');
|
$('#discord-rpc').addClass('checkbox-active');
|
||||||
|
|
||||||
$('#discord-rpc').on('classChange', () => {
|
$('#discord-rpc').on('classChange', () => {
|
||||||
Genshinlib.updateConfig('rpc', $('#discord-rpc').hasClass('checkbox-active'));
|
LauncherLib.updateConfig('rpc', $('#discord-rpc').hasClass('checkbox-active'));
|
||||||
|
|
||||||
ipcRenderer.send('rpc-toggle');
|
ipcRenderer.send('rpc-toggle');
|
||||||
});
|
});
|
||||||
|
|
||||||
/*$('#voice-list').on('change', (e) => {
|
/*$('#voice-list').on('change', (e) => {
|
||||||
let activeVP = Genshinlib.getConfig('voice');
|
let activeVP = LauncherLib.getConfig('voice');
|
||||||
|
|
||||||
if (activeVP != e.target.value)
|
if (activeVP != e.target.value)
|
||||||
{
|
{
|
||||||
Genshinlib.updateConfig('lang.voice', e.target.value);
|
LauncherLib.updateConfig('lang.voice', e.target.value);
|
||||||
|
|
||||||
ipcRenderer.send('updateVP', { 'oldvp': activeVP });
|
ipcRenderer.send('updateVP', { 'oldvp': activeVP });
|
||||||
|
|
||||||
|
@ -76,23 +76,23 @@ $(() => {
|
||||||
|
|
||||||
$('#env-list').on('propertyNameChanged', (e, data) => {
|
$('#env-list').on('propertyNameChanged', (e, data) => {
|
||||||
if (data.value != '')
|
if (data.value != '')
|
||||||
Genshinlib.updateConfig(`env.${data.name.after}`, data.value);
|
LauncherLib.updateConfig(`env.${data.name.after}`, data.value);
|
||||||
|
|
||||||
if (data.name.before != '')
|
if (data.name.before != '')
|
||||||
Genshinlib.deleteConfig(`env.${data.name.before}`);
|
LauncherLib.deleteConfig(`env.${data.name.before}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#env-list').on('propertyValueChanged', (e, data) => {
|
$('#env-list').on('propertyValueChanged', (e, data) => {
|
||||||
if (data.name != '')
|
if (data.name != '')
|
||||||
Genshinlib.updateConfig(`env.${data.name}`, data.value.after);
|
LauncherLib.updateConfig(`env.${data.name}`, data.value.after);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#env-list').on('propertyDeleted', (e, data) => {
|
$('#env-list').on('propertyDeleted', (e, data) => {
|
||||||
if (data.name != '')
|
if (data.name != '')
|
||||||
Genshinlib.deleteConfig(`env.${data.name}`);
|
LauncherLib.deleteConfig(`env.${data.name}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
let env = Genshinlib.getConfig('env');
|
let env = LauncherLib.getConfig('env');
|
||||||
|
|
||||||
Object.keys(env).forEach((property: string) => {
|
Object.keys(env).forEach((property: string) => {
|
||||||
$('#env-list .button#add')[0]!.click();
|
$('#env-list .button#add')[0]!.click();
|
||||||
|
@ -107,9 +107,9 @@ $(() => {
|
||||||
td.last().find('span').text(value);
|
td.last().find('span').text(value);
|
||||||
});
|
});
|
||||||
|
|
||||||
let activeRunner = Genshinlib.getConfig('runner');
|
let activeRunner = LauncherLib.getConfig('runner');
|
||||||
|
|
||||||
Genshinlib.getRunners().then(runners => {
|
LauncherLib.getRunners().then(runners => {
|
||||||
runners.forEach(category => {
|
runners.forEach(category => {
|
||||||
$(`<h3>${category.title}</h3>`).appendTo('#runners-list');
|
$(`<h3>${category.title}</h3>`).appendTo('#runners-list');
|
||||||
|
|
||||||
|
@ -164,9 +164,9 @@ $(() => {
|
||||||
|
|
||||||
if (item.find('div').css('display') === 'none')
|
if (item.find('div').css('display') === 'none')
|
||||||
{
|
{
|
||||||
Genshinlib.updateConfig('runner.name', runner.name);
|
LauncherLib.updateConfig('runner.name', runner.name);
|
||||||
Genshinlib.updateConfig('runner.folder', runner.folder);
|
LauncherLib.updateConfig('runner.folder', runner.folder);
|
||||||
Genshinlib.updateConfig('runner.executable', runner.executable);
|
LauncherLib.updateConfig('runner.executable', runner.executable);
|
||||||
|
|
||||||
$('#runners-list > .list-item').removeClass('list-item-active');
|
$('#runners-list > .list-item').removeClass('list-item-active');
|
||||||
item.addClass('list-item-active');
|
item.addClass('list-item-active');
|
||||||
|
@ -177,9 +177,9 @@ $(() => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
let activeDXVK = Genshinlib.getConfig('dxvk');
|
let activeDXVK = LauncherLib.getConfig('dxvk');
|
||||||
|
|
||||||
Genshinlib.getDXVKs().then(dxvks => {
|
LauncherLib.getDXVKs().then(dxvks => {
|
||||||
dxvks.forEach(dxvk => {
|
dxvks.forEach(dxvk => {
|
||||||
let item = $(`<div class="list-item">${dxvk.version}<div><img src="../images/download.png"></div></div>`).appendTo('#dxvk-list');
|
let item = $(`<div class="list-item">${dxvk.version}<div><img src="../images/download.png"></div></div>`).appendTo('#dxvk-list');
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ $(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
installer.on('close', () => {
|
installer.on('close', () => {
|
||||||
Genshinlib.updateConfig('dxvk', dxvk.version);
|
LauncherLib.updateConfig('dxvk', dxvk.version);
|
||||||
|
|
||||||
$('#dxvk-list > .list-item').removeClass('list-item-active');
|
$('#dxvk-list > .list-item').removeClass('list-item-active');
|
||||||
item.addClass('list-item-active');
|
item.addClass('list-item-active');
|
||||||
|
|
Loading…
Reference in a new issue