From f88b54e8c59f18f52531d85fb9262166c675ad2d Mon Sep 17 00:00:00 2001 From: TheFlash787 Date: Fri, 14 Aug 2020 02:12:59 +0100 Subject: [PATCH] Added support for showing multiple servers for the same code inside of the launcher. --- app/assets/css/launcher.css | 11 +++++++++- app/assets/js/distromanager.js | 9 ++++---- app/assets/js/scripts/settings.js | 35 +++++++++++++++++++++++++++---- app/settings.ejs | 1 + 4 files changed, 47 insertions(+), 9 deletions(-) diff --git a/app/assets/css/launcher.css b/app/assets/css/launcher.css index 278da6f..847114a 100644 --- a/app/assets/css/launcher.css +++ b/app/assets/css/launcher.css @@ -1387,7 +1387,16 @@ input:checked + .toggleSwitchSlider:before { font-weight: bold; } -.settingsServerCode:not([valid]) > .settingsServerCodeContent > .settingsServerCodeMainWrapper > .settingsServerCodeDetails > .settingsServerCodeServerName { +.settingsServerCodeServerNamesContent { + max-width: 650px; +} + +.settingsServerCodeServerName { + margin-right: 35px; + font-size: 14px; +} + +.settingsServerCode:not([valid]) > .settingsServerCodeContent > .settingsServerCodeMainWrapper > .settingsServerCodeDetails > .settingsServerCodeServerNamesContent > .settingsServerCodeServerName { color: red; } diff --git a/app/assets/js/distromanager.js b/app/assets/js/distromanager.js index 7407374..2422e76 100644 --- a/app/assets/js/distromanager.js +++ b/app/assets/js/distromanager.js @@ -512,15 +512,16 @@ class DistroIndex { * * @param {string} id The ID of the server. * - * @returns {Server} The server configuration with the given ID or null. + * @returns {Server[]} The server configuration with the given ID or null. */ - getServerFromCode(code){ + getServersFromCode(code){ + let servs = [] for(let serv of this.servers){ if(serv.serverCode === code){ - return serv + servs.push(serv) } } - return null + return servs } /** diff --git a/app/assets/js/scripts/settings.js b/app/assets/js/scripts/settings.js index d0368d1..27fdbe1 100644 --- a/app/assets/js/scripts/settings.js +++ b/app/assets/js/scripts/settings.js @@ -732,18 +732,21 @@ function resolveDropinModsForUI(){ } function resolveServerCodesForUI(){ + /* Server Codes */ let servCodes = '' for(let servCode of ConfigManager.getServerCodes()){ - const serv = DistroManager.getDistribution().getServerFromCode(servCode) + const servs = DistroManager.getDistribution().getServersFromCode(servCode) + const valid = servs && servs.length servCodes += ` -
+
${servCode} - ${serv ? serv.getName() : 'Invalid Code'} +
+
@@ -755,8 +758,32 @@ function resolveServerCodesForUI(){ } document.getElementById('settingsServerCodesListContent').innerHTML = servCodes -} + /* Server Names List */ + for(let ele of document.getElementsByClassName('settingsServerCodeServerNamesContent')){ + servNames = '' + const code = ele.getAttribute('code') + const servs = DistroManager.getDistribution().getServersFromCode(code) + const valid = servs && servs.length + loggerSettings.log('valid: ' + valid) + if(valid){ + for(let serv of servs){ + loggerSettings.log('server: ' + serv.getName()) + servNames += + ` + ${serv.getName()} + ` + } + } else { + servNames = + ` + Invalid Code + ` + } + + ele.innerHTML = servNames + } +} /** * Bind the remove button for each loaded drop-in mod. */ diff --git a/app/settings.ejs b/app/settings.ejs index 142effa..25bc7e5 100644 --- a/app/settings.ejs +++ b/app/settings.ejs @@ -275,6 +275,7 @@
+
Specify server codes here to grant access to hidden servers that wouldn't be available to all users by default.