From 1a99aae933f9e2b1d86f69e54519578825a32613 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Fri, 24 Dec 2021 21:57:27 +0200 Subject: [PATCH] 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 --- about.html => settings.html | 6 ++--- src/entry.js | 4 ---- src/pages/about.ts | 13 ----------- src/pages/index.ts | 46 +++++++++++++++++++++++++++++-------- src/pages/settings.ts | 11 +++++++++ src/ts/Launcher.ts | 11 +++++++++ src/ts/core/promisify.ts | 9 +++++--- vite.config.js | 2 +- 8 files changed, 67 insertions(+), 35 deletions(-) rename about.html => settings.html (77%) delete mode 100644 src/pages/about.ts create mode 100644 src/pages/settings.ts diff --git a/about.html b/settings.html similarity index 77% rename from about.html rename to settings.html index 07a1d4f..0b79093 100644 --- a/about.html +++ b/settings.html @@ -4,8 +4,6 @@ - - @@ -17,6 +15,6 @@ - + - + \ No newline at end of file diff --git a/src/entry.js b/src/entry.js index 53242ce..d08302b 100644 --- a/src/entry.js +++ b/src/entry.js @@ -1,5 +1 @@ Neutralino.init(); - -Neutralino.events.on('ready', () => { - import('./ts/neutralino/Window'); -}); diff --git a/src/pages/about.ts b/src/pages/about.ts deleted file mode 100644 index a33de36..0000000 --- a/src/pages/about.ts +++ /dev/null @@ -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'); diff --git a/src/pages/index.ts b/src/pages/index.ts index 042fe0d..1d15554 100644 --- a/src/pages/index.ts +++ b/src/pages/index.ts @@ -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(); }); } diff --git a/src/pages/settings.ts b/src/pages/settings.ts new file mode 100644 index 0000000..69961d3 --- /dev/null +++ b/src/pages/settings.ts @@ -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'); diff --git a/src/ts/Launcher.ts b/src/ts/Launcher.ts index c5bbd85..ab28cde 100644 --- a/src/ts/Launcher.ts +++ b/src/ts/Launcher.ts @@ -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 */ diff --git a/src/ts/core/promisify.ts b/src/ts/core/promisify.ts index 9fca3e0..7e74ef8 100644 --- a/src/ts/core/promisify.ts +++ b/src/ts/core/promisify.ts @@ -55,10 +55,13 @@ export default function promisify(callback: callback|PromiseOptions): Promise