aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/viper.115
-rw-r--r--docs/viper.1.md16
-rw-r--r--src/cli.js27
-rw-r--r--src/index.js16
-rw-r--r--src/lang/en.json9
-rw-r--r--src/utils.js26
6 files changed, 94 insertions, 15 deletions
diff --git a/docs/viper.1 b/docs/viper.1
index 5b5b913..52ec4c5 100644
--- a/docs/viper.1
+++ b/docs/viper.1
@@ -31,6 +31,18 @@ Viper is a program made to make updating and launching Northstar a lot easier\.
.P
\fB\-\-setpath\fP=<absolute\-path>
Sets the game path, this'll change the \fBgamepath\fP variable in your \fBviper\.json\fP, note that it only takes in absolute paths and not relative ones\.
+.P
+\fB\-\-mods\fP
+ Lists out all installed mods, and gives a count on how many are installed, enabled and or disabled\.
+.P
+\fB\-\-installmod\fP=<absolute\-path>
+ Installs a mod, this supports both Zip files and folders, just that the \fBmod\.json\fP file is easily found is all that matters\.
+.P
+\fB\-\-removemod\fP=<mod name>
+ Removes a mod, the mod name should be taken from \fB\-\-mods\fP as it provides accurate names\. Putting in \fBallmods\fP will remove all mods, no confirmation\.
+.P
+\fB\-\-togglemod\fP=<mod name>
+ Toggles a mod, the mod name should be taken from \fB\-\-mods\fP as it provides accurate names\. Putting in \fBallmods\fP will toggle all mods\. Keep in mind, if a mod is already disabled and some mods are enabled, the states will be flipped, so 3 enabled and 1 disabled, goes to 1 enabled and 3 disabled\.
.SH CONFIGURATION
.P
All configuration takes place in your \fBviper\.json\fP file, this file may be in various locations depending on your platform, for Linux you're likely to find it at:
@@ -45,6 +57,9 @@ All configuration takes place in your \fBviper\.json\fP file, this file may be i
On Windows it's likely to be in \fB%APPDATA%\\viper\.json\fP
.P
All configuration is done by Viper itself, the locale is auto set when the GUI launches through your systems locale, the gamepath is selected with \fB\-\-setpath\fP or in the GUI\.
+.SH MOD SUPPORT
+.P
+To toggle mods since Northstar itself has no filter as to what mods it loads, we have to move the mods into a separate folder, that folder being \fBdisabled\fP inside \fBR2Northstar/mods\fP, so you can also just manually move these if you want\.
.SH BUGS
.P
Report bugs on the GitHub issues page, and feel free to make a pull request if you also have the fix to the bug\.
diff --git a/docs/viper.1.md b/docs/viper.1.md
index e271f4f..daa9263 100644
--- a/docs/viper.1.md
+++ b/docs/viper.1.md
@@ -34,6 +34,18 @@ Viper is a program made to make updating and launching Northstar a lot easier. I
`--setpath`=<absolute-path>
Sets the game path, this'll change the `gamepath` variable in your `viper.json`, note that it only takes in absolute paths and not relative ones.
+`--mods`
+ Lists out all installed mods, and gives a count on how many are installed, enabled and or disabled.
+
+`--installmod`=<absolute-path>
+ Installs a mod, this supports both Zip files and folders, just that the `mod.json` file is easily found is all that matters.
+
+`--removemod`=<mod name>
+ Removes a mod, the mod name should be taken from `--mods` as it provides accurate names. Putting in `allmods` will remove all mods, no confirmation.
+
+`--togglemod`=<mod name>
+ Toggles a mod, the mod name should be taken from `--mods` as it provides accurate names. Putting in `allmods` will toggle all mods. Keep in mind, if a mod is already disabled and some mods are enabled, the states will be flipped, so 3 enabled and 1 disabled, goes to 1 enabled and 3 disabled.
+
## CONFIGURATION
All configuration takes place in your `viper.json` file, this file may be in various locations depending on your platform, for Linux you're likely to find it at:
@@ -45,6 +57,10 @@ On Windows it's likely to be in `%APPDATA%\viper.json`
All configuration is done by Viper itself, the locale is auto set when the GUI launches through your systems locale, the gamepath is selected with `--setpath` or in the GUI.
+## MOD SUPPORT
+
+To toggle mods since Northstar itself has no filter as to what mods it loads, we have to move the mods into a separate folder, that folder being `disabled` inside `R2Northstar/mods`, so you can also just manually move these if you want.
+
## BUGS
Report bugs on the GitHub issues page, and feel free to make a pull request if you also have the fix to the bug.
diff --git a/src/cli.js b/src/cli.js
index 55cee0e..d5ee3ad 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -16,7 +16,10 @@ function hasArgs() {
cli.hasSwitch("setpath") ||
cli.hasSwitch("version") ||
cli.hasSwitch("updatevp") ||
- cli.hasSwitch("gamepath")) {
+ cli.hasSwitch("gamepath") ||
+ cli.hasSwitch("togglemod") ||
+ cli.hasSwitch("removemod") ||
+ cli.hasSwitch("installmod")) {
return true;
} else {return false}
}
@@ -28,14 +31,18 @@ function exit(code) {
async function init() {
if (cli.hasSwitch("help")) {
console.log(`options:
- --help ${lang("cli.help.help")}
- --debug ${lang("cli.help.debug")}
- --version ${lang("cli.help.version")}
+ --help ${lang("cli.help.help")}
+ --debug ${lang("cli.help.debug")}
+ --version ${lang("cli.help.version")}
- --cli ${lang("cli.help.cli")}
- --update ${lang("cli.help.update")}
- --updatevp ${lang("cli.help.updatevp")}
- --setpath ${lang("cli.help.setpath")}`)
+ --cli ${lang("cli.help.cli")}
+ --update ${lang("cli.help.update")}
+ --updatevp ${lang("cli.help.updatevp")}
+ --setpath ${lang("cli.help.setpath")}
+
+ --installmod ${lang("cli.help.installmod")}
+ --removemod ${lang("cli.help.removemod")}
+ --togglemod ${lang("cli.help.togglemod")}`)
// In the future --setpath should be able to understand
// relative paths, instead of just absolute ones.
exit();
@@ -64,6 +71,10 @@ async function init() {
}
}
+ if (cli.hasSwitch("installmod")) {ipcMain.emit("installmod")}
+ if (cli.hasSwitch("removemod")) {ipcMain.emit("removemod", "", cli.getSwitchValue("removemod"))}
+ if (cli.hasSwitch("togglemod")) {ipcMain.emit("togglemod", "", cli.getSwitchValue("togglemod"))}
+
if (cli.hasSwitch("mods")) {ipcMain.emit("getmods")}
}
diff --git a/src/index.js b/src/index.js
index c03326c..09aa626 100644
--- a/src/index.js
+++ b/src/index.js
@@ -54,15 +54,20 @@ function start() {
ipcMain.on("updatenow", () => {
autoUpdater.quitAndInstall();
})
+}
- ipcMain.on("removemod", (event, mod) => {utils.mods.remove(mod)})
- ipcMain.on("togglemod", (event, mod) => {utils.mods.toggle(mod)})
- ipcMain.on("installmod", () => {
+ipcMain.on("installmod", () => {
+ if (cli.hasArgs()) {
+ utils.mods.install(cli.param("installmod"))
+ } else {
dialog.showOpenDialog({properties: ["openFile"]}).then(res => {
utils.mods.install(res.filePaths[0]);
}).catch(err => {console.error(err)})
- })
-}
+ }
+})
+
+ipcMain.on("removemod", (event, mod) => {utils.mods.remove(mod)})
+ipcMain.on("togglemod", (event, mod) => {utils.mods.toggle(mod)})
ipcMain.on("launch", (event) => {utils.launch()})
ipcMain.on("setlang", (event, lang) => {utils.setlang(lang)})
@@ -77,6 +82,7 @@ ipcMain.on("setpath", (event, value) => {
win.show();
}
});
+
ipcMain.on("newpath", (event, newpath) => {
if (newpath === false && !win.isVisible()) {
win.webContents.send("nopathselected");
diff --git a/src/lang/en.json b/src/lang/en.json
index 3f025a8..aa76cdf 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -6,6 +6,9 @@
"cli.help.update": "updates Northstar from your set game path",
"cli.help.setpath": "sets your game path",
"cli.help.updatevp": "updates Viper itself, if supported.",
+ "cli.help.installmod": "installs a mod, folder or zip",
+ "cli.help.removemod": "removes a mod",
+ "cli.help.togglemod": "toggles a mod",
"cli.setpath.noarg": "No argument provided for --setpath",
@@ -18,7 +21,13 @@
"cli.launch.linuxerror": "Launching the game is not currently supported on Linux",
+ "cli.mods.failed": "Failed to install mod!",
+ "cli.mods.removed": "Successfully removed mod!",
+ "cli.mods.toggled": "Successfully toggled mod",
+ "cli.mods.installed": "Successfully installed mod!",
+ "cli.mods.cantfind": "Can't find a mod with that name!",
"cli.mods.notamod": "Selected folder/file is not a mod",
+ "cli.mods.toggledall": "Successfully toggled all mods",
"cli.mods.improperjson": "%s's mod.json has formatting errors",
"gui.welcome": "Welcome to Viper!",
diff --git a/src/utils.js b/src/utils.js
index 18c52da..1e05fed 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -245,7 +245,9 @@ const mods = {
}
let installed = () => {
+ console.log(lang("cli.mods.installed"));
cli.exit();
+
winLog(lang("gui.mods.installedmod"))
ipcMain.emit("guigetmods");
}
@@ -314,6 +316,12 @@ const mods = {
}
let modName = mods.get(mod).FolderName;
+ if (! modName) {
+ console.log("error: " + lang("cli.mods.cantfind"))
+ cli.exit(1);
+ return;
+ }
+
let modPath = path.join(modpath, modName);
if (mods.get(mod).Disabled) {
@@ -322,18 +330,22 @@ const mods = {
if (fs.statSync(modPath).isDirectory()) {
fs.rmSync(modPath, {recursive: true});
+ console.log(lang("cli.mods.removed"));
cli.exit();
ipcMain.emit("guigetmods");
} else {
cli.exit(1);
}
},
- toggle: (mod) => {
+ toggle: (mod, fork) => {
if (mod == "allmods") {
let modlist = mods.list().all;
for (let i = 0; i < modlist.length; i++) {
- mods.toggle(modlist[i].Name)
+ mods.toggle(modlist[i].Name, true)
}
+
+ console.log(lang("cli.mods.toggledall"));
+ cli.exit(0);
return
}
@@ -343,6 +355,12 @@ const mods = {
}
let modName = mods.get(mod).FolderName;
+ if (! modName) {
+ console.log("error: " + lang("cli.mods.cantfind"))
+ cli.exit(1);
+ return;
+ }
+
let modPath = path.join(modpath, modName);
let dest = path.join(disabled, modName);
@@ -352,6 +370,10 @@ const mods = {
}
fs.moveSync(modPath, dest)
+ if (! fork) {
+ console.log(lang("cli.mods.toggled"));
+ cli.exit();
+ }
ipcMain.emit("guigetmods");
}
};