Compare commits

..

No commits in common. "756ae1be582e31f48a4676213b3d1ca3005d0bc6" and "1adb1b7dec69f1fa82971f4f75e95cfef78c4dbf" have entirely different histories.

9 changed files with 61 additions and 149 deletions

120
main.js
View File

@ -18,44 +18,32 @@ function isDev() {
function registerIPCPipes() { function registerIPCPipes() {
ipcMain.handle("ezpplauncher:login", async (e, args) => { ipcMain.handle("ezpplauncher:login", async (e, args) => {
const timeout = new AbortController(); const fetchResult = await fetch("https://ez-pp.farm/login/check", {
const timeoutId = setTimeout(() => timeout.abort(), 8000); method: "POST",
try { body: JSON.stringify({
const fetchResult = await fetch("https://ez-pp.farm/login/check", { username: args.username,
signal: timeout.signal, password: args.password,
method: "POST", }),
body: JSON.stringify({ headers: {
username: args.username, "Content-Type": "application/json",
password: args.password, },
}), });
headers: {
"Content-Type": "application/json",
},
});
clearTimeout(timeoutId); if (fetchResult.ok) {
const result = await fetchResult.json();
if (fetchResult.ok) { if ("user" in result) {
const result = await fetchResult.json(); if (args.saveCredentials) {
if ("user" in result) { config.set("username", args.username);
if (args.saveCredentials) { config.set("password", args.password);
config.set("username", args.username);
config.set("password", args.password);
}
config.remove("guest");
} }
return result; config.remove("guest");
} }
return { return result;
code: 500,
message: "Something went wrong while logging you in.",
};
} catch (err) {
return {
code: 500,
message: "Something went wrong while logging you in.",
};
} }
return {
code: 500,
message: "Something went wrong while logging you in.",
};
}); });
ipcMain.handle("ezpplauncher:autologin", async (e) => { ipcMain.handle("ezpplauncher:autologin", async (e) => {
@ -66,37 +54,25 @@ function registerIPCPipes() {
if (username == undefined || password == undefined) { if (username == undefined || password == undefined) {
return { code: 200, message: "No autologin" }; return { code: 200, message: "No autologin" };
} }
const timeout = new AbortController(); const fetchResult = await fetch("https://ez-pp.farm/login/check", {
const timeoutId = setTimeout(() => timeout.abort(), 8000); method: "POST",
try { body: JSON.stringify({
const fetchResult = await fetch("https://ez-pp.farm/login/check", { username: username,
signal: timeout.signal, password: password,
method: "POST", }),
body: JSON.stringify({ headers: {
username: username, "Content-Type": "application/json",
password: password, },
}), });
headers: {
"Content-Type": "application/json",
},
});
clearTimeout(timeoutId); if (fetchResult.ok) {
const result = await fetchResult.json();
if (fetchResult.ok) { return result;
const result = await fetchResult.json();
return result;
}
return {
code: 500,
message: "Something went wrong while logging you in.",
};
} catch (err) {
return {
code: 500,
message: "Something went wrong while logging you in.",
};
} }
return {
code: 500,
message: "Something went wrong while logging you in.",
};
}); });
ipcMain.handle("ezpplauncher:guestlogin", (e) => { ipcMain.handle("ezpplauncher:guestlogin", (e) => {
@ -111,24 +87,6 @@ function registerIPCPipes() {
config.remove("guest"); config.remove("guest");
return true; return true;
}); });
ipcMain.handle("ezpplauncher:launch", async (e) => {
mainWindow.webContents.send("ezpplauncher:launchstatus", {
status: "Checking osu! directory...",
});
await new Promise((res) => setTimeout(res, 1500));
mainWindow.webContents.send("ezpplauncher:launchstatus", {
status: "Checking for osu! updates...",
});
mainWindow.webContents.send("ezpplauncher:launchprogress", {
progress: 0,
});
await new Promise((res) => setTimeout(res, 1500));
mainWindow.webContents.send("ezpplauncher:launchprogress", {
progress: 100,
});
return true;
});
} }
function createWindow() { function createWindow() {

View File

@ -36,19 +36,3 @@ window.addEventListener("logout", async (e) => {
window.addEventListener("guest-login", async (e) => { window.addEventListener("guest-login", async (e) => {
await ipcRenderer.invoke("ezpplauncher:guestlogin"); await ipcRenderer.invoke("ezpplauncher:guestlogin");
}); });
window.addEventListener("launch", async (e) => {
await ipcRenderer.invoke("ezpplauncher:launch");
});
ipcRenderer.addListener("ezpplauncher:launchstatus", (e, args) => {
window.dispatchEvent(
new CustomEvent("launchStatusUpdate", { detail: args }),
);
});
ipcRenderer.addListener("ezpplauncher:launchprogress", (e, args) => {
window.dispatchEvent(
new CustomEvent("launchProgressUpdate", { detail: args }),
);
});

View File

@ -4,20 +4,19 @@
Dropdown, Dropdown,
DropdownItem, DropdownItem,
DropdownHeader, DropdownHeader,
DropdownDivider, DropdownDivider
} from "flowbite-svelte"; } from "flowbite-svelte";
import { import {
ArrowRightFromBracketSolid, ArrowRightFromBracketSolid,
ArrowRightToBracketSolid, ArrowRightToBracketSolid,
UserSettingsSolid, UserSettingsSolid
} from "flowbite-svelte-icons"; } from "flowbite-svelte-icons";
import ezppLogo from "../public/favicon.png"; import ezppLogo from "../public/favicon.png";
import { import {
currentPage, currentPage,
currentUser, currentUser,
launching, launching,
launchPercentage, launchStatus
launchStatus,
} from "./storage/localStore"; } from "./storage/localStore";
import { Page } from "./consts/pages"; import { Page } from "./consts/pages";
import Login from "./pages/Login.svelte"; import Login from "./pages/Login.svelte";
@ -41,16 +40,9 @@
}; };
window.addEventListener("launchStatusUpdate", (e) => { window.addEventListener("launchStatusUpdate", (e) => {
console.log((e as CustomEvent).detail); const status = (e as CustomEvent).detail;
const status = (e as CustomEvent).detail.status;
launchStatus.set(status); launchStatus.set(status);
}); });
window.addEventListener("launchProgressUpdate", (e) => {
console.log((e as CustomEvent).detail);
const progress = (e as CustomEvent).detail.progress;
launchPercentage.set(progress);
});
</script> </script>
<Toaster></Toaster> <Toaster></Toaster>

View File

@ -54,10 +54,6 @@ html .cet-titlebar .cet-control-icon svg {
} }
} }
.animatedProgress div {
transition: width 0.35s cubic-bezier(0.65, -0.02, 0.31, 1.01);
}
@keyframes progress-loading { @keyframes progress-loading {
50% { 50% {
background-position-x: -115%; background-position-x: -115%;

View File

@ -2,10 +2,9 @@
import { cubicOut } from "svelte/easing"; import { cubicOut } from "svelte/easing";
import { tweened } from "svelte/motion"; import { tweened } from "svelte/motion";
import { twMerge, twJoin } from "tailwind-merge"; import { twMerge, twJoin } from "tailwind-merge";
import { clamp } from "../util/mathUtil";
export let progress: number = 45; export let progress: string | number | undefined | null = "45";
export let precision = 2; export let precision = 0;
export let tweenDuration = 400; export let tweenDuration = 400;
export let animate = false; export let animate = false;
export let size = "h-2.5"; export let size = "h-2.5";
@ -13,10 +12,10 @@
export let labelOutside = ""; export let labelOutside = "";
export let easing = cubicOut; export let easing = cubicOut;
export let color = "primary"; export let color = "primary";
export let indeterminate = false;
export let labelInsideClass = export let labelInsideClass =
"text-primary-100 text-xs font-medium text-center p-0.5 leading-none rounded-full"; "text-primary-100 text-xs font-medium text-center p-0.5 leading-none rounded-full";
export let divClass = "w-full bg-gray-200 rounded-full dark:bg-gray-700"; export let divClass = "w-full bg-gray-200 rounded-full dark:bg-gray-700";
export let indeterminate = progress == null;
const barColors: Record<string, string> = { const barColors: Record<string, string> = {
primary: "bg-primary-600", primary: "bg-primary-600",
@ -29,14 +28,15 @@
indigo: "bg-indigo-600 dark:bg-indigo-500", indigo: "bg-indigo-600 dark:bg-indigo-500",
}; };
let _progress = tweened(0, { const _progress = tweened(0, {
duration: tweenDuration, duration: animate && !indeterminate ? tweenDuration : 0,
easing, easing,
}); });
$: { $: {
progress = clamp(Number(progress), 0, 100); if (!indeterminate) {
_progress.set(progress); _progress.set(Number(progress));
}
} }
</script> </script>
@ -49,9 +49,7 @@
>{labelOutside}</span >{labelOutside}</span
> >
<span class="text-sm font-medium text-blue-700 dark:text-white" <span class="text-sm font-medium text-blue-700 dark:text-white"
>{animate >{progress}%</span
? $_progress.toFixed(precision)
: progress.toFixed(precision)}%</span
> >
</div> </div>
{/if} {/if}
@ -61,9 +59,9 @@
{#if !indeterminate} {#if !indeterminate}
<div <div
class={twJoin(labelInsideClass, barColors[color])} class={twJoin(labelInsideClass, barColors[color])}
style="width: {animate ? $_progress : progress}%" style="width: {$_progress}%"
> >
{animate ? $_progress.toFixed(precision) : progress.toFixed(precision)}% {$_progress.toFixed(precision)}%
</div> </div>
{:else} {:else}
<div <div
@ -77,7 +75,7 @@
{:else if !indeterminate} {:else if !indeterminate}
<div <div
class={twJoin(barColors[color], size, "rounded-full")} class={twJoin(barColors[color], size, "rounded-full")}
style="width: {animate ? $_progress : progress}%" style="width: {$_progress}%"
/> />
{:else} {:else}
<div <div

View File

@ -1,12 +1,7 @@
<script lang="ts"> <script lang="ts">
import { Button, Checkbox } from "flowbite-svelte"; import { Button, Checkbox } from "flowbite-svelte";
import Progressbar from "../lib/Progressbar.svelte"; import Progressbar from "../lib/Progressbar.svelte";
import { import { launching, patch, launchStatus } from "./../storage/localStore";
launching,
patch,
launchStatus,
launchPercentage,
} from "./../storage/localStore";
let progressbarFix = true; let progressbarFix = true;
setTimeout(() => { setTimeout(() => {
@ -15,8 +10,7 @@
const launch = () => { const launch = () => {
launching.set(true); launching.set(true);
window.dispatchEvent(new CustomEvent("launch")); }
};
</script> </script>
<main <main
@ -32,7 +26,7 @@
? '' ? ''
: 'active:scale-95 '}transition-transform duration-75" : 'active:scale-95 '}transition-transform duration-75"
disabled={$launching} disabled={$launching}
on:click={launch}>Launch</Button on:click={() => launching.set(!$launching)}>Launch</Button
> >
<Checkbox <Checkbox
disabled={$launching} disabled={$launching}
@ -46,12 +40,10 @@
> >
<Progressbar <Progressbar
animate={true} animate={true}
progress={$launchPercentage} progress={null}
indeterminate={$launchPercentage == -1}
labelInside={true} labelInside={true}
size="h-3" size="h-3"
class="" labelInsideClass="bg-primary-600 drop-shadow-xl text-gray-100 text-base font-medium text-center p-1 leading-none rounded-full"
labelInsideClass="bg-primary-600 drop-shadow-xl text-gray-100 text-base font-medium text-center p-1 leading-none rounded-full !text-[0.7rem] !leading-[0.45]"
/> />
<p class="m-0 p-0 dark:text-gray-400 font-light">{$launchStatus}</p> <p class="m-0 p-0 dark:text-gray-400 font-light">{$launchStatus}</p>
</div> </div>

View File

@ -142,9 +142,7 @@
{/if} {/if}
</Button> </Button>
</Input> </Input>
<Checkbox bind:checked={saveCredentials} disabled={loading} <Checkbox bind:checked={saveCredentials}>Save credentials</Checkbox>
>Save credentials</Checkbox
>
<div class="flex flex-col justify-center items-center gap-5 mt-1"> <div class="flex flex-col justify-center items-center gap-5 mt-1">
<Button <Button
class="dark:active:!bg-gray-900 active:scale-95 transition-transform duration-75" class="dark:active:!bg-gray-900 active:scale-95 transition-transform duration-75"

View File

@ -1,3 +0,0 @@
export const clamp = (val: number, min: number, max: number) => {
return val <= min ? min : val >= max ? max : val;
};

View File

@ -21,9 +21,6 @@ const config = {
fadeIn: "fadeIn 1s ease forwards", fadeIn: "fadeIn 1s ease forwards",
fadeOut: "fadeOut 1s ease forwards", fadeOut: "fadeOut 1s ease forwards",
}, },
transitionProperty: {
'width': 'width',
},
colors: { colors: {
// flowbite-svelte // flowbite-svelte
primary: { primary: {