import { app, BrowserWindow, ipcMain, screen } from 'electron'

/**
 * Set `__static` path to static files in production
 * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
 */
if (process.env.NODE_ENV !== 'development') {
  global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
}

let mainWindow
const winURL = process.env.NODE_ENV === 'development'
  ? `http://localhost:9080`
  : `file://${__dirname}/index.html`

function createWindow () {
  /**
   * Initial window options
   */
  let screenSize = screen.getPrimaryDisplay().size;
  mainWindow = new BrowserWindow({
    height: screenSize.height,
    width: screenSize.width,
    useContentSize: true
  })

  mainWindow.webContents.on('dom-ready', () => {
    mainWindow.maximize();
  })

  mainWindow.webContents.on('did-finish-load', () => {
    mainWindow.setTitle("LC3Tools v" + autoUpdater.currentVersion);
    //mainWindow.webContents.openDevTools();
  });

  mainWindow.loadURL(winURL)

  mainWindow.on('closed', () => {
    mainWindow = null
  })
}

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

app.on('activate', () => {
  if (mainWindow === null) {
    createWindow()
  }
})

/**
 * Auto Updater
 *
 * Uncomment the following code below and install `electron-updater` to
 * support auto updating. Code Signing with a valid certificate is required.
 * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-electron-builder.html#auto-updating
 */
 
import { autoUpdater, AppUpdater } from 'electron-updater'
 
app.on('ready', () => {
  createWindow();
  if (process.env.NODE_ENV === 'production') {
    autoUpdater.logger = require("electron-log")
    autoUpdater.logger.transports.file.level = "debug"
 
    autoUpdater.autoDownload = false;
    autoUpdater.checkForUpdates();
  }
})
 
ipcMain.on('auto_updater', (event, text) => {
  if (text === "update_confirmed") {
    autoUpdater.downloadUpdate();
  }
})
 
autoUpdater.on('update-available', (info) => {
  mainWindow.webContents.send('auto_updater', "update_available")
})
 
autoUpdater.on('error', (err) => {
  mainWindow.webContents.send('auto_updater', err);
})
 
autoUpdater.on('download-progress', (progress) => {
  mainWindow.webContents.send('auto_updater', "download_progress", progress);
})
 
autoUpdater.on('update-downloaded', (info) => {
  autoUpdater.quitAndInstall();
})
@@ -37,16 +37,22 @@
 , screen
+, Menu
  %7D from 
@@ -1010,16 +1010,17 @@
 (winURL)
+;
 %0A%0A  main
@@ -1073,16 +1073,888 @@
 ull%0A  %7D)
+;%0A%0A  var template = %5B%7B%0A    label: %22Application%22,%0A    submenu: %5B%0A      %7B label: %22About Application%22, selector: %22orderFrontStandardAboutPanel:%22 %7D,%0A      %7B type: %22separator%22 %7D,%0A      %7B label: %22Quit%22, accelerator: %22Command+Q%22, click: function() %7B app.quit(); %7D%7D%0A    %5D%7D, %7B%0A      label: %22Edit%22,%0A      submenu: %5B%0A        %7B label: %22Undo%22, accelerator: %22CmdOrCtrl+Z%22, selector: %22undo:%22 %7D,%0A        %7B label: %22Redo%22, accelerator: %22Shift+CmdOrCtrl+Z%22, selector: %22redo:%22 %7D,%0A        %7B type: %22separator%22 %7D,%0A        %7B label: %22Cut%22, accelerator: %22CmdOrCtrl+X%22, selector: %22cut:%22 %7D,%0A        %7B label: %22Copy%22, accelerator: %22CmdOrCtrl+C%22, selector: %22copy:%22 %7D,%0A        %7B label: %22Paste%22, accelerator: %22CmdOrCtrl+V%22, selector: %22paste:%22 %7D,%0A        %7B label: %22Select All%22, accelerator: %22CmdOrCtrl+A%22, selector: %22selectAll:%22 %7D%0A      %5D%7D%0A  %5D;%0A%0A  Menu.setApplicationMenu(Menu.buildFromTemplate(template));
 %0A%7D%0A%0Aapp.

Add menubar