Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge next into main #44

Merged
merged 6 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
23 changes: 6 additions & 17 deletions plugins/dorion-settings/pages/PerformancePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,14 @@ export function PerformancePage() {
}
), true)
}
note="Detect OBS and Streamlabs OBS and automatically enable streamer mode when they are running."
>
Streamer Mode detection
</SwitchItem>

<SwitchItem
value={state().rpc_server}
onChange={(v) =>
setSettings((settings) => (
{
...settings,
rpc_server: v,
}
), true)
note={
<>
Detect OBS and Streamlabs OBS and automatically enable streamer mode when they are running. <b>Requires the integrated RPC server and RPC process scanning to be enabled (found in the Rich Presence tab).</b>
</>
}
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!"
disabled={!state().rpc_server}
>
Integrated rich presence server
Streamer Mode detection
</SwitchItem>

<SwitchItem
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
140 changes: 140 additions & 0 deletions plugins/dorion-settings/pages/RPC.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
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,
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, }
}, true)
}}
disabled={!settings().rpc_server}
note={`Enable this if you want ${appName} to scan for running processes and automatically enable streamer mode when they are running.`}
>
Enable Process Scanner
</SwitchItem>

<SwitchItem
value={settings().rpc_ipc_connector}
onChange={(v) => {
setSettings(p => {
return { ...p, rpc_ipc_connector: v }
}, true)
}}
disabled={!settings().rpc_server}
note={
<>
Enable this if you want {appName} to connect to local sockets.
Things such as the <a href="https://github.com/LeonardSSH/vscord">VSCord</a> extension 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 }
}, true)
}}
disabled={!settings().rpc_server}
note={`Enable this if you want ${appName} 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 }
}, true)
}}
disabled={!settings().rpc_server}
note={`Enable this to allow ${appName} 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;
}
10 changes: 5 additions & 5 deletions plugins/shelteRPC/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createApi, webpackChunk } from '@cumjar/websmack'
import { backend, invoke } from '../../api/api.js';
import RegisteredGames from './components/RegisteredGames'
import { backend, invoke } from '../../api/api.js'
import RegisteredGames from './components/RegisteredGames.jsx'
import { css, classes } from './index.scss'

const {
Expand Down Expand Up @@ -101,7 +101,7 @@ async function handleMessage(e: MessageEvent<string>) {

const handleCmd = async (payload: any) => {
switch(payload.cmd) {
case 'INVITE_BROWSER':
case 'INVITE_BROWSER': {
const code = payload.args.code

if (code === '') {
Expand Down Expand Up @@ -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) => {
Expand Down
12 changes: 12 additions & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ interface DorionSettings {
client_mods: string[];
unread_badge: boolean;
client_plugins: boolean;

tray_icon_enabled: boolean;
proxy_uri: string;

keybinds: Record<string, KeyStruct[]>;
keybinds_enabled: boolean;

// RPC-specific options
rpc_process_scanner: boolean;
rpc_ipc_connector: boolean;
rpc_websocket_connector: boolean;
rpc_secondary_events: boolean;
}

interface DorionTheme {
Expand Down
Loading