2017-05-17 06:26:46 +00:00
|
|
|
var $ = require('jQuery');
|
|
|
|
const remote = require('electron').remote
|
|
|
|
const shell = require('electron').shell
|
|
|
|
const path = require('path')
|
2017-05-18 05:49:28 +00:00
|
|
|
const os = require('os');
|
|
|
|
const ag = require(path.join(__dirname, 'assets', 'js', 'assetguard.js'))
|
|
|
|
|
|
|
|
function timestamp(){
|
|
|
|
let date = new Date();
|
|
|
|
const month = date.getMonth() < 9 ? '0'.concat((date.getMonth()+1)) : date.getMonth()
|
|
|
|
const day = date.getDate() < 10 ? '0'.concat(date.getDate()) : date.getDate();
|
|
|
|
let hour = date.getHours() > 12 ? date.getHours() - 12 : date.getHours();
|
|
|
|
hour = hour < 10 ? '0'.concat(hour) : hour
|
|
|
|
const min = date.getMinutes() < 10 ? '0'.concat(date.getMinutes()) : date.getMinutes();
|
|
|
|
const sec = date.getSeconds() < 10 ? '0'.concat(date.getSeconds()) : date.getSeconds();
|
|
|
|
|
2017-05-23 05:45:20 +00:00
|
|
|
return '[' + month + '/' + day + '/' + date.getFullYear() + ' ' + hour + ':' + min + ':' + sec + ']'
|
2017-05-18 05:49:28 +00:00
|
|
|
}
|
2017-05-17 06:26:46 +00:00
|
|
|
|
2017-05-17 09:03:09 +00:00
|
|
|
$(document).on('ready', function(){
|
|
|
|
$(".toggle-btn input[type=radio]").addClass("visuallyhidden");
|
|
|
|
$(".toggle-btn input[type=radio]").change(function() {
|
|
|
|
if($(this).attr("name")) {
|
|
|
|
$(this).parent().addClass("success").siblings().removeClass("success")
|
|
|
|
} else {
|
|
|
|
$(this).parent().toggleClass("success")
|
|
|
|
}
|
|
|
|
})
|
2017-05-23 05:45:20 +00:00
|
|
|
console.log = function(){
|
|
|
|
$('#launcher-log').append(timestamp() + ' [Log] - ' + Array.prototype.slice.call(arguments).join(' ') + os.EOL)
|
2017-05-18 05:49:28 +00:00
|
|
|
}
|
|
|
|
console.error = function(){
|
2017-05-23 05:45:20 +00:00
|
|
|
$('#launcher-log').append('<span class="log_debug">' + timestamp() + ' [Debug] - ' + Array.prototype.slice.call(arguments).join(' ') + "</span>" + os.EOL)
|
|
|
|
}
|
|
|
|
console.debug = function(){
|
|
|
|
$('#launcher-log').append('<span class="log_debug">' + timestamp() + ' [Error] - ' + Array.prototype.slice.call(arguments).join(' ') + "</span>" + os.EOL)
|
2017-05-18 05:49:28 +00:00
|
|
|
}
|
2017-05-17 21:44:46 +00:00
|
|
|
console.log('test')
|
2017-05-23 05:45:20 +00:00
|
|
|
console.debug('test')
|
2017-05-17 09:03:09 +00:00
|
|
|
})
|
|
|
|
|
2017-05-17 06:26:46 +00:00
|
|
|
/* Open web links in the user's default browser. */
|
|
|
|
$(document).on('click', 'a[href^="http"]', function(event) {
|
|
|
|
event.preventDefault();
|
2017-05-21 20:27:11 +00:00
|
|
|
testdownloads()
|
2017-05-21 05:06:01 +00:00
|
|
|
//console.log(os.homedir())
|
2017-05-21 20:27:11 +00:00
|
|
|
//shell.openExternal(this.href)
|
2017-05-17 06:26:46 +00:00
|
|
|
});
|
|
|
|
|
2017-05-21 05:06:01 +00:00
|
|
|
|
|
|
|
|
2017-05-17 06:26:46 +00:00
|
|
|
testdownloads = async function(){
|
|
|
|
const lp = require(path.join(__dirname, 'assets', 'js', 'launchprocess.js'))
|
|
|
|
const basePath = path.join(__dirname, '..', 'mcfiles')
|
|
|
|
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-21 05:06:01 +00:00
|
|
|
await ag.validateDistribution('WesterosCraft-1.11.2', basePath)
|
|
|
|
console.log('forge stuff done')
|
2017-05-21 22:06:48 +00: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 20:27:11 +00:00
|
|
|
//lp.launchMinecraft(versionData, basePath)
|
2017-05-17 06:26:46 +00: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-21 05:06:01 +00:00
|
|
|
break
|
2017-05-17 06:26:46 +00:00
|
|
|
case match[4]:
|
|
|
|
if(at === 4) ++at
|
|
|
|
break
|
|
|
|
default:
|
|
|
|
at = 0
|
|
|
|
}
|
|
|
|
if(at === 5) {
|
|
|
|
var window = remote.getCurrentWindow()
|
|
|
|
window.toggleDevTools()
|
|
|
|
at = 0
|
|
|
|
}
|
|
|
|
})
|