Added progress tracking to landing page. Fixed exclusions when extracting native files, fixed minor issue with config manager, optimizations and improvements to assetguard.
This commit is contained in:
parent
5352239f91
commit
dd9e1418c8
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
|||||||
/.vs/
|
/.vs/
|
||||||
/.vscode/
|
/.vscode/
|
||||||
/target/
|
/target/
|
||||||
|
/logs/
|
@ -9,11 +9,24 @@ body, html, div {
|
|||||||
padding: 0px;
|
padding: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Reset p presets. */
|
||||||
|
p {
|
||||||
|
-webkit-margin-before: 0em;
|
||||||
|
-webkit-margin-after: 0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*body {
|
/*body {
|
||||||
background: url('./../images/backgrounds/0.jpg') no-repeat center center fixed;
|
background: url('./../images/backgrounds/0.jpg') no-repeat center center fixed;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* frame.ejs *
|
||||||
|
* *
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
#frame_bar {
|
#frame_bar {
|
||||||
-webkit-app-region: drag;
|
-webkit-app-region: drag;
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
@ -21,6 +34,8 @@ body, html, div {
|
|||||||
min-height: 22px;
|
min-height: 22px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
position: relative;
|
||||||
|
z-index: 10000;
|
||||||
}
|
}
|
||||||
|
|
||||||
#frame_btn_dock {
|
#frame_btn_dock {
|
||||||
@ -65,6 +80,93 @@ body, html, div {
|
|||||||
background-color: #D6FFA6;
|
background-color: #D6FFA6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* login.ejs *
|
||||||
|
* *
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#login_main {
|
||||||
|
position: relative;
|
||||||
|
height: calc(100% - 22px);
|
||||||
|
width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
#login_filter {
|
||||||
|
height: calc(100% - 22px);
|
||||||
|
width: 100%;
|
||||||
|
z-index: 9000;
|
||||||
|
position: absolute;
|
||||||
|
filter: blur(8px) contrast(0.9) brightness(1.0);
|
||||||
|
background: url('./../images/backgrounds/0.jpg') no-repeat center center fixed;
|
||||||
|
transform: scale(1.2);
|
||||||
|
background-size: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
#login_container {
|
||||||
|
height: 100%;
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 9001;
|
||||||
|
}
|
||||||
|
|
||||||
|
#login_content {
|
||||||
|
width: 400px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#login_image_seal {
|
||||||
|
height: 150px;
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login_section {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Adds padding between flex children */
|
||||||
|
.login_section > * {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.login_section > *:last-child {
|
||||||
|
margin-bottom: 0px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#login_header_text {
|
||||||
|
font-family: 'Avenir Book';
|
||||||
|
color: #ded8cb;
|
||||||
|
}
|
||||||
|
|
||||||
|
#login_links a {
|
||||||
|
color: #5a534b;
|
||||||
|
font-family: 'Avenir Book';
|
||||||
|
font-size: 10px;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#login_information input {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
border-top: 2px solid #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*#login_information input[type='password'] {
|
||||||
|
letter-spacing: 0.3em;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* index.ejs *
|
||||||
|
* *
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
#main {
|
#main {
|
||||||
height: calc(100% - 22px);
|
height: calc(100% - 22px);
|
||||||
}
|
}
|
||||||
@ -132,6 +234,13 @@ body, html, div {
|
|||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#main > #lower > #right #launch_content {
|
||||||
|
position: relative;
|
||||||
|
top: 25px;
|
||||||
|
display: inline-flex;
|
||||||
|
line-height: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
#image_seal {
|
#image_seal {
|
||||||
height: 70px;
|
height: 70px;
|
||||||
width: auto;
|
width: auto;
|
||||||
@ -242,6 +351,7 @@ body, html, div {
|
|||||||
color: white;
|
color: white;
|
||||||
font-family: 'Avenir Book';
|
font-family: 'Avenir Book';
|
||||||
font-size: 9px;
|
font-size: 9px;
|
||||||
|
letter-spacing: 1px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-shadow: 0px 0px 0px #bebcbb;
|
text-shadow: 0px 0px 0px #bebcbb;
|
||||||
}
|
}
|
||||||
@ -290,3 +400,42 @@ body, html, div {
|
|||||||
line-height: 30px;
|
line-height: 30px;
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#launch_button {
|
||||||
|
font-family: 'Avenir Book';
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 900;
|
||||||
|
letter-spacing: 2px;
|
||||||
|
text-shadow: 0px 0px 0px #bebcbb;
|
||||||
|
font-size: 20px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#launch_details {
|
||||||
|
position: relative;
|
||||||
|
top: 25px;
|
||||||
|
/*display: flex;*/
|
||||||
|
display: none;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
#launch_progress[value] {
|
||||||
|
height: 2px;
|
||||||
|
width: 265px;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#launch_progress[value]::-webkit-progress-bar {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
#launch_progress[value]::-webkit-progress-value {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#launch_details_text {
|
||||||
|
font-size: 5px;
|
||||||
|
}
|
@ -410,15 +410,12 @@ function _finalizeForgeAsset(asset, basePath){
|
|||||||
*/
|
*/
|
||||||
function startAsyncProcess(identifier, limit = 5){
|
function startAsyncProcess(identifier, limit = 5){
|
||||||
let win = remote.getCurrentWindow()
|
let win = remote.getCurrentWindow()
|
||||||
|
|
||||||
let acc = 0
|
let acc = 0
|
||||||
const concurrentDlTracker = instance[identifier]
|
const concurrentDlTracker = instance[identifier]
|
||||||
const concurrentDlQueue = concurrentDlTracker.dlqueue.slice(0)
|
const concurrentDlQueue = concurrentDlTracker.dlqueue.slice(0)
|
||||||
console.log(concurrentDlQueue);
|
|
||||||
if(concurrentDlQueue.length === 0){
|
if(concurrentDlQueue.length === 0){
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
console.log(concurrentDlQueue)
|
|
||||||
async.eachLimit(concurrentDlQueue, limit, function(asset, cb){
|
async.eachLimit(concurrentDlQueue, limit, function(asset, cb){
|
||||||
let count = 0;
|
let count = 0;
|
||||||
mkpath.sync(path.join(asset.to, ".."))
|
mkpath.sync(path.join(asset.to, ".."))
|
||||||
@ -441,6 +438,7 @@ function startAsyncProcess(identifier, limit = 5){
|
|||||||
console.log('Failed to download ' + asset.from + '. Response code', resp.statusCode)
|
console.log('Failed to download ' + asset.from + '. Response code', resp.statusCode)
|
||||||
instance.progress += asset.size*1
|
instance.progress += asset.size*1
|
||||||
win.setProgressBar(instance.progress/instance.totaldlsize)
|
win.setProgressBar(instance.progress/instance.totaldlsize)
|
||||||
|
instance.emit('totaldlprogress', {acc: instance.progress, total: instance.totaldlsize})
|
||||||
cb()
|
cb()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -451,6 +449,7 @@ function startAsyncProcess(identifier, limit = 5){
|
|||||||
instance.emit(identifier + 'dlprogress', acc)
|
instance.emit(identifier + 'dlprogress', acc)
|
||||||
//console.log(identifier + ' Progress', acc/instance[identifier].dlsize)
|
//console.log(identifier + ' Progress', acc/instance[identifier].dlsize)
|
||||||
win.setProgressBar(instance.progress/instance.totaldlsize)
|
win.setProgressBar(instance.progress/instance.totaldlsize)
|
||||||
|
instance.emit('totaldlprogress', {acc: instance.progress, total: instance.totaldlsize})
|
||||||
})
|
})
|
||||||
}, function(err){
|
}, function(err){
|
||||||
if(err){
|
if(err){
|
||||||
@ -592,7 +591,6 @@ function _assetChainValidateAssets(versionData, basePath, indexData){
|
|||||||
cb()
|
cb()
|
||||||
}, function(err){
|
}, function(err){
|
||||||
instance.assets = new DLTracker(assetDlQueue, dlSize)
|
instance.assets = new DLTracker(assetDlQueue, dlSize)
|
||||||
instance.totaldlsize += dlSize*1
|
|
||||||
fulfill()
|
fulfill()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -630,7 +628,6 @@ function validateLibraries(versionData, basePath){
|
|||||||
cb()
|
cb()
|
||||||
}, function(err){
|
}, function(err){
|
||||||
instance.libraries = new DLTracker(libDlQueue, dlSize)
|
instance.libraries = new DLTracker(libDlQueue, dlSize)
|
||||||
instance.totaldlsize += dlSize*1
|
|
||||||
fulfill()
|
fulfill()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -697,7 +694,7 @@ function validateLogConfig(versionData, basePath){
|
|||||||
|
|
||||||
if(!_validateLocal(logConfig.to, 'sha1', logConfig.hash)){
|
if(!_validateLocal(logConfig.to, 'sha1', logConfig.hash)){
|
||||||
instance.files.dlqueue.push(logConfig)
|
instance.files.dlqueue.push(logConfig)
|
||||||
instance.files.dlsize += client.size*1
|
instance.files.dlsize += logConfig.size*1
|
||||||
fulfill()
|
fulfill()
|
||||||
} else {
|
} else {
|
||||||
fulfill()
|
fulfill()
|
||||||
@ -735,7 +732,6 @@ function validateDistribution(serverpackid, basePath){
|
|||||||
_finalizeForgeAsset(asset, basePath)
|
_finalizeForgeAsset(asset, basePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
instance.totaldlsize += instance.forge.dlsize*1
|
|
||||||
fulfill(serv)
|
fulfill(serv)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -863,6 +859,13 @@ function processDlQueues(identifiers = [{id:'assets', limit:20}, {id:'libraries'
|
|||||||
|
|
||||||
let shouldFire = true
|
let shouldFire = true
|
||||||
|
|
||||||
|
// Assign global dltracking variables.
|
||||||
|
instance.totaldlsize = 0
|
||||||
|
instance.progress = 0
|
||||||
|
for(let i=0; i<identifiers.length; i++){
|
||||||
|
instance.totaldlsize += instance[identifiers[i].id].dlsize
|
||||||
|
}
|
||||||
|
|
||||||
for(let i=0; i<identifiers.length; i++){
|
for(let i=0; i<identifiers.length; i++){
|
||||||
let iden = identifiers[i]
|
let iden = identifiers[i]
|
||||||
let r = startAsyncProcess(iden.id, iden.limit)
|
let r = startAsyncProcess(iden.id, iden.limit)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
const mkpath = require('mkdirp')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const uuidV4 = require('uuid/v4')
|
const uuidV4 = require('uuid/v4')
|
||||||
|
|
||||||
@ -28,6 +29,7 @@ class ConfigManager {
|
|||||||
|
|
||||||
load(){
|
load(){
|
||||||
if(!fs.existsSync(this.path)){
|
if(!fs.existsSync(this.path)){
|
||||||
|
mkpath.sync(path.join(this.path, '..'))
|
||||||
this._generateDefault()
|
this._generateDefault()
|
||||||
} else {
|
} else {
|
||||||
this.config = JSON.parse(fs.readFileSync(this.path, 'UTF-8'))
|
this.config = JSON.parse(fs.readFileSync(this.path, 'UTF-8'))
|
||||||
|
@ -236,7 +236,7 @@ class ProcessBuilder {
|
|||||||
|
|
||||||
// Exclude noted files.
|
// Exclude noted files.
|
||||||
exclusionArr.forEach(function(exclusion){
|
exclusionArr.forEach(function(exclusion){
|
||||||
if(exclusion.indexOf(fileName) > -1){
|
if(fileName.indexOf(exclusion) > -1){
|
||||||
shouldExclude = true
|
shouldExclude = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -37,11 +37,14 @@ document.onreadystatechange = function () {
|
|||||||
window.minimize()
|
window.minimize()
|
||||||
})
|
})
|
||||||
|
|
||||||
document.getElementById("menu_button").addEventListener('click', function(e){
|
// Bind launch button
|
||||||
console.log('testing')
|
document.getElementById("launch_button").addEventListener('click', function(e){
|
||||||
|
console.log('Launching game..')
|
||||||
testdownloads()
|
testdownloads()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Bind progress bar length to length of bot wrapper
|
||||||
|
document.getElementById("launch_progress").style.width = document.getElementById("launch_content").getBoundingClientRect().width
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,26 +56,63 @@ $(document).on('click', 'a[href^="http"]', function(event) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
testdownloads = async function(){
|
testdownloads = async function(){
|
||||||
//const lp = require(path.join(__dirname, 'assets', 'js', 'launchprocess.js'))
|
const details = document.getElementById("launch_details")
|
||||||
let versionData = await ag.loadVersionData('1.11.2', GAME_DIRECTORY)
|
const progress = document.getElementById("launch_progress")
|
||||||
|
const det_text = document.getElementById("launch_details_text")
|
||||||
|
|
||||||
|
det_text.innerHTML = 'Please wait..'
|
||||||
|
progress.setAttribute('max', '100')
|
||||||
|
details.style.display = 'flex'
|
||||||
|
|
||||||
|
det_text.innerHTML = 'Loading version information..'
|
||||||
|
const versionData = await ag.loadVersionData('1.11.2', GAME_DIRECTORY)
|
||||||
|
progress.setAttribute('value', 20)
|
||||||
|
|
||||||
|
det_text.innerHTML = 'Validating asset integrity..'
|
||||||
await ag.validateAssets(versionData, GAME_DIRECTORY)
|
await ag.validateAssets(versionData, GAME_DIRECTORY)
|
||||||
|
progress.setAttribute('value', 40)
|
||||||
console.log('assets done')
|
console.log('assets done')
|
||||||
|
|
||||||
|
det_text.innerHTML = 'Validating library integrity..'
|
||||||
await ag.validateLibraries(versionData, GAME_DIRECTORY)
|
await ag.validateLibraries(versionData, GAME_DIRECTORY)
|
||||||
|
progress.setAttribute('value', 60)
|
||||||
console.log('libs done')
|
console.log('libs done')
|
||||||
|
|
||||||
|
det_text.innerHTML = 'Validating miscellaneous file integrity..'
|
||||||
await ag.validateMiscellaneous(versionData, GAME_DIRECTORY)
|
await ag.validateMiscellaneous(versionData, GAME_DIRECTORY)
|
||||||
|
progress.setAttribute('value', 80)
|
||||||
console.log('files done')
|
console.log('files done')
|
||||||
|
|
||||||
|
det_text.innerHTML = 'Validating server distribution files..'
|
||||||
const serv = await ag.validateDistribution('WesterosCraft-1.11.2', GAME_DIRECTORY)
|
const serv = await ag.validateDistribution('WesterosCraft-1.11.2', GAME_DIRECTORY)
|
||||||
|
progress.setAttribute('value', 100)
|
||||||
console.log('forge stuff done')
|
console.log('forge stuff done')
|
||||||
|
|
||||||
|
det_text.innerHTML = 'Downloading files..'
|
||||||
|
ag.instance.on('totaldlprogress', function(data){
|
||||||
|
progress.setAttribute('max', data.total)
|
||||||
|
progress.setAttribute('value', data.acc)
|
||||||
|
})
|
||||||
|
|
||||||
ag.instance.on('dlcomplete', async function(){
|
ag.instance.on('dlcomplete', async function(){
|
||||||
|
det_text.innerHTML = 'Preparing to launch..'
|
||||||
const forgeData = await ag.loadForgeData('WesterosCraft-1.11.2', GAME_DIRECTORY)
|
const forgeData = await ag.loadForgeData('WesterosCraft-1.11.2', GAME_DIRECTORY)
|
||||||
const authUser = await mojang.auth('EMAIL', 'PASS', DEFAULT_CONFIG.getClientToken(), {
|
const authUser = await mojang.auth('EMAIL', 'PASS', DEFAULT_CONFIG.getClientToken(), {
|
||||||
name: 'Minecraft',
|
name: 'Minecraft',
|
||||||
version: 1
|
version: 1
|
||||||
})
|
})
|
||||||
//lp.launchMinecraft(versionData, forgeData, GAME_DIRECTORY)
|
|
||||||
//lp.launchMinecraft(versionData, GAME_DIRECTORY)
|
|
||||||
let pb = new ProcessBuilder(GAME_DIRECTORY, serv, versionData, forgeData, authUser)
|
let pb = new ProcessBuilder(GAME_DIRECTORY, serv, versionData, forgeData, authUser)
|
||||||
const proc = pb.build()
|
det_text.innerHTML = 'Launching game..'
|
||||||
|
let proc;
|
||||||
|
try{
|
||||||
|
proc = pb.build()
|
||||||
|
det_text.innerHTML = 'Done. Enjoy the server!'
|
||||||
|
} catch(err) {
|
||||||
|
det_text.innerHTML = 'Error while launching: ' + err.message;
|
||||||
|
}
|
||||||
|
setTimeout(function(){
|
||||||
|
details.style.display = 'none'
|
||||||
|
}, 5000)
|
||||||
})
|
})
|
||||||
ag.processDlQueues()
|
ag.processDlQueues()
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="right">
|
<div id="right">
|
||||||
|
<div class="bot_wrapper">
|
||||||
|
<div id="launch_content">
|
||||||
|
<button id="launch_button">PLAY</button>
|
||||||
|
<div class="bot_divider"></div>
|
||||||
|
<!-- Span until we implement the real selection -->
|
||||||
|
<span class="bot_label">• Westeroscraft Production Server</span>
|
||||||
|
</div>
|
||||||
|
<div id="launch_details">
|
||||||
|
<progress id="launch_progress" value="22" max="100"></progress>
|
||||||
|
<span id="launch_details_text" class="bot_label">Please wait..</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user