Improving application startup flow.
Major improvements to distribution index loading. Implemented new transitional UI for startup. If **no** distribution index is loaded on startup, completion of startup will be prevented and the user will be shown a message displaying the issue. Launch errors are now shown as overlays. Many more minor fixes and enhancements.
This commit is contained in:
@@ -418,13 +418,30 @@ function dlAsync(login = true){
|
||||
aEx.on('message', (m) => {
|
||||
if(m.content === 'validateDistribution'){
|
||||
|
||||
setLaunchPercentage(20, 100)
|
||||
serv = m.result
|
||||
console.log('Forge Validation Complete.')
|
||||
if(m.result instanceof Error){
|
||||
|
||||
// Begin version load.
|
||||
setLaunchDetails('Loading version information..')
|
||||
aEx.send({task: 0, content: 'loadVersionData', argsArr: [serv.mc_version]})
|
||||
setOverlayContent(
|
||||
'Fatal Error',
|
||||
'Could not load a copy of the distribution index. See the console for more details.',
|
||||
'Okay'
|
||||
)
|
||||
setOverlayHandler(null)
|
||||
|
||||
toggleOverlay(true)
|
||||
toggleLaunchArea(false)
|
||||
|
||||
// Disconnect from AssetExec
|
||||
aEx.disconnect()
|
||||
|
||||
} else {
|
||||
setLaunchPercentage(20, 100)
|
||||
serv = m.result
|
||||
console.log('Forge Validation Complete.')
|
||||
|
||||
// Begin version load.
|
||||
setLaunchDetails('Loading version information..')
|
||||
aEx.send({task: 0, content: 'loadVersionData', argsArr: [serv.mc_version]})
|
||||
}
|
||||
|
||||
} else if(m.content === 'loadVersionData'){
|
||||
|
||||
@@ -491,16 +508,30 @@ function dlAsync(login = true){
|
||||
}, 750)
|
||||
|
||||
} else if(m.task === 0.9) {
|
||||
|
||||
console.error(m.err)
|
||||
|
||||
if(m.err.code === 'ENOENT'){
|
||||
setLaunchDetails('Download error.. internet?')
|
||||
setOverlayContent(
|
||||
'Download Error',
|
||||
'Could not connect to the file server. Ensure that you are connected to the internet and try again.',
|
||||
'Okay'
|
||||
)
|
||||
setOverlayHandler(null)
|
||||
} else {
|
||||
setLaunchDetails('Download error.. try again.')
|
||||
setOverlayContent(
|
||||
'Download Error',
|
||||
'Check the console for more details. Please try again.',
|
||||
'Okay'
|
||||
)
|
||||
setOverlayHandler(null)
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
toggleLaunchArea(false)
|
||||
}, 5000)
|
||||
toggleOverlay(true)
|
||||
toggleLaunchArea(false)
|
||||
|
||||
// Disconnect from AssetExec
|
||||
aEx.disconnect()
|
||||
|
||||
} else if(m.task === 1){
|
||||
|
||||
@@ -565,7 +596,7 @@ function dlAsync(login = true){
|
||||
proc.stdout.on('data', gameStateChange)
|
||||
|
||||
// Init Discord Hook
|
||||
const distro = AssetGuard.retrieveDistributionDataSync(ConfigManager.getLauncherDirectory())
|
||||
const distro = AssetGuard.retrieveDistributionDataSync(ConfigManager.getLauncherDirectory(), true)
|
||||
if(distro.discord != null && serv.discord != null){
|
||||
DiscordWrapper.initRPC(distro.discord, serv.discord)
|
||||
hasRPC = true
|
||||
@@ -579,14 +610,15 @@ function dlAsync(login = true){
|
||||
|
||||
} catch(err) {
|
||||
|
||||
// Show that there was an error then hide the
|
||||
// progress area. Maybe switch this to an error
|
||||
// alert in the future. TODO
|
||||
setLaunchDetails('Error: See log for details..')
|
||||
console.log(err)
|
||||
setTimeout(function(){
|
||||
toggleLaunchArea(false)
|
||||
}, 5000)
|
||||
console.error('Error during launch', err)
|
||||
setOverlayContent(
|
||||
'Error During Launch',
|
||||
'Please check the console for more details.',
|
||||
'Okay'
|
||||
)
|
||||
setOverlayHandler(null)
|
||||
toggleOverlay(true)
|
||||
toggleLaunchArea(false)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -842,9 +874,8 @@ function loadNews(){
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
}).catch((err) => {
|
||||
console.log('Error Loading News', err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Load News
|
||||
initNews()
|
||||
}
|
||||
@@ -17,6 +17,7 @@ function toggleOverlay(toggleState, dismissable = false, content = 'overlayConte
|
||||
}
|
||||
if(typeof dismissable === 'string'){
|
||||
content = dismissable
|
||||
dismissable = false
|
||||
}
|
||||
if(toggleState){
|
||||
document.getElementById('main').setAttribute('overlay', true)
|
||||
|
||||
@@ -7,18 +7,63 @@ const path = require('path')
|
||||
const ConfigManager = require('./assets/js/configmanager.js')
|
||||
|
||||
let rscShouldLoad = false
|
||||
let fatalStartupError = false
|
||||
|
||||
function showMainUI(){
|
||||
updateSelectedServer(AssetGuard.getServerById(ConfigManager.getLauncherDirectory(), ConfigManager.getSelectedServer()).name)
|
||||
refreshServerStatus()
|
||||
setTimeout(() => {
|
||||
document.getElementById('frameBar').style.backgroundColor = 'rgba(1, 2, 1, 0.5)'
|
||||
document.body.style.backgroundImage = `url('assets/images/backgrounds/${document.body.getAttribute('bkid')}.jpg')`
|
||||
$('#main').show()
|
||||
|
||||
if(ConfigManager.isFirstLaunch()){
|
||||
$('#welcomeContainer').fadeIn(1000)
|
||||
} else {
|
||||
$('#landingContainer').fadeIn(1000)
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
$('#loadingContainer').fadeOut(750, () => {
|
||||
$('#loadSpinnerImage').removeClass('rotating')
|
||||
})
|
||||
}, 500)
|
||||
|
||||
}, 750)
|
||||
initNews()
|
||||
}
|
||||
|
||||
function showFatalStartupError(){
|
||||
setTimeout(() => {
|
||||
$('#loadingContainer').fadeOut(250, () => {
|
||||
document.getElementById('overlayContainer').style.background = 'none'
|
||||
setOverlayContent(
|
||||
'Fatal Error: Unable to Load Distribution Index',
|
||||
'A connection could not be established to our servers to download the distribution index. No local copies were available to load. <br><br>The distribution index is an essential file which provides the latest server information. The launcher is unable to start without it. Ensure you are connected to the internet and relaunch the application.',
|
||||
'Close'
|
||||
)
|
||||
setOverlayHandler(() => {
|
||||
const window = remote.getCurrentWindow()
|
||||
window.close()
|
||||
})
|
||||
toggleOverlay(true)
|
||||
})
|
||||
}, 750)
|
||||
}
|
||||
|
||||
// Synchronous Listener
|
||||
document.addEventListener('readystatechange', function(){
|
||||
|
||||
if (document.readyState === 'complete'){
|
||||
if(rscShouldLoad){
|
||||
if(ConfigManager.isFirstLaunch()){
|
||||
$('#welcomeContainer').fadeIn(500)
|
||||
if(!fatalStartupError){
|
||||
showMainUI()
|
||||
} else {
|
||||
$('#landingContainer').fadeIn(500)
|
||||
showFatalStartupError()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(document.readyState === 'interactive'){
|
||||
//toggleOverlay(true, 'loadingContent')
|
||||
}
|
||||
|
||||
/*if (document.readyState === 'interactive'){
|
||||
@@ -27,16 +72,19 @@ document.addEventListener('readystatechange', function(){
|
||||
}, false)
|
||||
|
||||
// Actions that must be performed after the distribution index is downloaded.
|
||||
ipcRenderer.on('distributionIndexDone', (data) => {
|
||||
updateSelectedServer(AssetGuard.getServerById(ConfigManager.getLauncherDirectory(), ConfigManager.getSelectedServer()).name)
|
||||
refreshServerStatus()
|
||||
if(document.readyState === 'complete'){
|
||||
if(ConfigManager.isFirstLaunch()){
|
||||
$('#welcomeContainer').fadeIn(500)
|
||||
ipcRenderer.on('distributionIndexDone', (event, data) => {
|
||||
if(data != null) {
|
||||
if(document.readyState === 'complete'){
|
||||
showMainUI()
|
||||
} else {
|
||||
$('#landingContainer').fadeIn(500)
|
||||
rscShouldLoad = true
|
||||
}
|
||||
} else {
|
||||
rscShouldLoad = true
|
||||
fatalStartupError = true
|
||||
if(document.readyState === 'complete'){
|
||||
showFatalStartupError()
|
||||
} else {
|
||||
rscShouldLoad = true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user