From a844a146e88faa0c5f7239b5d05869868f2a2aab Mon Sep 17 00:00:00 2001 From: 0neGal Date: Sat, 28 May 2022 01:52:03 +0200 Subject: initial commit for master server status This doesn't fully implement everything as the master server is down whilst making this commit, so I can't fully implement it. --- src/app/css/launcher.css | 29 +++++++++++++++++++++++++++++ src/app/index.html | 3 ++- src/app/launcher.js | 40 ++++++++++++++++++++++++++++++++++++++++ src/lang/en.json | 4 ++++ 4 files changed, 75 insertions(+), 1 deletion(-) diff --git a/src/app/css/launcher.css b/src/app/css/launcher.css index 03812c6..ce54ddf 100644 --- a/src/app/css/launcher.css +++ b/src/app/css/launcher.css @@ -297,3 +297,32 @@ code { margin-top: calc(var(--spacing) / 2); margin-bottom: calc(var(--spacing) / 2); } + +#serverstatus { + --spacing: calc(var(--padding) / 5); + + transition-duration: 0.2s; + transition-timing-function: ease-in-out; + transition-property: background, opacity; + + opacity: 0.0; + display: block; + margin: 0 auto; + font-weight: 700; + width: fit-content; + color: transparent; + border-radius: 50px; + flex-basis: max-content; + background: transparent; + margin-top: calc(var(--spacing) * 2); + padding: var(--spacing) calc(var(--spacing) * 3); +} + +#serverstatus.up, +#serverstatus.down { + color: white; + opacity: 1.0; +} + +#serverstatus.up {background: rgb(var(--blue));} +#serverstatus.down {background: rgb(var(--red));} diff --git a/src/app/index.html b/src/app/index.html index f67a7a8..2305e4c 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -197,6 +197,7 @@
(%%gui.update.check%%) +
@@ -240,4 +241,4 @@ - +< diff --git a/src/app/launcher.js b/src/app/launcher.js index 51d3a63..f426775 100644 --- a/src/app/launcher.js +++ b/src/app/launcher.js @@ -1,5 +1,9 @@ const markdown = require("marked").parse; +var servercount; +var playercount; +var masterserver; + // Changes the main page // This is the tabs in the sidebar function page(page) { @@ -107,3 +111,39 @@ function showNsSection(section) { break; } } + +async function loadServers() { + serverstatus.classList.add("checking"); + + try { + let servers = await (await fetch("https://northstar.tf/client/servers/")).json(); + masterserver = true; + }catch (err) { + playercount = 0; + servercount = 0; + masterserver = false; + } + + serverstatus.classList.remove("checking"); + + if (servercount == 0) {masterserver = false} + + if (masterserver) { + serverstatus.classList.add("up"); + // servercount and playercount don't actually get set anywhere, + // the reason for this is, while writing this code, the master + // server is down so I don't have anyway to test the code... + // + // it'll be added whenever the masterserver comes online again. + serverstatus.innerHTML = `${servercount} ${lang("gui.server.servers")} - ${playercount} ${lang("gui.server.players")}`; + } else { + serverstatus.classList.add("down"); + serverstatus.innerHTML = lang("gui.server.offline"); + + } +}; loadServers() + +// Refreshes every 5 minutes +setInterval(() => { + loadServers(); +}, 300000) diff --git a/src/lang/en.json b/src/lang/en.json index 2c068ac..045517d 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -113,6 +113,10 @@ "gui.nsupdate.gaming.title": "Northstar update available!", "gui.nsupdate.gaming.body": "An update for Northstar is available.\nYou can force its installation after closing the game.", + "gui.server.servers": "servers", + "gui.server.players": "players", + "gui.server.offline": "Masterserver is Offline", + "gui.launch": "Launch", "gui.launchvanilla": "Vanilla", "gui.launchnorthstar": "Northstar", -- cgit v1.2.3 From 45bf3b862d45bd925380f9d5be68b823b6df4998 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Sat, 28 May 2022 03:00:00 +0200 Subject: fully implement server+player counts --- src/app/launcher.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/launcher.js b/src/app/launcher.js index f426775..719048e 100644 --- a/src/app/launcher.js +++ b/src/app/launcher.js @@ -116,8 +116,15 @@ async function loadServers() { serverstatus.classList.add("checking"); try { - let servers = await (await fetch("https://northstar.tf/client/servers/")).json(); + let servers = await (await fetch("https://northstar.tf/client/servers")).json(); masterserver = true; + + playercount = 0; + servercount = servers.length; + + for (let i = 0; i < servers.length; i++) { + playercount += servers[i].playerCount + } }catch (err) { playercount = 0; servercount = 0; @@ -126,7 +133,7 @@ async function loadServers() { serverstatus.classList.remove("checking"); - if (servercount == 0) {masterserver = false} + if (servercount == 0 || ! servercount || ! playercount) {masterserver = false} if (masterserver) { serverstatus.classList.add("up"); -- cgit v1.2.3 From 6e7b66060e8655e013b74140b30f41f6d5ee52e8 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Mon, 30 May 2022 18:15:13 +0200 Subject: support for singular players While it's unlikely we'll ever get down to 1 player, it's best to be on the safe side :p --- src/app/launcher.js | 12 ++++++------ src/lang/en.json | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/app/launcher.js b/src/app/launcher.js index 719048e..569d0fe 100644 --- a/src/app/launcher.js +++ b/src/app/launcher.js @@ -135,14 +135,14 @@ async function loadServers() { if (servercount == 0 || ! servercount || ! playercount) {masterserver = false} + let playerstr = lang("gui.server.players"); + if (playercount == 1) { + playerstr = lang("gui.server.player"); + } + if (masterserver) { serverstatus.classList.add("up"); - // servercount and playercount don't actually get set anywhere, - // the reason for this is, while writing this code, the master - // server is down so I don't have anyway to test the code... - // - // it'll be added whenever the masterserver comes online again. - serverstatus.innerHTML = `${servercount} ${lang("gui.server.servers")} - ${playercount} ${lang("gui.server.players")}`; + serverstatus.innerHTML = `${servercount} ${lang("gui.server.servers")} - ${playercount} ${playerstr}`; } else { serverstatus.classList.add("down"); serverstatus.innerHTML = lang("gui.server.offline"); diff --git a/src/lang/en.json b/src/lang/en.json index 045517d..34c4619 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -113,8 +113,9 @@ "gui.nsupdate.gaming.title": "Northstar update available!", "gui.nsupdate.gaming.body": "An update for Northstar is available.\nYou can force its installation after closing the game.", - "gui.server.servers": "servers", + "gui.server.player": "player", "gui.server.players": "players", + "gui.server.servers": "servers", "gui.server.offline": "Masterserver is Offline", "gui.launch": "Launch", -- cgit v1.2.3 From a52f7ccbf5da1e62b7ff71b08d032663153be885 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Mon, 30 May 2022 18:24:08 +0200 Subject: [feat] add missing French translations --- src/lang/fr.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lang/fr.json b/src/lang/fr.json index 1f37948..3fba39f 100644 --- a/src/lang/fr.json +++ b/src/lang/fr.json @@ -113,6 +113,11 @@ "gui.nsupdate.gaming.title": "Mise à jour Northstar disponible !", "gui.nsupdate.gaming.body": "Une mise à jour pour Northstar est disponible.\nVous pourrez l'installer après avoir fermé le jeu.", + "gui.server.player": "joueur", + "gui.server.players": "joueurs", + "gui.server.servers": "serveurs", + "gui.server.offline": "Le serveur maître est hors-ligne", + "gui.launch": "Jouer", "gui.launchvanilla": "Vanilla", "gui.launchnorthstar": "Northstar", -- cgit v1.2.3 From 03e5208f6ed208f174b6579df0d6c372f9a26a31 Mon Sep 17 00:00:00 2001 From: Delta <31860825+AA-Delta@users.noreply.github.com> Date: Wed, 1 Jun 2022 12:16:24 -0500 Subject: Update es.json #130 --- src/lang/es.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lang/es.json b/src/lang/es.json index 8128440..4efa765 100644 --- a/src/lang/es.json +++ b/src/lang/es.json @@ -130,6 +130,11 @@ "gui.toast.desc.malformed": "tiene una estructura de carpetas incorrecta, si usted es el desarrollador, debe corregir esto.", "gui.toast.desc.failed": "Se produjo un error desconocido al intentar instalar la modificación. Esto puede ser culpa del autor de la modificación, y también puede ser culpa de Viper.", + "gui.server.player": "jugador", + "gui.server.players": "jugadores", + "gui.server.servers": "servidores", + "gui.server.offline": "El servidor Master está desconectado", + "viper.menu.main": "Viper", "viper.menu.release": "Notas de la versión", "viper.menu.info": "Extras", -- cgit v1.2.3