From 32c12cbe6bc3adab50001e124aca2e351bfddc1a Mon Sep 17 00:00:00 2001 From: SpikeHD <25207995+SpikeHD@users.noreply.github.com> Date: Sun, 10 Nov 2024 17:36:55 -0800 Subject: [PATCH 1/6] fix: rpc selectivity --- plugins/dorion-settings/index.tsx | 2 + .../dorion-settings/pages/PerformancePage.tsx | 16 -- .../pages/PluginsPage.tsx.scss | 24 --- plugins/dorion-settings/pages/RPC.tsx | 141 ++++++++++++++++++ plugins/dorion-settings/pages/RPC.tsx.scss | 8 + .../pages/SettingsPage.tsx.scss | 24 --- 6 files changed, 151 insertions(+), 64 deletions(-) create mode 100644 plugins/dorion-settings/pages/RPC.tsx create mode 100644 plugins/dorion-settings/pages/RPC.tsx.scss diff --git a/plugins/dorion-settings/index.tsx b/plugins/dorion-settings/index.tsx index 663c336..f7f2ac2 100644 --- a/plugins/dorion-settings/index.tsx +++ b/plugins/dorion-settings/index.tsx @@ -6,6 +6,7 @@ import { SettingsPage } from './pages/SettingsPage.jsx' import { ChangelogPage } from './pages/ChangelogPage.jsx' import { PluginsPage } from './pages/PluginsPage.jsx' import { ThemesPage } from './pages/ThemesPage.jsx' +import { RPCPage } from './pages/RPC.jsx' const { settings: { @@ -26,6 +27,7 @@ const settingsUninjects = [ registerSection('section', `${appName}-plugins`, 'Plugins', PluginsPage), registerSection('section', `${appName}-themes`, 'Themes', ThemesPage), registerSection('section', `${appName}-performance`, 'Performance & Extras', PerformancePage), + registerSection('section', `${appName}-rpc`, 'Rich Presence', RPCPage), registerSection('section', `${appName}-profiles`, 'Profiles', ProfilesPage), ] diff --git a/plugins/dorion-settings/pages/PerformancePage.tsx b/plugins/dorion-settings/pages/PerformancePage.tsx index fb10bcd..af0ed99 100644 --- a/plugins/dorion-settings/pages/PerformancePage.tsx +++ b/plugins/dorion-settings/pages/PerformancePage.tsx @@ -157,22 +157,6 @@ export function PerformancePage() { Streamer Mode detection - - setSettings((settings) => ( - { - ...settings, - rpc_server: v, - } - ), true) - } - tooltipNote="This is a work in progress, and won't do EVERYTHING arRPC does quite yet." - note="Enable the integrated RPC server, eliminating the need for a separate arRPC server running. Remember to enable the shelteRPC/arRPC plugin!" - > - Integrated rich presence server - - diff --git a/plugins/dorion-settings/pages/PluginsPage.tsx.scss b/plugins/dorion-settings/pages/PluginsPage.tsx.scss index 4fe3585..520a796 100644 --- a/plugins/dorion-settings/pages/PluginsPage.tsx.scss +++ b/plugins/dorion-settings/pages/PluginsPage.tsx.scss @@ -11,34 +11,10 @@ margin-bottom: 16px; } -.fcard { - display: flex; - flex-direction: row; - justify-content: space-between; - align-items: center; - - color: var(--text-primary); - - padding: 8px; -} - -.pcard { - display: flex; -} - .left16 { margin-left: 16px; } -.themeRow { - display: flex; - flex-direction: row; - justify-content: space-between; - align-items: center; - - height: 42px; -} - .openButton { margin-top: 16px; width: 100% !important; diff --git a/plugins/dorion-settings/pages/RPC.tsx b/plugins/dorion-settings/pages/RPC.tsx new file mode 100644 index 0000000..bad0e2c --- /dev/null +++ b/plugins/dorion-settings/pages/RPC.tsx @@ -0,0 +1,141 @@ +import { appName, backendRestartRequired, invoke } from '../../../api/api.js' +import { css, classes } from './RPC.tsx.scss' +import { WarningCard } from '../components/WarningCard.jsx' +import { defaultConfig } from '../util/settings.js' + +const { + ui: { + SwitchItem, + Text, + Header, + HeaderTags, + injectCss, + }, + solid: { createSignal, createEffect }, +} = shelter + +let injectedCss = false + +export function RPCPage() { + const [settings, setSettingsState] = createSignal(defaultConfig) + const [restartRequired, setRestartRequired] = createSignal(false) + + if (!injectedCss) { + injectedCss = true + injectCss(css) + } + + createEffect(async () => { + setSettingsState(JSON.parse(await invoke('read_config_file'))) + + // @ts-expect-error cry about it + setRestartRequired(window?.__DORION_RESTART__ === true) + }) + + const setSettings = (fn: (DorionSettings) => DorionSettings, requiresRestart?: boolean) => { + setSettingsState(fn(settings())) + + // Save the settings + invoke('write_config_file', { + contents: JSON.stringify(fn(settings())), + }) + + // If a restart is now required, set that + if (requiresRestart) { + setRestartRequired(true) + backendRestartRequired(true) + } + } + + return ( + <> +
RPC Settings
+ + {restartRequired() && ( + + )} + +
Server
+ + + setSettings((settings) => ( + { + ...settings, + rpc_server: v, + } + ), true) + } + tooltipNote="This is a work in progress, and won't do EVERYTHING arRPC does quite yet." + note={ + <> + Enable the integrated RPC server, eliminating the need for a separate arRPC server running. + Pairs best with shelteRPC, also works with arRPC. + + } + > + Integrated rich presence server + + +
Advanced Settings
+ + { + setSettings(p => { + return { ...p, rpc_process_scanner: v, } + }) + }} + disabled={!settings().rpc_server} + note="Enable this if you want Dorion to scan for and detect games running." + > + Enable Process Scanner + + + { + setSettings(p => { + return { ...p, rpc_ipc_connector: v } + }) + }} + disabled={!settings().rpc_server} + note={ + <> + Enable this if you want Dorion to connect to local sockets. + Things such as the VSCord use this method of connection. + + } + > + Enable IPC Connector + + + { + setSettings(p => { + return { ...p, rpc_websocket_connector: v } + }) + }} + disabled={!settings().rpc_server} + note="Enable this if you want Dorion to accept local websocket connections." + > + Enable Websocket Connector + + + { + setSettings((p) => { + return { ...p, rpc_secondary_events: v } + }) + }} + disabled={!settings().rpc_server} + note="Enable this to allow Dorion to properly handle server invites opened in the browser. Does not work with arRPC." + > + Enable secondary events + + + ) +} diff --git a/plugins/dorion-settings/pages/RPC.tsx.scss b/plugins/dorion-settings/pages/RPC.tsx.scss new file mode 100644 index 0000000..cb0214e --- /dev/null +++ b/plugins/dorion-settings/pages/RPC.tsx.scss @@ -0,0 +1,8 @@ +.shead { + margin-top: 16px; + margin-bottom: 8px; +} + +.bot16 { + margin-bottom: 16px; +} \ No newline at end of file diff --git a/plugins/dorion-settings/pages/SettingsPage.tsx.scss b/plugins/dorion-settings/pages/SettingsPage.tsx.scss index 8a477b7..a4a1af0 100644 --- a/plugins/dorion-settings/pages/SettingsPage.tsx.scss +++ b/plugins/dorion-settings/pages/SettingsPage.tsx.scss @@ -7,30 +7,6 @@ margin-bottom: 8px; } -.fcard { - display: flex; - flex-direction: row; - justify-content: space-between; - align-items: center; - - color: var(--text-primary); - - padding: 8px; -} - -.pcard { - display: flex; -} - .left16 { margin-left: 16px; } - -.themeRow { - display: flex; - flex-direction: row; - justify-content: space-between; - align-items: center; - - height: 42px; -} From 4a32817fc896a08a4b4e48fdbb47e53f0de1f1e5 Mon Sep 17 00:00:00 2001 From: SpikeHD <25207995+SpikeHD@users.noreply.github.com> Date: Tue, 26 Nov 2024 15:47:24 -0800 Subject: [PATCH 2/6] fix: obs scanner now depends on rsrpc --- plugins/dorion-settings/pages/PerformancePage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/dorion-settings/pages/PerformancePage.tsx b/plugins/dorion-settings/pages/PerformancePage.tsx index af0ed99..1665b48 100644 --- a/plugins/dorion-settings/pages/PerformancePage.tsx +++ b/plugins/dorion-settings/pages/PerformancePage.tsx @@ -153,6 +153,7 @@ export function PerformancePage() { ), true) } note="Detect OBS and Streamlabs OBS and automatically enable streamer mode when they are running." + disabled={!state().rpc_server} > Streamer Mode detection
From ce707196c90e5a17697190325a379647bb2cc130 Mon Sep 17 00:00:00 2001 From: SpikeHD <25207995+SpikeHD@users.noreply.github.com> Date: Tue, 26 Nov 2024 15:56:38 -0800 Subject: [PATCH 3/6] fix: note --- plugins/dorion-settings/pages/PerformancePage.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/dorion-settings/pages/PerformancePage.tsx b/plugins/dorion-settings/pages/PerformancePage.tsx index 1665b48..d335469 100644 --- a/plugins/dorion-settings/pages/PerformancePage.tsx +++ b/plugins/dorion-settings/pages/PerformancePage.tsx @@ -152,7 +152,11 @@ export function PerformancePage() { } ), true) } - note="Detect OBS and Streamlabs OBS and automatically enable streamer mode when they are running." + note={ + <> + Detect OBS and Streamlabs OBS and automatically enable streamer mode when they are running. Requires the integrated RPC Server to be enabled (found in the Rich Presence tab). + + } disabled={!state().rpc_server} > Streamer Mode detection From a22ee9f2275c2f94d3f2ef03fec62f9c5d3d9c24 Mon Sep 17 00:00:00 2001 From: SpikeHD <25207995+SpikeHD@users.noreply.github.com> Date: Mon, 2 Dec 2024 12:06:58 -0800 Subject: [PATCH 4/6] fix: rpc page tweaks --- plugins/dorion-settings/pages/RPC.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/plugins/dorion-settings/pages/RPC.tsx b/plugins/dorion-settings/pages/RPC.tsx index bad0e2c..cfab61d 100644 --- a/plugins/dorion-settings/pages/RPC.tsx +++ b/plugins/dorion-settings/pages/RPC.tsx @@ -1,4 +1,4 @@ -import { appName, backendRestartRequired, invoke } from '../../../api/api.js' +import { backendRestartRequired, invoke } from '../../../api/api.js' import { css, classes } from './RPC.tsx.scss' import { WarningCard } from '../components/WarningCard.jsx' import { defaultConfig } from '../util/settings.js' @@ -6,7 +6,6 @@ import { defaultConfig } from '../util/settings.js' const { ui: { SwitchItem, - Text, Header, HeaderTags, injectCss, @@ -85,10 +84,10 @@ export function RPCPage() { onChange={(v) => { setSettings(p => { return { ...p, rpc_process_scanner: v, } - }) + }, true) }} disabled={!settings().rpc_server} - note="Enable this if you want Dorion to scan for and detect games running." + note="Enable this if you want Dorion to scan for and detect games running. This is the most potentially performance-heavy component of RPC." > Enable Process Scanner @@ -98,13 +97,13 @@ export function RPCPage() { onChange={(v) => { setSettings(p => { return { ...p, rpc_ipc_connector: v } - }) + }, true) }} disabled={!settings().rpc_server} note={ <> Enable this if you want Dorion to connect to local sockets. - Things such as the VSCord use this method of connection. + Things such as the VSCord extension use this method of connection. } > @@ -116,7 +115,7 @@ export function RPCPage() { onChange={(v) => { setSettings(p => { return { ...p, rpc_websocket_connector: v } - }) + }, true) }} disabled={!settings().rpc_server} note="Enable this if you want Dorion to accept local websocket connections." @@ -129,7 +128,7 @@ export function RPCPage() { onChange={(v) => { setSettings((p) => { return { ...p, rpc_secondary_events: v } - }) + }, true) }} disabled={!settings().rpc_server} note="Enable this to allow Dorion to properly handle server invites opened in the browser. Does not work with arRPC." From e9e46396de87b0384c774a2c5af409087fdf321c Mon Sep 17 00:00:00 2001 From: SpikeHD <25207995+SpikeHD@users.noreply.github.com> Date: Mon, 2 Dec 2024 12:11:21 -0800 Subject: [PATCH 5/6] fix: more tweaks --- plugins/dorion-settings/pages/PerformancePage.tsx | 2 +- plugins/dorion-settings/pages/RPC.tsx | 10 +++++----- plugins/shelteRPC/index.tsx | 2 +- types.d.ts | 12 ++++++++++++ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/plugins/dorion-settings/pages/PerformancePage.tsx b/plugins/dorion-settings/pages/PerformancePage.tsx index d335469..4ae831a 100644 --- a/plugins/dorion-settings/pages/PerformancePage.tsx +++ b/plugins/dorion-settings/pages/PerformancePage.tsx @@ -154,7 +154,7 @@ export function PerformancePage() { } note={ <> - Detect OBS and Streamlabs OBS and automatically enable streamer mode when they are running. Requires the integrated RPC Server to be enabled (found in the Rich Presence tab). + Detect OBS and Streamlabs OBS and automatically enable streamer mode when they are running. Requires the integrated RPC server and RPC process scanning to be enabled (found in the Rich Presence tab). } disabled={!state().rpc_server} diff --git a/plugins/dorion-settings/pages/RPC.tsx b/plugins/dorion-settings/pages/RPC.tsx index cfab61d..330ae36 100644 --- a/plugins/dorion-settings/pages/RPC.tsx +++ b/plugins/dorion-settings/pages/RPC.tsx @@ -1,4 +1,4 @@ -import { backendRestartRequired, invoke } from '../../../api/api.js' +import { appName, backendRestartRequired, invoke } from '../../../api/api.js' import { css, classes } from './RPC.tsx.scss' import { WarningCard } from '../components/WarningCard.jsx' import { defaultConfig } from '../util/settings.js' @@ -87,7 +87,7 @@ export function RPCPage() { }, true) }} disabled={!settings().rpc_server} - note="Enable this if you want Dorion to scan for and detect games running. This is the most potentially performance-heavy component of RPC." + note={`Enable this if you want ${appName} to scan for running processes and automatically enable streamer mode when they are running.`} > Enable Process Scanner @@ -102,7 +102,7 @@ export function RPCPage() { disabled={!settings().rpc_server} note={ <> - Enable this if you want Dorion to connect to local sockets. + Enable this if you want {appName} to connect to local sockets. Things such as the VSCord extension use this method of connection. } @@ -118,7 +118,7 @@ export function RPCPage() { }, true) }} disabled={!settings().rpc_server} - note="Enable this if you want Dorion to accept local websocket connections." + note={`Enable this if you want ${appName} to accept local websocket connections.`} > Enable Websocket Connector @@ -131,7 +131,7 @@ export function RPCPage() { }, true) }} disabled={!settings().rpc_server} - note="Enable this to allow Dorion to properly handle server invites opened in the browser. Does not work with arRPC." + note={`Enable this to allow ${appName} to properly handle server invites opened in the browser. Does not work with arRPC.`} > Enable secondary events diff --git a/plugins/shelteRPC/index.tsx b/plugins/shelteRPC/index.tsx index 5bfce65..aa1b3dc 100644 --- a/plugins/shelteRPC/index.tsx +++ b/plugins/shelteRPC/index.tsx @@ -1,5 +1,5 @@ import { createApi, webpackChunk } from '@cumjar/websmack' -import { backend, invoke } from '../../api/api.js'; +import { backend, invoke } from '../../api/api.js' import RegisteredGames from './components/RegisteredGames' import { css, classes } from './index.scss' diff --git a/types.d.ts b/types.d.ts index 0d619c8..1f0e978 100644 --- a/types.d.ts +++ b/types.d.ts @@ -27,6 +27,18 @@ interface DorionSettings { client_mods: string[]; unread_badge: boolean; client_plugins: boolean; + + tray_icon_enabled: boolean; + proxy_uri: string; + + keybinds: Record; + keybinds_enabled: boolean; + + // RPC-specific options + rpc_process_scanner: boolean; + rpc_ipc_connector: boolean; + rpc_websocket_connector: boolean; + rpc_secondary_events: boolean; } interface DorionTheme { From 90650dd21877fb15685eb1b23fb8730179491bc2 Mon Sep 17 00:00:00 2001 From: SpikeHD <25207995+SpikeHD@users.noreply.github.com> Date: Mon, 2 Dec 2024 12:17:52 -0800 Subject: [PATCH 6/6] fix: shelterpc eslints --- plugins/shelteRPC/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/shelteRPC/index.tsx b/plugins/shelteRPC/index.tsx index aa1b3dc..7743358 100644 --- a/plugins/shelteRPC/index.tsx +++ b/plugins/shelteRPC/index.tsx @@ -1,6 +1,6 @@ import { createApi, webpackChunk } from '@cumjar/websmack' import { backend, invoke } from '../../api/api.js' -import RegisteredGames from './components/RegisteredGames' +import RegisteredGames from './components/RegisteredGames.jsx' import { css, classes } from './index.scss' const { @@ -101,7 +101,7 @@ async function handleMessage(e: MessageEvent) { const handleCmd = async (payload: any) => { switch(payload.cmd) { - case 'INVITE_BROWSER': + case 'INVITE_BROWSER': { const code = payload.args.code if (code === '') { @@ -140,8 +140,8 @@ const handleCmd = async (payload: any) => { invite, }) - backend !== 'None' && invoke('ultrashow') - } + if (backend !== 'None') invoke('ultrashow') + }} } const retry = async (fn: (curTry: number) => any, times: number = 5, wait: number = 500) => {