commit
803b8810f7
@ -127,6 +127,7 @@ const DEFAULT_CONFIG = {
|
||||
},
|
||||
launcher: {
|
||||
allowPrerelease: false,
|
||||
discordIntegration: true,
|
||||
dataDirectory: dataPath,
|
||||
serverCodes: []
|
||||
}
|
||||
@ -790,10 +791,29 @@ exports.getAllowPrerelease = function(def = false){
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the status of Whether or not the launcher should download prerelease versions.
|
||||
* Change the status of whether or not the launcher should download prerelease versions.
|
||||
*
|
||||
* @param {boolean} launchDetached Whether or not the launcher should download prerelease versions.
|
||||
*/
|
||||
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,16 +32,46 @@ exports.initRPC = function(genSettings, servSettings, initialDetails = 'Waiting
|
||||
})
|
||||
}
|
||||
|
||||
exports.updateDetails = function(details){
|
||||
activity.details = details
|
||||
client.setActivity(activity)
|
||||
exports.updateState = function(state){
|
||||
if(client){
|
||||
activity.state = state
|
||||
client.setActivity(activity)
|
||||
logger.log('Updated discord state to: ' + state)
|
||||
}
|
||||
}
|
||||
|
||||
exports.resetTime = function(){
|
||||
exports.clearState = function(){
|
||||
if(client){
|
||||
activity.startTimestamp = new Date().getTime()
|
||||
activity = {
|
||||
details: activity.details,
|
||||
largeImageKey: activity.largeImageKey,
|
||||
largeImageText: activity.largeImageText,
|
||||
startTimestamp: activity.startTimestamp,
|
||||
instance: activity.instance
|
||||
}
|
||||
client.setActivity(activity)
|
||||
logger.log('Reset the activity time!')
|
||||
logger.log('Cleared the activity state!')
|
||||
}
|
||||
}
|
||||
|
||||
exports.updateDetails = function(details){
|
||||
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!')
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,4 +81,8 @@ exports.shutdownRPC = function(){
|
||||
client.destroy()
|
||||
client = null
|
||||
activity = null
|
||||
}
|
||||
|
||||
exports.getClient = function(){
|
||||
return client
|
||||
}
|
@ -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,6 +119,10 @@ 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) => {
|
||||
@ -303,6 +308,27 @@ 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
|
||||
}
|
||||
}
|
||||
setTimeout(() => {
|
||||
if(hasRPC){
|
||||
if(serv){
|
||||
DiscordWrapper.updateDetails('Ready to Play!')
|
||||
DiscordWrapper.updateState('Modpack: ' + serv.getName())
|
||||
} else {
|
||||
DiscordWrapper.updateDetails('Landing Screen...')
|
||||
}
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
refreshMojangStatuses()
|
||||
// Server Status is refreshed in uibinder.js on distributionIndexDone.
|
||||
|
||||
@ -708,6 +734,10 @@ function dlAsync(login = true){
|
||||
|
||||
const onLoadComplete = () => {
|
||||
toggleLaunchArea(false)
|
||||
if(hasRPC){
|
||||
DiscordWrapper.updateDetails('Launching game...')
|
||||
DiscordWrapper.resetTime()
|
||||
}
|
||||
proc.stdout.on('data', gameStateChange)
|
||||
proc.stdout.on('data', gameCrashReportListener)
|
||||
proc.stdout.removeListener('data', tempListener)
|
||||
@ -737,6 +767,7 @@ function dlAsync(login = true){
|
||||
DiscordWrapper.updateDetails('Exploring the Realm!')
|
||||
} else if(GAME_JOINED_REGEX.test(data)){
|
||||
DiscordWrapper.updateDetails('Sailing to Vicarious Network!')
|
||||
DiscordWrapper.resetTime()
|
||||
}
|
||||
}
|
||||
|
||||
@ -783,17 +814,14 @@ function dlAsync(login = true){
|
||||
setLaunchDetails('Done. Enjoy the modpack!')
|
||||
|
||||
// Init Discord Hook
|
||||
const distro = DistroManager.getDistribution()
|
||||
if(distro.discord != null && serv.discord != null){
|
||||
DiscordWrapper.initRPC(distro.discord, serv.discord)
|
||||
hasRPC = true
|
||||
proc.on('close', (code, signal) => {
|
||||
loggerLaunchSuite.log('Shutting down Discord Rich Presence..')
|
||||
DiscordWrapper.shutdownRPC()
|
||||
hasRPC = false
|
||||
proc = null
|
||||
})
|
||||
}
|
||||
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()
|
||||
}
|
||||
})
|
||||
|
||||
} catch(err) {
|
||||
|
||||
@ -819,7 +847,7 @@ function dlAsync(login = true){
|
||||
function validateServerInformation() {
|
||||
|
||||
setLaunchDetails('Loading server information..')
|
||||
|
||||
DiscordWrapper.updateDetails('Loading server information...')
|
||||
DistroManager.pullRemoteIfOutdated().then(data => {
|
||||
onDistroRefresh(data)
|
||||
serv = data.getServer(ConfigManager.getSelectedServer())
|
||||
@ -944,6 +972,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')
|
||||
@ -953,6 +990,10 @@ document.getElementById('newsButton').onclick = () => {
|
||||
ConfigManager.setNewsCacheDismissed(true)
|
||||
ConfigManager.save()
|
||||
}
|
||||
if(hasRPC){
|
||||
DiscordWrapper.updateDetails('Reading the News...')
|
||||
DiscordWrapper.clearState()
|
||||
}
|
||||
}
|
||||
slide_(!newsActive)
|
||||
newsActive = !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('Modpack: ' + 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.
|
||||
@ -341,7 +371,7 @@ ipcRenderer.on('MSALoginWindowReply', (event, ...args) => {
|
||||
let errorDesc = queryMap.get('error_description')
|
||||
if(error === 'access_denied'){
|
||||
error = 'ERRPR'
|
||||
errorDesc = 'To use the Helios Launcher, you must agree to the required permissions! Otherwise you can\'t use this launcher with Microsoft accounts.<br><br>Despite agreeing to the permissions you don\'t give us the possibility to do anything with your account, because all data will always be sent back to you (the launcher) IMMEDIATELY and WITHOUT WAY.'
|
||||
errorDesc = 'To use the Vicarious Network Launcher, you must agree to the required permissions! Otherwise you can\'t use this launcher with Microsoft accounts.<br><br>Despite agreeing to the permissions you don\'t give us the possibility to do anything with your account, because all data will always be sent back to you (the launcher) IMMEDIATELY and WITHOUT WAY.'
|
||||
}
|
||||
setOverlayContent(error, errorDesc, 'OK')
|
||||
setOverlayHandler(() => {
|
||||
@ -366,6 +396,20 @@ ipcRenderer.on('MSALoginWindowReply', (event, ...args) => {
|
||||
// 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 Server...')
|
||||
}
|
||||
|
||||
/**
|
||||
@ -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)
|
||||
|
@ -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('Server: ' + serv.getName())
|
||||
} else {
|
||||
DiscordWrapper.updateDetails('Landing Screen...')
|
||||
}
|
||||
}
|
||||
} else {
|
||||
currentView = VIEWS.login
|
||||
$(VIEWS.login).fadeIn(1000)
|
||||
if(hasRPC){
|
||||
DiscordWrapper.updateDetails('Adding an Account...')
|
||||
DiscordWrapper.clearState()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,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){
|
||||
|
@ -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')
|
||||
}
|
||||
})
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user