diff --git a/src/defaultSettings.ts b/src/defaultSettings.ts index 1df3030..cddcc25 100644 --- a/src/defaultSettings.ts +++ b/src/defaultSettings.ts @@ -10,13 +10,29 @@ promisify(async () => { 'en-us' ] }, - - /** - * Path to wine prefix - * - * @default constants.paths.prefix.default - */ - prefix: await constants.paths.prefix.default, + + folders: { + /** + * Path to wine prefix + * + * @default "~/.local/share/anime-game-launcher" + */ + prefix: await constants.paths.prefix.default, + + /** + * Path to game installation folder + * + * @default "~/.local/share/anime-game-launcher/game/drive_c/Program Files/[An Anime Game]" + */ + game: `${await constants.paths.prefix.default}/game/drive_c/Program Files/${constants.placeholders.uppercase.first} ${constants.placeholders.uppercase.second}`, + + /** + * Path to some temp folder + * + * @default "~/.local/share/anime-game-launcher" + */ + temp: await constants.paths.prefix.default + }, /** * Runner name to use, or null if runner is not specified diff --git a/src/index.svelte b/src/index.svelte index 6f41e92..22b30d9 100644 --- a/src/index.svelte +++ b/src/index.svelte @@ -48,7 +48,7 @@ Downloader.closeStreams(true); Archive.closeStreams(true); - constants.paths.launcherDir.then(async (path) => { + constants.paths.tempDir.then(async (tempDir) => { // Remove IPC file await IPC.purge(); @@ -56,8 +56,8 @@ if (launcher.rpc) await launcher.rpc.stop(true); - // Remove .tmp files from the launcher folder - await Neutralino.os.execCommand(`rm -f "${Process.addSlashes(`${path}/*.tmp`)}"`); + // Remove .tmp files from the temp folder + await Neutralino.os.execCommand(`rm -f "${Process.addSlashes(`${tempDir}/*.tmp`)}"`); // Save logs const log = Debug.get().join("\r\n"); diff --git a/src/ts/Constants.ts b/src/ts/Constants.ts index 1b7590f..8c18ef8 100644 --- a/src/ts/Constants.ts +++ b/src/ts/Constants.ts @@ -109,16 +109,28 @@ class Paths public static readonly prefix = Prefix; + /** + * Temp directory + * + * @default "~/.local/share/anime-game-launcher" + * + * @returns "[folders.temp] config field" + */ + public static get tempDir(): Promise + { + return new Promise(async (resolve) => resolve(await Configs.get('folders.temp') as string)); + } + /** * Game directory * * @default "~/.local/share/anime-game-launcher/game/drive_c/Program Files/[An Anime Game]" * - * @returns "[constants.paths.prefix.current]/drive_c/Program Files/[An Anime Game]" + * @returns "[folders.game] config field" */ public static get gameDir(): Promise { - return new Promise(async (resolve) => resolve(`${await this.prefix.current}/drive_c/Program Files/${constants.placeholders.uppercase.full}`)); + return new Promise(async (resolve) => resolve(await Configs.get('folders.game') as string)); } /** @@ -126,7 +138,7 @@ class Paths * * @default "~/.local/share/anime-game-launcher/game/drive_c/Program Files/[An Anime Game]/[An Anime Game]_Data" * - * @returns "[constants.paths.gameDir]/[An Anime Game]_Data" + * @returns "[folders.game]/[An Anime Game]_Data" */ public static get gameDataDir(): Promise { @@ -163,15 +175,37 @@ export default class constants public static readonly placeholders = { uppercase: { + /** + * Anime + */ first: atob('R2Vuc2hpbg=='), + + /** + * Game + */ second: atob('SW1wYWN0'), + + /** + * Anime Game + */ full: atob('R2Vuc2hpbiBJbXBhY3Q='), + + /** + * anAnimeCompany + */ company: atob('bWlIb1lv') }, lowercase: { + /** + * anime + */ first: atob('Z2Vuc2hpbg=='), + + /** + * animecompany + */ company: atob('bWlob3lv') } }; diff --git a/src/ts/core/AbstractInstaller.ts b/src/ts/core/AbstractInstaller.ts index a973d2c..333d667 100644 --- a/src/ts/core/AbstractInstaller.ts +++ b/src/ts/core/AbstractInstaller.ts @@ -51,8 +51,8 @@ export default abstract class Installer } }); - constants.paths.launcherDir.then((launcherDir) => { - const archivePath = alreadyDownloaded ? uri : `${launcherDir}/${Downloader.fileFromUri(uri)}`; + constants.paths.tempDir.then((tempDir) => { + const archivePath = alreadyDownloaded ? uri : `${tempDir}/${Downloader.fileFromUri(uri)}`; // And then unpack it const unpackArchive = () => { diff --git a/src/ts/neutralino/Process.ts b/src/ts/neutralino/Process.ts index 92d2687..7f9270f 100644 --- a/src/ts/neutralino/Process.ts +++ b/src/ts/neutralino/Process.ts @@ -195,7 +195,7 @@ class Process public static run(command: string, options: ProcessOptions = {}): Promise { return new Promise(async (resolve) => { - const tmpFile = `${await constants.paths.launcherDir}/${10000 + Math.round(Math.random() * 89999)}.tmp`; + const tmpFile = `${await constants.paths.tempDir}/${10000 + Math.round(Math.random() * 89999)}.tmp`; // Set env variables if (options.env) diff --git a/src/ts/neutralino/Window.ts b/src/ts/neutralino/Window.ts index 1b5a176..440b650 100644 --- a/src/ts/neutralino/Window.ts +++ b/src/ts/neutralino/Window.ts @@ -43,7 +43,7 @@ class Window center(windowWidth: number, windowHeight: number) { - Neutralino.window.move((window.screen.width - windowWidth) / 2, (window.screen.height - windowHeight) / 2); + Neutralino.window.move(Math.round((window.screen.width - windowWidth) / 2), Math.round((window.screen.height - windowHeight) / 2)); } }; }