2017-04-22 14:20:23 -07:00
|
|
|
const {app, BrowserWindow} = require('electron')
|
|
|
|
const path = require('path')
|
|
|
|
const url = require('url')
|
|
|
|
|
|
|
|
// Keep a global reference of the window object, if you don't, the window will
|
|
|
|
// be closed automatically when the JavaScript object is garbage collected.
|
|
|
|
let win
|
|
|
|
|
|
|
|
function createWindow() {
|
2017-04-22 17:59:26 -07:00
|
|
|
win = new BrowserWindow({ width: 925, height: 500, icon: getPlatformIcon('WesterosSealSquare')})
|
2017-04-22 14:20:23 -07:00
|
|
|
|
|
|
|
win.loadURL(url.format({
|
|
|
|
pathname: path.join(__dirname, 'app', 'index.html'),
|
|
|
|
protocol: 'file:',
|
|
|
|
slashes: true
|
|
|
|
}))
|
|
|
|
|
|
|
|
win.setMenu(null)
|
|
|
|
|
2017-04-23 12:24:07 -07:00
|
|
|
//Code for testing, marked for removal one it's properly implemented.
|
2017-04-28 11:52:24 -07:00
|
|
|
/*const assetdl = require('./app/assets/js/assetdownload.js')
|
2017-04-24 15:48:02 -07:00
|
|
|
const basePath = path.join(__dirname, 'mcfiles')
|
|
|
|
const dataPromise = assetdl.parseVersionData('1.11.2', basePath)
|
|
|
|
dataPromise.then(function(data){
|
|
|
|
assetdl.downloadAssets(data, basePath)
|
2017-04-28 11:52:24 -07:00
|
|
|
assetdl.downloadClient(data, basePath)
|
|
|
|
assetdl.downloadLogConfig(data, basePath)
|
|
|
|
assetdl.downloadLibraries(data, basePath)
|
2017-04-28 00:59:28 -07:00
|
|
|
//require('./app/assets/js/launchprocess.js').launchMinecraft(data, basePath)
|
2017-04-28 11:52:24 -07:00
|
|
|
})*/
|
2017-04-23 12:24:07 -07:00
|
|
|
|
2017-04-22 14:20:23 -07:00
|
|
|
win.on('closed', () => {
|
|
|
|
win = null
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-04-22 17:59:26 -07:00
|
|
|
function getPlatformIcon(filename){
|
2017-04-24 15:48:02 -07:00
|
|
|
const opSys = process.platform
|
|
|
|
if (opSys === 'darwin') {
|
2017-04-22 17:59:26 -07:00
|
|
|
filename = filename + '.icns'
|
2017-04-24 15:48:02 -07:00
|
|
|
} else if (opSys === 'win32') {
|
2017-04-22 17:59:26 -07:00
|
|
|
filename = filename + '.ico'
|
|
|
|
} else {
|
|
|
|
filename = filename + '.png'
|
|
|
|
}
|
|
|
|
|
|
|
|
return path.join(__dirname, 'app', 'assets', 'images', filename)
|
|
|
|
}
|
|
|
|
|
2017-04-22 14:20:23 -07:00
|
|
|
app.on('ready', createWindow);
|
|
|
|
|
|
|
|
app.on('window-all-closed', () => {
|
|
|
|
// On macOS it is common for applications and their menu bar
|
|
|
|
// to stay active until the user quits explicitly with Cmd + Q
|
|
|
|
if (process.platform !== 'darwin') {
|
|
|
|
app.quit()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
app.on('activate', () => {
|
|
|
|
// On macOS it's common to re-create a window in the app when the
|
|
|
|
// dock icon is clicked and there are no other windows open.
|
|
|
|
if (win === null) {
|
|
|
|
createWindow()
|
|
|
|
}
|
|
|
|
})
|