aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-01-19 23:48:14 +0100
committer0neGal <mail@0negal.com>2022-01-19 23:48:14 +0100
commitcc2fcbbdba49149724de7a07415d0dee23cc57d1 (patch)
treebdb657e0ed27fc63c028ecd4572d3bd40482e490 /src
parent45b4c015a14da3a2860a87e7b704a89110943def (diff)
downloadViper-cc2fcbbdba49149724de7a07415d0dee23cc57d1.tar.gz
Viper-cc2fcbbdba49149724de7a07415d0dee23cc57d1.zip
documented the rest of the files
Diffstat (limited to 'src')
-rw-r--r--src/app/launcher.js5
-rw-r--r--src/app/main.js22
-rw-r--r--src/requests.js2
3 files changed, 27 insertions, 2 deletions
diff --git a/src/app/launcher.js b/src/app/launcher.js
index 2c8d123..60c0d18 100644
--- a/src/app/launcher.js
+++ b/src/app/launcher.js
@@ -1,5 +1,7 @@
const markdown = require("marked").parse;
+// 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")
@@ -18,6 +20,7 @@ function page(page) {
}; page(0)
+// Updates the Viper release notes
ipcRenderer.on("vp-notes", (event, response) => {
let content = "";
@@ -28,11 +31,13 @@ ipcRenderer.on("vp-notes", (event, response) => {
vpReleaseNotes.innerHTML = markdown(content);
});
+
async function loadVpReleases() {
ipcRenderer.send("get-vp-notes");
}; loadVpReleases();
+// Updates the Northstar release notes
ipcRenderer.on("ns-notes", (event, response) => {
let content = "";
diff --git a/src/app/main.js b/src/app/main.js
index 893572a..5f0cc9a 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -5,6 +5,7 @@ const { ipcRenderer, shell } = require("electron");
const lang = require("../lang");
let shouldInstallNorthstar = false;
+// Base settings
var settings = {
gamepath: "",
autoupdate: true,
@@ -16,8 +17,10 @@ var settings = {
]
}
+// Sets the lang to the system default
ipcRenderer.send("setlang", settings.lang);
+// Loads the settings
if (fs.existsSync("viper.json")) {
settings = {...settings, ...JSON.parse(fs.readFileSync("viper.json", "utf8"))};
settings.zip = path.join(settings.gamepath + "/northstar.zip");
@@ -38,11 +41,11 @@ function update() {ipcRenderer.send("update")}
// Reports to the main process about game path status.
// @param {boolean} value is game path loaded
-
function setpath(value = false) {
ipcRenderer.send("setpath", value);
}
+// Tells the main process to launch or install Northstar
function launch() {
if (shouldInstallNorthstar) {
update();
@@ -51,17 +54,23 @@ function launch() {
ipcRenderer.send("launch");
}
}
+
+// Tells the main process to launch the vanilla game
function launchVanilla() {ipcRenderer.send("launchVanilla")}
+// In conjunction with utils.js' winLog(), it'll send log messages in
+// the devTools from utils.js
function log(msg) {
console.log(msg);
- // welcome.innerHTML = msg;
}
+// Disables or enables certain buttons when for example
+// updating/installing Northstar.
function setButtons(state) {
playNsBtn.disabled = !state;
}
+// Frontend part of updating Northstar
ipcRenderer.on("ns-update-event", (event, key) => {
document.getElementById("update").innerText = `(${lang(key)})`;
console.log(key);
@@ -90,6 +99,7 @@ function select(entry) {
}
}
+// Mod selection
function selected(all) {
let selected = "";
if (all) {
@@ -138,17 +148,21 @@ function selected(all) {
}
}
+// Tells the main process to install a mod
function installmod() {
ipcRenderer.send("installmod")
}
+// Frontend part of settings a new game path
ipcRenderer.on("newpath", (event, newpath) => {
settings.gamepath = newpath;
})
+// Continuation of log()
ipcRenderer.on("log", (event, msg) => {log(msg)})
ipcRenderer.on("alert", (event, msg) => {alert(msg)})
+// Updates the installed mods
ipcRenderer.on("mods", (event, mods) => {
modcount.innerHTML = `${lang("gui.mods.count")} ${mods.all.length}`;
modsdiv.innerHTML = "";
@@ -169,6 +183,7 @@ ipcRenderer.on("mods", (event, mods) => {
select(lastselected);
})
+// Updates version numbers
ipcRenderer.on("version", (event, versions) => {
vpversion.innerText = versions.vp;
nsversion.innerText = versions.ns;
@@ -187,17 +202,20 @@ ipcRenderer.on("version", (event, versions) => {
}
}); ipcRenderer.send("getversion");
+// When an update is available it'll ask the user about it
ipcRenderer.on("updateavailable", () => {
if (confirm(lang("gui.update.available"))) {
ipcRenderer.send("updatenow");
}
})
+// Error out when no game path is set
ipcRenderer.on("nopathselected", () => {
alert(lang("gui.gamepath.must"));
exit();
});
+// Error out when game path is wrong
ipcRenderer.on("wrongpath", () => {
alert(lang("gui.gamepath.wrong"));
setpath(false);
diff --git a/src/requests.js b/src/requests.js
index 5452b0d..16b1330 100644
--- a/src/requests.js
+++ b/src/requests.js
@@ -71,6 +71,7 @@ function getLatestNsVersionLink() {
return cache[NORTHSTAR_LATEST_RELEASE_KEY]["body"].assets[0].browser_download_url;
}
+// Returns and caches the Northstar release notes
async function getNsReleaseNotes() {
return new Promise(resolve => {
let cache = _getRequestsCache();
@@ -107,6 +108,7 @@ async function getNsReleaseNotes() {
});
}
+// Returns and caches the Viper release notes
async function getVpReleaseNotes() {
return new Promise(resolve => {
let cache = _getRequestsCache();