an-anime-game-launcher/src/splash.svelte

70 lines
1.9 KiB
Svelte
Raw Normal View History

<script context="module" lang="ts">
declare const Neutralino;
</script>
2021-12-29 15:59:55 +03:00
<script lang="ts">
import { onMount } from 'svelte';
import { _, locale } from 'svelte-i18n';
2022-01-28 20:37:44 +03:00
import { Configs, IPC, Windows } from './empathize';
2022-01-30 17:26:20 +03:00
import constants from './ts/Constants';
import Splash from './assets/gifs/running-qiqi.gif';
import SplashSecret from './assets/gifs/loading-marie-please.gif';
const splash = Math.round(Math.random() * 100) < 100 ? Splash : SplashSecret;
let phrase = Math.round(Math.random() * 8);
onMount(() => {
2022-01-28 20:37:44 +03:00
Windows.current.show();
Windows.current.center(300, 400);
});
const isLauncherLoaded = () => {
2022-01-02 00:57:50 +03:00
IPC.read().then(async (records) => {
const launcherLoaded = records.filter((record) => record.data === 'launcher-loaded');
if (launcherLoaded.length > 0)
{
2022-01-02 00:57:50 +03:00
for (const record of launcherLoaded)
await record.pop();
2022-01-28 20:37:44 +03:00
Windows.current.hide();
Neutralino.app.exit();
}
2022-01-06 00:27:00 +03:00
else setTimeout(isLauncherLoaded, 500);
});
};
2022-01-06 00:27:00 +03:00
Neutralino.events.on('ready', () => isLauncherLoaded());
Neutralino.events.on('windowClose', () => {
Neutralino.app.exit();
});
// Auto theme switcher
Configs.get('theme').then((theme) => {
if (theme === 'system')
theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
document.body.setAttribute('data-theme', theme as string);
});
</script>
{#if typeof $locale === 'string'}
<main>
<img src={splash} alt="" />
<h2>{$_('splash.title')}</h2>
2022-01-30 17:26:20 +03:00
<p>{$_(`splash.phrases.${phrase}`, {
values: {
// Required by de-de locale
game: constants.placeholders.uppercase.full
}
})}</p>
</main>
{/if}