index.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. const {app, BrowserWindow, globalShortcut} = require("electron");
  2. const path = require("path");
  3. const url = require("url");
  4. const config = require("../compiled/minty.cfg.json");
  5. const paths = require("../compiled/paths.json");
  6. const exec = require("child_process").exec;
  7. var win, splash;
  8. function createWindow () {
  9. // Create the browser window.
  10. console.log(app.getAppPath());
  11. win = new BrowserWindow({width: 800, height: 600, icon: "./icon/minty.svg.png", useContentSize: true, show: false, webPreferences:{nodeIntegrationInWorker: true}});
  12. splash = new BrowserWindow({width: 400, height: 400 , transparent: true, useContentSize:true, center: true, frame: false, alwaysOnTop:true});
  13. splash.setMenu(null);
  14. win.setMenu(null);
  15. // and load the index.html of the app.
  16. splash.loadFile("./base/splash.html");
  17. win.loadFile("./base/index.html");
  18. if (config.developer) {
  19. win.toggleDevTools();
  20. globalShortcut.register('F7', function() {
  21. win.toggleDevTools();
  22. });
  23. globalShortcut.register('F5', function() {
  24. win.reload();
  25. });
  26. globalShortcut.register('F6', function() {
  27. exec("sh compile.sh " + paths.project_name, () => {console.log("Rebuilt the engine, press F5 to apply changes")});
  28. });
  29. }
  30. let fullscreen = false;
  31. globalShortcut.register('F11', () => {
  32. win.setFullScreen(!fullscreen);
  33. fullscreen = !fullscreen;
  34. })
  35. win.once("ready-to-show", () => {
  36. splash.close();
  37. win.show();
  38. });
  39. }
  40. app.on('ready', createWindow);