Merge pull request #11 from VicariousNetwork/refresh-attempt2
Refresh attempt2
This commit is contained in:
commit
206de5d4fd
@ -3105,6 +3105,19 @@ input:checked + .toggleSwitchSlider:before {
|
||||
height: 23px;
|
||||
}
|
||||
|
||||
#refreshSVG {
|
||||
fill: #ffffff;
|
||||
height: 15px;
|
||||
}
|
||||
#refreshSVG:hover {
|
||||
height: 25px;
|
||||
fill: #ffffff;
|
||||
}
|
||||
|
||||
#refreshMediaButton[inprogress] #refreshSVG {
|
||||
animation: spin 0.8s infinite;
|
||||
}
|
||||
|
||||
/* Settings tooltip styles. */
|
||||
#settingsTooltip {
|
||||
visibility: hidden;
|
||||
|
8
app/assets/images/icons/refresh.svg
Normal file
8
app/assets/images/icons/refresh.svg
Normal file
@ -0,0 +1,8 @@
|
||||
<svg id="Capa_1" enable-background="new 0 0 515.556 515.556" height="512" viewBox="0 0 515.556 515.556" width="512" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<style>.cls-1{fill:none;}.cls-2{clip-path:url(#clip-path);}</style>
|
||||
<clipPath id="clip-path"><rect class="cls-1" x="45.65" y="42.62" width="49.58" height="52.43"/></clipPath>
|
||||
</defs>
|
||||
<title>refresh</title>
|
||||
<path d="m418.889 290c0 88.832-72.28 161.111-161.111 161.111s-161.111-72.279-161.111-161.111c0-77.798 55.445-142.882 128.889-157.855v61.188l96.667-96.667-96.667-96.666v67.017c-109.124 15.718-193.334 109.578-193.334 222.983 0 124.373 101.182 225.556 225.556 225.556s225.556-101.182 225.556-225.556z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 704 B |
@ -21,23 +21,22 @@ exports.getLauncherDirectory = function(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the file hash for the current stored distribution file
|
||||
* Retrieve the ETag version for the current stored distribution file
|
||||
*
|
||||
* @returns {string} The absolute path of the launcher directory.
|
||||
*/
|
||||
exports.getDistributionHash = function(){
|
||||
return config.distributionHash
|
||||
exports.getDistributionVersion = function(){
|
||||
return config.distributionVersion
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the current distribution file hash into the configuration
|
||||
* Stores the current distribution ETag version into the configuration
|
||||
*
|
||||
* @returns {string} The absolute path of the launcher directory.
|
||||
*/
|
||||
exports.setDistributionHash = function(hash){
|
||||
config.distributionHash = hash
|
||||
exports.setDistributionVersion = function(version){
|
||||
config.distributionVersion = version
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the launcher's data directory. This is where all files related
|
||||
* to game launch are installed (common, instances, java, etc).
|
||||
@ -86,13 +85,12 @@ exports.getAbsoluteMinRAM = function(){
|
||||
|
||||
exports.getAbsoluteMaxRAM = function(){
|
||||
const mem = os.totalmem()
|
||||
const gT16 = mem-16000000000
|
||||
return Math.floor((mem-1000000000-(gT16 > 0 ? (Number.parseInt(gT16/8) + 16000000000/4) : mem/4))/1000000000)
|
||||
return Math.floor((mem/1000000000))
|
||||
}
|
||||
|
||||
function resolveMaxRAM(){
|
||||
const mem = os.totalmem()
|
||||
return mem >= 8000000000 ? '4G' : (mem >= 6000000000 ? '3G' : '2G')
|
||||
return mem >= 16000000000 ? '8G' : (mem >= 8000000000 ? '6G' : (mem >= 6000000000 ? '4G' : '2G'))
|
||||
}
|
||||
|
||||
function resolveMinRAM(){
|
||||
@ -115,7 +113,8 @@ const DEFAULT_CONFIG = {
|
||||
'-XX:+UseConcMarkSweepGC',
|
||||
'-XX:+CMSIncrementalMode',
|
||||
'-XX:-UseAdaptiveSizePolicy',
|
||||
'-Xmn128M'
|
||||
'-Xmn128M',
|
||||
'-Dfml.loginTimeout=180'
|
||||
],
|
||||
},
|
||||
game: {
|
||||
@ -128,6 +127,7 @@ const DEFAULT_CONFIG = {
|
||||
},
|
||||
launcher: {
|
||||
allowPrerelease: false,
|
||||
discordIntegration: true,
|
||||
dataDirectory: dataPath,
|
||||
serverCodes: []
|
||||
}
|
||||
@ -138,7 +138,7 @@ const DEFAULT_CONFIG = {
|
||||
dismissed: false
|
||||
},
|
||||
clientToken: null,
|
||||
distributionHash: null,
|
||||
distributionVersion: null,
|
||||
selectedServer: null, // Resolved
|
||||
selectedAccount: null,
|
||||
authenticationDatabase: {},
|
||||
@ -797,4 +797,23 @@ exports.getAllowPrerelease = function(def = false){
|
||||
*/
|
||||
exports.setAllowPrerelease = function(allowPrerelease){
|
||||
config.settings.launcher.allowPrerelease = allowPrerelease
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the launcher should enable discord presence features
|
||||
*
|
||||
* @param {boolean} def Optional. If true, the default value will be returned.
|
||||
* @returns {boolean} Whether or not the launcher should enable discord presence features
|
||||
*/
|
||||
exports.getDiscordIntegration = function(def = false){
|
||||
return !def ? config.settings.launcher.discordIntegration : DEFAULT_CONFIG.settings.launcher.discordIntegration
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the status of whether or not the launcher should denable discord presence features
|
||||
*
|
||||
* @param {boolean} discordIntegration Whether or not the launcher should enable discord presence features
|
||||
*/
|
||||
exports.setDiscordIntegration = function(discordIntegration){
|
||||
config.settings.launcher.discordIntegration = discordIntegration
|
||||
}
|
@ -6,16 +6,14 @@ const {Client} = require('discord-rpc')
|
||||
let client
|
||||
let activity
|
||||
|
||||
exports.initRPC = function(genSettings, servSettings, initialDetails = 'Waiting for Client..'){
|
||||
exports.initRPC = function(genSettings, servSettings = null, initialDetails = 'Waiting for Client..'){
|
||||
logger.log('Now Loading Discord RPC')
|
||||
client = new Client({ transport: 'ipc' })
|
||||
|
||||
activity = {
|
||||
details: initialDetails,
|
||||
state: 'Modpack: ' + servSettings.shortId,
|
||||
largeImageKey: servSettings.largeImageKey,
|
||||
largeImageText: servSettings.largeImageText,
|
||||
smallImageKey: genSettings.smallImageKey,
|
||||
smallImageText: genSettings.smallImageText,
|
||||
largeImageKey: genSettings.smallImageKey,
|
||||
largeImageText: genSettings.smallImageText,
|
||||
startTimestamp: new Date().getTime(),
|
||||
instance: false
|
||||
}
|
||||
@ -34,9 +32,55 @@ exports.initRPC = function(genSettings, servSettings, initialDetails = 'Waiting
|
||||
})
|
||||
}
|
||||
|
||||
exports.updateState = function(state){
|
||||
if(client){
|
||||
activity.state = state
|
||||
client.setActivity(activity)
|
||||
logger.log('Updated discord state to: ' + state)
|
||||
}
|
||||
}
|
||||
|
||||
exports.clearState = function(){
|
||||
if(client){
|
||||
activity = {
|
||||
details: activity.details,
|
||||
largeImageKey: activity.largeImageKey,
|
||||
largeImageText: activity.largeImageText,
|
||||
startTimestamp: activity.startTimestamp,
|
||||
instance: activity.instance
|
||||
}
|
||||
client.setActivity(activity)
|
||||
logger.log('Cleared the activity state!')
|
||||
}
|
||||
}
|
||||
|
||||
exports.updateDetails = function(details){
|
||||
activity.details = details
|
||||
client.setActivity(activity)
|
||||
if(client){
|
||||
activity.details = details
|
||||
client.setActivity(activity)
|
||||
logger.log('Updated discord details to: ' + details)
|
||||
}
|
||||
}
|
||||
|
||||
exports.clearDetails = function(){
|
||||
if(client){
|
||||
activity = {
|
||||
state: activity.state,
|
||||
largeImageKey: activity.largeImageKey,
|
||||
largeImageText: activity.largeImageText,
|
||||
startTimestamp: activity.startTimestamp,
|
||||
instance: activity.instance
|
||||
}
|
||||
logger.log('Cleared the activity details!')
|
||||
}
|
||||
}
|
||||
|
||||
exports.resetTime = function(){
|
||||
if(client){
|
||||
activity.startTimestamp = new Date().getTime()
|
||||
client.setActivity(activity)
|
||||
logger.log('Reset the activity time!')
|
||||
}
|
||||
}
|
||||
|
||||
exports.shutdownRPC = function(){
|
||||
@ -45,4 +89,8 @@ exports.shutdownRPC = function(){
|
||||
client.destroy()
|
||||
client = null
|
||||
activity = null
|
||||
}
|
||||
|
||||
exports.getClient = function(){
|
||||
return client
|
||||
}
|
@ -1,10 +1,12 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const crypto = require('crypto')
|
||||
const request = require('request')
|
||||
|
||||
const ConfigManager = require('./configmanager')
|
||||
const logger = require('./loggerutil')('%c[DistroManager]', 'color: #a02d2a; font-weight: bold')
|
||||
const logger = require('./loggerutil')('%c[DistroManager]', 'color: #a02d2a; font-weight: bold')
|
||||
const constants = require('../../config/constants')
|
||||
const isDev = require('../../assets/js/isdev')
|
||||
|
||||
const distributionURL = isDev ? constants.DEV_DISTRIBUTION_URL : constants.LIVE_DISTRIBUTION_URL
|
||||
|
||||
/**
|
||||
* Represents the download information
|
||||
@ -563,10 +565,10 @@ exports.pullRemote = function(){
|
||||
return exports.pullLocal()
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
const distroURL = 'http://launcher.vicariousnetwork.com/distribution.json'
|
||||
//const distroURL = 'http://launcher.vicariousnetwork.com/distribution.json'
|
||||
//const distroURL = 'https://gist.githubusercontent.com/dscalzi/53b1ba7a11d26a5c353f9d5ae484b71b/raw/'
|
||||
const opts = {
|
||||
url: distroURL,
|
||||
url: distributionURL,
|
||||
timeout: 2500
|
||||
}
|
||||
const distroDest = path.join(ConfigManager.getLauncherDirectory(), 'distribution.json')
|
||||
@ -582,7 +584,7 @@ exports.pullRemote = function(){
|
||||
|
||||
fs.writeFile(distroDest, body, 'utf-8', (err) => {
|
||||
if(!err){
|
||||
ConfigManager.setDistributionHash(crypto.createHash('md5').update(body).digest('hex'))
|
||||
ConfigManager.setDistributionVersion(String(resp.headers['etag']))
|
||||
ConfigManager.save()
|
||||
resolve(data)
|
||||
return
|
||||
@ -601,13 +603,16 @@ exports.pullRemote = function(){
|
||||
|
||||
/**
|
||||
* @returns {Promise.<DistroIndex>}
|
||||
* Pulls the local version of the distribution file, does not require any downloading.
|
||||
*/
|
||||
exports.pullLocal = function(){
|
||||
exports.pullLocal = function(){
|
||||
logger.info('Now preparing to pull distribution from local.')
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readFile(DEV_MODE ? DEV_PATH : DISTRO_PATH, 'utf-8', (err, d) => {
|
||||
if(!err){
|
||||
data = DistroIndex.fromJSON(JSON.parse(d))
|
||||
resolve(data)
|
||||
logger.info('Pulled distribution from local.')
|
||||
return
|
||||
} else {
|
||||
reject(err)
|
||||
@ -617,6 +622,35 @@ exports.pullLocal = function(){
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise.<DistroIndex>}
|
||||
* Runs a remote ETag version check on the distribution file. If it matches the locally stored version, grab the local.
|
||||
*/
|
||||
exports.pullRemoteIfOutdated = function(){
|
||||
return new Promise((resolve, reject) => {
|
||||
request.head(distributionURL, (err, resp) => {
|
||||
if(!err && resp.statusCode === 200){
|
||||
const tag = resp.headers['etag']
|
||||
if(tag === ConfigManager.getDistributionVersion()){
|
||||
this.pullLocal().then(data => {
|
||||
resolve(data)
|
||||
}).catch(err => {
|
||||
resolve(err)
|
||||
})
|
||||
} else {
|
||||
this.pullRemote().then(data => {
|
||||
resolve(data)
|
||||
}).catch(err => {
|
||||
resolve(err)
|
||||
})
|
||||
}
|
||||
} else {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
exports.setDevMode = function(value){
|
||||
if(value){
|
||||
logger.log('Developer mode enabled.')
|
||||
|
@ -37,7 +37,7 @@ function sendLoadFromCacheNotification(data){
|
||||
}
|
||||
|
||||
// Ensure Distribution is downloaded and cached.
|
||||
DistroManager.pullRemote().then((data) => {
|
||||
DistroManager.pullRemoteIfOutdated().then((data) => {
|
||||
logger.log('Loaded distribution index.')
|
||||
|
||||
onDistroLoad(data)
|
||||
|
@ -72,6 +72,7 @@ function setLaunchPercentage(value, max, percent = ((value/max)*100)){
|
||||
function setDownloadPercentage(value, max, percent = ((value/max)*100)){
|
||||
remote.getCurrentWindow().setProgressBar(value/max)
|
||||
setLaunchPercentage(value, max, percent)
|
||||
DiscordWrapper.updateDetails('Downloading... (' + percent + '%)')
|
||||
}
|
||||
|
||||
/**
|
||||
@ -118,16 +119,61 @@ document.getElementById('launch_button').addEventListener('click', function(e){
|
||||
document.getElementById('settingsMediaButton').onclick = (e) => {
|
||||
prepareSettings()
|
||||
switchView(getCurrentView(), VIEWS.settings)
|
||||
if(hasRPC){
|
||||
DiscordWrapper.updateDetails('In the Settings...')
|
||||
DiscordWrapper.clearState()
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('openInstanceMediaButton').onclick = (e) => {
|
||||
if(ConfigManager.getSelectedServer()){
|
||||
shell.openPath(path.join(ConfigManager.getDataDirectory(), 'instances', ConfigManager.getSelectedServer()))
|
||||
let INSTANCE_PATH = path.join(ConfigManager.getDataDirectory(), 'instances', ConfigManager.getSelectedServer())
|
||||
let INSTANCES_PATH = path.join(ConfigManager.getDataDirectory(), 'instances')
|
||||
if(ConfigManager.getSelectedServer() && fs.pathExistsSync(INSTANCE_PATH)){
|
||||
shell.openPath(INSTANCE_PATH)
|
||||
} else if (fs.pathExistsSync(INSTANCES_PATH)){
|
||||
shell.openPath(INSTANCES_PATH)
|
||||
} else {
|
||||
shell.openPath(path.join(ConfigManager.getDataDirectory(), 'instances'))
|
||||
shell.openPath(ConfigManager.getDataDirectory())
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('refreshMediaButton').onclick = (e) => {
|
||||
let ele = document.getElementById('refreshMediaButton')
|
||||
ele.setAttribute('inprogress', '')
|
||||
DistroManager.pullRemote().then((data) => {
|
||||
onDistroRefresh(data)
|
||||
showMainUI(data)
|
||||
setOverlayContent(
|
||||
'Launcher Refreshed!',
|
||||
'This is a confirmation letting you know that you have manually refreshed your launcher, your server list is now up to date and should be good to go! If you have any problems please do let us know!',
|
||||
'Great! Thank you.',
|
||||
'Join our Discord'
|
||||
)
|
||||
setOverlayHandler(() => {
|
||||
toggleOverlay(false)
|
||||
})
|
||||
setDismissHandler(() => {
|
||||
shell.openExternal('https://vcnet.work/discord')
|
||||
})
|
||||
toggleOverlay(true, true)
|
||||
}).catch(err => {
|
||||
setOverlayContent(
|
||||
'Error Refreshing Distribution',
|
||||
'We were unable to grab the latest server information from the internet upon startup, so we have used a previously stored version instead.<br><br>This is not recommended, and you should restart your client to fix this to avoid your modpack files being out of date. If you wish to continue using the launcher, you can try again at any time by pressing the refresh button on the landing screen.<br><br>If this continues to occur, and you are not too sure why, come and see us on Discord!<br><br>Error Code:<br>' + err,
|
||||
'Understood.',
|
||||
'Join our Discord'
|
||||
)
|
||||
setOverlayHandler(() => {
|
||||
toggleOverlay(false)
|
||||
})
|
||||
setDismissHandler(() => {
|
||||
shell.openExternal('https://vcnet.work/discord')
|
||||
})
|
||||
toggleOverlay(true, true)
|
||||
ele.removeAttribute('inprogress')
|
||||
})
|
||||
}
|
||||
|
||||
// Bind avatar overlay button.
|
||||
document.getElementById('avatarOverlay').onclick = (e) => {
|
||||
prepareSettings()
|
||||
@ -262,6 +308,17 @@ const refreshServerStatus = async function(fade = false){
|
||||
|
||||
}
|
||||
|
||||
function loadDiscord(){
|
||||
if(!ConfigManager.getDiscordIntegration()) return
|
||||
const distro = DistroManager.getDistribution()
|
||||
if(!hasRPC){
|
||||
if(distro.discord != null){
|
||||
DiscordWrapper.initRPC(distro.discord, null, '...')
|
||||
hasRPC = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
refreshMojangStatuses()
|
||||
// Server Status is refreshed in uibinder.js on distributionIndexDone.
|
||||
|
||||
@ -337,7 +394,7 @@ function asyncSystemScan(mcVersion, launchAfter = true){
|
||||
// Show this information to the user.
|
||||
setOverlayContent(
|
||||
'No Compatible<br>Java Installation Found',
|
||||
'In order to join WesterosCraft, you need a 64-bit installation of Java 8. Would you like us to install a copy? By installing, you accept <a href="http://www.oracle.com/technetwork/java/javase/terms/license/index.html">Oracle\'s license agreement</a>.',
|
||||
'In order to join any Vicarious Network Modpack, you need a 64-bit installation of Java 8. Would you like us to install a copy? By installing, you accept <a href="http://www.oracle.com/technetwork/java/javase/terms/license/index.html">Oracle\'s license agreement</a>.',
|
||||
'Install Java',
|
||||
'Install Manually'
|
||||
)
|
||||
@ -668,7 +725,8 @@ function dlAsync(login = true){
|
||||
const onLoadComplete = () => {
|
||||
toggleLaunchArea(false)
|
||||
if(hasRPC){
|
||||
DiscordWrapper.updateDetails('Loading game..')
|
||||
DiscordWrapper.updateDetails('Launching game...')
|
||||
DiscordWrapper.resetTime()
|
||||
}
|
||||
proc.stdout.on('data', gameStateChange)
|
||||
proc.stdout.on('data', gameCrashReportListener)
|
||||
@ -698,7 +756,7 @@ function dlAsync(login = true){
|
||||
if(SERVER_JOINED_REGEX.test(data)){
|
||||
DiscordWrapper.updateDetails('Exploring the Realm!')
|
||||
} else if(GAME_JOINED_REGEX.test(data)){
|
||||
DiscordWrapper.updateDetails('Sailing to Westeros!')
|
||||
DiscordWrapper.updateDetails('Sailing to Vicarious Network!')
|
||||
}
|
||||
}
|
||||
|
||||
@ -743,6 +801,14 @@ function dlAsync(login = true){
|
||||
proc.stderr.on('data', gameErrorListener)
|
||||
|
||||
setLaunchDetails('Done. Enjoy the modpack!')
|
||||
proc.on('close', (code, signal) => {
|
||||
if(hasRPC){
|
||||
const serv = DistroManager.getDistribution().getServer(ConfigManager.getSelectedServer())
|
||||
DiscordWrapper.updateDetails('Ready to Play!')
|
||||
DiscordWrapper.updateState('Modpack: ' + serv.getName())
|
||||
DiscordWrapper.resetTime()
|
||||
}
|
||||
})
|
||||
|
||||
// Init Discord Hook
|
||||
const distro = DistroManager.getDistribution()
|
||||
@ -774,30 +840,30 @@ function dlAsync(login = true){
|
||||
// Begin Validations
|
||||
|
||||
// Validate Forge files.
|
||||
setLaunchDetails('Loading server information..')
|
||||
|
||||
refreshDistributionIndex(true, (data) => {
|
||||
validateServerInformation()
|
||||
}
|
||||
|
||||
function validateServerInformation() {
|
||||
|
||||
setLaunchDetails('Loading server information..')
|
||||
DiscordWrapper.updateDetails('Loading server information...')
|
||||
|
||||
DistroManager.pullRemoteIfOutdated().then(data => {
|
||||
onDistroRefresh(data)
|
||||
serv = data.getServer(ConfigManager.getSelectedServer())
|
||||
aEx.send({task: 'execute', function: 'validateEverything', argsArr: [ConfigManager.getSelectedServer(), DistroManager.isDevMode()]})
|
||||
}, (err) => {
|
||||
loggerLaunchSuite.log('Error while fetching a fresh copy of the distribution index.', err)
|
||||
refreshDistributionIndex(false, (data) => {
|
||||
onDistroRefresh(data)
|
||||
}).catch(err => {
|
||||
loggerLaunchSuite.error('Unable to refresh distribution index.', err)
|
||||
if(DistroManager.getDistribution() == null){
|
||||
showLaunchFailure('Fatal Error', 'Could not load a copy of the distribution index. See the console (CTRL + Shift + i) for more details.')
|
||||
|
||||
// Disconnect from AssetExec
|
||||
aEx.disconnect()
|
||||
} else {
|
||||
serv = data.getServer(ConfigManager.getSelectedServer())
|
||||
aEx.send({task: 'execute', function: 'validateEverything', argsArr: [ConfigManager.getSelectedServer(), DistroManager.isDevMode()]})
|
||||
}, (err) => {
|
||||
loggerLaunchSuite.error('Unable to refresh distribution index.', err)
|
||||
if(DistroManager.getDistribution() == null){
|
||||
showLaunchFailure('Fatal Error', 'Could not load a copy of the distribution index. See the console (CTRL + Shift + i) for more details.')
|
||||
|
||||
// Disconnect from AssetExec
|
||||
aEx.disconnect()
|
||||
} else {
|
||||
serv = data.getServer(ConfigManager.getSelectedServer())
|
||||
aEx.send({task: 'execute', function: 'validateEverything', argsArr: [ConfigManager.getSelectedServer(), DistroManager.isDevMode()]})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -907,6 +973,15 @@ document.getElementById('newsButton').onclick = () => {
|
||||
if(newsActive){
|
||||
$('#landingContainer *').removeAttr('tabindex')
|
||||
$('#newsContainer *').attr('tabindex', '-1')
|
||||
if(hasRPC){
|
||||
if(ConfigManager.getSelectedServer()){
|
||||
const serv = DistroManager.getDistribution().getServer(ConfigManager.getSelectedServer())
|
||||
DiscordWrapper.updateDetails('Ready to Play!')
|
||||
DiscordWrapper.updateState('Modpack: ' + serv.getName())
|
||||
} else {
|
||||
DiscordWrapper.updateDetails('Landing Screen...')
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$('#landingContainer *').attr('tabindex', '-1')
|
||||
$('#newsContainer, #newsContainer *, #lower, #lower #center *').removeAttr('tabindex')
|
||||
@ -915,6 +990,10 @@ document.getElementById('newsButton').onclick = () => {
|
||||
newsAlertShown = false
|
||||
ConfigManager.setNewsCacheDismissed(true)
|
||||
ConfigManager.save()
|
||||
if(hasRPC){
|
||||
DiscordWrapper.updateDetails('Reading the News...')
|
||||
DiscordWrapper.clearState()
|
||||
}
|
||||
}
|
||||
}
|
||||
slide_(!newsActive)
|
||||
|
@ -249,6 +249,22 @@ loginCancelButton.onclick = (e) => {
|
||||
loginViewCancelHandler()
|
||||
loginViewCancelHandler = null
|
||||
}
|
||||
if(loginViewOnSuccess === VIEWS.settings){
|
||||
if(hasRPC){
|
||||
DiscordWrapper.updateDetails('In the Settings...')
|
||||
DiscordWrapper.clearState()
|
||||
}
|
||||
} else {
|
||||
if(hasRPC){
|
||||
if(ConfigManager.getSelectedServer()){
|
||||
const serv = DistroManager.getDistribution().getServer(ConfigManager.getSelectedServer())
|
||||
DiscordWrapper.updateDetails('Ready to Play!')
|
||||
DiscordWrapper.updateState('Server: ' + serv.getName())
|
||||
} else {
|
||||
DiscordWrapper.updateDetails('Landing Screen...')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -273,6 +289,20 @@ loginButton.addEventListener('click', () => {
|
||||
// Temporary workaround
|
||||
if(loginViewOnSuccess === VIEWS.settings){
|
||||
prepareSettings()
|
||||
if(hasRPC){
|
||||
DiscordWrapper.updateDetails('In the Settings...')
|
||||
DiscordWrapper.clearState()
|
||||
}
|
||||
} else {
|
||||
if(hasRPC){
|
||||
if(ConfigManager.getSelectedServer()){
|
||||
const serv = DistroManager.getDistribution().getServer(ConfigManager.getSelectedServer())
|
||||
DiscordWrapper.updateDetails('Ready to Play!')
|
||||
DiscordWrapper.updateState('Modpack: ' + serv.getName())
|
||||
} else {
|
||||
DiscordWrapper.updateDetails('Landing Screen...')
|
||||
}
|
||||
}
|
||||
}
|
||||
loginViewOnSuccess = VIEWS.landing // Reset this for good measure.
|
||||
loginCancelEnabled(false) // Reset this for good measure.
|
||||
|
@ -120,6 +120,7 @@ function toggleOverlay(toggleState, dismissable = false, content = 'overlayConte
|
||||
function toggleServerSelection(toggleState) {
|
||||
prepareServerSelectionList()
|
||||
toggleOverlay(toggleState, true, 'serverSelectContent')
|
||||
DiscordWrapper.updateDetails('Selecting modpack...')
|
||||
}
|
||||
|
||||
/**
|
||||
@ -179,6 +180,8 @@ document.getElementById('serverSelectConfirm').addEventListener('click', () => {
|
||||
updateSelectedServer(serv)
|
||||
refreshServerStatus(true)
|
||||
toggleOverlay(false)
|
||||
DiscordWrapper.updateDetails('Ready to Play!')
|
||||
DiscordWrapper.updateState('Modpack: ' + serv.getName())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -312,6 +312,15 @@ settingsNavDone.onclick = () => {
|
||||
saveDropinModConfiguration()
|
||||
saveShaderpackSettings()
|
||||
switchView(getCurrentView(), VIEWS.landing)
|
||||
if(hasRPC){
|
||||
if(ConfigManager.getSelectedServer()){
|
||||
const serv = DistroManager.getDistribution().getServer(ConfigManager.getSelectedServer())
|
||||
DiscordWrapper.updateDetails('Ready to Play!')
|
||||
DiscordWrapper.updateState('Modpack: ' + serv.getName())
|
||||
} else {
|
||||
DiscordWrapper.updateDetails('Landing Screen...')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -324,6 +333,10 @@ document.getElementById('settingsAddAccount').onclick = (e) => {
|
||||
loginViewOnCancel = VIEWS.settings
|
||||
loginViewOnSuccess = VIEWS.settings
|
||||
loginCancelEnabled(true)
|
||||
if(hasRPC){
|
||||
DiscordWrapper.updateDetails('Adding an Account...')
|
||||
DiscordWrapper.clearState()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -410,6 +423,10 @@ function bindAuthAccountLogOut(){
|
||||
processLogOut(val, isLastAccount)
|
||||
toggleOverlay(false)
|
||||
switchView(getCurrentView(), VIEWS.login)
|
||||
if(hasRPC){
|
||||
DiscordWrapper.updateDetails('Adding an Account...')
|
||||
DiscordWrapper.clearState()
|
||||
}
|
||||
})
|
||||
setDismissHandler(() => {
|
||||
toggleOverlay(false)
|
||||
@ -1088,9 +1105,9 @@ settingsMinRAMRange.onchange = (e) => {
|
||||
const max = (os.totalmem()-1000000000)/1000000000
|
||||
|
||||
// Change range bar color based on the selected value.
|
||||
if(sMinV >= max/2){
|
||||
if(sMinV >= max/1.25){
|
||||
bar.style.background = '#e86060'
|
||||
} else if(sMinV >= max/4) {
|
||||
} else if(sMinV >= max/2) {
|
||||
bar.style.background = '#e8e18b'
|
||||
} else {
|
||||
bar.style.background = null
|
||||
@ -1120,9 +1137,9 @@ settingsMaxRAMRange.onchange = (e) => {
|
||||
const max = (os.totalmem()-1000000000)/1000000000
|
||||
|
||||
// Change range bar color based on the selected value.
|
||||
if(sMaxV >= max/2){
|
||||
if(sMaxV >= max/1.25){
|
||||
bar.style.background = '#e86060'
|
||||
} else if(sMaxV >= max/4) {
|
||||
} else if(sMaxV >= max/2) {
|
||||
bar.style.background = '#e8e18b'
|
||||
} else {
|
||||
bar.style.background = null
|
||||
|
@ -65,6 +65,7 @@ function showMainUI(data){
|
||||
prepareSettings(true)
|
||||
updateSelectedServer(data.getServer(ConfigManager.getSelectedServer()))
|
||||
refreshServerStatus()
|
||||
loadDiscord()
|
||||
setTimeout(() => {
|
||||
document.getElementById('frameBar').style.backgroundColor = 'rgba(0, 0, 0, 0.5)'
|
||||
document.body.style.backgroundImage = `url('assets/images/backgrounds/${document.body.getAttribute('bkid')}.jpg')`
|
||||
@ -81,13 +82,30 @@ function showMainUI(data){
|
||||
if(ConfigManager.isFirstLaunch()){
|
||||
currentView = VIEWS.welcome
|
||||
$(VIEWS.welcome).fadeIn(1000)
|
||||
if(hasRPC){
|
||||
DiscordWrapper.updateDetails('Welcome and continue.')
|
||||
DiscordWrapper.updateState('Launcher Setup')
|
||||
}
|
||||
} else {
|
||||
if(isLoggedIn){
|
||||
currentView = VIEWS.landing
|
||||
$(VIEWS.landing).fadeIn(1000)
|
||||
if(hasRPC && !ConfigManager.isFirstLaunch()){
|
||||
if(ConfigManager.getSelectedServer()){
|
||||
const serv = DistroManager.getDistribution().getServer(ConfigManager.getSelectedServer())
|
||||
DiscordWrapper.updateDetails('Ready to Play!')
|
||||
DiscordWrapper.updateState('Modpack: ' + serv.getName())
|
||||
} else {
|
||||
DiscordWrapper.updateDetails('Landing Screen...')
|
||||
}
|
||||
}
|
||||
} else {
|
||||
currentView = VIEWS.login
|
||||
$(VIEWS.login).fadeIn(1000)
|
||||
if(hasRPC){
|
||||
DiscordWrapper.updateDetails('Adding an Account...')
|
||||
DiscordWrapper.clearState()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,14 +128,17 @@ function showFatalStartupError(){
|
||||
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'
|
||||
'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. <br><br>It is very possible that the launcher has updated and changed the location for the distribution index file. We would recommend installing the latest version of the launcher from our releases page. <br><br>If you continue to have issues, please contact us on the Vicarious Network Discord server.',
|
||||
'Download Latest Version',
|
||||
'Join our Discord'
|
||||
)
|
||||
setOverlayHandler(() => {
|
||||
const window = remote.getCurrentWindow()
|
||||
window.close()
|
||||
shell.openExternal('https://github.com/VicariousNetwork/HeliosLauncher/releases/latest')
|
||||
})
|
||||
toggleOverlay(true)
|
||||
setDismissHandler(() => {
|
||||
shell.openExternal('https://vcnet.work/discord')
|
||||
})
|
||||
toggleOverlay(true, true)
|
||||
})
|
||||
}, 750)
|
||||
}
|
||||
@ -302,17 +323,17 @@ function mergeModConfiguration(o, n, nReq = false){
|
||||
return n
|
||||
}
|
||||
|
||||
function refreshDistributionIndex(remote, onSuccess, onError){
|
||||
if(remote){
|
||||
DistroManager.pullRemote()
|
||||
.then(onSuccess)
|
||||
.catch(onError)
|
||||
} else {
|
||||
DistroManager.pullLocal()
|
||||
.then(onSuccess)
|
||||
.catch(onError)
|
||||
}
|
||||
}
|
||||
//function refreshDistributionIndex(remote, onSuccess, onError){
|
||||
// if(remote){
|
||||
// DistroManager.pullRemote()
|
||||
// .then(onSuccess)
|
||||
// .catch(onError)
|
||||
// } else {
|
||||
// DistroManager.pullLocal()
|
||||
// .then(onSuccess)
|
||||
// .catch(onError)
|
||||
// }
|
||||
//}
|
||||
|
||||
async function validateSelectedAccount(){
|
||||
const selectedAcc = ConfigManager.getSelectedAccount()
|
||||
@ -343,6 +364,10 @@ async function validateSelectedAccount(){
|
||||
}
|
||||
toggleOverlay(false)
|
||||
switchView(getCurrentView(), VIEWS.login)
|
||||
if(hasRPC){
|
||||
DiscordWrapper.updateDetails('Adding an Account...')
|
||||
DiscordWrapper.clearState()
|
||||
}
|
||||
})
|
||||
setDismissHandler(() => {
|
||||
if(accLen > 1){
|
||||
|
@ -141,7 +141,7 @@ document.addEventListener('readystatechange', function () {
|
||||
Array.from(document.getElementsByClassName('fCb')).map((val) => {
|
||||
val.addEventListener('click', e => {
|
||||
const window = remote.getCurrentWindow()
|
||||
window.close()
|
||||
window.destroy()
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -3,4 +3,8 @@
|
||||
*/
|
||||
document.getElementById('welcomeButton').addEventListener('click', e => {
|
||||
switchView(VIEWS.welcome, VIEWS.login)
|
||||
if(hasRPC){
|
||||
DiscordWrapper.updateDetails('Adding an Account...')
|
||||
DiscordWrapper.updateState('Launcher Setup')
|
||||
}
|
||||
})
|
5
app/config/constants.js
Normal file
5
app/config/constants.js
Normal file
@ -0,0 +1,5 @@
|
||||
const APP_DATA_NAME = 'Vicarious Network Launcher'
|
||||
const LIVE_DISTRIBUTION_URL = 'https://launcher.vicariousnetwork.com/distribution.json'
|
||||
const DEV_DISTRIBUTION_URL = 'https://launcher.vicariousnetwork.com/dev_distribution.json'
|
||||
|
||||
module.exports = { APP_DATA_NAME, LIVE_DISTRIBUTION_URL, DEV_DISTRIBUTION_URL }
|
@ -25,8 +25,13 @@
|
||||
</svg>
|
||||
<div id="settingsTooltip">Settings</div>
|
||||
</button>
|
||||
<div class="mediaContainer" id="settingsMediaContainer">
|
||||
<button class="mediaButton" id="openInstanceMediaButton">
|
||||
<button class="mediaButton" id="refreshMediaButton">
|
||||
<svg id="refreshSVG" class="mediaSVG" viewBox="0 0 515.556 515.556">
|
||||
<path d="m418.889 290c0 88.832-72.28 161.111-161.111 161.111s-161.111-72.279-161.111-161.111c0-77.798 55.445-142.882 128.889-157.855v61.188l96.667-96.667-96.667-96.666v67.017c-109.124 15.718-193.334 109.578-193.334 222.983 0 124.373 101.182 225.556 225.556 225.556s225.556-101.182 225.556-225.556z" id="svg_4" class=""/>
|
||||
</svg>
|
||||
<div id="settingsTooltip">Refresh</div>
|
||||
</button>
|
||||
<button class="mediaButton" id="openInstanceMediaButton">
|
||||
<svg id="openInstanceSVG" class="mediaSVG" viewBox="0 0 198.084 198.084">
|
||||
<g>
|
||||
<path d="M197.951,77.097l-16.024,78.532c-1.222,5.987-6.488,10.288-12.599,10.288H20.196c-8.135,0-14.225-7.459-12.599-15.429
|
||||
@ -36,8 +41,8 @@
|
||||
v92.186L12.142,78.198z"/>
|
||||
</g>
|
||||
</svg>
|
||||
<div id="settingsTooltip">Data Folder</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mediaDivider"></div>
|
||||
|
@ -179,7 +179,7 @@
|
||||
<span id="settingsMinRAMLabel" class="settingsMemoryLabel">3G</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="settingsMemoryDesc">The recommended minimum RAM is 3 gigabytes. Setting the minimum and maximum values to the same value may reduce lag. In order to use the memory you have allocated, it must be free and available in your system. Allocating all of your total memory is not recommended.</div>
|
||||
<div id="settingsMemoryDesc">The recommended minimum RAM is 4-6 gigabytes. Setting the minimum and maximum values to the same value may reduce lag. In order to use the memory you have allocated, it must be free and available in your system. Allocating all of your total memory is not recommended.</div>
|
||||
</div>
|
||||
<div id="settingsMemoryContentRight">
|
||||
<div id="settingsMemoryStatus">
|
||||
@ -259,6 +259,18 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="settingsFieldContainer">
|
||||
<div class="settingsFieldLeft">
|
||||
<span class="settingsFieldTitle">Enable Discord Integration</span>
|
||||
<span class="settingsFieldDesc">This option will allow the launcher to control your presence on Discord. If you close the launcher at any time, this feature will no longer work.</span>
|
||||
</div>
|
||||
<div class="settingsFieldRight">
|
||||
<label class="toggleSwitch">
|
||||
<input type="checkbox" cValue="DiscordIntegration">
|
||||
<span class="toggleSwitchSlider"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="settingsFileSelContainer">
|
||||
<div class="settingsFileSelContent">
|
||||
<div class="settingsFieldTitle" id="settingsDataDirTitle">Data Directory</div>
|
||||
|
4
index.js
4
index.js
@ -13,6 +13,10 @@ const { pathToFileURL } = require('url')
|
||||
const redirectUriPrefix = 'https://login.microsoftonline.com/common/oauth2/nativeclient?'
|
||||
const clientID = '71a6e661-ee73-4166-a21a-26ce6e15b3de'
|
||||
|
||||
if(isDev) {
|
||||
console.log('Is in dev mode!')
|
||||
}
|
||||
|
||||
// Setup auto updater.
|
||||
function initAutoUpdater(event, data) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user