XVoxel-ASync/main.js

50 lines
1017 B
JavaScript

/* Dependencies */
const electron = require("electron");
const path = require("node:path");
/* Initialization */
let gameWindow;
/* Functions */
function createWindow() {
if (gameWindow) return;
gameWindow = new electron.BrowserWindow({
"width": 800,
"height": 450,
"frame": false,
"transparent": true,
"backgroundColor": "#FFFFFFFF",
"webPreferences": {
"preload": path.join(__dirname, "preload.js"),
"webgl": true
},
"title": "XVoxel",
"icon": path.join("assets", "images", "xvoxel.png"),
"show": false
});
gameWindow.loadFile(path.join(__dirname, "index.html"));
gameWindow.once("ready-to-show", function () {
gameWindow.show();
});
}
/* Events */
electron.app.on("ready", function (event) {
createWindow();
electron.app.on("activate", function () {
if (electron.BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
electron.app.on("window-all-closed", function () {
if (process.platform !== "darwin") electron.app.quit();
});