SkirdaElectronLauncher/app/assets/js/preloader.js
Daniel Scalzi 714daace18
Added server status retrieval and implemented it on UI.
The player count on the landing page is now functional. If the server cannot be reached, the label and value will change to SERVER and OFFLINE, respectively. This behavior can be modified.
2018-04-15 22:35:14 -04:00

29 lines
972 B
JavaScript

const {AssetGuard} = require('./assetguard.js')
const ConfigManager = require('./configmanager.js')
const os = require('os')
const path = require('path')
const rimraf = require('rimraf')
console.log('Preloading')
// Load ConfigManager
ConfigManager.load()
// Ensure Distribution is downloaded and cached.
AssetGuard.retrieveDistributionDataSync(ConfigManager.getGameDirectory(), false)
// Resolve the selected server if its value has yet to be set.
if(ConfigManager.getSelectedServer() == null){
console.log('Determining default selected server..')
ConfigManager.setSelectedServer(AssetGuard.resolveSelectedServer(ConfigManager.getGameDirectory()).id)
ConfigManager.save()
}
// Clean up temp dir incase previous launches ended unexpectedly.
rimraf(path.join(os.tmpdir(), ConfigManager.getTempNativeFolder()), (err) => {
if(err){
console.warn('Error while cleaning temp dir', err)
} else {
console.log('Cleaned temp dir.')
}
})