Removed Discord Launcher Integration
Removed RPC Discord Integration
This commit is contained in:
parent
1036adc915
commit
d20601320c
@ -127,7 +127,6 @@ const DEFAULT_CONFIG = {
|
||||
},
|
||||
launcher: {
|
||||
allowPrerelease: false,
|
||||
discordIntegration: true,
|
||||
dataDirectory: dataPath,
|
||||
serverCodes: []
|
||||
}
|
||||
@ -797,23 +796,4 @@ 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,14 +6,16 @@ const {Client} = require('discord-rpc')
|
||||
let client
|
||||
let activity
|
||||
|
||||
exports.initRPC = function(genSettings, servSettings = null, initialDetails = 'Waiting for Client..'){
|
||||
logger.log('Now Loading Discord RPC')
|
||||
exports.initRPC = function(genSettings, servSettings, initialDetails = 'Waiting for Client..'){
|
||||
client = new Client({ transport: 'ipc' })
|
||||
|
||||
activity = {
|
||||
details: initialDetails,
|
||||
largeImageKey: genSettings.smallImageKey,
|
||||
largeImageText: genSettings.smallImageText,
|
||||
state: 'Modpack: ' + servSettings.shortId,
|
||||
largeImageKey: servSettings.largeImageKey,
|
||||
largeImageText: servSettings.largeImageText,
|
||||
smallImageKey: genSettings.smallImageKey,
|
||||
smallImageText: genSettings.smallImageText,
|
||||
startTimestamp: new Date().getTime(),
|
||||
instance: false
|
||||
}
|
||||
@ -32,47 +34,9 @@ exports.initRPC = function(genSettings, servSettings = null, initialDetails = 'W
|
||||
})
|
||||
}
|
||||
|
||||
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){
|
||||
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!')
|
||||
}
|
||||
activity.details = details
|
||||
client.setActivity(activity)
|
||||
}
|
||||
|
||||
exports.resetTime = function(){
|
||||
@ -89,8 +53,4 @@ exports.shutdownRPC = function(){
|
||||
client.destroy()
|
||||
client = null
|
||||
activity = null
|
||||
}
|
||||
|
||||
exports.getClient = function(){
|
||||
return client
|
||||
}
|
@ -72,7 +72,6 @@ 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 + '%)')
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,10 +118,6 @@ 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) => {
|
||||
@ -308,17 +303,6 @@ 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.
|
||||
|
||||
@ -724,10 +708,6 @@ 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)
|
||||
@ -801,14 +781,6 @@ 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()
|
||||
@ -847,7 +819,6 @@ function dlAsync(login = true){
|
||||
function validateServerInformation() {
|
||||
|
||||
setLaunchDetails('Loading server information..')
|
||||
DiscordWrapper.updateDetails('Loading server information...')
|
||||
|
||||
DistroManager.pullRemoteIfOutdated().then(data => {
|
||||
onDistroRefresh(data)
|
||||
@ -973,15 +944,6 @@ 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')
|
||||
@ -990,10 +952,6 @@ document.getElementById('newsButton').onclick = () => {
|
||||
newsAlertShown = false
|
||||
ConfigManager.setNewsCacheDismissed(true)
|
||||
ConfigManager.save()
|
||||
if(hasRPC){
|
||||
DiscordWrapper.updateDetails('Reading the News...')
|
||||
DiscordWrapper.clearState()
|
||||
}
|
||||
}
|
||||
}
|
||||
slide_(!newsActive)
|
||||
|
@ -249,22 +249,6 @@ 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...')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -289,20 +273,6 @@ 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,7 +120,6 @@ function toggleOverlay(toggleState, dismissable = false, content = 'overlayConte
|
||||
function toggleServerSelection(toggleState) {
|
||||
prepareServerSelectionList()
|
||||
toggleOverlay(toggleState, true, 'serverSelectContent')
|
||||
DiscordWrapper.updateDetails('Selecting modpack...')
|
||||
}
|
||||
|
||||
/**
|
||||
@ -180,8 +179,6 @@ document.getElementById('serverSelectConfirm').addEventListener('click', () => {
|
||||
updateSelectedServer(serv)
|
||||
refreshServerStatus(true)
|
||||
toggleOverlay(false)
|
||||
DiscordWrapper.updateDetails('Ready to Play!')
|
||||
DiscordWrapper.updateState('Modpack: ' + serv.getName())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -312,15 +312,6 @@ 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...')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -333,10 +324,6 @@ document.getElementById('settingsAddAccount').onclick = (e) => {
|
||||
loginViewOnCancel = VIEWS.settings
|
||||
loginViewOnSuccess = VIEWS.settings
|
||||
loginCancelEnabled(true)
|
||||
if(hasRPC){
|
||||
DiscordWrapper.updateDetails('Adding an Account...')
|
||||
DiscordWrapper.clearState()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -423,10 +410,6 @@ function bindAuthAccountLogOut(){
|
||||
processLogOut(val, isLastAccount)
|
||||
toggleOverlay(false)
|
||||
switchView(getCurrentView(), VIEWS.login)
|
||||
if(hasRPC){
|
||||
DiscordWrapper.updateDetails('Adding an Account...')
|
||||
DiscordWrapper.clearState()
|
||||
}
|
||||
})
|
||||
setDismissHandler(() => {
|
||||
toggleOverlay(false)
|
||||
|
@ -65,7 +65,6 @@ 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')`
|
||||
@ -82,30 +81,13 @@ 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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -364,10 +346,6 @@ async function validateSelectedAccount(){
|
||||
}
|
||||
toggleOverlay(false)
|
||||
switchView(getCurrentView(), VIEWS.login)
|
||||
if(hasRPC){
|
||||
DiscordWrapper.updateDetails('Adding an Account...')
|
||||
DiscordWrapper.clearState()
|
||||
}
|
||||
})
|
||||
setDismissHandler(() => {
|
||||
if(accLen > 1){
|
||||
|
@ -3,8 +3,4 @@
|
||||
*/
|
||||
document.getElementById('welcomeButton').addEventListener('click', e => {
|
||||
switchView(VIEWS.welcome, VIEWS.login)
|
||||
if(hasRPC){
|
||||
DiscordWrapper.updateDetails('Adding an Account...')
|
||||
DiscordWrapper.updateState('Launcher Setup')
|
||||
}
|
||||
})
|
@ -259,18 +259,6 @@
|
||||
</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