2024-01-11 14:56:02 +00:00
|
|
|
<script lang="ts">
|
2024-01-19 14:04:58 +00:00
|
|
|
import { Button, ButtonGroup, Input, Toggle } from "flowbite-svelte";
|
2024-01-18 15:32:57 +00:00
|
|
|
import { FileSearchSolid, FolderSolid } from "flowbite-svelte-icons";
|
2024-01-18 18:47:56 +00:00
|
|
|
import { patch, presence } from "./../storage/localStore";
|
2024-01-12 13:19:00 +00:00
|
|
|
|
|
|
|
let folderPath: string = "";
|
|
|
|
|
|
|
|
window.addEventListener("settings-result", (e) => {
|
|
|
|
const settings: Record<string, string>[] = (e as CustomEvent).detail;
|
|
|
|
const osuPath = settings.find((setting) => setting.key == "osuPath");
|
2024-01-19 14:04:58 +00:00
|
|
|
const settingPatch = settings.find((setting) => setting.key == "patch");
|
|
|
|
const settingPresence = settings.find(
|
|
|
|
(setting) => setting.key == "presence"
|
|
|
|
);
|
|
|
|
patch.set(settingPatch ? settingPatch.val == "true" : true);
|
|
|
|
presence.set(settingPresence ? settingPresence.val == "true" : true);
|
2024-01-12 13:19:00 +00:00
|
|
|
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
|
|
|
|
2024-01-18 15:32:57 +00:00
|
|
|
const detectFolderPath = () => {
|
|
|
|
window.dispatchEvent(new CustomEvent("folder-auto"));
|
|
|
|
};
|
|
|
|
|
2024-01-18 13:10:47 +00:00
|
|
|
const togglePatching = () => {
|
2024-01-18 18:47:56 +00:00
|
|
|
patch.set(!$patch);
|
2024-01-19 14:04:58 +00:00
|
|
|
window.dispatchEvent(
|
|
|
|
new CustomEvent("setting-update", { detail: { patch: $patch } })
|
|
|
|
);
|
2024-01-18 13:10:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const togglePresence = () => {
|
2024-01-18 18:47:56 +00:00
|
|
|
presence.set(!$presence);
|
2024-01-19 14:04:58 +00:00
|
|
|
window.dispatchEvent(
|
|
|
|
new CustomEvent("setting-update", { detail: { presence: $presence } })
|
|
|
|
);
|
2024-01-18 13:10:47 +00:00
|
|
|
};
|
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">
|
2024-01-18 18:47:56 +00:00
|
|
|
<Toggle class="w-fit" bind:checked={$presence} on:click={togglePresence}
|
2024-01-18 13:10:47 +00:00
|
|
|
>Discord Presence</Toggle
|
|
|
|
>
|
2024-01-18 18:47:56 +00:00
|
|
|
<Toggle class="w-fit" bind:checked={$patch} on:click={togglePatching}
|
2024-01-18 13:10:47 +00:00
|
|
|
>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"
|
2024-01-18 15:32:57 +00:00
|
|
|
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-25 09:23:03 +00:00
|
|
|
<Button color="light" on:click={detectFolderPath}>
|
2024-01-18 15:32:57 +00:00
|
|
|
<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"
|
2024-01-18 15:32:57 +00:00
|
|
|
/>
|
|
|
|
</Button>
|
2024-01-25 09:23:03 +00:00
|
|
|
<Button color="light" class="active:!rounded-lg" on:click={setFolderPath}>
|
2024-01-18 15:32:57 +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>
|