aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/app/browser.js6
-rw-r--r--src/app/main.js30
-rw-r--r--src/app/settings.js2
-rw-r--r--src/index.js54
-rw-r--r--src/utils.js26
5 files changed, 60 insertions, 58 deletions
diff --git a/src/app/browser.js b/src/app/browser.js
index 72ab24e..4b9f2e3 100644
--- a/src/app/browser.js
+++ b/src/app/browser.js
@@ -373,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) {
@@ -381,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,
@@ -391,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"));
diff --git a/src/app/main.js b/src/app/main.js
index d132c35..647e5cd 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -76,12 +76,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
@@ -105,11 +105,11 @@ function setButtons(state) {
disablearray(document.querySelectorAll("#browser #browserEntries .text button"));
}
-ipcRenderer.on("setbuttons", (event, state) => {
+ipcRenderer.on("set-buttons", (event, state) => {
setButtons(state);
})
-ipcRenderer.on("gamepathlost", (event, state) => {
+ipcRenderer.on("gamepath-lost", (event, state) => {
page(0);
setButtons(false);
alert(lang("gui.gamepath.lost"));
@@ -175,7 +175,7 @@ function selected(all) {
}
}
- ipcRenderer.send("removemod", selected);
+ ipcRenderer.send("remove-mod", selected);
},
toggle: () => {
if (selected.match(/^Northstar\./)) {
@@ -188,7 +188,7 @@ function selected(all) {
}
}
- ipcRenderer.send("togglemod", selected);
+ ipcRenderer.send("toggle-mod", selected);
}
}
}
@@ -198,13 +198,13 @@ 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
@@ -238,7 +238,7 @@ function installFromURL(url, dependencies, clearqueue) {
}
setButtons(false);
- ipcRenderer.send("installfromurl", url, dependencies);
+ ipcRenderer.send("install-from-url", url, dependencies);
if (dependencies) {
installqueue = dependencies;
@@ -263,7 +263,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()
@@ -311,23 +311,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);
});
diff --git a/src/app/settings.js b/src/app/settings.js
index 051d6a1..63b4b99 100644
--- a/src/app/settings.js
+++ b/src/app/settings.js
@@ -22,7 +22,7 @@ var Settings = {
},
apply: () => {
settings = {...settings, ...Settings.get()};
- ipcRenderer.send("savesettings", Settings.get());
+ ipcRenderer.send("save-settings", Settings.get());
},
reloadSwitches: () => {
let switches = document.querySelectorAll(".switch");
diff --git a/src/index.js b/src/index.js
index 37ea11e..96976b7 100644
--- a/src/index.js
+++ b/src/index.js
@@ -51,18 +51,18 @@ function start() {
ipcMain.on("relaunch", () => {app.relaunch();app.exit()});
// passthrough to renderer from main
- ipcMain.on("winLog", (event, ...args) => {send("log", ...args)});
- ipcMain.on("winAlert", (event, ...args) => {send("alert", ...args)});
+ ipcMain.on("win-log", (event, ...args) => {send("log", ...args)});
+ ipcMain.on("win-alert", (event, ...args) => {send("alert", ...args)});
// mod states
- ipcMain.on("failedmod", (event, modname) => {send("failedmod", modname)});
- ipcMain.on("removedmod", (event, modname) => {send("removedmod", modname)});
- ipcMain.on("guigetmods", (event, ...args) => {send("mods", utils.mods.list())});
- ipcMain.on("installedmod", (event, modname) => {send("installedmod", modname)});
+ ipcMain.on("failed-mod", (event, modname) => {send("failed-mod", modname)});
+ ipcMain.on("removed-mod", (event, modname) => {send("removed-mod", modname)});
+ ipcMain.on("gui-getmods", (event, ...args) => {send("mods", utils.mods.list())});
+ ipcMain.on("installed-mod", (event, modname) => {send("installed-mod", modname)});
// install calls
- ipcMain.on("installfrompath", (event, path) => {utils.mods.install(path)});
- ipcMain.on("installfromurl", (event, url) => {utils.mods.installFromURL(url)});
+ ipcMain.on("install-from-path", (event, path) => {utils.mods.install(path)});
+ ipcMain.on("install-from-url", (event, url) => {utils.mods.installFromURL(url)});
win.webContents.on("dom-ready", () => {
send("mods", utils.mods.list());
@@ -70,14 +70,14 @@ function start() {
// ensures gamepath still exists and is valid on startup
let gamepathlost = false;
- ipcMain.on("gamepathlost", (event, ...args) => {
+ ipcMain.on("gamepath-lost", (event, ...args) => {
if (! gamepathlost) {
gamepathlost = true;
- send("gamepathlost");
+ send("gamepath-lost");
}
});
- ipcMain.on("savesettings", (event, obj) => {utils.saveSettings(obj)});
+ ipcMain.on("save-settings", (event, obj) => {utils.saveSettings(obj)});
// allows renderer to check for updates
ipcMain.on("ns-update-event", (event) => {send("ns-update-event", event)});
@@ -99,19 +99,19 @@ function start() {
}
autoUpdater.on("update-downloaded", () => {
- send("updateavailable");
+ send("update-available");
});
// updates and restarts Viper, if user says yes to do so.
// otherwise it'll do it on the next start up.
- ipcMain.on("updatenow", () => {
+ ipcMain.on("update-now", () => {
autoUpdater.quitAndInstall();
})
}
// General events used to handle utils.js stuff without requiring the
// module inside the file that sent the event. {
-ipcMain.on("installmod", () => {
+ipcMain.on("install-mod", () => {
if (cli.hasArgs()) {
utils.mods.install(cli.param("installmod"));
} else {
@@ -119,22 +119,22 @@ ipcMain.on("installmod", () => {
if (res.filePaths.length != 0) {
utils.mods.install(res.filePaths[0]);
} else {
- send("setbuttons", true);
+ send("set-buttons", true);
}
}).catch(err => {error(err)});
}
})
-ipcMain.on("removemod", (event, mod) => {utils.mods.remove(mod)});
-ipcMain.on("togglemod", (event, mod) => {utils.mods.toggle(mod)});
+ipcMain.on("remove-mod", (event, mod) => {utils.mods.remove(mod)});
+ipcMain.on("toggle-mod", (event, mod) => {utils.mods.toggle(mod)});
-ipcMain.on("launch", () => {utils.launch()});
-ipcMain.on("launchVanilla", () => {utils.launch("vanilla")});
+ipcMain.on("launch-ns", () => {utils.launch()});
+ipcMain.on("launch-vanilla", () => {utils.launch("vanilla")});
ipcMain.on("setlang", (event, lang) => {utils.setlang(lang)});
ipcMain.on("update", () => {utils.update()})
-ipcMain.on("setpathcli", () => {utils.setpath()});
+ipcMain.on("setpath-cli", () => {utils.setpath()});
ipcMain.on("setpath", (event, value) => {
if (! value) {
if (! win.isVisible()) {
@@ -157,10 +157,10 @@ function sendVersionsInfo() {
}
// sends the version info back to the renderer
-ipcMain.on("getversion", () => {sendVersionsInfo()});
+ipcMain.on("get-version", () => {sendVersionsInfo()});
// prints out version info for the CLI
-ipcMain.on("versioncli", () => {
+ipcMain.on("version-cli", () => {
log("Viper: v" + require("../package.json").version);
log("Northstar: " + utils.getNSVersion());
log("Node: " + process.version);
@@ -168,6 +168,7 @@ ipcMain.on("versioncli", () => {
cli.exit();
})
+// sends installed mods info to renderer
ipcMain.on("getmods", () => {
let mods = utils.mods.list();
if (mods.all.length > 0) {
@@ -191,17 +192,18 @@ ipcMain.on("getmods", () => {
})
// }
+// allows renderer to set a new renderer
ipcMain.on("newpath", (event, newpath) => {
- if (newpath === false && !win.isVisible()) {
- win.send("nopathselected");
+ if (newpath === false && ! win.isVisible()) {
+ win.send("no-path-selected");
} else {
_sendVersionsInfo();
if (!win.isVisible()) {
win.show();
}
}
-}); ipcMain.on("wrongpath", () => {
- win.send("wrongpath");
+}); ipcMain.on("wrong-path", () => {
+ win.send("wrong-path");
});
// ensures PWD/CWD is the config folder where viper.json is located
diff --git a/src/utils.js b/src/utils.js
index d8e968c..b69a9a2 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -42,12 +42,12 @@ var settings = {
// Logs into the dev tools of the renderer
function winLog(msg) {
- ipcMain.emit("winLog", msg, msg);
+ ipcMain.emit("win-log", msg, msg);
}
// Sends an alert to the renderer
function winAlert(msg) {
- ipcMain.emit("winAlert", msg, msg);
+ ipcMain.emit("win-alert", msg, msg);
}
// Creates the settings file with the base settings if it doesn't exist.
@@ -187,7 +187,7 @@ async function setpath(win, forcedialog) {
return;
}
if (! fs.existsSync(path.join(res.filePaths[0], "Titanfall2.exe"))) {
- ipcMain.emit("wrongpath");
+ ipcMain.emit("wrong-path");
return;
}
@@ -326,11 +326,11 @@ async function update() {
fs.createReadStream(settings.zip).pipe(unzip.Extract({path: settings.gamepath}))
.on("finish", () => {
fs.writeFileSync(path.join(settings.gamepath, "ns_version.txt"), latestAvailableVersion);
- ipcMain.emit("getversion");
+ ipcMain.emit("get-version");
restoreExcludedFiles();
- ipcMain.emit("guigetmods");
+ ipcMain.emit("gui-getmods");
ipcMain.emit("ns-update-event", "cli.update.uptodate.short");
winLog(lang("gui.update.finished"));
console.log(lang("cli.update.finished"));
@@ -603,11 +603,11 @@ const mods = {
}
}
- ipcMain.emit("installedmod", "", {
+ ipcMain.emit("installed-mod", "", {
name: modname,
malformed: malformed,
});
- ipcMain.emit("guigetmods");
+ ipcMain.emit("gui-getmods");
return true;
}
@@ -679,7 +679,7 @@ const mods = {
}
if (files.length == 0) {
- ipcMain.emit("failedmod");
+ ipcMain.emit("failed-mod");
return notamod();
}
}
@@ -778,8 +778,8 @@ const mods = {
fs.rmSync(modPath, {recursive: true});
console.log(lang("cli.mods.removed"));
cli.exit();
- ipcMain.emit("guigetmods");
- ipcMain.emit("removedmod", "", {
+ ipcMain.emit("gui-getmods");
+ ipcMain.emit("removed-mod", "", {
name: mod.replace(/^.*(\\|\/|\:)/, ""),
manifestname: manifestname
});
@@ -818,17 +818,17 @@ const mods = {
console.log(lang("cli.mods.toggled"));
cli.exit();
}
- ipcMain.emit("guigetmods");
+ ipcMain.emit("gui-getmods");
}
};
setInterval(() => {
if (gamepathExists()) {
- ipcMain.emit("guigetmods");
+ ipcMain.emit("gui-getmods");
} else {
if (fs.existsSync("viper.json")) {
if (settings.gamepath != "") {
- ipcMain.emit("gamepathlost");
+ ipcMain.emit("gamepath-lost");
}
}
}