2017-12-01 23:59:25 -08:00
|
|
|
const {AssetGuard} = require('./assetguard.js')
|
2017-12-02 19:41:47 -08:00
|
|
|
const ConfigManager = require('./configmanager.js')
|
2018-04-14 21:00:08 -07:00
|
|
|
const os = require('os')
|
2017-12-02 19:41:47 -08:00
|
|
|
const path = require('path')
|
2018-04-14 21:00:08 -07:00
|
|
|
const rimraf = require('rimraf')
|
2017-12-01 23:59:25 -08:00
|
|
|
|
2018-04-25 23:01:46 -07:00
|
|
|
console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Loading..')
|
2017-12-01 23:59:25 -08:00
|
|
|
|
2017-12-02 21:38:22 -08:00
|
|
|
// Load ConfigManager
|
|
|
|
ConfigManager.load()
|
2017-12-02 19:41:47 -08:00
|
|
|
|
2017-12-02 21:38:22 -08:00
|
|
|
// Ensure Distribution is downloaded and cached.
|
|
|
|
AssetGuard.retrieveDistributionDataSync(ConfigManager.getGameDirectory(), false)
|
2017-12-02 19:41:47 -08:00
|
|
|
|
2017-12-02 21:38:22 -08:00
|
|
|
// Resolve the selected server if its value has yet to be set.
|
|
|
|
if(ConfigManager.getSelectedServer() == null){
|
2017-12-02 19:41:47 -08:00
|
|
|
console.log('Determining default selected server..')
|
2018-04-15 19:35:14 -07:00
|
|
|
ConfigManager.setSelectedServer(AssetGuard.resolveSelectedServer(ConfigManager.getGameDirectory()).id)
|
2017-12-02 21:38:22 -08:00
|
|
|
ConfigManager.save()
|
2018-04-14 21:00:08 -07:00
|
|
|
}
|
|
|
|
|
2018-04-14 21:49:20 -07:00
|
|
|
// Clean up temp dir incase previous launches ended unexpectedly.
|
2018-04-14 21:00:08 -07:00
|
|
|
rimraf(path.join(os.tmpdir(), ConfigManager.getTempNativeFolder()), (err) => {
|
|
|
|
if(err){
|
2018-04-25 23:01:46 -07:00
|
|
|
console.warn('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Error while cleaning natives directory', err)
|
2018-04-14 21:00:08 -07:00
|
|
|
} else {
|
2018-04-25 23:01:46 -07:00
|
|
|
console.log('%c[Preloader]', 'color: #a02d2a; font-weight: bold', 'Cleaned natives directory.')
|
2018-04-14 21:00:08 -07:00
|
|
|
}
|
|
|
|
})
|