EZPPLauncher/src/pages/Settings.svelte

88 lines
2.3 KiB
Svelte
Raw Normal View History

2024-01-11 14:56:02 +00:00
<script lang="ts">
import {
Button,
ButtonGroup,
Input,
Label,
Toggle,
Tooltip,
} from "flowbite-svelte";
import { FileSearchSolid, FolderSolid } from "flowbite-svelte-icons";
2024-01-11 14:56:02 +00:00
import { currentPage } from "../storage/localStore";
import { Page } from "../consts/pages";
2024-01-12 13:19:00 +00:00
let folderPath: string = "";
2024-01-18 13:10:47 +00:00
let patching: boolean = true;
let presence: boolean = true;
2024-01-12 13:19:00 +00:00
window.addEventListener("settings-result", (e) => {
const settings: Record<string, string>[] = (e as CustomEvent).detail;
const osuPath = settings.find((setting) => setting.key == "osuPath");
folderPath = osuPath ? osuPath.val : "";
});
window.dispatchEvent(new CustomEvent("settings-get"));
const setFolderPath = () => {
window.dispatchEvent(new CustomEvent("folder-set"));
};
2024-01-18 13:10:47 +00:00
const detectFolderPath = () => {
window.dispatchEvent(new CustomEvent("folder-auto"));
};
2024-01-18 13:10:47 +00:00
const togglePatching = () => {
patching = !patching;
};
const togglePresence = () => {
presence = !presence;
};
2024-01-11 14:56:02 +00:00
</script>
<main
2024-01-18 13:10:47 +00:00
class="h-[265px] flex flex-col justify-start p-3 animate-fadeIn opacity-0"
2024-01-11 14:56:02 +00:00
>
2024-01-18 13:10:47 +00:00
<div class="flex flex-col gap-2 p-3">
<Toggle class="w-fit" bind:checked={presence} on:click={togglePresence}
>Discord Presence</Toggle
>
<Toggle class="w-fit" bind:checked={patching} on:click={togglePatching}
>Patching</Toggle
>
</div>
2024-01-11 14:56:02 +00:00
<div
class="container flex flex-col items-center justify-center gap-5 rounded-lg p-3"
>
<ButtonGroup class="w-full">
2024-01-11 15:09:38 +00:00
<Input
type="text"
id="oip"
2024-01-11 15:09:38 +00:00
placeholder="Path to your osu! installation"
2024-01-12 13:19:00 +00:00
value={folderPath}
2024-01-11 15:09:38 +00:00
readonly
/>
2024-01-12 13:19:00 +00:00
<Button
color="light"
class="dark:active:!bg-gray-900"
on:click={detectFolderPath}
>
<FileSearchSolid
2024-01-11 14:56:02 +00:00
size="sm"
class="dark:text-gray-300 text-gray-500 outline-none border-none select-none pointer-events-none"
/>
</Button>
2024-01-11 14:56:02 +00:00
<Button
color="light"
class="dark:active:!bg-gray-900 active:!rounded-lg"
on:click={setFolderPath}
2024-01-11 14:56:02 +00:00
>
<FolderSolid
size="sm"
class="dark:text-gray-300 text-gray-500 outline-none border-none select-none pointer-events-none"
/>
</Button>
</ButtonGroup>
2024-01-11 14:56:02 +00:00
</div>
</main>