aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2021-12-30 22:05:54 +0100
committer0neGal <mail@0negal.com>2021-12-30 22:05:54 +0100
commitee885beeed57d95ffb58922cfc6b826b7ebf9a31 (patch)
tree6cc217060683a950561b3e5da828d52f7b60c63a /src
parent823d34f6f41c65c7b1cb8e55bd429b9efc4f3878 (diff)
downloadViper-ee885beeed57d95ffb58922cfc6b826b7ebf9a31.tar.gz
Viper-ee885beeed57d95ffb58922cfc6b826b7ebf9a31.zip
first-ish draft of the mod UI and utils
Diffstat (limited to 'src')
-rw-r--r--src/app/index.html10
-rw-r--r--src/app/main.css25
-rw-r--r--src/app/main.js8
-rw-r--r--src/cli.js3
-rw-r--r--src/index.js19
-rw-r--r--src/lang/en.json7
-rw-r--r--src/utils.js20
7 files changed, 84 insertions, 8 deletions
diff --git a/src/app/index.html b/src/app/index.html
index dc65d67..edf7fbe 100644
--- a/src/app/index.html
+++ b/src/app/index.html
@@ -20,6 +20,16 @@
<button id="northstar" onclick="launch()">%%gui.launchnorthstar%%</button>
</div>
</div>
+ <div id="modsdiv">
+ </div>
+ <div class="line">
+ <div class="text" id="modcount">%%gui.mods%%</div>
+ <div class="buttons">
+ <button id="removemod">%%gui.mods.removemod%%</button>
+ <button id="removeall">%%gui.mods.removeall%%</button>
+ <button id="installmod">%%gui.mods.install%%</button>
+ </div>
+ </div>
</div>
<script src="lang.js"></script>
diff --git a/src/app/main.css b/src/app/main.css
index b668f55..3684d10 100644
--- a/src/app/main.css
+++ b/src/app/main.css
@@ -1,7 +1,9 @@
:root {
+ --padding: 15px;
--disabled: #656E7F;
- --background: #4C515B;
--foreground: #DDE2EB;
+ --background: #4C515B;
+ --boxbackground: #666E7F;
--btnforeground: var(--foreground);
}
@@ -9,6 +11,7 @@
:root {
--background: #FFFFFF;
--foreground: #4C566A;
+ --boxbackground: #EEF0F4;
--btnforeground: var(--background);
}
}
@@ -33,30 +36,36 @@ nobr {white-space: nowrap}
.line {
display: flex;
- margin-top: 15px;
+ margin-top: var(--padding);
+}
+
+#modsdiv {
+ border-radius: var(--padding);
+ background: var(--boxbackground);
+ margin: calc(var(--padding) / 3) var(--padding);
}
.buttons {
text-align: right;
margin-left: auto;
- margin-right: 7px;
+ margin-right: calc(var(--padding) / 1.9);
}
.text {max-width: 38vw}
.buttons {max-width: 55vw}
-button, .text {
+button, .text, .mod {
border: none;
outline: none;
- padding: 5px 15px;
border-radius: 50px;
transition: 0.2s ease-in-out;
+ padding: calc(var(--padding) / 3) var(--padding);
}
button {
- margin-bottom: 10px;
color: var(--btnforeground);
-webkit-app-region: no-drag;
+ margin-bottom: calc(var(--padding) / 1.5);
}
button:hover {opacity: 0.9}
@@ -66,8 +75,8 @@ button:active {
}
-#update {background: #81A1C1}
+#update, #installmod {background: #81A1C1}
#setpath {background: #5E81AC}
-#northstar {background: #C7777F}
#vanilla, #exit {background: #656E7F}
+#northstar, #removeall, #removemod {background: #C7777F}
button:disabled {background: var(--disabled) !important; opacity: 0.5}
diff --git a/src/app/main.js b/src/app/main.js
index 809b5c8..f512d4f 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -53,6 +53,14 @@ ipcRenderer.on("newpath", (event, newpath) => {
ipcRenderer.on("log", (event, msg) => {log(msg)})
+ipcRenderer.on("mods", (event, mods) => {
+ modcount.innerHTML = `${lang("gui.mods.count")} ${mods.length}`;
+ modsdiv.innerHTML = "";
+ for (let i = 0; i < mods.length; i++) {
+ modsdiv.innerHTML += `<div class="mod">${mods[i].Name}</div>`;
+ }
+})
+
setlang();
setInterval(() => {
ipcRenderer.send("setsize", document.querySelector(".lines").offsetHeight + 20);
diff --git a/src/cli.js b/src/cli.js
index 6696d36..f1962e7 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -10,6 +10,7 @@ const lang = require("./lang");
function hasArgs() {
if (cli.hasSwitch("cli") ||
cli.hasSwitch("help") ||
+ cli.hasSwitch("mods") ||
cli.hasSwitch("update") ||
cli.hasSwitch("launch") ||
cli.hasSwitch("setpath") ||
@@ -65,6 +66,8 @@ async function init() {
break;
}
}
+
+ if (cli.hasSwitch("mods")) {ipcMain.emit("getmods")}
}
module.exports = {
diff --git a/src/index.js b/src/index.js
index c99e367..3f301ae 100644
--- a/src/index.js
+++ b/src/index.js
@@ -41,6 +41,11 @@ function start() {
ipcMain.on("ns-updated", () => {win.webContents.send("ns-updated")})
ipcMain.on("ns-updating", () => {win.webContents.send("ns-updating")})
ipcMain.on("winLog", (event, ...args) => {win.webContents.send("log", ...args)})
+ ipcMain.on("guigetmods", (event, ...args) => {win.webContents.send("mods", utils.mods.list())})
+
+ win.webContents.once("dom-ready", () => {
+ win.webContents.send("mods", utils.mods.list());
+ });
}
ipcMain.on("launch", (event) => {utils.launch()})
@@ -50,6 +55,20 @@ ipcMain.on("launchVanilla", (event) => {utils.launch("vanilla")})
ipcMain.on("update", (event) => {utils.update()})
ipcMain.on("setpathcli", (event) => {utils.setpath()})
+ipcMain.on("getmods", (event) => {
+ let mods = utils.mods.list();
+ if (mods.length > 0) {
+ console.log(`${utils.lang("general.mods.installed")} ${mods.length}`)
+ for (let i = 0; i < mods.length; i++) {
+ console.log(` ${mods[i].Name} ${mods[i].Version}`)
+ }
+ cli.exit(0);
+ } else {
+ console.log("No mods installed");
+ cli.exit(0);
+ }
+})
+
process.chdir(app.getPath("appData"));
if (cli.hasArgs()) {
diff --git a/src/lang/en.json b/src/lang/en.json
index e30d576..0aa7ef2 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -22,6 +22,12 @@
"gui.update": "Update",
"gui.setpath": "Game Path",
+ "gui.mods": "Mods",
+ "gui.mods.count": "Mods Installed:",
+ "gui.mods.install": "Install Mod",
+ "gui.mods.removemod": "Remove Mod",
+ "gui.mods.removeall": "Remove All",
+
"gui.update.downloading": "Downloading...",
"gui.update.extracting": "Extracting update...",
"gui.update.finished": "Done! Ready to play!",
@@ -35,5 +41,6 @@
"general.launching": "Launching",
+ "general.mods.installed": "Installed mods:",
"general.missingpath": "Game path is not set!"
}
diff --git a/src/utils.js b/src/utils.js
index b4ff04d..8bc6440 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -147,7 +147,27 @@ function winLog(msg) {
ipcMain.emit("winLog", msg, msg);
}
+const mods = {
+ list: () => {
+ let mods = [];
+ let modpath = path.join(settings.gamepath, "R2Northstar/mods");
+
+ files = fs.readdirSync(modpath)
+ files.forEach((file) => {
+ if (fs.statSync(path.join(modpath, file)).isDirectory()) {
+ if (fs.existsSync(path.join(modpath, file, "mod.json"))) {
+ mods.push(require(path.join(modpath, file, "mod.json")))
+ }
+ }
+ })
+
+ return mods;
+ },
+}
+
module.exports = {
+ mods,
+ lang,
winLog,
launch,
update,