index.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. const {app, BrowserWindow} = require('electron')
  2. const path = require('path')
  3. const url = require('url')
  4. // Keep a global reference of the window object, if you don't, the window will
  5. // be closed automatically when the JavaScript object is garbage collected.
  6. let win
  7. function createWindow() {
  8. win = new BrowserWindow({ width: 925, height: 500, icon: getPlatformIcon('WesterosSealSquare')})
  9. win.loadURL(url.format({
  10. pathname: path.join(__dirname, 'app', 'index.html'),
  11. protocol: 'file:',
  12. slashes: true
  13. }))
  14. win.setMenu(null)
  15. /*//Code for testing, marked for removal one it's properly implemented.
  16. const assetdl = require('./app/assets/js/assetdownload.js')
  17. const basePath = path.join(__dirname, 'mcfiles')
  18. const dataPromise = assetdl.parseVersionData('1.11.2', basePath)
  19. dataPromise.then(function(data){
  20. assetdl.downloadAssets(data, basePath)
  21. //assetdl.downloadAssets(data, basePath)
  22. //assetdl.downloadClient(data, basePath)
  23. //assetdl.downloadLogConfig(data, basePath)
  24. //assetdl.downloadLibraries(data, basePath)
  25. //require('./app/assets/js/launchprocess.js').launchMinecraft(data, basePath)
  26. })*/
  27. win.on('closed', () => {
  28. win = null
  29. })
  30. }
  31. function getPlatformIcon(filename){
  32. const opSys = process.platform
  33. if (opSys === 'darwin') {
  34. filename = filename + '.icns'
  35. } else if (opSys === 'win32') {
  36. filename = filename + '.ico'
  37. } else {
  38. filename = filename + '.png'
  39. }
  40. return path.join(__dirname, 'app', 'assets', 'images', filename)
  41. }
  42. app.on('ready', createWindow);
  43. app.on('window-all-closed', () => {
  44. // On macOS it is common for applications and their menu bar
  45. // to stay active until the user quits explicitly with Cmd + Q
  46. if (process.platform !== 'darwin') {
  47. app.quit()
  48. }
  49. })
  50. app.on('activate', () => {
  51. // On macOS it's common to re-create a window in the app when the
  52. // dock icon is clicked and there are no other windows open.
  53. if (win === null) {
  54. createWindow()
  55. }
  56. })