Several changes

- added splash screen
- added `Process.kill()` static method
This commit is contained in:
Observer KRypt0n_ 2021-12-29 14:02:12 +02:00
parent ee58e179c3
commit faee9c4a35
No known key found for this signature in database
GPG key ID: DC5D4EC1303465DA
12 changed files with 151 additions and 5 deletions

View file

@ -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

View file

@ -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:

View file

@ -1,3 +1,12 @@
# Сплэш хуйня
splash:
title: Загрузка лаунчера
phrases:
- Делаем всякие важные штуки...
- Издеваемся над Паймон...
- Пытаемся получить Яэ...
# Окно настроек
settings:
# Основное
general:

16
splash.html Normal file
View file

@ -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>

Binary file not shown.

View file

@ -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

12
src/pages/splash.ts Normal file
View file

@ -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;

27
src/sass/splash.sass Normal file
View file

@ -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)

52
src/splash.svelte Normal file
View file

@ -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}

View file

@ -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();
});
}

View file

@ -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 '\''

View file

@ -14,7 +14,8 @@ export default defineConfig({
rollupOptions: {
input: [
'index.html',
'settings.html'
'settings.html',
'splash.html'
]
}
}