diff --git a/README.md b/README.md index a126d9f..28e1be9 100644 --- a/README.md +++ b/README.md @@ -166,10 +166,10 @@ This is our current roadmap goals. You can find older ones [here](ROADMAP.md) * <s>Telemetry checking</s> * <s>Tooltips for some options</s> * <s>Debugger</s> +* <s>Splash screen</s> * Game pre-installation * Launcher auto-updates * Statistics window -* Splash screen * Theming system * Chengelog window * Default runner auto-installation diff --git a/public/locales/en-us.yaml b/public/locales/en-us.yaml index 5a5c61c..0cc8168 100644 --- a/public/locales/en-us.yaml +++ b/public/locales/en-us.yaml @@ -1,3 +1,12 @@ +# Splash window +splash: + title: Loading launcher + phrases: + - Doing some important stuff... + - Bullying Paimon... + - Pulling for Yae... + +# Settings window settings: # General general: diff --git a/public/locales/ru-ru.yaml b/public/locales/ru-ru.yaml index 6486d17..9e44bb4 100644 --- a/public/locales/ru-ru.yaml +++ b/public/locales/ru-ru.yaml @@ -1,3 +1,12 @@ +# Сплэш хуйня +splash: + title: Загрузка лаунчера + phrases: + - Делаем всякие важные штуки... + - Издеваемся над Паймон... + - Пытаемся получить Яэ... + +# Окно настроек settings: # Основное general: diff --git a/splash.html b/splash.html new file mode 100644 index 0000000..b3d1896 --- /dev/null +++ b/splash.html @@ -0,0 +1,16 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="UTF-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + + <link rel="stylesheet" lang="sass" href="/src/sass/splash.sass" /> + </head> + + <body data-theme="light"> + <div id="app"></div> + + <script src="neutralino.js"></script> + <script type="module" src="/src/pages/splash.ts" lang="ts"></script> + </body> +</html> \ No newline at end of file diff --git a/src/assets/webms/loading.webm b/src/assets/webms/loading.webm new file mode 100644 index 0000000..a0be6eb Binary files /dev/null and b/src/assets/webms/loading.webm differ diff --git a/src/index.svelte b/src/index.svelte index 40955d3..780e24d 100644 --- a/src/index.svelte +++ b/src/index.svelte @@ -11,6 +11,17 @@ import Game from './ts/Game'; import Background from './ts/launcher/Background'; + // @ts-expect-error + Neutralino.events.on('ready', () => { + Window.open('splash', { + title: 'Splash', + width: 400, + height: 500, + borderless: true, + exitProcessOnClose: false + }); + }); + const launcher = new Launcher(onMount); // Do some stuff when all the content will be loaded diff --git a/src/pages/splash.ts b/src/pages/splash.ts new file mode 100644 index 0000000..ab1fc17 --- /dev/null +++ b/src/pages/splash.ts @@ -0,0 +1,12 @@ +import '../i18n'; +import App from '../splash.svelte'; + +declare const Neutralino; + +Neutralino.init(); + +const app = new App({ + target: document.getElementById('app')! +}); + +export default app; diff --git a/src/sass/splash.sass b/src/sass/splash.sass new file mode 100644 index 0000000..9db3a31 --- /dev/null +++ b/src/sass/splash.sass @@ -0,0 +1,27 @@ +@use "sass:map" + +@import "basic" + +@mixin themable($theme-name, $theme-map) + body[data-theme=#{$theme-name}] + div + width: 60% + margin: 56px auto 0 auto + + video + width: 100% + + h2, p + margin: 0 + text-align: center + + p + color: grey + font-weight: 600 + margin-top: 12px + +@import "themes/light" +@import "themes/dark" + +@include themable(light, $light) +@include themable(dark, $dark) diff --git a/src/splash.svelte b/src/splash.svelte new file mode 100644 index 0000000..873234f --- /dev/null +++ b/src/splash.svelte @@ -0,0 +1,52 @@ +<script lang="ts"> + import { onMount } from 'svelte'; + import { _, locale } from 'svelte-i18n'; + + import Window from './ts/neutralino/Window'; + + import Splash from './assets/webms/loading.webm'; + + let phrase = Math.round(Math.random() * 2); + + onMount(() => { + Window.current.show(); + }); + + const isLauncherLoaded = () => { + // @ts-expect-error + Neutralino.storage.getData('launcherLoaded') + .then(() => { + // @ts-expect-error + Neutralino.storage.setData('launcherLoaded', undefined); + + Window.current.hide(); + + // @ts-expect-error + Neutralino.app.exit(); + }) + .catch(() => setTimeout(isLauncherLoaded, 1000)); + }; + + // @ts-expect-error + Neutralino.events.on('ready', () => setTimeout(isLauncherLoaded, 1000)); + + // @ts-expect-error + Neutralino.events.on('windowClose', () => { + // @ts-expect-error + Neutralino.app.exit(); + }); + + // Auto theme switcher + // TODO: an option to disable it + if (window.matchMedia('(prefers-color-scheme: dark)').matches) + document.body.setAttribute('data-theme', 'dark'); +</script> + +{#if typeof $locale === 'string'} + <main> + <video src={Splash} loop muted autoplay></video> + + <h2>{$_('splash.title')}</h2> + <p>{$_(`splash.phrases.${phrase}`)}</p> + </main> +{/if} diff --git a/src/ts/launcher/State.ts b/src/ts/launcher/State.ts index 32322eb..03ab1b1 100644 --- a/src/ts/launcher/State.ts +++ b/src/ts/launcher/State.ts @@ -7,6 +7,8 @@ import Game from '../Game'; import Patch from '../Patch'; import Voice from '../Voice'; +declare const Neutralino; + export default class State { public launcher: Launcher; @@ -49,6 +51,8 @@ export default class State }; this.update().then(() => { + Neutralino.storage.setData('launcherLoaded', 'aboba'); + Window.current.show(); }); } diff --git a/src/ts/neutralino/Process.ts b/src/ts/neutralino/Process.ts index 24b211f..bdb032c 100644 --- a/src/ts/neutralino/Process.ts +++ b/src/ts/neutralino/Process.ts @@ -155,9 +155,7 @@ class Process */ public kill(forced: boolean = false): Promise<void> { - return new Promise((resolve) => { - Neutralino.os.execCommand(`kill ${forced ? '-9' : '-15'} ${this.id}`).then(() => resolve()); - }); + return Process.kill(this.id, forced); } /** @@ -215,6 +213,13 @@ class Process }); } + public static kill(id: number, forced: boolean = false): Promise<void> + { + return new Promise((resolve) => { + Neutralino.os.execCommand(`kill ${forced ? '-9' : '-15'} ${id}`).then(() => resolve()); + }); + } + /** * Replace '\a\b' to '\\a\\b' * And replace ''' to '\'' diff --git a/vite.config.js b/vite.config.js index f8f06a9..591a89d 100644 --- a/vite.config.js +++ b/vite.config.js @@ -14,7 +14,8 @@ export default defineConfig({ rollupOptions: { input: [ 'index.html', - 'settings.html' + 'settings.html', + 'splash.html' ] } }