Skip to content

Commit

Permalink
fix: rpc selectivity
Browse files Browse the repository at this point in the history
  • Loading branch information
SpikeHD committed Nov 11, 2024
1 parent 520b6eb commit 041861b
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 64 deletions.
2 changes: 2 additions & 0 deletions plugins/dorion-settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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),
]

Expand Down
16 changes: 0 additions & 16 deletions plugins/dorion-settings/pages/PerformancePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,22 +157,6 @@ export function PerformancePage() {
Streamer Mode detection
</SwitchItem>

<SwitchItem
value={state().rpc_server}
onChange={(v) =>
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
</SwitchItem>

<SwitchItem
value={state().disable_hardware_accel}
onChange={(v) =>
Expand Down
24 changes: 0 additions & 24 deletions plugins/dorion-settings/pages/PluginsPage.tsx.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
141 changes: 141 additions & 0 deletions plugins/dorion-settings/pages/RPC.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import { appName, backendRestartRequired, invoke } from '../../../api/api.js'

Check failure on line 1 in plugins/dorion-settings/pages/RPC.tsx

View workflow job for this annotation

GitHub Actions / tsc-eslint-checks

'appName' is defined but never used
import { css, classes } from './RPC.tsx.scss'
import { WarningCard } from '../components/WarningCard.jsx'
import { defaultConfig } from '../util/settings.js'

const {
ui: {
SwitchItem,
Text,

Check failure on line 9 in plugins/dorion-settings/pages/RPC.tsx

View workflow job for this annotation

GitHub Actions / tsc-eslint-checks

'Text' is assigned a value but never used
Header,
HeaderTags,
injectCss,
},
solid: { createSignal, createEffect },
} = shelter

let injectedCss = false

export function RPCPage() {
const [settings, setSettingsState] = createSignal<DorionSettings>(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 (
<>
<Header tag={HeaderTags.H1} class={classes.bot16}>RPC Settings</Header>

{restartRequired() && (
<WarningCard />
)}

<Header class={classes.shead}>Server</Header>

<SwitchItem
value={settings().rpc_server}
onChange={(v) =>
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 <a href="https://github.com/SpikeHD/shelter-plugins?tab=readme-ov-file#shelterpc" target="_blank">shelteRPC</a>, also works with <a href="https://github.com/OpenAsar/arRPC" target="_blank">arRPC</a>.
</>
}
>
Integrated rich presence server
</SwitchItem>

<Header class={classes.shead}>Advanced Settings</Header>

<SwitchItem
value={settings().rpc_process_scanner}
onChange={(v) => {
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
</SwitchItem>

<SwitchItem
value={settings().rpc_ipc_connector}
onChange={(v) => {
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 <a href="https://github.com/LeonardSSH/vscord">VSCord</a> use this method of connection.
</>
}
>
Enable IPC Connector
</SwitchItem>

<SwitchItem
value={settings().rpc_websocket_connector}
onChange={(v) => {
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
</SwitchItem>

<SwitchItem
value={settings().rpc_secondary_events}
onChange={(v) => {
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
</SwitchItem>
</>
)
}
8 changes: 8 additions & 0 deletions plugins/dorion-settings/pages/RPC.tsx.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.shead {
margin-top: 16px;
margin-bottom: 8px;
}

.bot16 {
margin-bottom: 16px;
}
24 changes: 0 additions & 24 deletions plugins/dorion-settings/pages/SettingsPage.tsx.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 041861b

Please sign in to comment.