2017-08-26 23:24:04 -07:00
|
|
|
const $ = require('jquery');
|
2017-05-16 23:26:46 -07:00
|
|
|
const remote = require('electron').remote
|
|
|
|
const shell = require('electron').shell
|
|
|
|
const path = require('path')
|
2017-05-17 22:49:28 -07:00
|
|
|
const os = require('os');
|
|
|
|
const ag = require(path.join(__dirname, 'assets', 'js', 'assetguard.js'))
|
|
|
|
|
2017-05-17 02:03:09 -07:00
|
|
|
$(document).on('ready', function(){
|
2017-08-26 23:24:04 -07:00
|
|
|
console.log('okay');
|
2017-05-17 02:03:09 -07:00
|
|
|
})
|
|
|
|
|
2017-08-26 23:24:04 -07:00
|
|
|
document.onreadystatechange = function () {
|
|
|
|
if (document.readyState == "complete") {
|
|
|
|
|
|
|
|
document.getElementById("frame_btn_close").addEventListener("click", function (e) {
|
|
|
|
const window = remote.getCurrentWindow()
|
|
|
|
window.close()
|
|
|
|
})
|
|
|
|
|
|
|
|
document.getElementById("frame_btn_restoredown").addEventListener("click", function (e) {
|
|
|
|
const window = remote.getCurrentWindow()
|
|
|
|
if(window.isMaximized()){
|
|
|
|
window.unmaximize();
|
|
|
|
} else {
|
|
|
|
window.maximize()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
document.getElementById("frame_btn_minimize").addEventListener("click", function (e) {
|
|
|
|
const window = remote.getCurrentWindow()
|
|
|
|
window.minimize()
|
|
|
|
})
|
|
|
|
|
2017-08-29 13:40:42 -07:00
|
|
|
/*document.getElementById("test_btn").addEventListener('click', function(e){
|
2017-08-27 00:49:03 -07:00
|
|
|
console.log('testing')
|
|
|
|
testdownloads()
|
2017-08-29 13:40:42 -07:00
|
|
|
})*/
|
2017-08-27 00:49:03 -07:00
|
|
|
|
2017-08-26 23:24:04 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-16 23:26:46 -07:00
|
|
|
/* Open web links in the user's default browser. */
|
|
|
|
$(document).on('click', 'a[href^="http"]', function(event) {
|
|
|
|
event.preventDefault();
|
2017-05-21 13:27:11 -07:00
|
|
|
testdownloads()
|
2017-05-20 22:06:01 -07:00
|
|
|
//console.log(os.homedir())
|
2017-05-21 13:27:11 -07:00
|
|
|
//shell.openExternal(this.href)
|
2017-08-26 23:24:04 -07:00
|
|
|
})
|
2017-05-20 22:06:01 -07:00
|
|
|
|
2017-05-16 23:26:46 -07:00
|
|
|
testdownloads = async function(){
|
|
|
|
const lp = require(path.join(__dirname, 'assets', 'js', 'launchprocess.js'))
|
2017-08-26 22:13:48 -07:00
|
|
|
const basePath = path.join(__dirname, '..', 'target', 'test', 'mcfiles')
|
2017-05-16 23:26:46 -07:00
|
|
|
let versionData = await ag.loadVersionData('1.11.2', basePath)
|
|
|
|
await ag.validateAssets(versionData, basePath)
|
|
|
|
console.log('assets done')
|
|
|
|
await ag.validateLibraries(versionData, basePath)
|
|
|
|
console.log('libs done')
|
|
|
|
await ag.validateMiscellaneous(versionData, basePath)
|
|
|
|
console.log('files done')
|
2017-05-20 22:06:01 -07:00
|
|
|
await ag.validateDistribution('WesterosCraft-1.11.2', basePath)
|
|
|
|
console.log('forge stuff done')
|
2017-05-21 15:06:48 -07:00
|
|
|
ag.instance.on('dlcomplete', async function(){
|
|
|
|
let forgeData = await ag.loadForgeData('WesterosCraft-1.11.2', basePath)
|
|
|
|
lp.launchMinecraft(versionData, forgeData, basePath)
|
2017-05-21 13:27:11 -07:00
|
|
|
//lp.launchMinecraft(versionData, basePath)
|
2017-05-16 23:26:46 -07:00
|
|
|
})
|
|
|
|
ag.processDlQueues()
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Opens DevTools window if you type "wcdev" in sequence.
|
|
|
|
This will crash the program if you are using multiple
|
|
|
|
DevTools, for example the chrome debugger in VS Code. */
|
|
|
|
const match = [87, 67, 68, 69, 86]
|
|
|
|
let at = 0;
|
|
|
|
|
|
|
|
document.addEventListener('keydown', function (e) {
|
|
|
|
switch(e.keyCode){
|
|
|
|
case match[0]:
|
|
|
|
if(at === 0) ++at
|
|
|
|
break
|
|
|
|
case match[1]:
|
|
|
|
if(at === 1) ++at
|
|
|
|
break
|
|
|
|
case match[2]:
|
|
|
|
if(at === 2) ++at
|
|
|
|
break
|
|
|
|
case match[3]:
|
|
|
|
if(at === 3) ++at
|
2017-05-20 22:06:01 -07:00
|
|
|
break
|
2017-05-16 23:26:46 -07:00
|
|
|
case match[4]:
|
|
|
|
if(at === 4) ++at
|
|
|
|
break
|
|
|
|
default:
|
|
|
|
at = 0
|
|
|
|
}
|
|
|
|
if(at === 5) {
|
|
|
|
var window = remote.getCurrentWindow()
|
|
|
|
window.toggleDevTools()
|
|
|
|
at = 0
|
|
|
|
}
|
|
|
|
})
|