From cef085c13da78b8052d283465a2447605b0e79fb Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Thu, 18 Jan 2024 19:47:56 +0100 Subject: [PATCH] fix patching --- electron/richPresence.js | 5 ++++- main.js | 43 ++++++++++++++++++++++----------------- src/App.svelte | 18 ++++++++-------- src/pages/Launch.svelte | 8 ++------ src/pages/Settings.svelte | 18 ++++++++-------- src/storage/localStore.ts | 1 + 6 files changed, 48 insertions(+), 45 deletions(-) diff --git a/electron/richPresence.js b/electron/richPresence.js index 976c5f8..5378cf3 100644 --- a/electron/richPresence.js +++ b/electron/richPresence.js @@ -52,4 +52,7 @@ module.exports = { currentStatus.smallImageKey = osuVersion ? "osu" : " "; currentStatus.smallImageText = osuVersion ? `osu! ${osuVersion}` : " "; }, -}; + update: () => { + richPresence.setActivity(currentStatus); + } +}; diff --git a/main.js b/main.js index 9bceb8b..2e565ce 100644 --- a/main.js +++ b/main.js @@ -36,7 +36,9 @@ let mainWindow; let osuCheckInterval; let userOsuPath; let osuLoaded = false; +let patch = false; let lastOsuStatus = ""; +let lastStatusUpdate; let currentUser = undefined; @@ -56,13 +58,15 @@ function startOsuStatus() { if (!osuLoaded) { osuLoaded = true; setTimeout(() => { - const patcherExecuteable = path.join( - userOsuPath, - "EZPPLauncher", - "patcher.exe", - ); - if (existsSync(patcherExecuteable)) { - runFileDetached(userOsuPath, patcherExecuteable); + if (patch) { + const patcherExecuteable = path.join( + userOsuPath, + "EZPPLauncher", + "patcher.exe", + ); + if (existsSync(patcherExecuteable)) { + runFileDetached(userOsuPath, patcherExecuteable); + } } }, 3000); } @@ -121,7 +125,9 @@ function startOsuStatus() { richPresence.updateStatus({ details, state: infoText - }) + }); + + richPresence.update(); } }, 2500); } @@ -290,7 +296,7 @@ function registerIPCPipes() { }); ipcMain.handle("ezpplauncher:launch", async (e, args) => { - const patch = args.patch; + patch = args.patch; mainWindow.webContents.send("ezpplauncher:launchstatus", { status: "Checking osu! directory...", }); @@ -338,9 +344,8 @@ function registerIPCPipes() { progress: Math.ceil(data.progress), }); mainWindow.webContents.send("ezpplauncher:launchstatus", { - status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${ - formatBytes(data.total) - })...`, + status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${formatBytes(data.total) + })...`, }); }); await uiDownloader.startDownload(); @@ -369,9 +374,8 @@ function registerIPCPipes() { progress: Math.ceil(data.progress), }); mainWindow.webContents.send("ezpplauncher:launchstatus", { - status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${ - formatBytes(data.total) - })...`, + status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${formatBytes(data.total) + })...`, }); }); await updateDownloader.startDownload(); @@ -416,9 +420,8 @@ function registerIPCPipes() { progress: Math.ceil(data.progress), }); mainWindow.webContents.send("ezpplauncher:launchstatus", { - status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${ - formatBytes(data.total) - })...`, + status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${formatBytes(data.total) + })...`, }); }); await patcherDownloader.startDownload(); @@ -446,6 +449,7 @@ function registerIPCPipes() { const userConfig = getUserConfig(osuPath); richPresence.updateVersion(await userConfig.get("LastVersion")); + richPresence.update(); if (currentUser) { await userConfig.set("Username", currentUser.username); await userConfig.set("Password", currentUser.password); @@ -463,7 +467,8 @@ function registerIPCPipes() { richPresence.updateStatus({ state: "Idle in Launcher...", details: undefined - }) + }); + richPresence.update(); mainWindow.webContents.send("ezpplauncher:launchstatus", { status: "Waiting for cleanup...", }); diff --git a/src/App.svelte b/src/App.svelte index bcc4faf..0c4edf8 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -5,13 +5,13 @@ DropdownItem, DropdownHeader, DropdownDivider, - Button, + Button } from "flowbite-svelte"; import { ArrowLeftSolid, ArrowRightFromBracketSolid, ArrowRightToBracketSolid, - UserSettingsSolid, + UserSettingsSolid } from "flowbite-svelte-icons"; import ezppLogo from "../public/favicon.png"; import { @@ -19,7 +19,7 @@ currentUser, launching, launchPercentage, - launchStatus, + launchStatus } from "./storage/localStore"; import { Page } from "./consts/pages"; import Login from "./pages/Login.svelte"; @@ -44,7 +44,7 @@ position: "bottom-center", className: "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", - duration: 2000, + duration: 2000 }); }; @@ -75,7 +75,7 @@ position: "bottom-center", className: "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", - duration: 2000, + duration: 2000 }); break; } @@ -84,7 +84,7 @@ position: "bottom-center", className: "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", - duration: 4000, + duration: 4000 }); break; } @@ -94,7 +94,7 @@ position: "bottom-center", className: "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", - duration: 1500, + duration: 1500 }); } } @@ -107,8 +107,8 @@
{#if $currentPage == Page.Settings} - patch.set(!$patch)}>Patch
{ const settings: Record[] = (e as CustomEvent).detail; const osuPath = settings.find((setting) => setting.key == "osuPath"); @@ -32,11 +28,13 @@ }; const togglePatching = () => { - patching = !patching; + patch.set(!$patch); + //TODO: save in config }; const togglePresence = () => { - presence = !presence; + presence.set(!$presence); + //TODO: save in config }; @@ -44,10 +42,10 @@ class="h-[265px] flex flex-col justify-start p-3 animate-fadeIn opacity-0" >
- Discord Presence - Patching
diff --git a/src/storage/localStore.ts b/src/storage/localStore.ts index 424519b..df5aec3 100644 --- a/src/storage/localStore.ts +++ b/src/storage/localStore.ts @@ -8,5 +8,6 @@ export const launchStatus = writable("Waiting..."); export const launchPercentage = writable(-1); export const osuPath: Writable = writable(undefined); export const patch = writable(true); +export const presence = writable(true); export const currentUser: Writable = writable(undefined); export const currentPage = writable(Page.Login);