diff --git a/frontend/src/windows/main/main.ts b/frontend/src/windows/main/main.ts index 3d08d43..8768442 100644 --- a/frontend/src/windows/main/main.ts +++ b/frontend/src/windows/main/main.ts @@ -26,18 +26,6 @@ events.on('ready', async () => { /** Launch the process manager */ const watchdog = new AbloxWatchdog(); watchdog.start().catch(console.error); - - // DiscordRPC - const settings = await loadSettings('integrations'); - if (settings && settings.rpc.enable_rpc) { - await RPCController.set({ - clientId: '1257650541677383721', - details: 'Currently in the launcher', - largeImage: 'appleblox', - largeImageText: 'AppleBlox Logo', - enableTime: true, - }); - } }, 500); }); diff --git a/frontend/src/windows/main/pages/Integrations.svelte b/frontend/src/windows/main/pages/Integrations.svelte index 0c25055..31ef0ba 100644 --- a/frontend/src/windows/main/pages/Integrations.svelte +++ b/frontend/src/windows/main/pages/Integrations.svelte @@ -3,7 +3,6 @@ import Panel from './Settings/Panel.svelte'; import { loadSettings, saveSettings } from '../ts/settings'; import { RPCController } from '../ts/rpc'; - import { os } from '@neutralinojs/lib'; async function loadRPC(settings?: { [key: string]: any }) { if (settings == null) { @@ -12,15 +11,7 @@ return; } } - if (settings.rpc.enable_rpc) { - await RPCController.set({ - clientId: '1257650541677383721', - details: 'Currently in the launcher', - largeImage: 'appleblox', - largeImageText: 'AppleBlox Logo', - enableTime: true, - }).catch(console.error); - } else { + if (!settings.rpc.enable_rpc) { await RPCController.stop(); } } diff --git a/frontend/src/windows/main/ts/roblox/launch.ts b/frontend/src/windows/main/ts/roblox/launch.ts index 4fc1fe5..2ac0d18 100644 --- a/frontend/src/windows/main/ts/roblox/launch.ts +++ b/frontend/src/windows/main/ts/roblox/launch.ts @@ -137,14 +137,9 @@ async function onGameEvent(data: GameEventInfo) { break; case 'GameDisconnected': case 'GameLeaving': - const normalRpcOptions = { - clientId: '1257650541677383721', - details: 'Currently in the launcher', - largeImage: 'appleblox', - largeImageText: 'AppleBlox Logo', - enableTime: true, - }; - RPCController.set(normalRpcOptions); + if (settings && settings.rpc.enable_rpc) { + RPCController.preset('inRobloxApp'); + } console.log('Disconnected/Left game'); break; case 'GameJoinedEntry': @@ -294,7 +289,7 @@ export async function launchRoblox( Roblox.Window.setDesktopRes(maxRes[0], maxRes[2], 5); showNotification({ title: 'Resolution changed', - content: "Your resolution was temporarily changed (5s) by the 'Spoof Resolution' setting.", + content: "Your resolution was temporarily changed (5s) by the 'Fix Resolution' setting.", timeout: 10, }); } @@ -304,6 +299,12 @@ export async function launchRoblox( await robloxInstance.start(); setRobloxConnected(true); rbxInstance = robloxInstance; + + const integrationsSettings = await loadSettings('integrations'); + if (integrationsSettings && integrationsSettings.rpc.enable_rpc) { + RPCController.preset('inRobloxApp'); + } + robloxInstance.on('gameEvent', onGameEvent); robloxInstance.on('exit', async () => { if (modSettings && modSettings.general.enable_mods) { @@ -313,6 +314,7 @@ export async function launchRoblox( console.log(`Removed mod files from "${path.join(robloxPath, 'Contents/Resources/')}"`); }); } + RPCController.stop() setRobloxConnected(false); rbxInstance = null; console.log('Roblox exited'); diff --git a/frontend/src/windows/main/ts/rpc.ts b/frontend/src/windows/main/ts/rpc.ts index ff89f2a..021b1a2 100644 --- a/frontend/src/windows/main/ts/rpc.ts +++ b/frontend/src/windows/main/ts/rpc.ts @@ -239,14 +239,32 @@ export class DiscordRPC { } let discordRPC: DiscordRPC | null = null; +const presets: {[key: string]: RPCOptions} = { + inRobloxApp: { + clientId: '1257650541677383721', + details: 'Currently browsing the menus', + state: 'In the launcher', + largeImage: 'roblox', + largeImageText: 'Roblox', + enableTime: true, + }, +}; + export class RPCController { + public static preset(preset: string) { + if (presets[preset]) { + this.set(presets[preset]) + } + } + public static async set(options: RPCOptions) { if (discordRPC) { - await discordRPC.update(options); + discordRPC.stop(); } else { - discordRPC = new DiscordRPC(); - await discordRPC.start(options); + await os.execCommand(`pkill -f "discordrpc_ablox"`); } + discordRPC = new DiscordRPC(); + await discordRPC.start(options); } public static async stop() { diff --git a/package.json b/package.json index 6c67fa4..9f8a743 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "appleblox", - "version": "0.6.4", + "version": "0.6.5", "description": "MacOS roblox launcher", "main": "frontend/src/windows/main/main.ts", "scripts": {