Several changes

- added template settings html file
- removed excess code from the entry file
- fixed windows loading
- added proper main window title
- added settings button events
- also `index.ts` now works through `promisify()`
- added `Launcher.showSettings()` method
- fixed `promisify()` issues related to `callAtOnce` property
This commit is contained in:
Observer KRypt0n_ 2021-12-24 21:57:27 +02:00
parent 843196e0e1
commit 1a99aae933
No known key found for this signature in database
GPG key ID: DC5D4EC1303465DA
8 changed files with 67 additions and 35 deletions

View file

@ -4,8 +4,6 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="/favicon.ico" />
<link rel="stylesheet" lang="sass" href="/src/sass/basic.sass" />
</head>
@ -17,6 +15,6 @@
<script src="neutralino.js"></script>
<script type="module" src="/src/entry.js"></script>
<script type="module" lang="ts" src="/src/pages/about.ts"></script>
<script type="module" lang="ts" src="/src/pages/settings.ts"></script>
</body>
</html>

View file

@ -1,5 +1 @@
Neutralino.init();
Neutralino.events.on('ready', () => {
import('./ts/neutralino/Window');
});

View file

@ -1,13 +0,0 @@
import * as Vue from 'vue/dist/vue.esm-bundler';
import Window from '../ts/neutralino/Window';
Vue.createApp({
data: () => {
return {
title: 'about'
};
},
mounted: () => Window.current.show()
}).mount('#app');

View file

@ -1,4 +1,4 @@
import { createApp } from 'vue';
import { createApp } from 'vue/dist/vue.esm-bundler';
import Window from '../ts/neutralino/Window';
@ -6,6 +6,7 @@ import Launcher from '../ts/Launcher';
import Configs from '../ts/Configs';
import constants from '../ts/Constants';
import promisify from '../ts/core/promisify';
import Game from '../ts/Game';
promisify(async () => {
Configs.defaults({
@ -46,20 +47,45 @@ let app = createApp({
}
}),
methods: {
showAbout: () => Window.open('about')
},
mounted()
{
const launcher = new Launcher(this);
new Promise(async (resolve) => {
await launcher.updateSocial();
await launcher.updateBackground();
/**
* Update launcher's title
*/
Game.latest.then((game) => {
Window.current.setTitle(`${constants.placeholders.uppercase.full} Linux Launcher - ${game.version}`);
});
resolve(null);
}).then(() => {
/**
* Add some events to some elements
*/
const settingsButton = document.getElementById('settings');
settingsButton!.onclick = () => launcher.showSettings();
settingsButton!.onmouseenter = () => {
settingsButton?.classList.add('hovered');
};
settingsButton!.onmouseleave = () => {
settingsButton?.classList.remove('hovered');
};
/**
* Do some launcher stuff
*/
const pipeline = promisify({
callbacks: [
() => launcher.updateSocial(),
() => launcher.updateBackground()
],
callAtOnce: true
});
// Show window when all the stuff was completed
pipeline.then(() => {
Window.current.show();
});
}

11
src/pages/settings.ts Normal file
View file

@ -0,0 +1,11 @@
import { createApp } from 'vue/dist/vue.esm-bundler';
import Window from '../ts/neutralino/Window';
createApp({
data: () => ({
title: 'about'
}),
mounted: () => Window.current.show()
}).mount('#app');

View file

@ -1,3 +1,5 @@
import Window from './neutralino/Window';
import constants from './Constants';
import Configs from './Configs';
@ -44,6 +46,15 @@ export default class Launcher
t(0);
}
public showSettings()
{
Window.open('settings', {
title: 'Settings',
width: 900,
height: 600
});
}
/**
* Update launcher background picture
*/

View file

@ -55,11 +55,14 @@ export default function promisify(callback: callback|PromiseOptions): Promise<an
setTimeout(updater, callback.interval ?? 100);
}
else for (let i = 0; i < callback.callbacks.length; ++i)
outputs[i] = await promisify(callback.callbacks[i]());
else
{
for (let i = 0; i < callback.callbacks.length; ++i)
outputs[i] = await promisify(callback.callbacks[i]);
resolve(outputs);
}
}
});
};

View file

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