diff --git a/README.md b/README.md index 8633c64..3d8311b 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ sudo pacman -Syu unzip tar git xdelta3 | --- | --- | | [MangoHud](https://github.com/flightlessmango/MangoHud) | To use MangoHud | | [vkBasalt](https://github.com/DadSchoorse/vkBasalt) | To use shaders | -| [GameMode](https://github.com/FeralInteractive/gamemode) | To use GameMode (performance optimisation) | +| [GameMode](https://github.com/FeralInteractive/gamemode) | To use GameMode (performance optimization) | | [switcheroo-control](https://gitlab.freedesktop.org/hadess/switcheroo-control/) | To select the GPU launcher should use to run the game | These requirements can't be easily installed so you should do it manually @@ -127,6 +127,7 @@ npm start * Add winetricks auto-downloading when new prefix creates so it is no longer required *(1.6.0)* * DXVK logs auto-deletion option *(1.6.0)* * Add default wine version to download (Proton-6.20-GE-1) *(1.6.0)* +* Add dark theme support for settings menu * Fix button flickering at start when the launcher's state updates * Wine prefix folder selection *(symlinks?)* * Game's update pre-installation diff --git a/public/locales/de.json b/public/locales/de.json index 7381ee4..320eec7 100644 --- a/public/locales/de.json +++ b/public/locales/de.json @@ -31,7 +31,7 @@ "hours": "Stunden und", "minutes": "Minuten gespielt", "Downloading": "wird Heruntergeladen", - "Unpack": "wird Entpackt", + "Unpacking": "wird Entpackt", "GameDownloaded": "Spiel würde erfolgreich heruntergeladen", "ApplyPatch": "Patch wird angewendet", "PatchRequired": "Patch nicht verfügbar", diff --git a/public/locales/en-us.json b/public/locales/en-us.json index b291aa7..55d2d4f 100644 --- a/public/locales/en-us.json +++ b/public/locales/en-us.json @@ -31,7 +31,7 @@ "YouPlayedFor": "You've played for", "hours": "hours", "minutes": "minutes", - "Unpack": "Unpacking", + "Unpacking": "Unpacking", "GameDownloaded": "Game was successfully installed", "ApplyPatch": "Applying patch...", "PatchRequired": "Patch required", diff --git a/public/locales/en.json b/public/locales/en.json index bbbcf9b..a9c3d51 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -31,7 +31,7 @@ "hours": "hours", "minutes": "minutes", "Downloading": "Downloading", - "Unpack": "Unpacking", + "Unpacking": "Unpacking", "GameDownloaded": "Game was successfully installed", "ApplyPatch": "Applying patch...", "PatchRequired": "Patch required", diff --git a/public/locales/es.json b/public/locales/es.json index bbbcf9b..a9c3d51 100644 --- a/public/locales/es.json +++ b/public/locales/es.json @@ -31,7 +31,7 @@ "hours": "hours", "minutes": "minutes", "Downloading": "Downloading", - "Unpack": "Unpacking", + "Unpacking": "Unpacking", "GameDownloaded": "Game was successfully installed", "ApplyPatch": "Applying patch...", "PatchRequired": "Patch required", diff --git a/public/locales/fr.json b/public/locales/fr.json index bbbcf9b..a9c3d51 100644 --- a/public/locales/fr.json +++ b/public/locales/fr.json @@ -31,7 +31,7 @@ "hours": "hours", "minutes": "minutes", "Downloading": "Downloading", - "Unpack": "Unpacking", + "Unpacking": "Unpacking", "GameDownloaded": "Game was successfully installed", "ApplyPatch": "Applying patch...", "PatchRequired": "Patch required", diff --git a/public/locales/id.json b/public/locales/id.json index 5fed90b..c5533a6 100644 --- a/public/locales/id.json +++ b/public/locales/id.json @@ -31,7 +31,7 @@ "hours": "jam", "minutes": "menit", "Downloading": "Mengunduh", - "Unpack": "Membuka paket", + "Unpacking": "Membuka paket", "GameDownloaded": "Game berhasil dipasang", "ApplyPatch": "Memasang patch...", "PatchRequired": "Patch dibutuhkan", diff --git a/public/locales/ja.json b/public/locales/ja.json index 3f16cd1..e2ffd21 100644 --- a/public/locales/ja.json +++ b/public/locales/ja.json @@ -31,7 +31,7 @@ "YouPlayedFor": "あなたはのためにプレーしてきました", "hours": "時間", "minutes": "分", - "Unpack": "開梱", + "Unpacking": "開梱", "GameDownloaded": "ゲームのインストールに成功しました", "ApplyPatch": "パッチの適用...", "PatchRequired": "要パッチ", diff --git a/public/locales/ko.json b/public/locales/ko.json index f334c28..c2bb2aa 100644 --- a/public/locales/ko.json +++ b/public/locales/ko.json @@ -31,7 +31,7 @@ "hours": "시간", "minutes": "분", "Downloading": "다운로드 중", - "Unpack": "풀기", + "Unpacking": "풀기", "GameDownloaded": "게임이 성공적으로 설치되었습니다", "ApplyPatch": "패치 적용...", "PatchRequired": "패치 필요", diff --git a/public/locales/pt.json b/public/locales/pt.json index bbbcf9b..a9c3d51 100644 --- a/public/locales/pt.json +++ b/public/locales/pt.json @@ -31,7 +31,7 @@ "hours": "hours", "minutes": "minutes", "Downloading": "Downloading", - "Unpack": "Unpacking", + "Unpacking": "Unpacking", "GameDownloaded": "Game was successfully installed", "ApplyPatch": "Applying patch...", "PatchRequired": "Patch required", diff --git a/public/locales/ru.json b/public/locales/ru.json index d918279..ef5671d 100644 --- a/public/locales/ru.json +++ b/public/locales/ru.json @@ -31,7 +31,7 @@ "hours": "часов", "minutes": "минут", "Downloading": "Загрузка", - "Unpack": "Распаковка", + "Unpacking": "Распаковка", "GameDownloaded": "Игра была успешно установлена", "ApplyPatch": "Применение патча...", "PatchRequired": "Необходим патч", diff --git a/public/locales/th.json b/public/locales/th.json index bbbcf9b..a9c3d51 100644 --- a/public/locales/th.json +++ b/public/locales/th.json @@ -31,7 +31,7 @@ "hours": "hours", "minutes": "minutes", "Downloading": "Downloading", - "Unpack": "Unpacking", + "Unpacking": "Unpacking", "GameDownloaded": "Game was successfully installed", "ApplyPatch": "Applying patch...", "PatchRequired": "Patch required", diff --git a/public/locales/vi.json b/public/locales/vi.json index bbbcf9b..a9c3d51 100644 --- a/public/locales/vi.json +++ b/public/locales/vi.json @@ -31,7 +31,7 @@ "hours": "hours", "minutes": "minutes", "Downloading": "Downloading", - "Unpack": "Unpacking", + "Unpacking": "Unpacking", "GameDownloaded": "Game was successfully installed", "ApplyPatch": "Applying patch...", "PatchRequired": "Patch required", diff --git a/public/locales/zh-cn.json b/public/locales/zh-cn.json index 3f35d6d..c55e528 100644 --- a/public/locales/zh-cn.json +++ b/public/locales/zh-cn.json @@ -31,7 +31,7 @@ "YouPlayedFor": "You've played for", "hours": "hours", "minutes": "minutes", - "Unpack": "开箱", + "Unpacking": "开箱", "GameDownloaded": "游戏安装成功", "ApplyPatch": "应用补丁...", "PatchRequired": "需要补丁", diff --git a/public/locales/zh-tw.json b/public/locales/zh-tw.json index f8c955e..ac0c2d0 100644 --- a/public/locales/zh-tw.json +++ b/public/locales/zh-tw.json @@ -31,7 +31,7 @@ "YouPlayedFor": "You've played for", "hours": "hours", "minutes": "minutes", - "Unpack": "解壓縮中...", + "Unpacking": "解壓縮中...", "GameDownloaded": "遊戲安裝成功", "ApplyPatch": "套用補丁...", "PatchRequired": "需要補丁", diff --git a/src/ts/index.ts b/src/ts/index.ts index 3260be3..d1eb501 100644 --- a/src/ts/index.ts +++ b/src/ts/index.ts @@ -4,6 +4,7 @@ const { exec } = require('child_process'); const { ipcRenderer } = require('electron'); const semver = require('semver'); +const commandExists = require('command-exists').sync; import $ from 'cash-dom'; @@ -78,6 +79,52 @@ $(() => { await LauncherUI.updateLauncherState(data); $('#launch').on('click', async () => { + // Download default wine if we + // don'thave wine or any runner installed + if (LauncherLib.getConfig('runner') === null && !commandExists('wine')) + { + const runners = await LauncherLib.getRunners(); + + let defaultRunner = runners[0].runners[0]; + + // Search defaul runner to download (Proton-6.20-GE-1) + runners.forEach(category => { + category.runners.forEach(runner => { + if (runner.name == 'Proton-6.20-GE-1') + defaultRunner = runner; + }); + }); + + LauncherUI.initProgressBar(); + + await Tools.downloadFile(defaultRunner.uri, path.join(constants.launcherDir, defaultRunner.name), (current: number, total: number, difference: number) => { + LauncherUI.updateProgressBar(LauncherUI.i18n.translate('Downloading'), current, total, difference); + }).then(async () => { + const unpacker = defaultRunner.archive === 'tar' ? + Tools.untar : Tools.unzip; + + LauncherUI.initProgressBar(); + + await unpacker( + path.join(constants.launcherDir, defaultRunner.name), + defaultRunner.makeFolder ? + path.join(constants.runnersDir, defaultRunner.folder) : + constants.runnersDir, + (current: number, total: number, difference: number) => { + LauncherUI.updateProgressBar(LauncherUI.i18n.translate('Unpacking'), current, total, difference); + } + ).then(() => { + fs.unlinkSync(path.join(constants.launcherDir, defaultRunner.name)); + + LauncherLib.updateConfig('runner.name', defaultRunner.name); + LauncherLib.updateConfig('runner.folder', defaultRunner.folder); + LauncherLib.updateConfig('runner.executable', defaultRunner.executable); + + LauncherUI.clearProgressBar(); + }); + }); + } + // Creating wine prefix if (!LauncherLib.isPrefixInstalled(constants.prefixDir)) { @@ -240,8 +287,8 @@ $(() => { { const removeExts = [ '.log', - '.dxvk-cache', - '.dmp' + '.dmp', + // '.dxvk-cache' ]; fs.readdirSync(constants.gameDir).forEach((file: string) => { @@ -276,44 +323,6 @@ $(() => { }, data => console.log(data.toString())); } - // Download default wine because we don't have it - else if (LauncherUI.launcherState == 'wine-installation-required') - { - const runners = await LauncherLib.getRunners(); - - let defaultRunner = runners[0].runners[0]; - - // Search defaul runner to download (Proton-6.20-GE-1) - runners.forEach(category => { - category.runners.forEach(runner => { - if (runner.name == 'Proton-6.20-GE-1') - defaultRunner = runner; - }); - }); - - LauncherUI.setState('wine-installing'); - - Tools.downloadFile(defaultRunner.uri, path.join(constants.launcherDir, defaultRunner.name)).then(() => { - const unpacker = defaultRunner.archive === 'tar' ? - Tools.untar : Tools.unzip; - - unpacker( - path.join(constants.launcherDir, defaultRunner.name), - defaultRunner.makeFolder ? - path.join(constants.runnersDir, defaultRunner.folder) : - constants.runnersDir - ).then(() => { - fs.unlinkSync(path.join(constants.launcherDir, defaultRunner.name)); - - LauncherLib.updateConfig('runner.name', defaultRunner.name); - LauncherLib.updateConfig('runner.folder', defaultRunner.folder); - LauncherLib.updateConfig('runner.executable', defaultRunner.executable); - - LauncherUI.updateLauncherState(); - }); - }); - } - // Voice pack update else if (LauncherUI.launcherState == 'game-voice-update-required') { @@ -367,7 +376,7 @@ $(() => { LauncherUI.initProgressBar(); Tools.unzip(path.join(constants.launcherDir, voicePack.name), constants.gameDir, (current: number, total: number, difference: number) => { - LauncherUI.updateProgressBar(LauncherUI.i18n.translate('Unpack'), current, total, difference); + LauncherUI.updateProgressBar(LauncherUI.i18n.translate('Unpacking'), current, total, difference); }).then(() => { fs.unlinkSync(path.join(constants.launcherDir, voicePack.name)); @@ -427,7 +436,7 @@ $(() => { LauncherUI.initProgressBar(); Tools.unzip(path.join(constants.launcherDir, diff.name), constants.gameDir, (current: number, total: number, difference: number) => { - LauncherUI.updateProgressBar(LauncherUI.i18n.translate('Unpack'), current, total, difference); + LauncherUI.updateProgressBar(LauncherUI.i18n.translate('Unpacking'), current, total, difference); }).then(() => { /** * Downloading voice data @@ -461,7 +470,7 @@ $(() => { LauncherUI.initProgressBar(); Tools.unzip(path.join(constants.launcherDir, voicePack.name), constants.gameDir, (current: number, total: number, difference: number) => { - LauncherUI.updateProgressBar(LauncherUI.i18n.translate('Unpack'), current, total, difference); + LauncherUI.updateProgressBar(LauncherUI.i18n.translate('Unpacking'), current, total, difference); }).then(() => { fs.unlinkSync(path.join(constants.launcherDir, voicePack.name)); diff --git a/src/ts/lib/LauncherLib.ts b/src/ts/lib/LauncherLib.ts index 230f19e..fc557b2 100644 --- a/src/ts/lib/LauncherLib.ts +++ b/src/ts/lib/LauncherLib.ts @@ -10,6 +10,7 @@ const { spawn, exec } = require('child_process'); const store = require('electron-store'); const https = require('follow-redirects').https; const got = require('got'); +const commandExists = require('command-exists').sync; const config = new store ({ cwd: path.join(os.homedir(), '.local', 'share', 'anime-game-launcher'), @@ -225,7 +226,7 @@ export default class LauncherLib } // WINEPREFIX='...../wineprefix' winetricks corefonts usetakefocus=n - public static async installPrefix (prefixpath: string, progress: (output: string, current: number, total: number) => void): Promise + public static async installPrefix (prefixPath: string, progress: (output: string, current: number, total: number) => void): Promise { const installationSteps = [ // corefonts @@ -252,11 +253,25 @@ export default class LauncherLib Tools.downloadFile(constants.uri.winetricks, winetricksSh).then(() => { let installationProgress = 0; - let installerProcess = spawn('bash', [winetricksSh, 'corefonts', 'usetakefocus=n'], { - env: { - ...process.env, - WINEPREFIX: prefixpath - } + let env: any = { + ...process.env, + WINEPREFIX: prefixPath + }; + + if (!commandExists('wine') && LauncherLib.getConfig('runner') !== null) + { + env['WINE'] = path.join( + constants.runnersDir, + LauncherLib.getConfig('runner.folder'), + LauncherLib.getConfig('runner.executable') + ); + + if (!fs.existsSync(env['WINE'])) + console.error(`Patcher supposed to use ${LauncherLib.getConfig('runner.name')} runner, but it doesn't installed`); + } + + const installerProcess = spawn('bash', [winetricksSh, 'corefonts', 'usetakefocus=n'], { + env: env }); installerProcess.stdout.on('data', (data: string) => { diff --git a/src/ts/lib/LauncherUI.ts b/src/ts/lib/LauncherUI.ts index 2235e5c..d13f6ec 100644 --- a/src/ts/lib/LauncherUI.ts +++ b/src/ts/lib/LauncherUI.ts @@ -6,8 +6,6 @@ import i18n from './i18n'; import Tools from './Tools'; import Colors from './Colors'; -const commandExists = require('command-exists').sync; - type LauncherState = 'patch-unavailable' | 'test-patch-available' | @@ -15,8 +13,6 @@ type LauncherState = 'game-update-available' | 'game-installation-available' | 'game-voice-update-required' | - 'wine-installation-required' | - 'wine-installing' | 'game-launch-available'; export default class LauncherUI @@ -87,17 +83,6 @@ export default class LauncherUI break; - case 'wine-installation-required': - $('#launch').text(this.i18n.translate('DownloadWine')); - - break; - - case 'wine-installing': - $('#launch').text(this.i18n.translate('Downloading')); - $('#launch').attr('disabled', 'disabled'); - - break; - case 'game-launch-available': $('#launch').removeAttr('disabled') .removeAttr('data-hint'); @@ -169,10 +154,6 @@ export default class LauncherUI }, data => console.log(data.toString())); } - // If we don't have wine or any runner installed - else if (LauncherLib.getConfig('runner') === null && !commandExists('wine')) - this.setState('wine-installation-required'); - else this.setState('game-launch-available'); }