Merge branch 'marie/splash' into 'main'

Add Launcher Splash

See merge request KRypt0n_/an-anime-game-launcher!12
This commit is contained in:
Observer KRypt0n_ 2021-12-12 12:15:48 +00:00
commit 265c02bb1e
4 changed files with 42 additions and 3 deletions

View file

@ -13,7 +13,7 @@ const path = require('path');
require('electron-store').initRenderer(); require('electron-store').initRenderer();
let mainWindow, analyticsWindow, settingsWindow; let mainWindow, analyticsWindow, settingsWindow, splashWindow;
ipcMain.handle('hide-window', () => mainWindow.hide()); ipcMain.handle('hide-window', () => mainWindow.hide());
ipcMain.handle('show-window', () => mainWindow.show()); ipcMain.handle('show-window', () => mainWindow.show());
@ -70,6 +70,7 @@ ipcMain.handle('hide-analytics-participation', () => analyticsWindow.close());
function createWindow () function createWindow ()
{ {
// Launcher
// https://www.electronjs.org/docs/latest/api/browser-window/#class-browserwindow // https://www.electronjs.org/docs/latest/api/browser-window/#class-browserwindow
mainWindow = new BrowserWindow ({ mainWindow = new BrowserWindow ({
width: 1280, width: 1280,
@ -85,7 +86,6 @@ function createWindow ()
}); });
mainWindow.loadFile(path.join(__dirname, 'public', 'html', 'index.html')); mainWindow.loadFile(path.join(__dirname, 'public', 'html', 'index.html'));
mainWindow.once('ready-to-show', mainWindow.show);
// open URLs in Browser instead of an pop-up in electron app. // open URLs in Browser instead of an pop-up in electron app.
mainWindow.webContents.setWindowOpenHandler(({ url }) => { mainWindow.webContents.setWindowOpenHandler(({ url }) => {
@ -93,8 +93,21 @@ function createWindow ()
return { action: 'deny' }; return { action: 'deny' };
}); });
// mainWindow.webContents.openDevTools(); // mainWindow.webContents.openDevTools();
// Splash
splashWindow = new BrowserWindow({
width: 250,
height: 320,
transparent: true,
frame: false,
icon: path.join(__dirname, 'public', 'images', 'icons', '64x64.png'),
autoHideMenuBar: true
});
splashWindow.loadFile(path.join(__dirname, 'public', 'splash', 'index.html'));
splashWindow.center();
} }
@ -112,6 +125,13 @@ app.whenReady().then(() => {
createWindow(); createWindow();
}); });
ipcMain.handle('loaded', () => {
setTimeout(() => {
mainWindow.show();
splashWindow.close();
}, 2000);
});
// This has to be here otherwise webContents is invalid // This has to be here otherwise webContents is invalid
ipcMain.on('change-lang', (event, args) => { ipcMain.on('change-lang', (event, args) => {
mainWindow.webContents.send('change-lang', { 'lang': args.lang }); mainWindow.webContents.send('change-lang', { 'lang': args.lang });

18
public/splash/index.html Normal file
View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- CSS styles -->
<link rel="stylesheet" href="../css/settings.css">
<title>An Anime Game Launcher</title>
</head>
<body theme="dark" style="text-align: center;">
<video src="./loading.webm" style="padding-top: 15%; padding-left: 5%;" width="60%" height="60%" loop muted autoplay></video>
<h4 style="color: white; padding-top: 6%;">Starting Launcher...</h4>
</body>
</html>

BIN
public/splash/loading.webm Normal file

Binary file not shown.

View file

@ -97,6 +97,7 @@ $(() => {
$('#settings').on('mouseleave', () => $('#settings').removeClass('hovered')); $('#settings').on('mouseleave', () => $('#settings').removeClass('hovered'));
LauncherLib.getData().then(async data => { LauncherLib.getData().then(async data => {
ipcRenderer.invoke('loaded');
await LauncherUI.updateLauncherState(data); await LauncherUI.updateLauncherState(data);
$('#launch').on('click', async () => { $('#launch').on('click', async () => {