aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app/main.js2
-rw-r--r--src/index.js1
-rw-r--r--src/utils.js24
3 files changed, 23 insertions, 4 deletions
diff --git a/src/app/main.js b/src/app/main.js
index 897c82c..8db6561 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -104,9 +104,9 @@ ipcRenderer.on("newpath", (event, newpath) => {
})
ipcRenderer.on("log", (event, msg) => {log(msg)})
+ipcRenderer.on("alert", (event, msg) => {alert(msg)})
ipcRenderer.on("mods", (event, mods) => {
- console.log("refreshed mods")
modcount.innerHTML = `${lang("gui.mods.count")} ${mods.all.length}`;
modsdiv.innerHTML = "";
diff --git a/src/index.js b/src/index.js
index 7ef9321..45400a5 100644
--- a/src/index.js
+++ b/src/index.js
@@ -42,6 +42,7 @@ 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("winAlert", (event, ...args) => {win.webContents.send("alert", ...args)})
ipcMain.on("guigetmods", (event, ...args) => {win.webContents.send("mods", utils.mods.list())})
win.webContents.once("dom-ready", () => {
diff --git a/src/utils.js b/src/utils.js
index ef8b586..a34f91f 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -166,6 +166,10 @@ function winLog(msg) {
ipcMain.emit("winLog", msg, msg);
}
+function winAlert(msg) {
+ ipcMain.emit("winAlert", msg, msg);
+}
+
let modpath = path.join(settings.gamepath, "R2Northstar/mods");
const mods = {
list: () => {
@@ -220,7 +224,9 @@ const mods = {
},
install: (mod) => {
if (fs.statSync(mod).isDirectory()) {
- if (fs.statSync(path.join(mod, "mod.json"))) {
+ if (fs.existsSync(path.join(mod, "mod.json")) &&
+ fs.statSync(path.join(mod, "mod.json")).isFile()) {
+
copy.sync(mod, path.join(modpath, mod.replace(/^.*(\\|\/|\:)/, "")), {
mode: true,
cover: true,
@@ -228,11 +234,23 @@ const mods = {
});
cli.exit();
ipcMain.emit("guigetmods");
- return
+ return true;
} else {
+ files = fs.readdirSync(mod);
+
+ for (let i = 0; i < files.length; i++) {
+ if (fs.statSync(path.join(mod, files[i])).isDirectory()) {
+ if (fs.existsSync(path.join(mod, files[i], "mod.json")) &&
+ fs.statSync(path.join(mod, files[i], "mod.json")).isFile()) {
+
+ if (mods.install(path.join(mod, files[i]))) {return};
+ }
+ }
+ }
+ winAlert(lang("cli.mods.notamod"))
console.log("error: " + lang("cli.mods.notamod"))
cli.exit(1);
- return;
+ return false;
}
}