diff --git a/entry.js b/entry.js index d248bf9..fb0ff9e 100644 --- a/entry.js +++ b/entry.js @@ -13,7 +13,7 @@ const path = require('path'); require('electron-store').initRenderer(); -let mainWindow, analyticsWindow, settingsWindow; +let mainWindow, analyticsWindow, settingsWindow, splashWindow; ipcMain.handle('hide-window', () => mainWindow.hide()); ipcMain.handle('show-window', () => mainWindow.show()); @@ -70,6 +70,7 @@ ipcMain.handle('hide-analytics-participation', () => analyticsWindow.close()); function createWindow () { + // Launcher // https://www.electronjs.org/docs/latest/api/browser-window/#class-browserwindow mainWindow = new BrowserWindow ({ width: 1280, @@ -85,7 +86,6 @@ function createWindow () }); 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. mainWindow.webContents.setWindowOpenHandler(({ url }) => { @@ -93,8 +93,21 @@ function createWindow () return { action: 'deny' }; }); - + // 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(); }); + ipcMain.handle('loaded', () => { + setTimeout(() => { + mainWindow.show(); + splashWindow.close(); + }, 2000); + }); + // This has to be here otherwise webContents is invalid ipcMain.on('change-lang', (event, args) => { mainWindow.webContents.send('change-lang', { 'lang': args.lang }); diff --git a/public/splash/index.html b/public/splash/index.html new file mode 100644 index 0000000..65e59b3 --- /dev/null +++ b/public/splash/index.html @@ -0,0 +1,18 @@ + + + + + + + + + + + An Anime Game Launcher + + + + +

Starting Launcher...

+ + diff --git a/public/splash/loading.webm b/public/splash/loading.webm new file mode 100644 index 0000000..a0be6eb Binary files /dev/null and b/public/splash/loading.webm differ diff --git a/src/ts/index.ts b/src/ts/index.ts index 9c0f1b4..11440f7 100644 --- a/src/ts/index.ts +++ b/src/ts/index.ts @@ -97,6 +97,7 @@ $(() => { $('#settings').on('mouseleave', () => $('#settings').removeClass('hovered')); LauncherLib.getData().then(async data => { + ipcRenderer.invoke('loaded'); await LauncherUI.updateLauncherState(data); $('#launch').on('click', async () => {