diff --git a/app/assets/js/assetguard.js b/app/assets/js/assetguard.js index f6b2a4e..b025006 100644 --- a/app/assets/js/assetguard.js +++ b/app/assets/js/assetguard.js @@ -29,7 +29,8 @@ const mkpath = require('mkdirp'); const async = require('async') const crypto = require('crypto') const AdmZip = require('adm-zip') -const EventEmitter = require('events'); +const child_process = require('child_process') +const EventEmitter = require('events') const {remote} = require('electron') // Classes @@ -269,6 +270,21 @@ function _validateForgeJar(buf, checksums){ return true } +function _extractPackXZ(filePath){ + const libPath = path.join(__dirname, '..', 'libraries', 'java', 'PackXZExtract.jar') + console.log(libPath) + const child = child_process.spawn('C:\\Program Files\\Java\\jre1.8.0_131\\bin\\javaw.exe', ['-jar', libPath, '-packxz', filePath]) + child.stdout.on('data', (data) => { + console.log('minecraft:', data.toString('utf8')) + }) + child.stderr.on('data', (data) => { + console.log('minecraft:', data.toString('utf8')) + }) + child.on('close', (code, signal) => { + console.log('exited with code', code) + }) +} + /** * Initiate an async download process for an AssetGuard DLTracker. * @@ -594,5 +610,6 @@ module.exports = { processDlQueues, instance, Asset, - Library + Library, + _extractPackXZ } \ No newline at end of file diff --git a/app/assets/js/script.js b/app/assets/js/script.js index 290f67e..a23c7ad 100644 --- a/app/assets/js/script.js +++ b/app/assets/js/script.js @@ -2,6 +2,20 @@ var $ = require('jQuery'); const remote = require('electron').remote const shell = require('electron').shell const path = require('path') +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(); + + return os.EOL + '[' + month + '/' + day + '/' + date.getFullYear() + ' ' + hour + ':' + min + ':' + sec + ']' +} $(document).on('ready', function(){ $(".toggle-btn input[type=radio]").addClass("visuallyhidden"); @@ -12,27 +26,25 @@ $(document).on('ready', function(){ $(this).parent().toggleClass("success") } }) - process.stdout.on('data', (data) => { - $('#launcher-log').append(data.toString('utf8')) - //console.log('minecraft:', data.toString('utf8')) - }) - process.stderr.on('data', (data) => { - $('#launcher-log').append(data.toString('utf8')) - //console.log('minecraft:', data.toString('utf8')) - }) + /*console.log = function(){ + $('#launcher-log').append(timestamp() + ' [Log] - ' + Array.prototype.slice.call(arguments).join(' ')) + } + console.error = function(){ + $('#launcher-log').append(timestamp() + ' [Error] - ' + Array.prototype.slice.call(arguments).join(' ')) + } console.log('test') - console.debug('test') + //console.debug('test')*/ }) /* Open web links in the user's default browser. */ $(document).on('click', 'a[href^="http"]', function(event) { event.preventDefault(); - testdownloads() - //shell.openExternal(this.href) + //ag._extractPackXZ(path.join(__dirname, '..', 'mcfiles', 'scala-continuations-library_2.11-1.0.2.jar.pack.xz')) + //testdownloads() + shell.openExternal(this.href) }); testdownloads = async function(){ - const ag = require(path.join(__dirname, 'assets', 'js', 'assetguard.js')) 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) diff --git a/app/assets/libraries/java/PackXZExtract.jar b/app/assets/libraries/java/PackXZExtract.jar new file mode 100644 index 0000000..5994c15 Binary files /dev/null and b/app/assets/libraries/java/PackXZExtract.jar differ