fix patching

This commit is contained in:
HorizonCode 2024-01-18 19:47:56 +01:00
parent a02737ef1b
commit cef085c13d
6 changed files with 48 additions and 45 deletions

View File

@ -52,4 +52,7 @@ module.exports = {
currentStatus.smallImageKey = osuVersion ? "osu" : " ";
currentStatus.smallImageText = osuVersion ? `osu! ${osuVersion}` : " ";
},
update: () => {
richPresence.setActivity(currentStatus);
}
};

23
main.js
View File

@ -36,7 +36,9 @@ let mainWindow;
let osuCheckInterval;
let userOsuPath;
let osuLoaded = false;
let patch = false;
let lastOsuStatus = "";
let lastStatusUpdate;
let currentUser = undefined;
@ -56,6 +58,7 @@ function startOsuStatus() {
if (!osuLoaded) {
osuLoaded = true;
setTimeout(() => {
if (patch) {
const patcherExecuteable = path.join(
userOsuPath,
"EZPPLauncher",
@ -64,6 +67,7 @@ function startOsuStatus() {
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,8 +344,7 @@ 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)
})...`,
});
});
@ -369,8 +374,7 @@ 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)
})...`,
});
});
@ -416,8 +420,7 @@ 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)
})...`,
});
});
@ -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...",
});

View File

@ -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 @@
<div class="flex flex-row items-center animate-fadeIn opacity-0">
{#if $currentPage == Page.Settings}
<Button
class="dark:!bg-gray-800 dark:active:!bg-gray-950 !ring-0 outline-none !border-none dark:text-white w-10 h-10 mr-1 rounded-lg animate-sideIn opacity-0"
color="none"
class="dark:active:!bg-gray-900 !ring-0 w-10 h-10 mr-1 rounded-lg animate-sideIn opacity-0 active:scale-95 transition-transform duration-75"
color="light"
on:click={() => {
currentPage.set(Page.Launch);
}}

View File

@ -15,7 +15,8 @@
const launch = () => {
launching.set(true);
window.dispatchEvent(new CustomEvent("launch", { detail: { patch: $patch } }));;
const patching = $patch;
window.dispatchEvent(new CustomEvent("launch", { detail: { patch: patching } }));;
};
</script>
@ -34,11 +35,6 @@
disabled={$launching}
on:click={launch}>Launch</Button
>
<Checkbox
disabled={$launching}
bind:checked={$patch}
on:click={() => patch.set(!$patch)}>Patch</Checkbox
>
<div
class="w-full flex flex-col justify-center items-center gap-2 mt-2 {$launching
? 'animate-fadeIn '

View File

@ -5,17 +5,13 @@
Input,
Label,
Toggle,
Tooltip,
Tooltip
} from "flowbite-svelte";
import { FileSearchSolid, FolderSolid } from "flowbite-svelte-icons";
import { currentPage } from "../storage/localStore";
import { Page } from "../consts/pages";
import { patch, presence } from "./../storage/localStore";
let folderPath: string = "";
let patching: boolean = true;
let presence: boolean = true;
window.addEventListener("settings-result", (e) => {
const settings: Record<string, string>[] = (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
};
</script>
@ -44,10 +42,10 @@
class="h-[265px] flex flex-col justify-start p-3 animate-fadeIn opacity-0"
>
<div class="flex flex-col gap-2 p-3">
<Toggle class="w-fit" bind:checked={presence} on:click={togglePresence}
<Toggle class="w-fit" bind:checked={$presence} on:click={togglePresence}
>Discord Presence</Toggle
>
<Toggle class="w-fit" bind:checked={patching} on:click={togglePatching}
<Toggle class="w-fit" bind:checked={$patch} on:click={togglePatching}
>Patching</Toggle
>
</div>

View File

@ -8,5 +8,6 @@ export const launchStatus = writable("Waiting...");
export const launchPercentage = writable(-1);
export const osuPath: Writable<undefined | string> = writable(undefined);
export const patch = writable(true);
export const presence = writable(true);
export const currentUser: Writable<undefined | User> = writable(undefined);
export const currentPage = writable(Page.Login);