- added verification for MangoHud and shaders when you want to select them
  if they even exist in your system
- now statistics also shows amount of minutes
- fixed some possible issue with patching process
- all classes now are exported as default
- improved some inner functions
This commit is contained in:
Observer KRypt0n_ 2021-11-16 20:20:24 +02:00
parent de5b01a846
commit 013c3dce47
No known key found for this signature in database
GPG key ID: DC5D4EC1303465DA
29 changed files with 115 additions and 53 deletions

View file

@ -14,7 +14,7 @@
| Game version | Launcher version | Patch version |
| :---: | :---: | :---: |
| 2.2.0 | 1.5.3 | 2.2.0 stable ✅ |
| 2.2.0 | 1.5.4 | 2.2.0 stable ✅ |
> ⚠️ New patch's version will be delayed for a week because of some author's personal reasons
@ -117,8 +117,8 @@ npm start
* <s>Add vkBasalt support and "shaders library"</s> *(1.5.0)*
- [yagocl's](https://notabug.org/Krock/GI-on-Linux/src/master/static/vkBasalt_yagocl.conf) basic sharpening preset *(without pictures)*
- [notahuman's](https://notabug.org/Krock/GI-on-Linux/src/master/static/vkBasalt_notahuman.conf) prime preset v2
* Make shaders manager hidden if vkBasalt is not installed
* Make MangoHud option hidden if it is not installed
* <s>Make shaders manager hidden if vkBasalt is not installed</s> *(1.5.4)*
* <s>Make MangoHud option hidden if it is not installed</s> *(1.5.4)*
* Screenshots explorer
* Make force launch button when the launcher's repository is unavailable *(waiting for the repository's unavailability lmao)*
* Game's update pre-installation *(waiting for the pre-installation date to find out how it actually works)*

View file

@ -1,6 +1,6 @@
{
"name": "an-anime-game-launcher",
"version": "1.5.3",
"version": "1.5.4",
"description": "An Anime Game Linux Launcher",
"author": "Nikita Podvirnyy <suimin.tu.mu.ga.mi@gmail.com>",
"contributors": [
@ -40,15 +40,17 @@
}
},
"devDependencies": {
"@types/command-exists": "^1.2.0",
"@types/discord-rpc": "^4.0.0",
"@types/semver": "^7.3.9",
"electron": "^15.3.1",
"electron": "^16.0.0",
"electron-builder": "^22.13.1",
"sass": "^1.43.4",
"typescript": "^4.4.4"
},
"dependencies": {
"cash-dom": "^8.1.0",
"command-exists": "^1.2.9",
"discord-rpc": "^4.0.1",
"electron-store": "^8.0.1",
"follow-redirects": "^1.14.5",

View file

@ -89,7 +89,7 @@
<ul>
<li value="none">None</li>
<li value="dxvk">DXVK</li>
<li value="mangohud" class="hint--top hint--small">MangoHud</li>
<li value="mangohud">MangoHud</li>
</ul>
</div>
@ -172,6 +172,8 @@
<span i18id="YouPlayedFor">You've played for</span>
<span id="play-hours"></span>
<span i18id="hours">hours</span>
<span id="play-minutes"></span>
<span i18id="minutes">minutes</span>
</div>
</div>
</div>

View file

@ -9,6 +9,7 @@
"PreInstallationRequired": "vorinstallation erforderlich",
"ToggleShadersText": "Verwenden Sie die Home-Taste, um Shader im Spiel umzuschalten",
"Shaders": "Shadern",
"ReshadeNotInstalled": "Sie haben die vkBasalt- und Reshade-Shader-Bibliothek nicht installiert",
"Author": "Autor",
"NoImages": "Keine Bilder hinzugefügt",
"SettingsTitle": "Einstellungen",
@ -22,7 +23,8 @@
"Delete": "Löschen",
"Statistics": "Statistik",
"YouPlayedFor": "Sie haben ungefähr",
"hours": "Stunden gespielt",
"hours": "Öffnungszeit",
"minutes": "Minuten",
"Downloading": "wird Heruntergeladen",
"Unpack": "wird Entpackt",
"GameDownloaded": "Spiel würde erfolgreich heruntergeladen",

View file

@ -9,6 +9,7 @@
"PreInstallationRequired": "pre-installation required",
"ToggleShadersText": "Use Home button to toggle shaders in the game",
"Shaders": "Shaders",
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
"Author": "Author",
"NoImages": "No images added",
"SettingsTitle": "Settings",
@ -24,6 +25,7 @@
"Statistics": "Statistics",
"YouPlayedFor": "You've played for",
"hours": "hours",
"minutes": "minutes",
"Unpack": "Unpacking",
"GameDownloaded": "Game was successfully installed",
"ApplyPatch": "Applying patch...",

View file

@ -9,6 +9,7 @@
"PreInstallationRequired": "pre-installation required",
"ToggleShadersText": "Use Home button to toggle shaders in the game",
"Shaders": "Shaders",
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
"Author": "Author",
"NoImages": "No images added",
"SettingsTitle": "Settings",
@ -23,6 +24,7 @@
"Statistics": "Statistics",
"YouPlayedFor": "You've played for",
"hours": "hours",
"minutes": "minutes",
"Downloading": "Downloading",
"Unpack": "Unpacking",
"GameDownloaded": "Game was successfully installed",

View file

@ -9,6 +9,7 @@
"PreInstallationRequired": "pre-installation required",
"ToggleShadersText": "Use Home button to toggle shaders in the game",
"Shaders": "Shaders",
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
"Author": "Author",
"NoImages": "No images added",
"SettingsTitle": "Settings",
@ -23,6 +24,7 @@
"Statistics": "Statistics",
"YouPlayedFor": "You've played for",
"hours": "hours",
"minutes": "minutes",
"Downloading": "Downloading",
"Unpack": "Unpacking",
"GameDownloaded": "Game was successfully installed",

View file

@ -9,6 +9,7 @@
"PreInstallationRequired": "pre-installation required",
"ToggleShadersText": "Use Home button to toggle shaders in the game",
"Shaders": "Shaders",
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
"Author": "Author",
"NoImages": "No images added",
"SettingsTitle": "Settings",
@ -23,6 +24,7 @@
"Statistics": "Statistics",
"YouPlayedFor": "You've played for",
"hours": "hours",
"minutes": "minutes",
"Downloading": "Downloading",
"Unpack": "Unpacking",
"GameDownloaded": "Game was successfully installed",

View file

@ -9,6 +9,7 @@
"PreInstallationRequired": "pre-installation required",
"ToggleShadersText": "Use Home button to toggle shaders in the game",
"Shaders": "Shaders",
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
"Author": "Author",
"NoImages": "No images added",
"SettingsTitle": "Settings",
@ -23,6 +24,7 @@
"Statistics": "Statistics",
"YouPlayedFor": "You've played for",
"hours": "hours",
"minutes": "minutes",
"Downloading": "Downloading",
"Unpack": "Unpacking",
"GameDownloaded": "Game was successfully installed",

View file

@ -9,6 +9,7 @@
"PreInstallationRequired": "事前インストールが必要",
"ToggleShadersText": "ホームボタンを使用してゲーム内のシェーダを切り替えます",
"Shaders": "シェーダ",
"ReshadeNotInstalled": "vkBasaltとreshade-shadersライブラリをインストールしていません",
"Author": "著者",
"NoImages": "画像は追加されていません",
"SettingsTitle": "設定",
@ -24,6 +25,7 @@
"Statistics": "統計",
"YouPlayedFor": "あなたはのためにプレーしてきました",
"hours": "時間",
"minutes": "分",
"Unpack": "開梱",
"GameDownloaded": "ゲームのインストールに成功しました",
"ApplyPatch": "パッチの適用...",

View file

@ -9,6 +9,7 @@
"PreInstallationRequired": "사전 설치 필요",
"ToggleShadersText": "홈 버튼을 사용하여 게임에서 쉐이더를 전환하십시오",
"Shaders": "쉐이더",
"ReshadeNotInstalled": "vkBasalt 및 reshade-shaders 라이브러리를 설치하지 않았습니다",
"Author": "저자",
"NoImages": "추가 된 이미지 없음",
"SettingsTitle": "설정",
@ -23,6 +24,7 @@
"Statistics": "통계",
"YouPlayedFor": "당신은 위해 연주했습니다",
"hours": "시간",
"minutes": "분",
"Downloading": "다운로드 중",
"Unpack": "풀기",
"GameDownloaded": "게임이 성공적으로 설치되었습니다",

View file

@ -9,6 +9,7 @@
"PreInstallationRequired": "pre-installation required",
"ToggleShadersText": "Use Home button to toggle shaders in the game",
"Shaders": "Shaders",
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
"Author": "Author",
"NoImages": "No images added",
"SettingsTitle": "Settings",
@ -23,6 +24,7 @@
"Statistics": "Statistics",
"YouPlayedFor": "You've played for",
"hours": "hours",
"minutes": "minutes",
"Downloading": "Downloading",
"Unpack": "Unpacking",
"GameDownloaded": "Game was successfully installed",

View file

@ -9,6 +9,7 @@
"PreInstallationRequired": "требуется предустановка",
"ToggleShadersText": "Используйте кнопку Home для переключения шейдеров в игре",
"Shaders": "Шейдеры",
"ReshadeNotInstalled": "Вы не установили vkBasalt и библиотеку reshade-shaders",
"Author": "Автор",
"NoImages": "Изображения не добавлены",
"SettingsTitle": "Настройки",
@ -23,6 +24,7 @@
"Statistics": "Статистика",
"YouPlayedFor": "Вы играли",
"hours": "часов",
"minutes": "минут",
"Downloading": "Загрузка",
"Unpack": "Распаковка",
"GameDownloaded": "Игра была успешно установлена",

View file

@ -9,6 +9,7 @@
"PreInstallationRequired": "pre-installation required",
"ToggleShadersText": "Use Home button to toggle shaders in the game",
"Shaders": "Shaders",
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
"Author": "Author",
"NoImages": "No images added",
"SettingsTitle": "Settings",
@ -23,6 +24,7 @@
"Statistics": "Statistics",
"YouPlayedFor": "You've played for",
"hours": "hours",
"minutes": "minutes",
"Downloading": "Downloading",
"Unpack": "Unpacking",
"GameDownloaded": "Game was successfully installed",

View file

@ -9,6 +9,7 @@
"PreInstallationRequired": "pre-installation required",
"ToggleShadersText": "Use Home button to toggle shaders in the game",
"Shaders": "Shaders",
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
"Author": "Author",
"NoImages": "No images added",
"SettingsTitle": "Settings",
@ -23,6 +24,7 @@
"Statistics": "Statistics",
"YouPlayedFor": "You've played for",
"hours": "hours",
"minutes": "minutes",
"Downloading": "Downloading",
"Unpack": "Unpacking",
"GameDownloaded": "Game was successfully installed",

View file

@ -9,6 +9,7 @@
"PreInstallationRequired": "pre-installation required",
"ToggleShadersText": "Use Home button to toggle shaders in the game",
"Shaders": "Shaders",
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
"Author": "Author",
"NoImages": "No images added",
"SettingsTitle": "设置",
@ -24,6 +25,7 @@
"Statistics": "Statistics",
"YouPlayedFor": "You've played for",
"hours": "hours",
"minutes": "minutes",
"Unpack": "开箱",
"GameDownloaded": "游戏安装成功",
"ApplyPatch": "应用补丁...",

View file

@ -9,6 +9,7 @@
"PreInstallationRequired": "pre-installation required",
"ToggleShadersText": "Use Home button to toggle shaders in the game",
"Shaders": "Shaders",
"ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library",
"Author": "Author",
"NoImages": "No images added",
"SettingsTitle": "設定",
@ -24,6 +25,7 @@
"Statistics": "Statistics",
"YouPlayedFor": "You've played for",
"hours": "hours",
"minutes": "minutes",
"Unpack": "解壓縮中...",
"GameDownloaded": "遊戲安裝成功",
"ApplyPatch": "套用補丁...",

View file

@ -246,10 +246,15 @@ $secondary: #e1e7ff
border-radius: 8px
padding: 8px 12px
&:hover
&:hover:not([disabled])
background-color: $light2
color: $primary
&[disabled]
display: block
color: #b2c0d3
cursor: default
li:not(last-child)
margin-bottom: 4px

View file

@ -2,8 +2,8 @@ const { ipcRenderer } = require('electron');
import $ from 'cash-dom';
import { LauncherLib } from './lib/LauncherLib';
import { LauncherUI } from './lib/LauncherUI';
import LauncherLib from './lib/LauncherLib';
import LauncherUI from './lib/LauncherUI';
$(() => {
LauncherUI.updateLang(LauncherLib.getConfig('lang.launcher'));

View file

@ -7,11 +7,11 @@ const semver = require('semver');
import $ from 'cash-dom';
import { constants } from './lib/constants';
import { LauncherLib } from './lib/LauncherLib';
import { LauncherUI } from './lib/LauncherUI';
import { Tools } from './lib/Tools';
import { DiscordRPC } from './lib/DiscordRPC';
import constants from './lib/constants';
import LauncherLib from './lib/LauncherLib';
import LauncherUI from './lib/LauncherUI';
import Tools from './lib/Tools';
import DiscordRPC from './lib/DiscordRPC';
const launcher_version = require('../../package.json').version;

View file

@ -19,7 +19,7 @@ export type LAB = {
/**
* Based on https://stackoverflow.com/a/59602352
*/
export class Colors
export default class Colors
{
// X, Y, Z of a "D65" light source.
// "D65" is a standard 6500K Daylight light source.

View file

@ -1,6 +1,6 @@
import discordRpc, { Client, Presence } from 'discord-rpc';
export class DiscordRPC
export default class DiscordRPC
{
protected static readonly clientId = '901534333360304168';

View file

@ -1,6 +1,6 @@
import GIJSON from '../types/GIJSON';
import { constants } from './constants';
import { Tools } from './Tools';
import constants from './constants';
import Tools from './Tools';
const fs = require('fs');
const path = require('path');
@ -63,7 +63,7 @@ type DXVK = {
uri: string
};
export class LauncherLib
export default class LauncherLib
{
public static get version(): string|null
{
@ -78,7 +78,7 @@ export class LauncherLib
.then(runners => resolve(runners));
});*/
return new Promise(resolve => fs.readFile(path.join(path.dirname(__dirname), '..', 'runners.json'), (err: any, data: string) => resolve(JSON.parse(data))));
return new Promise(resolve => fs.readFile(path.join(constants.appDir, 'public', 'runners.json'), (err: any, data: string) => resolve(JSON.parse(data))));
}
public static getDXVKs (): Promise<DXVK[]>
@ -89,7 +89,7 @@ export class LauncherLib
.then(dxvks => resolve(dxvks));
});*/
return new Promise(resolve => fs.readFile(path.join(path.dirname(__dirname), '..', 'dxvks.json'), (err: any, data: string) => resolve(JSON.parse(data))));
return new Promise(resolve => fs.readFile(path.join(constants.appDir, 'public', 'dxvks.json'), (err: any, data: string) => resolve(JSON.parse(data))));
}
public static getConfig (property: string|null = null): any
@ -273,8 +273,8 @@ export class LauncherLib
public static patchGame (onFinish: () => void, onData: (data: string) => void)
{
this.getPatchInfo().then(pathInfo => {
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.downloadFile(constants.patchUri, path.join(constants.launcherDir, 'patch.zip')).then(() => {
Tools.unzip(path.join(constants.launcherDir, 'patch.zip'), constants.launcherDir).then(() => {
// Delete zip file and assign patch directory.
fs.unlinkSync(path.join(constants.launcherDir, 'patch.zip'));
@ -299,7 +299,7 @@ export class LauncherLib
patcherProcess.on('close', () => {
// Make sure that launcher.bat exists if not run patch.sh again.
if (!path.join(constants.gameDir, 'launcher.bat'))
if (!fs.existsSync(path.join(constants.gameDir, 'launcher.bat')))
exec(`yes yes | ${path.join(patchDir, 'patch.sh')}`, {
cwd: constants.gameDir,
env: {

View file

@ -1,10 +1,10 @@
import $ from 'cash-dom';
import { constants } from './constants';
import { LauncherLib } from './LauncherLib';
import { i18n } from './i18n';
import { Tools } from './Tools';
import { Colors } from './Colors';
import constants from './constants';
import LauncherLib from './LauncherLib';
import i18n from './i18n';
import Tools from './Tools';
import Colors from './Colors';
type LauncherState =
'patch-unavailable' |
@ -15,7 +15,7 @@ type LauncherState =
'game-voice-update-required' |
'game-launch-available';
export class LauncherUI
export default class LauncherUI
{
protected static _launcherState: LauncherState = 'game-launch-available';
protected static _i18n: any;

View file

@ -22,7 +22,7 @@ type Pixel = {
}
};
export class Tools
export default class Tools
{
public static getImagePixels (path: string): Promise<Pixel[]>
{
@ -97,7 +97,7 @@ export class Tools
});
}
public static async downloadFile (uri: string, savePath: string, progress: (current: number, total: number, difference: number) => void): Promise<void|Error>
public static async downloadFile (uri: string, savePath: string, progress: null|((current: number, total: number, difference: number) => void) = null): Promise<void|Error>
{
return new Promise((resolve, reject) => {
https.get(uri, (response: any) => {
@ -107,7 +107,8 @@ export class Tools
response.on('data', (chunk: any) => {
total += chunk.length;
progress(total, length, chunk.length);
if (progress !== null)
progress(total, length, chunk.length);
fs.appendFileSync(savePath, chunk);
});
@ -117,7 +118,7 @@ export class Tools
});
}
public static async unzip (zipPath: string, unpackedPath: string, progress: (current: number, total: number, difference: number) => void): Promise<void|Error>
public static async unzip (zipPath: string, unpackedPath: string, progress: null|((current: number, total: number, difference: number) => void) = null): Promise<void|Error>
{
return new Promise((resolve, reject) => {
let listenerProcess = spawn('unzip', ['-v', zipPath]),
@ -158,7 +159,8 @@ export class Tools
{
current += file.compressedSize;
progress(current, total, file.compressedSize);
if (progress !== null)
progress(current, total, file.compressedSize);
}
});
}
@ -170,7 +172,7 @@ export class Tools
});
}
public static async untar (tarPath: string, unpackedPath: string, progress: (current: number, total: number, difference: number) => void): Promise<void|Error>
public static async untar (tarPath: string, unpackedPath: string, progress: null|((current: number, total: number, difference: number) => void) = null): Promise<void|Error>
{
return new Promise((resolve, reject) => {
let listenerProcess = spawn('tar', ['-tvf', tarPath]),
@ -210,7 +212,8 @@ export class Tools
{
current += file.uncompressedSize; // compressedSize
progress(current, total, file.uncompressedSize); // compressedSize
if (progress !== null)
progress(current, total, file.uncompressedSize); // compressedSize
}
});
});

View file

@ -36,7 +36,7 @@ $(() => {
{
li = item = $(li[0]);
if (!item.hasClass('selected'))
if (!item.hasClass('selected') && !item.is('[disabled]'))
{
while (!item.hasClass('select'))
item = item.parent();

View file

@ -1,7 +1,7 @@
const path = require('path');
const os = require('os');
export class constants
export default class constants
{
public static readonly placeholders = {
uppercase:

View file

@ -1,9 +1,9 @@
const path = require('path');
const fs = require('fs');
import { constants } from './constants';
import constants from './constants';
export class i18n
export default class i18n
{
public static readonly localesDir = path.join(path.dirname(__dirname), '..', 'locales');

View file

@ -3,12 +3,14 @@ const path = require('path');
const { ipcRenderer } = require('electron');
const { exec } = require('child_process');
const commandExists = require('command-exists').sync;
import $ from 'cash-dom';
import { constants } from './lib/constants';
import { LauncherLib } from './lib/LauncherLib';
import { LauncherUI } from './lib/LauncherUI';
import { Tools } from './lib/Tools';
import constants from './lib/constants';
import LauncherLib from './lib/LauncherLib';
import LauncherUI from './lib/LauncherUI';
import Tools from './lib/Tools';
$(() => {
// Make sure settings is shown in correct language.
@ -84,7 +86,13 @@ $(() => {
LauncherLib.updateConfig('hud', data.value);
});
$('#hud li[value=mangohud]').attr('data-hint', LauncherUI.i18n.translate('PreInstallationRequired'));
if (!commandExists('mangohud'))
{
$('#hud li[value=mangohud]')
.attr('disabled', '')
.addClass('hint--top hint--small')
.attr('data-hint', LauncherUI.i18n.translate('PreInstallationRequired'));
}
/**
* Discord RPC
@ -103,11 +111,26 @@ $(() => {
* Shaders
*/
let reshadeAvailable = fs.existsSync('/usr/share/reshade');
if (!reshadeAvailable)
process.env.PATH?.split(':').forEach(path => reshadeAvailable |= fs.existsSync(`${path}/reshade`));
if (!reshadeAvailable)
$(`<p>⚠️ ${LauncherUI.i18n.translate('ReshadeNotInstalled')}</p>`).appendTo('#shaders');
fs.readdirSync(constants.shadersDir).forEach((folder: string) => {
const shaders: any = JSON.parse(fs.readFileSync(path.join(constants.shadersDir, folder, 'shaders.json')));
$(`<li value="${folder}">${shaders.name}</li>`).appendTo('#shaders-list ul');
// Selectable item
let li = $(`<li value="${folder}">${shaders.name}</li>`).appendTo('#shaders-list ul');
if (!reshadeAvailable)
li.attr('disabled', '')
.addClass('hint--top hint--small')
.attr('data-hint', LauncherUI.i18n.translate('PreInstallationRequired'));
// Shaders description
$(`<h3>${shaders.name}</h3>`).appendTo('#shaders');
$(`<p>${LauncherUI.i18n.translate('Author')}: ${shaders.author}</p>`).appendTo('#shaders');
@ -202,12 +225,11 @@ $(() => {
* Statistics
*/
$('#play-hours').text((LauncherLib.getConfig('playtime') / 3600).toFixed(1).toString());
const playedHours = Math.floor(LauncherLib.getConfig('playtime') / 3600);
const playedMinutes = Math.floor((LauncherLib.getConfig('playtime') - playedHours * 3600) / 60);
// Update this once per two minute
setInterval(() => {
$('#play-hours').text((LauncherLib.getConfig('playtime') / 3600).toFixed(1).toString());
}, 120 * 1000);
$('#play-hours').text(playedHours.toString());
$('#play-minutes').text(playedMinutes.toString());
/**
* Wine versions manager