From 4c8f40a941079a11ab944c2ca39c8f2586370534 Mon Sep 17 00:00:00 2001 From: Laurin Neff Date: Wed, 24 Nov 2021 22:02:41 +0100 Subject: [PATCH 1/2] Add GameMode integration --- public/html/settings.html | 10 ++++++++++ public/locales/de.json | 1 + public/locales/en-us.json | 1 + public/locales/en.json | 1 + public/locales/es.json | 1 + public/locales/fr.json | 1 + public/locales/id.json | 1 + public/locales/ja.json | 1 + public/locales/ko.json | 1 + public/locales/pt.json | 1 + public/locales/ru.json | 1 + public/locales/th.json | 1 + public/locales/vi.json | 1 + public/locales/zh-cn.json | 1 + public/locales/zh-tw.json | 1 + src/ts/index.ts | 8 +++++++- src/ts/lib/LauncherLib.ts | 1 + src/ts/settings.ts | 19 +++++++++++++++++++ 18 files changed, 51 insertions(+), 1 deletion(-) diff --git a/public/html/settings.html b/public/html/settings.html index 9320084..8ea2633 100644 --- a/public/html/settings.html +++ b/public/html/settings.html @@ -109,6 +109,16 @@ + +
+ +
+ GameMode + +
+ +
+

