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:
parent
cd4f7918c8
commit
f161e196be
15
app/app.ejs
15
app/app.ejs
@ -7,10 +7,13 @@
|
|||||||
<link type="text/css" rel="stylesheet" href="./assets/css/launcher.css">
|
<link type="text/css" rel="stylesheet" href="./assets/css/launcher.css">
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
background: url('assets/images/backgrounds/<%=bkid%>.jpg') no-repeat center center fixed;
|
/*background: url('assets/images/backgrounds/<%=bkid%>.jpg') no-repeat center center fixed;*/
|
||||||
|
transition: background-image 1s ease;
|
||||||
|
background-image: url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD//gA+Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2ODApLCBkZWZhdWx0IHF1YWxpdHkK/9sAQwAIBgYHBgUIBwcHCQkICgwUDQwLCwwZEhMPFB0aHx4dGhwcICQuJyAiLCMcHCg3KSwwMTQ0NB8nOT04MjwuMzQy/9sAQwEJCQkMCwwYDQ0YMiEcITIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy/8AAEQgAPwBwAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/aAAwDAQACEQMRAD8A8VooopDCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAP/9k=');
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
}
|
}
|
||||||
#main {
|
#main {
|
||||||
|
display: none;
|
||||||
height: calc(100% - 22px);
|
height: calc(100% - 22px);
|
||||||
background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0) 100%);
|
background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0) 100%);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -22,7 +25,7 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body bkid="<%=bkid%>">
|
||||||
<% include frame.ejs %>
|
<% include frame.ejs %>
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<% include welcome.ejs %>
|
<% include welcome.ejs %>
|
||||||
@ -30,5 +33,13 @@
|
|||||||
<% include landing.ejs %>
|
<% include landing.ejs %>
|
||||||
</div>
|
</div>
|
||||||
<% include overlay.ejs %>
|
<% include overlay.ejs %>
|
||||||
|
<div id="loadingContainer">
|
||||||
|
<div id="loadingContent">
|
||||||
|
<div id="loadSpinnerContainer">
|
||||||
|
<img id="loadCenterImage" src="assets/images/westeroscraftlogo1.png">
|
||||||
|
<img id="loadSpinnerImage" class="rotating" src="assets/images/westeroscraftlogo2.png">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -55,7 +55,8 @@ p {
|
|||||||
z-index: 100;
|
z-index: 100;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
background: rgba(1, 2, 1, 0.5);
|
transition: background-color 1s ease;
|
||||||
|
/*background-color: rgba(1, 2, 1, 0.5);*/
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -809,67 +810,6 @@ p {
|
|||||||
transform: rotate(45deg);
|
transform: rotate(45deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* * *
|
|
||||||
* Login View | Loader
|
|
||||||
* * */
|
|
||||||
/* Will reuse this elsewhere down the line.
|
|
||||||
#loginLoading {
|
|
||||||
position: absolute;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background: rgba(0, 0, 0, 0.80);
|
|
||||||
}
|
|
||||||
|
|
||||||
#loginLoadingContent {
|
|
||||||
position: relative;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
#loadSpinnerContainer {
|
|
||||||
position: relative;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
#loadCenterImage {
|
|
||||||
position: absolute;
|
|
||||||
width: 200px;
|
|
||||||
height: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
#loadSpinnerImage {
|
|
||||||
width: 280px;
|
|
||||||
height: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
#loadDescText {
|
|
||||||
color: #f1eada;
|
|
||||||
font-family: 'Avenir Medium';
|
|
||||||
font-weight: bold;
|
|
||||||
letter-spacing: 1px;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes rotating {
|
|
||||||
from {
|
|
||||||
transform: rotate(0deg);
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
transform: rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.rotating {
|
|
||||||
animation: rotating 10s linear infinite;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#login_filter {
|
#login_filter {
|
||||||
height: calc(100% - 22px);
|
height: calc(100% - 22px);
|
||||||
@ -2092,3 +2032,65 @@ p {
|
|||||||
#serverSelectCancel:active {
|
#serverSelectCancel:active {
|
||||||
color: rgba(165, 165, 165, 0.75);
|
color: rgba(165, 165, 165, 0.75);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Loading Element (app.ejs) *
|
||||||
|
* *
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
/* Loading container, placed above everything. */
|
||||||
|
#loadingContainer {
|
||||||
|
position: absolute;
|
||||||
|
z-index: 400;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
height: calc(100% - 22px);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Loading content container. */
|
||||||
|
#loadingContent {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Spinner container. */
|
||||||
|
#loadSpinnerContainer {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Stationary image for the spinner. */
|
||||||
|
#loadCenterImage {
|
||||||
|
position: absolute;
|
||||||
|
width: 200px;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Rotating image for the spinner. */
|
||||||
|
#loadSpinnerImage {
|
||||||
|
width: 280px;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Rotating animation for the spinner. */
|
||||||
|
@keyframes rotating {
|
||||||
|
from {
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Class which is applied when the spinner image is spinning. */
|
||||||
|
.rotating {
|
||||||
|
animation: rotating 10s linear infinite;
|
||||||
|
}
|
@ -41,6 +41,8 @@ process.on('message', (msg) => {
|
|||||||
if(res instanceof Promise){
|
if(res instanceof Promise){
|
||||||
res.then((v) => {
|
res.then((v) => {
|
||||||
process.send({result: v, content: msg.content})
|
process.send({result: v, content: msg.content})
|
||||||
|
}).catch((err) => {
|
||||||
|
process.send({result: v, content: msg.content})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
process.send({result: res, content: msg.content})
|
process.send({result: res, content: msg.content})
|
||||||
|
@ -373,21 +373,17 @@ class AssetGuard extends EventEmitter {
|
|||||||
// #region
|
// #region
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Statically retrieve the distribution data.
|
* Retrieve a new copy of the distribution index from our servers.
|
||||||
*
|
*
|
||||||
* @param {string} launcherPath The root launcher directory.
|
* @param {string} launcherPath The root launcher directory.
|
||||||
* @param {boolean} cached Optional. False if the distro should be freshly downloaded, else
|
|
||||||
* a cached copy will be returned.
|
|
||||||
* @returns {Promise.<Object>} A promise which resolves to the distribution data object.
|
* @returns {Promise.<Object>} A promise which resolves to the distribution data object.
|
||||||
*/
|
*/
|
||||||
static retrieveDistributionData(launcherPath, cached = true){
|
static retrieveDistributionDataFresh(launcherPath){
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if(!cached || distributionData == null){
|
const distroURL = 'http://mc.westeroscraft.com/WesterosCraftLauncher/westeroscraft.json'
|
||||||
// TODO Download file from upstream.
|
const distroDest = path.join(launcherPath, 'westeroscraft.json')
|
||||||
const distroURL = 'http://mc.westeroscraft.com/WesterosCraftLauncher/westeroscraft.json'
|
request(distroURL, (error, resp, body) => {
|
||||||
const distroDest = path.join(launcherPath, 'westeroscraft.json')
|
if(!error){
|
||||||
// TODO Fulfill with JSON.parse()
|
|
||||||
request(distroURL, (error, resp, body) => {
|
|
||||||
distributionData = JSON.parse(body)
|
distributionData = JSON.parse(body)
|
||||||
|
|
||||||
fs.writeFile(distroDest, body, 'utf-8', (err) => {
|
fs.writeFile(distroDest, body, 'utf-8', (err) => {
|
||||||
@ -397,12 +393,32 @@ class AssetGuard extends EventEmitter {
|
|||||||
reject(err)
|
reject(err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a local copy of the distribution index asynchronously.
|
||||||
|
*
|
||||||
|
* @param {string} launcherPath The root launcher directory.
|
||||||
|
* @param {boolean} cached Optional. False if the distro file should be read from the
|
||||||
|
* disk and re-cached, otherwise a cached copy will be returned.
|
||||||
|
* @returns {Promise.<Object>} A promise which resolves to the distribution data object.
|
||||||
|
*/
|
||||||
|
static retrieveDistributionData(launcherPath, cached = true){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if(!cached || distributionData == null){
|
||||||
|
fs.readFile(path.join(launcherPath, 'westeroscraft.json'), 'utf-8', (err, data) => {
|
||||||
|
if(!err){
|
||||||
|
distributionData = JSON.parse(data)
|
||||||
|
resolve(distributionData)
|
||||||
|
} else {
|
||||||
|
reject(err)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
// Workaround while file is not hosted.
|
|
||||||
/*fs.readFile(path.join(__dirname, '..', 'westeroscraft.json'), 'utf-8', (err, data) => {
|
|
||||||
distributionData = JSON.parse(data)
|
|
||||||
resolve(distributionData)
|
|
||||||
})*/
|
|
||||||
} else {
|
} else {
|
||||||
resolve(distributionData)
|
resolve(distributionData)
|
||||||
}
|
}
|
||||||
@ -410,11 +426,11 @@ class AssetGuard extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recieved a cached version of the distribution index.
|
* Retrieve a local copy of the distribution index synchronously.
|
||||||
*
|
*
|
||||||
* @param {string} launcherPath The root launcher directory.
|
* @param {string} launcherPath The root launcher directory.
|
||||||
* @param {boolean} cached Optional. False if the distro should be freshly downloaded, else
|
* @param {boolean} cached Optional. False if the distro file should be read from the
|
||||||
* a cached copy will be returned.
|
* disk and re-cached, otherwise a cached copy will be returned.
|
||||||
* @returns {Object} The distribution data object.
|
* @returns {Object} The distribution data object.
|
||||||
*/
|
*/
|
||||||
static retrieveDistributionDataSync(launcherPath, cached = true){
|
static retrieveDistributionDataSync(launcherPath, cached = true){
|
||||||
@ -453,7 +469,7 @@ class AssetGuard extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
static getServerById(launcherPath, serverID){
|
static getServerById(launcherPath, serverID){
|
||||||
if(distributionData == null){
|
if(distributionData == null){
|
||||||
AssetGuard.retrieveDistributionDataSync(launcherPath, false)
|
AssetGuard.retrieveDistributionDataSync(launcherPath, true)
|
||||||
}
|
}
|
||||||
const servers = distributionData.servers
|
const servers = distributionData.servers
|
||||||
let serv = null
|
let serv = null
|
||||||
@ -1285,15 +1301,8 @@ class AssetGuard extends EventEmitter {
|
|||||||
validateDistribution(serverpackid){
|
validateDistribution(serverpackid){
|
||||||
const self = this
|
const self = this
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
AssetGuard.retrieveDistributionData(self.launcherPath, false).then((value) => {
|
|
||||||
/*const servers = value.servers
|
const cbFunc = function(){
|
||||||
let serv = null
|
|
||||||
for(let i=0; i<servers.length; i++){
|
|
||||||
if(servers[i].id === serverpackid){
|
|
||||||
serv = servers[i]
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
const serv = AssetGuard.getServerById(self.launcherPath, serverpackid)
|
const serv = AssetGuard.getServerById(self.launcherPath, serverpackid)
|
||||||
|
|
||||||
if(serv == null) {
|
if(serv == null) {
|
||||||
@ -1310,6 +1319,32 @@ class AssetGuard extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
resolve(serv)
|
resolve(serv)
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetGuard.retrieveDistributionDataFresh(self.launcherPath).then((value) => {
|
||||||
|
|
||||||
|
console.log('Loaded fresh copy of the distribution index.')
|
||||||
|
|
||||||
|
cbFunc()
|
||||||
|
|
||||||
|
}).catch((err) => {
|
||||||
|
|
||||||
|
console.log('Failed to load fresh copy of the distribution index.')
|
||||||
|
console.log('Attempting to load an older copy of the distribution index.')
|
||||||
|
|
||||||
|
AssetGuard.retrieveDistributionData(self.launcherPath, false).then((value) => {
|
||||||
|
|
||||||
|
console.log('Successfully loaded an older copy of the distribution index.')
|
||||||
|
|
||||||
|
cbFunc()
|
||||||
|
|
||||||
|
}).catch((err) => {
|
||||||
|
|
||||||
|
console.log('Failed to load an older copy of the distribution index. Cannot launch.')
|
||||||
|
|
||||||
|
reject(err)
|
||||||
|
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -1370,7 +1405,7 @@ class AssetGuard extends EventEmitter {
|
|||||||
loadForgeData(serverpack){
|
loadForgeData(serverpack){
|
||||||
const self = this
|
const self = this
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
let distro = AssetGuard.retrieveDistributionDataSync(self.launcherPath)
|
let distro = AssetGuard.retrieveDistributionDataSync(self.launcherPath, true)
|
||||||
|
|
||||||
const servers = distro.servers
|
const servers = distro.servers
|
||||||
let serv = null
|
let serv = null
|
||||||
|
@ -10,22 +10,47 @@ console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Loading..')
|
|||||||
// Load ConfigManager
|
// Load ConfigManager
|
||||||
ConfigManager.load()
|
ConfigManager.load()
|
||||||
|
|
||||||
|
function onDistroLoad(data){
|
||||||
|
if(data != null){
|
||||||
|
|
||||||
|
// Resolve the selected server if its value has yet to be set.
|
||||||
|
if(ConfigManager.getSelectedServer() == null || AssetGuard.getServerById(ConfigManager.getLauncherDirectory(), ConfigManager.getSelectedServer()) == null){
|
||||||
|
console.log('Determining default selected server..')
|
||||||
|
ConfigManager.setSelectedServer(AssetGuard.resolveSelectedServer(ConfigManager.getLauncherDirectory()).id)
|
||||||
|
ConfigManager.save()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ipcRenderer.send('distributionIndexDone', data)
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure Distribution is downloaded and cached.
|
// Ensure Distribution is downloaded and cached.
|
||||||
AssetGuard.retrieveDistributionData(ConfigManager.getLauncherDirectory(), false).then((data) => {
|
AssetGuard.retrieveDistributionDataFresh(ConfigManager.getLauncherDirectory()).then((data) => {
|
||||||
console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Loaded distribution index.')
|
console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Loaded distribution index.')
|
||||||
|
|
||||||
// Resolve the selected server if its value has yet to be set.
|
onDistroLoad(data)
|
||||||
if(ConfigManager.getSelectedServer() == null){
|
|
||||||
console.log('Determining default selected server..')
|
|
||||||
ConfigManager.setSelectedServer(AssetGuard.resolveSelectedServer(ConfigManager.getLauncherDirectory()).id)
|
|
||||||
ConfigManager.save()
|
|
||||||
}
|
|
||||||
|
|
||||||
ipcRenderer.send('distributionIndexDone', data)
|
}).catch((err) => {
|
||||||
|
|
||||||
}).catch(err => {
|
|
||||||
console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Failed to load distribution index.')
|
console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Failed to load distribution index.')
|
||||||
console.err(err)
|
console.error(err)
|
||||||
|
|
||||||
|
console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Attempting to load an older version of the distribution index.')
|
||||||
|
// Try getting a local copy, better than nothing.
|
||||||
|
AssetGuard.retrieveDistributionData(ConfigManager.getLauncherDirectory(), false).then((data) => {
|
||||||
|
console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Successfully loaded an older version of the distribution index.')
|
||||||
|
|
||||||
|
onDistroLoad(data)
|
||||||
|
|
||||||
|
|
||||||
|
}).catch((err) => {
|
||||||
|
|
||||||
|
console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Failed to load an older version of the distribution index.')
|
||||||
|
console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Application cannot run.')
|
||||||
|
console.error(err)
|
||||||
|
|
||||||
|
onDistroLoad(null)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Clean up temp dir incase previous launches ended unexpectedly.
|
// Clean up temp dir incase previous launches ended unexpectedly.
|
||||||
|
@ -418,13 +418,30 @@ function dlAsync(login = true){
|
|||||||
aEx.on('message', (m) => {
|
aEx.on('message', (m) => {
|
||||||
if(m.content === 'validateDistribution'){
|
if(m.content === 'validateDistribution'){
|
||||||
|
|
||||||
setLaunchPercentage(20, 100)
|
if(m.result instanceof Error){
|
||||||
serv = m.result
|
|
||||||
console.log('Forge Validation Complete.')
|
|
||||||
|
|
||||||
// Begin version load.
|
setOverlayContent(
|
||||||
setLaunchDetails('Loading version information..')
|
'Fatal Error',
|
||||||
aEx.send({task: 0, content: 'loadVersionData', argsArr: [serv.mc_version]})
|
'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'){
|
} else if(m.content === 'loadVersionData'){
|
||||||
|
|
||||||
@ -492,15 +509,29 @@ function dlAsync(login = true){
|
|||||||
|
|
||||||
} else if(m.task === 0.9) {
|
} else if(m.task === 0.9) {
|
||||||
|
|
||||||
|
console.error(m.err)
|
||||||
|
|
||||||
if(m.err.code === 'ENOENT'){
|
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 {
|
} else {
|
||||||
setLaunchDetails('Download error.. try again.')
|
setOverlayContent(
|
||||||
|
'Download Error',
|
||||||
|
'Check the console for more details. Please try again.',
|
||||||
|
'Okay'
|
||||||
|
)
|
||||||
|
setOverlayHandler(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
toggleOverlay(true)
|
||||||
toggleLaunchArea(false)
|
toggleLaunchArea(false)
|
||||||
}, 5000)
|
|
||||||
|
// Disconnect from AssetExec
|
||||||
|
aEx.disconnect()
|
||||||
|
|
||||||
} else if(m.task === 1){
|
} else if(m.task === 1){
|
||||||
|
|
||||||
@ -565,7 +596,7 @@ function dlAsync(login = true){
|
|||||||
proc.stdout.on('data', gameStateChange)
|
proc.stdout.on('data', gameStateChange)
|
||||||
|
|
||||||
// Init Discord Hook
|
// Init Discord Hook
|
||||||
const distro = AssetGuard.retrieveDistributionDataSync(ConfigManager.getLauncherDirectory())
|
const distro = AssetGuard.retrieveDistributionDataSync(ConfigManager.getLauncherDirectory(), true)
|
||||||
if(distro.discord != null && serv.discord != null){
|
if(distro.discord != null && serv.discord != null){
|
||||||
DiscordWrapper.initRPC(distro.discord, serv.discord)
|
DiscordWrapper.initRPC(distro.discord, serv.discord)
|
||||||
hasRPC = true
|
hasRPC = true
|
||||||
@ -579,14 +610,15 @@ function dlAsync(login = true){
|
|||||||
|
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
|
|
||||||
// Show that there was an error then hide the
|
console.error('Error during launch', err)
|
||||||
// progress area. Maybe switch this to an error
|
setOverlayContent(
|
||||||
// alert in the future. TODO
|
'Error During Launch',
|
||||||
setLaunchDetails('Error: See log for details..')
|
'Please check the console for more details.',
|
||||||
console.log(err)
|
'Okay'
|
||||||
setTimeout(function(){
|
)
|
||||||
toggleLaunchArea(false)
|
setOverlayHandler(null)
|
||||||
}, 5000)
|
toggleOverlay(true)
|
||||||
|
toggleLaunchArea(false)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -842,9 +874,8 @@ function loadNews(){
|
|||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
reject(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'){
|
if(typeof dismissable === 'string'){
|
||||||
content = dismissable
|
content = dismissable
|
||||||
|
dismissable = false
|
||||||
}
|
}
|
||||||
if(toggleState){
|
if(toggleState){
|
||||||
document.getElementById('main').setAttribute('overlay', true)
|
document.getElementById('main').setAttribute('overlay', true)
|
||||||
|
@ -7,18 +7,63 @@ const path = require('path')
|
|||||||
const ConfigManager = require('./assets/js/configmanager.js')
|
const ConfigManager = require('./assets/js/configmanager.js')
|
||||||
|
|
||||||
let rscShouldLoad = false
|
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
|
// Synchronous Listener
|
||||||
document.addEventListener('readystatechange', function(){
|
document.addEventListener('readystatechange', function(){
|
||||||
|
|
||||||
if (document.readyState === 'complete'){
|
if (document.readyState === 'complete'){
|
||||||
if(rscShouldLoad){
|
if(rscShouldLoad){
|
||||||
if(ConfigManager.isFirstLaunch()){
|
if(!fatalStartupError){
|
||||||
$('#welcomeContainer').fadeIn(500)
|
showMainUI()
|
||||||
} else {
|
} else {
|
||||||
$('#landingContainer').fadeIn(500)
|
showFatalStartupError()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if(document.readyState === 'interactive'){
|
||||||
|
//toggleOverlay(true, 'loadingContent')
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (document.readyState === 'interactive'){
|
/*if (document.readyState === 'interactive'){
|
||||||
@ -27,16 +72,19 @@ document.addEventListener('readystatechange', function(){
|
|||||||
}, false)
|
}, false)
|
||||||
|
|
||||||
// Actions that must be performed after the distribution index is downloaded.
|
// Actions that must be performed after the distribution index is downloaded.
|
||||||
ipcRenderer.on('distributionIndexDone', (data) => {
|
ipcRenderer.on('distributionIndexDone', (event, data) => {
|
||||||
updateSelectedServer(AssetGuard.getServerById(ConfigManager.getLauncherDirectory(), ConfigManager.getSelectedServer()).name)
|
if(data != null) {
|
||||||
refreshServerStatus()
|
if(document.readyState === 'complete'){
|
||||||
if(document.readyState === 'complete'){
|
showMainUI()
|
||||||
if(ConfigManager.isFirstLaunch()){
|
|
||||||
$('#welcomeContainer').fadeIn(500)
|
|
||||||
} else {
|
} else {
|
||||||
$('#landingContainer').fadeIn(500)
|
rscShouldLoad = true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rscShouldLoad = true
|
fatalStartupError = true
|
||||||
|
if(document.readyState === 'complete'){
|
||||||
|
showFatalStartupError()
|
||||||
|
} else {
|
||||||
|
rscShouldLoad = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
6
index.js
6
index.js
@ -51,8 +51,8 @@ ipcMain.on('autoUpdateAction', (event, arg) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
// Redirect distribution index event from preloader to renderer.
|
// Redirect distribution index event from preloader to renderer.
|
||||||
ipcMain.on('distributionIndexDone', (event, arg) => {
|
ipcMain.on('distributionIndexDone', (event, data) => {
|
||||||
event.sender.send('distributionIndexDone', arg)
|
event.sender.send('distributionIndexDone', data)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Disable hardware acceleration.
|
// Disable hardware acceleration.
|
||||||
@ -73,7 +73,7 @@ function createWindow() {
|
|||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.join(__dirname, 'app', 'assets', 'js', 'preloader.js')
|
preload: path.join(__dirname, 'app', 'assets', 'js', 'preloader.js')
|
||||||
},
|
},
|
||||||
backgroundColor: '#2e2c29'
|
backgroundColor: '#171614'
|
||||||
})
|
})
|
||||||
|
|
||||||
ejse.data('bkid', Math.floor((Math.random() * fs.readdirSync(path.join(__dirname, 'app', 'assets', 'images', 'backgrounds')).length)))
|
ejse.data('bkid', Math.floor((Math.random() * fs.readdirSync(path.join(__dirname, 'app', 'assets', 'images', 'backgrounds')).length)))
|
||||||
|
Loading…
Reference in New Issue
Block a user