aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-06-29 21:27:40 +0200
committerGitHub <noreply@github.com>2022-06-29 21:27:40 +0200
commit0c54139fc9279fd081eb57e62008456585ffd927 (patch)
tree8c2e78470c0945e66895cf13cc231b4b672a5400 /src/app
parentd21931a94c20bd37278986185433df60c495250a (diff)
parent4145f882671c5ddde487a456a15dada979ea35c1 (diff)
downloadViper-0c54139fc9279fd081eb57e62008456585ffd927.tar.gz
Viper-0c54139fc9279fd081eb57e62008456585ffd927.zip
Merge branch 'main' into deprecate-nsversiontxt
Diffstat (limited to 'src/app')
-rw-r--r--src/app/browser.js41
-rw-r--r--src/app/css/launcher.css29
-rw-r--r--src/app/css/popups.css18
-rw-r--r--src/app/css/webview.css4
-rw-r--r--src/app/icons/game.pngbin0 -> 1454 bytes
-rw-r--r--src/app/icons/language.pngbin0 -> 7132 bytes
-rw-r--r--src/app/icons/updates.pngbin0 -> 10300 bytes
-rw-r--r--src/app/index.html33
-rw-r--r--src/app/lang.js2
-rw-r--r--src/app/launcher.js56
-rw-r--r--src/app/main.css4
-rw-r--r--src/app/main.js48
-rw-r--r--src/app/settings.js14
13 files changed, 190 insertions, 59 deletions
diff --git a/src/app/browser.js b/src/app/browser.js
index a292cf6..4b9f2e3 100644
--- a/src/app/browser.js
+++ b/src/app/browser.js
@@ -18,7 +18,6 @@ var Browser = {
}
}
- console.log(other)
return pkgs;
},
get: () => {
@@ -88,8 +87,8 @@ var Browser = {
toggle: (state) => {
if (state) {
browser.scrollTo(0, 0);
- overlay.classList.add("shown")
- browser.classList.add("shown")
+ overlay.classList.add("shown");
+ browser.classList.add("shown");
if (browserEntries.querySelectorAll(".el").length == 0) {
Browser.loadfront();
@@ -98,16 +97,16 @@ var Browser = {
} else if (! state) {
if (state != undefined) {
Browser.filters.toggle(false);
- overlay.classList.remove("shown")
- browser.classList.remove("shown")
- preview.classList.remove("shown")
+ overlay.classList.remove("shown");
+ browser.classList.remove("shown");
+ preview.classList.remove("shown");
return
}
}
browser.scrollTo(0, 0);
- overlay.classList.toggle("shown")
- browser.classList.toggle("shown")
+ overlay.classList.toggle("shown");
+ browser.classList.toggle("shown");
},
loadfront: async () => {
Browser.loading();
@@ -162,11 +161,11 @@ var Browser = {
}
if (pkgs.length == 0 || isEnd) {
- Browser.msg(`${lang('gui.browser.endoflist')}`)
+ Browser.msg(`${lang('gui.browser.endoflist')}`);
return
}
- Browser.msg(`<button id="loadmore">${lang("gui.browser.loadmore")}</button>`)
+ Browser.msg(`<button id="loadmore">${lang("gui.browser.loadmore")}</button>`);
loadmore.addEventListener("click", () => {
Browser.loadpkgs(pkgs);
Browser.endoflist(pkgs);
@@ -177,7 +176,7 @@ var Browser = {
let res = fuse.search(string);
if (res.length < 1) {
- Browser.loading(lang("gui.browser.noresults"))
+ Browser.loading(lang("gui.browser.noresults"));
return
}
@@ -244,12 +243,11 @@ var Browser = {
}
Browser.endoflist();
- console.log(pkgs)
break
}
try {
- new BrowserElFromObj(pkgs[i])
+ new BrowserElFromObj(pkgs[i]);
}catch(e) {}
count++;
@@ -375,7 +373,7 @@ function BrowserEl(properties) {
browserEntries.appendChild(entry);
}
-ipcRenderer.on("removedmod", (event, mod) => {
+ipcRenderer.on("removed-mod", (event, mod) => {
setButtons(true);
Browser.setbutton(mod.name, lang("gui.browser.install"));
if (mod.manifestname) {
@@ -383,7 +381,7 @@ ipcRenderer.on("removedmod", (event, mod) => {
}
})
-ipcRenderer.on("failedmod", (event, modname) => {
+ipcRenderer.on("failed-mod", (event, modname) => {
setButtons(true);
new Toast({
timeout: 10000,
@@ -393,7 +391,7 @@ ipcRenderer.on("failedmod", (event, modname) => {
})
})
-ipcRenderer.on("installedmod", (event, mod) => {
+ipcRenderer.on("installed-mod", (event, mod) => {
setButtons(true);
Browser.setbutton(mod.name, lang("gui.browser.reinstall"));
@@ -420,10 +418,12 @@ ipcRenderer.on("installedmod", (event, mod) => {
function normalize(items) {
let main = (string) => {
- return string.replaceAll(" ", "").replaceAll(".", "").replaceAll("-", "").replaceAll("_", "").toLowerCase()
+ return string.replaceAll(" ", "")
+ .replaceAll(".", "").replaceAll("-", "")
+ .replaceAll("_", "").toLowerCase();
}
if (typeof items == "string") {
- return main(items)
+ return main(items);
} else {
let newArray = [];
for (let i = 0; i < items.length; i++) {
@@ -462,7 +462,6 @@ events.forEach((event) => {
let mouseAt = document.elementsFromPoint(mouseX, mouseY);
if (! mouseAt.includes(document.querySelector("#filter"))
&& ! mouseAt.includes(document.querySelector(".overlay"))) {
- console.log(mouseAt)
Browser.filters.toggle(false);
}
})
@@ -498,5 +497,7 @@ browser.addEventListener("mousemove", (event) => {
let checks = document.querySelectorAll(".check");
for (let i = 0; i < checks.length; i++) {
- checks[i].setAttribute("onclick", "this.classList.toggle('checked');Browser.loadfront();search.value = ''")
+ checks[i].setAttribute("onclick",
+ "this.classList.toggle('checked');Browser.loadfront();search.value = ''"
+ )
}
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/css/popups.css b/src/app/css/popups.css
index bff7d07..826955b 100644
--- a/src/app/css/popups.css
+++ b/src/app/css/popups.css
@@ -350,4 +350,22 @@
background: rgb(var(--red));
}
+.switch.on:hover::after {
+ transform: scale(1.2);
+}
+
+.title {
+ display: flex;
+}
+
+.title img {
+ width: 30px;
+ height: 30px;
+ margin: auto 0;
+}
+
+.title h2 {
+ margin-left: calc(var(--padding) / 3);
+}
+
/* } */
diff --git a/src/app/css/webview.css b/src/app/css/webview.css
index 9e26b5d..982ebfc 100644
--- a/src/app/css/webview.css
+++ b/src/app/css/webview.css
@@ -4,9 +4,11 @@ body {
background-color: transparent !important;
}
+#ncmp_tool,
.navbar, .bottom-padding,
.card-header, .breadcrumb,
-.list-group, .mb-4, .my-2, .mt-2 {
+.list-group, .mb-4, .my-2, .mt-2,
+#thunderstore-mod-manager-ad-alert {
display: none !important;
}
diff --git a/src/app/icons/game.png b/src/app/icons/game.png
new file mode 100644
index 0000000..7db058f
--- /dev/null
+++ b/src/app/icons/game.png
Binary files differ
diff --git a/src/app/icons/language.png b/src/app/icons/language.png
new file mode 100644
index 0000000..011e1f9
--- /dev/null
+++ b/src/app/icons/language.png
Binary files differ
diff --git a/src/app/icons/updates.png b/src/app/icons/updates.png
new file mode 100644
index 0000000..4b505ee
--- /dev/null
+++ b/src/app/icons/updates.png
Binary files differ
diff --git a/src/app/index.html b/src/app/index.html
index f67a7a8..819caac 100644
--- a/src/app/index.html
+++ b/src/app/index.html
@@ -36,7 +36,10 @@
</button>
</div>
<div class="options">
- <h2>%%gui.settings.title.ns%%</h2>
+ <div class="title">
+ <img src="icons/game.png">
+ <h2>%%gui.settings.title.ns%%</h2>
+ </div>
<div class="option" name="nsargs">
<div class="text">
%%gui.settings.nsargs.title%%
@@ -48,7 +51,10 @@
<input>
</div>
</div>
- <h2>%%gui.settings.title.language%%</h2>
+ <div class="title">
+ <img src="icons/language.png">
+ <h2>%%gui.settings.title.language%%</h2>
+ </div>
<div class="option" name="autolang">
<div class="text">
%%gui.settings.autolang.title%%
@@ -73,7 +79,10 @@
</select>
</div>
</div>
- <h2>%%gui.settings.title.updates%%</h2>
+ <div class="title">
+ <img src="icons/updates.png">
+ <h2>%%gui.settings.title.updates%%</h2>
+ </div>
<div class="option" name="autoupdate">
<div class="text">
%%gui.settings.autoupdate.title%%
@@ -107,6 +116,21 @@
<input type="text">
</div>
</div>
+ <div class="title">
+ <img src="icons/settings.png">
+ <h2>%%gui.settings.title.misc%%</h2>
+ </div>
+ <div class="option" name="originkill">
+ <div class="text">
+ %%gui.settings.originkill.title%%
+ <div class="desc">
+ %%gui.settings.originkill.desc%%
+ </div>
+ </div>
+ <div class="actions">
+ <button class="switch off"></button>
+ </div>
+ </div>
</div>
</div>
@@ -197,6 +221,7 @@
<div class="inline">
<div id="nsversion"></div>
<a id="update" href="#" onclick="update()">(%%gui.update.check%%)</a>
+ <div id="serverstatus" class="checking"></div>
</div>
</div>
</div>
@@ -240,4 +265,4 @@
<script src="settings.js"></script>
<script src="launcher.js"></script>
</body>
-</html>
+<
diff --git a/src/app/lang.js b/src/app/lang.js
index 6fdcd8d..f1c31d3 100644
--- a/src/app/lang.js
+++ b/src/app/lang.js
@@ -10,7 +10,7 @@ function setlang() {
if (html[i][0] != " " &&
html[i][html[i].length - 1] != " ") {
// Replaces it with it's string
- html[i] = lang(html[i])
+ html[i] = lang(html[i]);
}
}
diff --git a/src/app/launcher.js b/src/app/launcher.js
index 51d3a63..fbeb703 100644
--- a/src/app/launcher.js
+++ b/src/app/launcher.js
@@ -1,10 +1,14 @@
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) {
- let pages = document.querySelectorAll(".mainContainer .contentContainer")
- let btns = document.querySelectorAll(".gamesContainer button")
+ let btns = document.querySelectorAll(".gamesContainer button");
+ let pages = document.querySelectorAll(".mainContainer .contentContainer");
for (let i = 0; i < pages.length; i++) {
pages[i].classList.add("hidden");
@@ -82,7 +86,10 @@ function showVpSection(section) {
}
function showNsSection(section) {
- if (!["main", "release", "mods"].includes(section)) throw new Error("unknown ns section");
+ if (!["main", "release", "mods"].includes(section)) {
+ throw new Error("unknown ns section");
+ }
+
nsMainBtn.removeAttribute("active");
nsModsBtn.removeAttribute("active");
nsReleaseBtn.removeAttribute("active");
@@ -107,3 +114,46 @@ 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;
+
+ playercount = 0;
+ servercount = servers.length;
+
+ for (let i = 0; i < servers.length; i++) {
+ playercount += servers[i].playerCount
+ }
+ }catch (err) {
+ playercount = 0;
+ servercount = 0;
+ masterserver = false;
+ }
+
+ serverstatus.classList.remove("checking");
+
+ 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");
+ serverstatus.innerHTML = `${servercount} ${lang("gui.server.servers")} - ${playercount} ${playerstr}`;
+ } else {
+ serverstatus.classList.add("down");
+ serverstatus.innerHTML = lang("gui.server.offline");
+
+ }
+}; loadServers()
+
+// Refreshes every 5 minutes
+setInterval(() => {
+ loadServers();
+}, 300000)
diff --git a/src/app/main.css b/src/app/main.css
index ce45f35..f39c5a1 100644
--- a/src/app/main.css
+++ b/src/app/main.css
@@ -59,6 +59,10 @@ button:active {filter: brightness(90%)}
#winbtns #minimize {background-image: url("icons/minimize.png")}
#winbtns #settings {background-image: url("icons/settings.png")}
+#winbtns #settings:hover {
+ transform: rotate(90deg);
+}
+
#winbtns div:hover {opacity: 1.0}
#winbtns div:active {transform: scale(0.95)}
/* } */
diff --git a/src/app/main.js b/src/app/main.js
index 362450a..9fb3191 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -14,6 +14,7 @@ var settings = {
autolang: true,
forcedlang: "en",
autoupdate: true,
+ originkill: false,
zip: "/northstar.zip",
lang: navigator.language,
excludes: [
@@ -36,9 +37,9 @@ if (fs.existsSync("viper.json")) {
}catch (e) {
let reset = confirm(lang("general.invalidconfig", navigator.language) + e);
if (! reset) {
- ipcRenderer.send("exit")
+ ipcRenderer.send("exit");
} else {
- fs.writeFileSync("viper.json", "{}")
+ fs.writeFileSync("viper.json", "{}");
ipcRenderer.send("relaunch");
}
@@ -76,12 +77,12 @@ function launch() {
update();
shouldInstallNorthstar = false;
} else {
- ipcRenderer.send("launch");
+ ipcRenderer.send("launch-ns");
}
}
// Tells the main process to launch the vanilla game
-function launchVanilla() {ipcRenderer.send("launchVanilla")}
+function launchVanilla() {ipcRenderer.send("launch-vanilla")}
// In conjunction with utils.js' winLog(), it'll send log messages in
// the devTools from utils.js
@@ -100,13 +101,16 @@ function setButtons(state) {
}
}
- disablearray(document.querySelectorAll(".playBtnContainer .playBtn"))
- disablearray(document.querySelectorAll("#nsMods .buttons.modbtns button"))
- disablearray(document.querySelectorAll("#browser #browserEntries .text button"))
+ disablearray(document.querySelectorAll(".playBtnContainer .playBtn"));
+ disablearray(document.querySelectorAll("#nsMods .buttons.modbtns button"));
+ disablearray(document.querySelectorAll("#browser #browserEntries .text button"));
}
-ipcRenderer.on("setbuttons", (event, state) => {setButtons(state)})
-ipcRenderer.on("gamepathlost", (event, state) => {
+ipcRenderer.on("set-buttons", (event, state) => {
+ setButtons(state);
+})
+
+ipcRenderer.on("gamepath-lost", (event, state) => {
page(0);
setButtons(false);
alert(lang("gui.gamepath.lost"));
@@ -172,7 +176,7 @@ function selected(all) {
}
}
- ipcRenderer.send("removemod", selected)
+ ipcRenderer.send("remove-mod", selected);
},
toggle: () => {
if (selected.match(/^Northstar\./)) {
@@ -185,7 +189,7 @@ function selected(all) {
}
}
- ipcRenderer.send("togglemod", selected)
+ ipcRenderer.send("toggle-mod", selected);
}
}
}
@@ -195,19 +199,18 @@ let installqueue = [];
// Tells the main process to install a mod through the file selector
function installmod() {
setButtons(false);
- ipcRenderer.send("installmod")
+ ipcRenderer.send("install-mod");
}
// Tells the main process to directly install a mod from this path
function installFromPath(path) {
setButtons(false);
- ipcRenderer.send("installfrompath", path)
+ ipcRenderer.send("install-from-path", path);
}
// Tells the main process to install a mod from a URL
function installFromURL(url, dependencies, clearqueue) {
if (clearqueue) {installqueue = []};
- console.log(installqueue)
let prettydepends = [];
@@ -215,7 +218,6 @@ function installFromURL(url, dependencies, clearqueue) {
let newdepends = [];
for (let i = 0; i < dependencies.length; i++) {
let depend = dependencies[i].toLowerCase();
- console.log(depend)
if (! depend.match(/northstar-northstar-.*/)) {
depend = dependencies[i].replaceAll("-", "/");
let pkg = depend.split("/");
@@ -237,7 +239,7 @@ function installFromURL(url, dependencies, clearqueue) {
}
setButtons(false);
- ipcRenderer.send("installfromurl", url, dependencies)
+ ipcRenderer.send("install-from-url", url, dependencies);
if (dependencies) {
installqueue = dependencies;
@@ -262,7 +264,7 @@ function isModInstalled(modname) {
// Frontend part of settings a new game path
ipcRenderer.on("newpath", (event, newpath) => {
settings.gamepath = newpath;
- ipcRenderer.send("guigetmods");
+ ipcRenderer.send("gui-getmods");
})
// Continuation of log()
@@ -310,23 +312,23 @@ ipcRenderer.on("version", (event, versions) => {
shouldInstallNorthstar = true;
playNsBtn.innerText = lang("gui.installnorthstar");
}
-}); ipcRenderer.send("getversion");
+}); ipcRenderer.send("get-version");
// When an update is available it'll ask the user about it
-ipcRenderer.on("updateavailable", () => {
+ipcRenderer.on("update-available", () => {
if (confirm(lang("gui.update.available"))) {
- ipcRenderer.send("updatenow");
+ ipcRenderer.send("update-now");
}
})
// Error out when no game path is set
-ipcRenderer.on("nopathselected", () => {
+ipcRenderer.on("no-path-selected", () => {
alert(lang("gui.gamepath.must"));
exit();
});
// Error out when game path is wrong
-ipcRenderer.on("wrongpath", () => {
+ipcRenderer.on("wrong-path", () => {
alert(lang("gui.gamepath.wrong"));
setpath(false);
});
@@ -355,7 +357,7 @@ document.addEventListener("drop", (e) => {
event.stopPropagation();
dragUI.classList.remove("shown");
- installFromPath(event.dataTransfer.files[0].path)
+ installFromPath(event.dataTransfer.files[0].path);
});
document.body.addEventListener("keyup", (e) => {
diff --git a/src/app/settings.js b/src/app/settings.js
index 23b38c9..63b4b99 100644
--- a/src/app/settings.js
+++ b/src/app/settings.js
@@ -3,26 +3,26 @@ var Settings = {
if (state) {
Settings.load();
options.scrollTo(0, 0);
- overlay.classList.add("shown")
- options.classList.add("shown")
+ overlay.classList.add("shown");
+ options.classList.add("shown");
return
} else if (! state) {
if (state != undefined) {
- overlay.classList.remove("shown")
- options.classList.remove("shown")
+ overlay.classList.remove("shown");
+ options.classList.remove("shown");
return
}
}
Settings.load();
options.scrollTo(0, 0);
- overlay.classList.toggle("shown")
- options.classList.toggle("shown")
+ overlay.classList.toggle("shown");
+ options.classList.toggle("shown");
},
apply: () => {
settings = {...settings, ...Settings.get()};
- ipcRenderer.send("savesettings", Settings.get());
+ ipcRenderer.send("save-settings", Settings.get());
},
reloadSwitches: () => {
let switches = document.querySelectorAll(".switch");