From a4a1d3501e42d90b55422a95bf75416c603ae4d5 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Thu, 3 Feb 2022 17:12:55 +0200 Subject: [PATCH] 2.1.2 - added `latest.log` file generation, changed log files naming From previous commits: - fixed chinese voice data installation (!33) - don't attempt to edit /etc/hosts or use pkexec when running as flatpak (!31) From beta-1: - fixed compatibility issues with patch repos --- README.md | 2 +- neutralino.config.json | 2 +- package.json | 2 +- scripts/bundle-appimage.cjs | 2 +- src/index.svelte | 22 +++++++++++++++++++--- src/ts/Constants.ts | 2 +- src/ts/Launcher.ts | 19 +++++++++++-------- src/ts/Patch.ts | 2 -- 8 files changed, 35 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index b406ed2..311ebf6 100644 --- a/README.md +++ b/README.md @@ -135,8 +135,8 @@ This is our current roadmap goals. You can find older ones [here](repository/pag * Move launcher on [Empathize](https://github.com/empathizejs/framework) *(2.1.0)* * Make notifications translations *(2.1.0)* * ToS Violation Window *(2.1.0)* +* Add `latest.log` file generation *(2.1.2)* * Add Chinese game's version support (due to changes in the Krock's patch) -* Add `latest.log` file generation * Implement manual config flushing functionality from the Empathize's API * Add analytics window * Add an option to show terminal with the wine's log of the game diff --git a/neutralino.config.json b/neutralino.config.json index 19bbd91..1076ff3 100644 --- a/neutralino.config.json +++ b/neutralino.config.json @@ -1,6 +1,6 @@ { "applicationId": "com.gitlab.KRypt0n_.an-anime-game-launcher", - "version": "2.1.2-beta1", + "version": "2.1.2", "defaultMode": "window", "port": 0, "documentRoot": "/bundle/", diff --git a/package.json b/package.json index bbd6c41..d833fc0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "an-anime-game-launcher", - "version": "2.1.2-beta1", + "version": "2.1.2", "license": "GPL-3.0", "type": "module", "scripts": { diff --git a/scripts/bundle-appimage.cjs b/scripts/bundle-appimage.cjs index 5f9c64d..9322562 100644 --- a/scripts/bundle-appimage.cjs +++ b/scripts/bundle-appimage.cjs @@ -39,7 +39,7 @@ const bundler = new Bundler({ output: path.join(__dirname, '../dist/An Anime Game Launcher.AppImage'), // Application version - version: '2.1.2-beta1' + version: '2.1.2' }); // Bundle project diff --git a/src/index.svelte b/src/index.svelte index ad61606..b83a673 100644 --- a/src/index.svelte +++ b/src/index.svelte @@ -19,6 +19,22 @@ const launcher = new Launcher(onMount); + const getLogFilename = (date: Date = Debug.startedAt) => { + const prefixZero = (num: number) => num < 10 ? `0${num}` : num; + + return `${date.getFullYear()}-${prefixZero(date.getMonth() + 1)}-${prefixZero(date.getDate())}-${prefixZero(date.getHours())}-${prefixZero(date.getMinutes())}-${prefixZero(date.getSeconds())}.log`; + }; + + constants.paths.launcherDir.then((launcherDir) => { + Neutralino.filesystem.getStats(`${launcherDir}/logs/latest.log`) + .then(async () => { + const created_at = (await Neutralino.os.execCommand(`stat -c '%W' "${path.addSlashes(`${launcherDir}/logs/latest.log`)}"`)).stdOut; + + Neutralino.filesystem.moveFile(`${launcherDir}/logs/latest.log`, `${launcherDir}/logs/${getLogFilename(new Date(created_at * 1000))}`); + }) + .catch(() => {}); + }); + Neutralino.events.on('windowClose', async () => { Downloader.closeStreams(true); Archive.closeStreams(true); @@ -46,7 +62,7 @@ const log = Debug.get().join('\r\n'); if (log != '') - await Neutralino.filesystem.writeFile(`${launcherDir}/logs/${Debug.startedAt.getDate()}-${Debug.startedAt.getMonth() + 1}-${Debug.startedAt.getFullYear()}-${Debug.startedAt.getHours()}-${Debug.startedAt.getMinutes()}-${Debug.startedAt.getSeconds()}.log`, log); + await Neutralino.filesystem.writeFile(`${launcherDir}/logs/latest.log`, log); // And close the launcher when they was saved Neutralino.app.exit(); @@ -64,7 +80,7 @@ const log = `=== Log can be incomplete ===\r\n\r\n${Debug.get().join('\r\n')}`; if (log != '') - await Neutralino.filesystem.writeFile(`${await constants.paths.launcherDir}/logs/${Debug.startedAt.getDate()}-${Debug.startedAt.getMonth() + 1}-${Debug.startedAt.getFullYear()}-${Debug.startedAt.getHours()}-${Debug.startedAt.getMinutes()}-${Debug.startedAt.getSeconds()}.log`, log); + await Neutralino.filesystem.writeFile(`${await constants.paths.launcherDir}/logs/latest.log`, log); logSavingStarted = false; }, 5000); @@ -77,7 +93,7 @@ * Update launcher's title */ Game.latest.then((game) => { - Windows.current.setTitle(`An Anime Game Launcher - ${game.version} (beta revision)`); + Windows.current.setTitle(`An Anime Game Launcher - ${game.version}`); }); /** diff --git a/src/ts/Constants.ts b/src/ts/Constants.ts index 77377e6..f3964ac 100644 --- a/src/ts/Constants.ts +++ b/src/ts/Constants.ts @@ -100,7 +100,7 @@ class Paths /** * Cache file * - * @default "~/.local/share/anime-game-launcher/cache.json" + * @default "~/.local/share/anime-game-launcher/.cache.json" */ public static get cache(): Promise { diff --git a/src/ts/Launcher.ts b/src/ts/Launcher.ts index 14375b6..bd2f2de 100644 --- a/src/ts/Launcher.ts +++ b/src/ts/Launcher.ts @@ -186,13 +186,16 @@ export default class Launcher }); }); } - - public static async isFlatpak(): Promise { - try { - const stats = await Neutralino.filesystem.getStats("/.flatpak-info"); - return stats.isFile; - } catch (error) { - return false; - } + + /** + * Check if the launcher is running under flatpak + */ + public static isFlatpak(): Promise + { + return new Promise((resolve) => { + Neutralino.filesystem.getStats('/.flatpak-info') + .then((stats) => resolve(stats.isFile)) + .catch(() => resolve(false)); + }); } }; diff --git a/src/ts/Patch.ts b/src/ts/Patch.ts index e3bbbf3..4ecd003 100644 --- a/src/ts/Patch.ts +++ b/src/ts/Patch.ts @@ -305,8 +305,6 @@ export default class Patch const originalPlayer = /if \[ "\${sum}" == "([a-z0-9]{32})" \]; then/mg.exec(response); - console.log(originalPlayer); - // If we could get original UnityPlayer.dll hash - then we can // compare it with actual UnityPlayer.dll hash and say whether the patch // was applied or not