Skip to content

Commit

Permalink
Merge pull request #822 from NickRimmer/features/splash-size
Browse files Browse the repository at this point in the history
Configurable splash screen size
  • Loading branch information
FlorianRappl committed Feb 14, 2024
2 parents 3476145 + 94dc82e commit 0a80367
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/ElectronNET.Host/main.js
Expand Up @@ -115,17 +115,10 @@ function isSplashScreenEnabled() {

function startSplashScreen() {
let imageFile = path.join(currentBinPath, manifestJsonFile.splashscreen.imageFile);
imageSize(imageFile, (error, dimensions) => {
if (error) {
console.log(`load splashscreen error:`);
console.error(error);

throw new Error(error.message);
}

const startWindow = (width, height) => {
splashScreen = new BrowserWindow({
width: dimensions.width,
height: dimensions.height,
width: width,
height: height,
transparent: true,
center: true,
frame: false,
Expand All @@ -143,10 +136,25 @@ function startSplashScreen() {

const loadSplashscreenUrl = path.join(__dirname, 'splashscreen', 'index.html') + '?imgPath=' + imageFile;
splashScreen.loadURL('file://' + loadSplashscreenUrl);

splashScreen.once('closed', () => {
splashScreen = null;
});
}

if (manifestJsonFile.splashscreen.width && manifestJsonFile.splashscreen.height) {
startWindow(manifestJsonFile.splashscreen.width, manifestJsonFile.splashscreen.height);
return;
}

imageSize(imageFile, (error, dimensions) => {
if (error) {
console.log(`load splashscreen error:`);
console.error(error);

throw new Error(error.message);
}

startWindow(dimensions.width, dimensions.height)
});
}

Expand Down

0 comments on commit 0a80367

Please sign in to comment.