Added support for showing multiple servers for the same code inside of the launcher.

This commit is contained in:
TheFlash787 2020-08-14 02:12:59 +01:00
parent f5d51413ad
commit f88b54e8c5
4 changed files with 47 additions and 9 deletions

View File

@ -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;
}

View File

@ -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
}
/**

View File

@ -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 +=
`
<div id="${servCode}" class="settingsServerCode" ${serv ? 'valid' : ''}>
<div id="${servCode}" class="settingsServerCode" ${valid ? 'valid' : ''}>
<div class="settingsServerCodeContent">
<div class="settingsServerCodeMainWrapper">
<div class="settingsServerCodeStatus"></div>
<div class="settingsServerCodeDetails">
<span class="settingsServerCodeName">${servCode}</span>
<span class="settingsServerCodeServerName"> ${serv ? serv.getName() : 'Invalid Code'}</span>
<div class="settingsServerCodeServerNamesContent" code="${servCode}">
</div>
</div>
</div>
<div class="settingsServerCodeRemoveWrapper">
@ -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 +=
`
<span class="settingsServerCodeServerName">${serv.getName()}</span>
`
}
} else {
servNames =
`
<span class="settingsServerCodeServerName">Invalid Code</span>
`
}
ele.innerHTML = servNames
}
}
/**
* Bind the remove button for each loaded drop-in mod.
*/

View File

@ -275,6 +275,7 @@
</div>
</div>
<div id="settingsServerCodesListContent">
</div>
<div class="settingsServerCodesDesc">Specify server codes here to grant access to hidden servers that wouldn't be available to all users by default.</div>
</div>