diff --git a/public/locales/de.json b/public/locales/de.json index ab9b6fa..468ecfd 100644 --- a/public/locales/de.json +++ b/public/locales/de.json @@ -10,6 +10,7 @@ "ToggleShadersText": "Verwenden Sie die Home-Taste (POS 1), um Shader im Spiel ein/aus-zuschalten", "Shaders": "Shadern", "ReshadeNotInstalled": "Sie haben vkBasalt und Reshade-Shader nicht installiert", + "GameModeNotInstalled": "Sie haben GameMode nicht installiert", "Author": "Autor", "NoImages": "Bilder sind nicht verfügbar", "SettingsTitle": "Einstellungen", diff --git a/public/locales/en-us.json b/public/locales/en-us.json index a7fd7e9..77c8b2c 100644 --- a/public/locales/en-us.json +++ b/public/locales/en-us.json @@ -10,6 +10,7 @@ "ToggleShadersText": "Use Home button to toggle shaders in the game", "Shaders": "Shaders", "ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library", + "GameModeNotInstalled": "You don't have GameMode installed", "Author": "Author", "NoImages": "No images added", "SettingsTitle": "Settings", diff --git a/public/locales/en.json b/public/locales/en.json index 39b6786..ab04190 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -10,6 +10,7 @@ "ToggleShadersText": "Use Home button to toggle shaders in the game", "Shaders": "Shaders", "ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library", + "GameModeNotInstalled": "You don't have GameMode installed", "Author": "Author", "NoImages": "No images added", "SettingsTitle": "Settings", diff --git a/public/locales/es.json b/public/locales/es.json index 39b6786..ab04190 100644 --- a/public/locales/es.json +++ b/public/locales/es.json @@ -10,6 +10,7 @@ "ToggleShadersText": "Use Home button to toggle shaders in the game", "Shaders": "Shaders", "ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library", + "GameModeNotInstalled": "You don't have GameMode installed", "Author": "Author", "NoImages": "No images added", "SettingsTitle": "Settings", diff --git a/public/locales/fr.json b/public/locales/fr.json index 39b6786..ab04190 100644 --- a/public/locales/fr.json +++ b/public/locales/fr.json @@ -10,6 +10,7 @@ "ToggleShadersText": "Use Home button to toggle shaders in the game", "Shaders": "Shaders", "ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library", + "GameModeNotInstalled": "You don't have GameMode installed", "Author": "Author", "NoImages": "No images added", "SettingsTitle": "Settings", diff --git a/public/locales/id.json b/public/locales/id.json index e3b50d7..b8a1a65 100644 --- a/public/locales/id.json +++ b/public/locales/id.json @@ -10,6 +10,7 @@ "ToggleShadersText": "Gunakan tombol Home untuk menyalakan/mematikan shader di dalam Game", "Shaders": "Shader", "ReshadeNotInstalled": "Kamu belum memasang vkBasalt dan library reshade-shaders", + "GameModeNotInstalled": "You don't have GameMode installed", "Author": "Pembuat", "NoImages": "Tidak ada gambar ditambahkan", "SettingsTitle": "Pengaturan", diff --git a/public/locales/ja.json b/public/locales/ja.json index 25a38bb..ec325e6 100644 --- a/public/locales/ja.json +++ b/public/locales/ja.json @@ -10,6 +10,7 @@ "ToggleShadersText": "ホームボタンを使用してゲーム内のシェーダを切り替えます", "Shaders": "シェーダ", "ReshadeNotInstalled": "vkBasaltとreshade-shadersライブラリをインストールしていません", + "GameModeNotInstalled": "You don't have GameMode installed", "Author": "著者", "NoImages": "画像は追加されていません", "SettingsTitle": "設定", diff --git a/public/locales/ko.json b/public/locales/ko.json index 3b3c741..248d712 100644 --- a/public/locales/ko.json +++ b/public/locales/ko.json @@ -10,6 +10,7 @@ "ToggleShadersText": "홈 버튼을 사용하여 게임에서 쉐이더를 전환하십시오", "Shaders": "쉐이더", "ReshadeNotInstalled": "vkBasalt 및 reshade-shaders 라이브러리를 설치하지 않았습니다", + "GameModeNotInstalled": "You don't have GameMode installed", "Author": "저자", "NoImages": "추가 된 이미지 없음", "SettingsTitle": "설정", diff --git a/public/locales/pt.json b/public/locales/pt.json index 39b6786..ab04190 100644 --- a/public/locales/pt.json +++ b/public/locales/pt.json @@ -10,6 +10,7 @@ "ToggleShadersText": "Use Home button to toggle shaders in the game", "Shaders": "Shaders", "ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library", + "GameModeNotInstalled": "You don't have GameMode installed", "Author": "Author", "NoImages": "No images added", "SettingsTitle": "Settings", diff --git a/public/locales/ru.json b/public/locales/ru.json index 9ecb610..ac19d5d 100644 --- a/public/locales/ru.json +++ b/public/locales/ru.json @@ -10,6 +10,7 @@ "ToggleShadersText": "Используйте кнопку Home для переключения шейдеров в игре", "Shaders": "Шейдеры", "ReshadeNotInstalled": "Вы не установили vkBasalt и библиотеку reshade-shaders", + "GameModeNotInstalled": "You don't have GameMode installed", "Author": "Автор", "NoImages": "Изображения не добавлены", "SettingsTitle": "Настройки", diff --git a/public/locales/th.json b/public/locales/th.json index 39b6786..ab04190 100644 --- a/public/locales/th.json +++ b/public/locales/th.json @@ -10,6 +10,7 @@ "ToggleShadersText": "Use Home button to toggle shaders in the game", "Shaders": "Shaders", "ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library", + "GameModeNotInstalled": "You don't have GameMode installed", "Author": "Author", "NoImages": "No images added", "SettingsTitle": "Settings", diff --git a/public/locales/vi.json b/public/locales/vi.json index 39b6786..ab04190 100644 --- a/public/locales/vi.json +++ b/public/locales/vi.json @@ -10,6 +10,7 @@ "ToggleShadersText": "Use Home button to toggle shaders in the game", "Shaders": "Shaders", "ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library", + "GameModeNotInstalled": "You don't have GameMode installed", "Author": "Author", "NoImages": "No images added", "SettingsTitle": "Settings", diff --git a/public/locales/zh-cn.json b/public/locales/zh-cn.json index 5594314..5947d7e 100644 --- a/public/locales/zh-cn.json +++ b/public/locales/zh-cn.json @@ -10,6 +10,7 @@ "ToggleShadersText": "Use Home button to toggle shaders in the game", "Shaders": "Shaders", "ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library", + "GameModeNotInstalled": "You don't have GameMode installed", "Author": "Author", "NoImages": "No images added", "SettingsTitle": "设置", diff --git a/public/locales/zh-tw.json b/public/locales/zh-tw.json index 0d976fb..3b3b5c0 100644 --- a/public/locales/zh-tw.json +++ b/public/locales/zh-tw.json @@ -10,6 +10,7 @@ "ToggleShadersText": "Use Home button to toggle shaders in the game", "Shaders": "Shaders", "ReshadeNotInstalled": "You haven't installed vkBasalt and reshade-shaders library", + "GameModeNotInstalled": "You don't have GameMode installed", "Author": "Author", "NoImages": "No images added", "SettingsTitle": "設定", diff --git a/src/ts/index.ts b/src/ts/index.ts index 8d2a80f..fa7936e 100644 --- a/src/ts/index.ts +++ b/src/ts/index.ts @@ -177,11 +177,17 @@ $(() => { fs.writeFileSync(launcherShadersFile, fs.readFileSync(userShadersFile)); } + + let cmd = `${wineExeutable} launcher.bat`; + + if (LauncherLib.getConfig('gamemode')) { + cmd = `gamemoderun ${cmd}`; + } // Starting the game const startTime = Date.now(); - exec(`${wineExeutable} launcher.bat`, { + exec(cmd, { cwd: constants.gameDir, env: { ...process.env, diff --git a/src/ts/lib/LauncherLib.ts b/src/ts/lib/LauncherLib.ts index 02fd630..97a6425 100644 --- a/src/ts/lib/LauncherLib.ts +++ b/src/ts/lib/LauncherLib.ts @@ -32,6 +32,7 @@ const config = new store ({ playtime: 0, // Number of seconds user spent in game hud: 'none', // none / dxvk / mangohud shaders: 'none', // none / shader's folder + gamemode: false, // Version of the game we asked about analytics last time, // or null if user said don't ask him again diff --git a/src/ts/settings.ts b/src/ts/settings.ts index a72b6ce..a23a4a7 100644 --- a/src/ts/settings.ts +++ b/src/ts/settings.ts @@ -107,6 +107,25 @@ $(() => { ipcRenderer.send('rpc-toggle'); }); + /** + * GameMode + */ + + let gameModeAvailable = 0; + process.env.PATH?.split(':').forEach(path => gameModeAvailable |= fs.existsSync(`${path}/gamemoderun`)); + + if(!gameModeAvailable) + $(`

⚠️ ${LauncherUI.i18n.translate('GameModeNotInstalled')}

`).insertAfter('#gamemode'); + + if (LauncherLib.getConfig("gamemode")) + $("#gamemode").addClass("checkbox-active"); + + $("#gamemode").on("classChange", () => { + LauncherLib.updateConfig("gamemode",$("#gamemode").hasClass("checkbox-active")); + + ipcRenderer.send("rpc-toggle"); + }); + /** * Shaders */ From 8d1578753e53672c65fcad3915aade4012477851 Mon Sep 17 00:00:00 2001 From: Laurin Neff Date: Wed, 24 Nov 2021 23:41:10 +0100 Subject: [PATCH 2/2] Remove ipcRenderer call when toggling the GameMode checkbox --- src/ts/settings.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ts/settings.ts b/src/ts/settings.ts index a23a4a7..bdbf4d7 100644 --- a/src/ts/settings.ts +++ b/src/ts/settings.ts @@ -122,8 +122,6 @@ $(() => { $("#gamemode").on("classChange", () => { LauncherLib.updateConfig("gamemode",$("#gamemode").hasClass("checkbox-active")); - - ipcRenderer.send("rpc-toggle"); }); /**