2021-09-26 16:04:20 +02:00
|
|
|
<script lang="ts">
|
|
|
|
import Footer from "./components/Footer.svelte";
|
2021-09-26 21:02:02 +02:00
|
|
|
import Header from "./components/Header.svelte";
|
2021-09-27 08:38:26 +02:00
|
|
|
import Wrapper from "./components/Wrapper.svelte";
|
2021-09-27 11:12:31 +02:00
|
|
|
import { SharkGame } from "./shark/SharkGame";
|
2021-09-27 08:38:26 +02:00
|
|
|
|
2021-10-02 20:56:40 +02:00
|
|
|
import { Modals, closeAllModals } from "svelte-modals";
|
2021-09-29 22:49:39 +02:00
|
|
|
import { onDestroy, onMount } from "svelte";
|
|
|
|
import type { Unsubscriber } from "svelte/store";
|
|
|
|
|
|
|
|
let root: HTMLElement;
|
|
|
|
let unsubscribeSettings: Unsubscriber;
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
root = document.documentElement;
|
|
|
|
|
2021-09-30 13:49:00 +02:00
|
|
|
SharkGame.Settings.settings.subscribe((settings) => {
|
2021-09-30 21:26:11 +02:00
|
|
|
root.classList.toggle("no-theme", !settings.appearance.enableThemes.current);
|
2021-09-30 11:10:48 +02:00
|
|
|
settings.appearance.theme.options.forEach((theme) => {
|
2021-09-30 21:26:11 +02:00
|
|
|
root.classList.toggle(theme, theme === settings.appearance.theme.current);
|
2021-09-29 22:49:39 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
onDestroy(() => {
|
|
|
|
unsubscribeSettings();
|
|
|
|
});
|
|
|
|
|
|
|
|
function handleKeyUp(event: KeyboardEvent) {
|
|
|
|
if (event.key === "Escape") {
|
2021-10-02 20:56:40 +02:00
|
|
|
closeAllModals();
|
2021-09-29 22:49:39 +02:00
|
|
|
}
|
|
|
|
}
|
2021-09-26 16:04:20 +02:00
|
|
|
</script>
|
|
|
|
|
2021-09-29 22:49:39 +02:00
|
|
|
<svelte:body on:keyup={handleKeyUp} />
|
|
|
|
|
|
|
|
<Modals>
|
2021-10-02 20:56:40 +02:00
|
|
|
<div slot="backdrop" id="modal-backdrop" on:click={closeAllModals} />
|
2021-09-29 22:49:39 +02:00
|
|
|
</Modals>
|
2021-10-02 20:12:21 +02:00
|
|
|
{#await SharkGame.initialize()}
|
|
|
|
Loading...
|
|
|
|
{:then}
|
|
|
|
<Header game={SharkGame} title={SharkGame.title} />
|
|
|
|
<Wrapper game={SharkGame} />
|
|
|
|
<Footer />
|
|
|
|
{/await}
|