From 10b5edb657b0c8b5f96872c6aefcc7ac390b4c9b Mon Sep 17 00:00:00 2001 From: Maroxy Date: Sat, 11 Dec 2021 12:12:43 +0100 Subject: [PATCH 1/5] Add main settings div for Discord RPC --- public/html/settings.html | 4 ++++ public/locales/de.json | 3 +-- public/locales/en-us.json | 3 +-- public/locales/en.json | 3 +-- public/locales/es.json | 3 +-- public/locales/fr.json | 3 +-- public/locales/id.json | 3 +-- public/locales/ja.json | 3 +-- public/locales/ko.json | 3 +-- public/locales/pt.json | 3 +-- public/locales/ru.json | 3 +-- public/locales/th.json | 3 +-- public/locales/vi.json | 3 +-- public/locales/zh-cn.json | 3 +-- public/locales/zh-tw.json | 3 +-- src/ts/settings.ts | 8 ++++++++ 16 files changed, 26 insertions(+), 28 deletions(-) diff --git a/public/html/settings.html b/public/html/settings.html index cd02f34..2494de4 100644 --- a/public/html/settings.html +++ b/public/html/settings.html @@ -25,6 +25,7 @@ +
@@ -310,6 +311,9 @@
+ diff --git a/public/locales/de.json b/public/locales/de.json index 117422a..9341de9 100644 --- a/public/locales/de.json +++ b/public/locales/de.json @@ -62,6 +62,5 @@ "TelemetryNotDisabled": "{placeholders.uppercase.company} Telemetrieserver sind nicht deaktiviert!", "PatchRepoUnavailableTitle": "Patch's repository is not available", "PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding", - "DefPrefix": "Zurücksetzen zum Standard-Prefix", - "ChangePrefix": "Prefix ändern" + "DRPConf": "Discord RPC" } \ No newline at end of file diff --git a/public/locales/en-us.json b/public/locales/en-us.json index 2801440..104c7ed 100644 --- a/public/locales/en-us.json +++ b/public/locales/en-us.json @@ -62,6 +62,5 @@ "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!", "PatchRepoUnavailableTitle": "Patch's repository is not available", "PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding", - "DefPrefix": "Reset to Default", - "ChangePrefix": "Change Prefix" + "DRPConf": "Discord RPC" } \ No newline at end of file diff --git a/public/locales/en.json b/public/locales/en.json index ec49242..ac08913 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -62,6 +62,5 @@ "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!", "PatchRepoUnavailableTitle": "Patch's repository is not available", "PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding", - "DefPrefix": "Reset to Default", - "ChangePrefix": "Change Prefix" + "DRPConf": "Discord RPC" } \ No newline at end of file diff --git a/public/locales/es.json b/public/locales/es.json index ec49242..ac08913 100644 --- a/public/locales/es.json +++ b/public/locales/es.json @@ -62,6 +62,5 @@ "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!", "PatchRepoUnavailableTitle": "Patch's repository is not available", "PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding", - "DefPrefix": "Reset to Default", - "ChangePrefix": "Change Prefix" + "DRPConf": "Discord RPC" } \ No newline at end of file diff --git a/public/locales/fr.json b/public/locales/fr.json index ec49242..ac08913 100644 --- a/public/locales/fr.json +++ b/public/locales/fr.json @@ -62,6 +62,5 @@ "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!", "PatchRepoUnavailableTitle": "Patch's repository is not available", "PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding", - "DefPrefix": "Reset to Default", - "ChangePrefix": "Change Prefix" + "DRPConf": "Discord RPC" } \ No newline at end of file diff --git a/public/locales/id.json b/public/locales/id.json index 8767f70..eb72071 100644 --- a/public/locales/id.json +++ b/public/locales/id.json @@ -62,6 +62,5 @@ "TelemetryNotDisabled": "Peladen telemetri {placeholders.uppercase.company} tidak dimatikan!", "PatchRepoUnavailableTitle": "Repositori patch tidak tersedia", "PatchRepoUnavailableBody": "Sepertinya notabug sedang dalam serangan dan tidak merespon", - "DefPrefix": "Setel ulang ke bawaan", - "ChangePrefix": "Ganti Prefix" + "DRPConf": "Discord RPC" } \ No newline at end of file diff --git a/public/locales/ja.json b/public/locales/ja.json index 7ddd5ed..c2bd303 100644 --- a/public/locales/ja.json +++ b/public/locales/ja.json @@ -62,6 +62,5 @@ "TelemetryNotDisabled": "{placeholders.uppercase.company}のテレメトリサーバは無効になっていません!", "PatchRepoUnavailableTitle": "Patch's repository is not available", "PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding", - "DefPrefix": "デフォルトへのリセット", - "ChangePrefix": "プレフィックスを変更" + "DRPConf": "Discord RPC" } \ No newline at end of file diff --git a/public/locales/ko.json b/public/locales/ko.json index dbc224f..fc97301 100644 --- a/public/locales/ko.json +++ b/public/locales/ko.json @@ -62,6 +62,5 @@ "TelemetryNotDisabled": "{placeholders.uppercase.company} 의 원격 측정 서버가 비활성화되지 않음!", "PatchRepoUnavailableTitle": "Patch's repository is not available", "PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding", - "DefPrefix": "Reset to Default", - "ChangePrefix": "Change Prefix" + "DRPConf": "Discord RPC" } \ No newline at end of file diff --git a/public/locales/pt.json b/public/locales/pt.json index ec49242..ac08913 100644 --- a/public/locales/pt.json +++ b/public/locales/pt.json @@ -62,6 +62,5 @@ "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!", "PatchRepoUnavailableTitle": "Patch's repository is not available", "PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding", - "DefPrefix": "Reset to Default", - "ChangePrefix": "Change Prefix" + "DRPConf": "Discord RPC" } \ No newline at end of file diff --git a/public/locales/ru.json b/public/locales/ru.json index c92b3b8..9e7f26d 100644 --- a/public/locales/ru.json +++ b/public/locales/ru.json @@ -62,6 +62,5 @@ "TelemetryNotDisabled": "Серверы сбора телеметрии {placeholders.uppercase.company} не отключены!", "PatchRepoUnavailableTitle": "Репозиторий патча недоступен", "PatchRepoUnavailableBody": "Скорее всего notabug находится под атакой и не отвечает", - "DefPrefix": "Сбросить до умолчания", - "ChangePrefix": "Изменить префикс" + "DRPConf": "Discord RPC" } \ No newline at end of file diff --git a/public/locales/th.json b/public/locales/th.json index ec49242..ac08913 100644 --- a/public/locales/th.json +++ b/public/locales/th.json @@ -62,6 +62,5 @@ "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!", "PatchRepoUnavailableTitle": "Patch's repository is not available", "PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding", - "DefPrefix": "Reset to Default", - "ChangePrefix": "Change Prefix" + "DRPConf": "Discord RPC" } \ No newline at end of file diff --git a/public/locales/vi.json b/public/locales/vi.json index ec49242..ac08913 100644 --- a/public/locales/vi.json +++ b/public/locales/vi.json @@ -62,6 +62,5 @@ "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!", "PatchRepoUnavailableTitle": "Patch's repository is not available", "PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding", - "DefPrefix": "Reset to Default", - "ChangePrefix": "Change Prefix" + "DRPConf": "Discord RPC" } \ No newline at end of file diff --git a/public/locales/zh-cn.json b/public/locales/zh-cn.json index 25e8507..845c950 100644 --- a/public/locales/zh-cn.json +++ b/public/locales/zh-cn.json @@ -62,6 +62,5 @@ "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!", "PatchRepoUnavailableTitle": "Patch's repository is not available", "PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding", - "DefPrefix": "Reset to Default", - "ChangePrefix": "Change Prefix" + "DRPConf": "Discord RPC" } \ No newline at end of file diff --git a/public/locales/zh-tw.json b/public/locales/zh-tw.json index 5e906b0..bb5bc01 100644 --- a/public/locales/zh-tw.json +++ b/public/locales/zh-tw.json @@ -62,6 +62,5 @@ "TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!", "PatchRepoUnavailableTitle": "Patch's repository is not available", "PatchRepoUnavailableBody": "Most likely notabug is under attack and is not responding", - "DefPrefix": "Reset to Default", - "ChangePrefix": "Change Prefix" + "DRPConf": "Discord RPC" } \ No newline at end of file diff --git a/src/ts/settings.ts b/src/ts/settings.ts index ef7335a..45219aa 100644 --- a/src/ts/settings.ts +++ b/src/ts/settings.ts @@ -208,8 +208,16 @@ $(() => { if (LauncherLib.getConfig('rpc')) $('#discord-rpc').addClass('checkbox-active'); + // Unhides the settings for discord rpc + $('#discord-rpc-conf').toggle(); + $('#discord-rpc-conf-btn').toggle(); + $('#discord-rpc').on('classChange', () => { LauncherLib.updateConfig('rpc', $('#discord-rpc').hasClass('checkbox-active')); + + // Toggles the RPC Settings (hide/show) + $('#discord-rpc-conf').toggle(); + $('#discord-rpc-conf-btn').toggle(); ipcRenderer.send('rpc-toggle'); }); From 7c6dbd14f27583b2817629d68d50e7ce38625fa5 Mon Sep 17 00:00:00 2001 From: Maroxy Date: Sat, 11 Dec 2021 12:39:19 +0100 Subject: [PATCH 2/5] Add setting fields and configure them when opening window --- public/html/settings.html | 21 +++++++++++++++++++++ src/sass/components.sass | 16 ++++++++++++++++ src/ts/lib/LauncherLib.ts | 8 ++++++++ src/ts/settings.ts | 9 ++++++++- 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/public/html/settings.html b/public/html/settings.html index 2494de4..89a49a7 100644 --- a/public/html/settings.html +++ b/public/html/settings.html @@ -313,6 +313,27 @@ diff --git a/src/sass/components.sass b/src/sass/components.sass index c2aebc9..aceb185 100644 --- a/src/sass/components.sass +++ b/src/sass/components.sass @@ -12,6 +12,22 @@ p, span, div color: map.get($theme-map, "text") + /* Text Field + + .text-field + width: calc(100% - 28px) + border-radius: 16px + padding: 8px + background-color: map.get($theme-map, "background2") + color: map.get($theme-map, "text") + border: unset + outline: none + font-size: 15px + + &:placeholder + color: map.get($theme-map, "text") + + /* Directory selector .directory-selector diff --git a/src/ts/lib/LauncherLib.ts b/src/ts/lib/LauncherLib.ts index 0488a69..dfef4ba 100644 --- a/src/ts/lib/LauncherLib.ts +++ b/src/ts/lib/LauncherLib.ts @@ -34,6 +34,14 @@ const config = new store ({ patch: null, // Installed patch info ({ version, state } - related game's version and patch's state) runner: null, // Selected runner ({ folder, executable }) rpc: false, // Discord RPC + rpcsettings: { + launcher: 'Preparing to launch', + ingame: { + details: 'In-Game', + state: null, + elapsed: true + } + }, playtime: 0, // Number of seconds user spent in game hud: 'none', // none / dxvk / mangohud shaders: 'none', // none / shader's folder diff --git a/src/ts/settings.ts b/src/ts/settings.ts index 45219aa..105b955 100644 --- a/src/ts/settings.ts +++ b/src/ts/settings.ts @@ -212,9 +212,16 @@ $(() => { $('#discord-rpc-conf').toggle(); $('#discord-rpc-conf-btn').toggle(); + if (LauncherLib.getConfig('rpcsettings.ingame.elapsed')) + $('#rpc-game-elapsed').addClass('checkbox-active'); + + $('#rpc-game-state').attr('placeholder', LauncherLib.getConfig('rpcsettings.ingame.state')); + $('#rpc-game-details').attr('placeholder', LauncherLib.getConfig('rpcsettings.ingame.details')); + $('#rpc-launch-details').attr('placeholder', LauncherLib.getConfig('rpcsettings.launcher')); + $('#discord-rpc').on('classChange', () => { LauncherLib.updateConfig('rpc', $('#discord-rpc').hasClass('checkbox-active')); - + // Toggles the RPC Settings (hide/show) $('#discord-rpc-conf').toggle(); $('#discord-rpc-conf-btn').toggle(); From f84d59919aaae7f94f2aad52d80a3b09066bf4cc Mon Sep 17 00:00:00 2001 From: Maroxy Date: Sat, 11 Dec 2021 12:42:10 +0100 Subject: [PATCH 3/5] Remove unapplied css --- src/sass/components.sass | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/sass/components.sass b/src/sass/components.sass index aceb185..9cfe8ee 100644 --- a/src/sass/components.sass +++ b/src/sass/components.sass @@ -23,11 +23,7 @@ border: unset outline: none font-size: 15px - - &:placeholder - color: map.get($theme-map, "text") - /* Directory selector .directory-selector From d8a112e14c3f66a8207137c5a6c3062dbf3b2a7a Mon Sep 17 00:00:00 2001 From: Maroxy Date: Sat, 11 Dec 2021 12:56:38 +0100 Subject: [PATCH 4/5] Add functions to the RPC Settings --- src/ts/settings.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/ts/settings.ts b/src/ts/settings.ts index 105b955..52c92fc 100644 --- a/src/ts/settings.ts +++ b/src/ts/settings.ts @@ -229,6 +229,31 @@ $(() => { ipcRenderer.send('rpc-toggle'); }); + $('#rpc-launch-details').on('change', () => { + if ($('#rpc-launch-details').val() == "") + LauncherLib.updateConfig('rpcsettings.launcher', 'Preparing to launch'); + + LauncherLib.updateConfig('rpcsettings.launcher', $('#rpc-launch-details').val() as string); + }); + + $('#rpc-game-details').on('change', () => { + if ($('#rpc-game-details').val() == "") + LauncherLib.updateConfig('rpcsettings.ingame.details', 'In-Game'); + + LauncherLib.updateConfig('rpcsettings.ingame.details', $('#rpc-game-details').val() as string); + }); + + $('#rpc-game-state').on('change', () => { + if ($('#rpc-game-state').val() == "") + LauncherLib.updateConfig('rpcsettings.ingame.state', null); + + LauncherLib.updateConfig('rpcsettings.ingame.state', $('#rpc-game-state').val() as string); + }); + + $('#rpc-game-elapsed').on('classChange', () => { + LauncherLib.updateConfig('rpcsettings.ingame.elapsed', $('#rpc-game-elapsed').hasClass('checkbox-active')); + }); + /** * Auto-delete DXVK logs */ From ecf1db11307ee284957797f96b7f5237ab6ebf3b Mon Sep 17 00:00:00 2001 From: Maroxy Date: Sat, 11 Dec 2021 13:28:10 +0100 Subject: [PATCH 5/5] Configure Discord RPC --- src/ts/index.ts | 5 +++-- src/ts/lib/DiscordRPC.ts | 3 ++- src/ts/settings.ts | 18 +++++++++--------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/ts/index.ts b/src/ts/index.ts index d83c187..9c0f1b4 100644 --- a/src/ts/index.ts +++ b/src/ts/index.ts @@ -203,10 +203,11 @@ $(() => { if (DiscordRPC.isActive()) { DiscordRPC.setActivity({ - details: 'In-Game', + details: LauncherLib.getConfig('rpcsettings.ingame.details'), + state: LauncherLib.getConfig('rpcsettings.ingame.state') ? LauncherLib.getConfig('rpcsettings.ingame.state') : undefined, largeImageKey: 'game', largeImageText: 'An Anime Game', - startTimestamp: Date.now() + startTimestamp: LauncherLib.getConfig('rpcsettings.ingame.elapsed') ? Date.now() : undefined }); } diff --git a/src/ts/lib/DiscordRPC.ts b/src/ts/lib/DiscordRPC.ts index 17f5d49..1dd4456 100644 --- a/src/ts/lib/DiscordRPC.ts +++ b/src/ts/lib/DiscordRPC.ts @@ -1,4 +1,5 @@ import discordRpc, { Client, Presence } from 'discord-rpc'; +import LauncherLib from './LauncherLib'; export default class DiscordRPC { @@ -14,7 +15,7 @@ export default class DiscordRPC this.rpc.on('ready', () => { this.rpc.setActivity({ - details: 'Preparing to launch', + details: LauncherLib.getConfig('rpcsettings.launcher'), largeImageKey: 'launcher', largeImageText: 'An Anime Game' }); diff --git a/src/ts/settings.ts b/src/ts/settings.ts index 52c92fc..6d28de3 100644 --- a/src/ts/settings.ts +++ b/src/ts/settings.ts @@ -230,24 +230,24 @@ $(() => { }); $('#rpc-launch-details').on('change', () => { - if ($('#rpc-launch-details').val() == "") + if ($('#rpc-launch-details').val() == " ") LauncherLib.updateConfig('rpcsettings.launcher', 'Preparing to launch'); - - LauncherLib.updateConfig('rpcsettings.launcher', $('#rpc-launch-details').val() as string); + else + LauncherLib.updateConfig('rpcsettings.launcher', $('#rpc-launch-details').val() as string); }); $('#rpc-game-details').on('change', () => { - if ($('#rpc-game-details').val() == "") + if ($('#rpc-game-details').val() == " ") LauncherLib.updateConfig('rpcsettings.ingame.details', 'In-Game'); - - LauncherLib.updateConfig('rpcsettings.ingame.details', $('#rpc-game-details').val() as string); + else + LauncherLib.updateConfig('rpcsettings.ingame.details', $('#rpc-game-details').val() as string); }); $('#rpc-game-state').on('change', () => { - if ($('#rpc-game-state').val() == "") + if ($('#rpc-game-state').val() == " ") LauncherLib.updateConfig('rpcsettings.ingame.state', null); - - LauncherLib.updateConfig('rpcsettings.ingame.state', $('#rpc-game-state').val() as string); + else + LauncherLib.updateConfig('rpcsettings.ingame.state', $('#rpc-game-state').val() as string); }); $('#rpc-game-elapsed').on('classChange', () => {