aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cli.js1
-rw-r--r--src/index.js1
-rw-r--r--src/modules/console.js27
-rw-r--r--src/modules/findgame.js8
-rw-r--r--src/modules/launch.js6
-rw-r--r--src/modules/mods.js24
-rw-r--r--src/modules/settings.js4
-rw-r--r--src/modules/update.js28
8 files changed, 69 insertions, 30 deletions
diff --git a/src/cli.js b/src/cli.js
index e332085..34dd8dc 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -7,6 +7,7 @@ const events = new Emitter();
const cli = app.commandLine;
const lang = require("./lang");
const json = require("./modules/json");
+console = require("./modules/console");
function hasArgs() {
// Makes sure the GUI isn't launched.
diff --git a/src/index.js b/src/index.js
index 3d2f65b..259f7cc 100644
--- a/src/index.js
+++ b/src/index.js
@@ -21,6 +21,7 @@ const settings = require("./modules/settings");
const requests = require("./modules/requests");
const is_running = require("./modules/is_running");
+console = require("./modules/console");
var log = console.log;
// Starts the actual BrowserWindow, which is only run when using the
diff --git a/src/modules/console.js b/src/modules/console.js
new file mode 100644
index 0000000..7112071
--- /dev/null
+++ b/src/modules/console.js
@@ -0,0 +1,27 @@
+let new_console = {
+ ...console
+}
+
+let orig_console = console;
+
+new_console.ok = (...args) => {
+ orig_console.log('\x1b[92m%s\x1b[0m', ...args)
+}
+
+new_console.misc = (...args) => {
+ orig_console.warn('\x1b[90m%s\x1b[0m', ...args)
+}
+
+new_console.info = (...args) => {
+ orig_console.warn('\x1b[94m%s\x1b[0m', ...args)
+}
+
+new_console.warn = (...args) => {
+ orig_console.warn('\x1b[93m%s\x1b[0m', ...args)
+}
+
+new_console.error = (...args) => {
+ orig_console.error('\x1b[91m%s\x1b[0m', ...args)
+}
+
+module.exports = new_console;
diff --git a/src/modules/findgame.js b/src/modules/findgame.js
index 1c330df..505595f 100644
--- a/src/modules/findgame.js
+++ b/src/modules/findgame.js
@@ -6,6 +6,8 @@ const { app } = require("electron");
const util = require("util");
const exec = util.promisify(require("child_process").exec);
+console = require("./console");
+
module.exports = async () => {
let gamepath = "";
@@ -40,10 +42,10 @@ module.exports = async () => {
let data_array = Object.values(values[i]);
if (fs.existsSync(data_array[0] + "/steamapps/common/Titanfall2/Titanfall2.exe")) {
- console.log("Found game in:", data_array[0]);
+ console.ok("Found game in:", data_array[0]);
return data_array[0] + "/steamapps/common/Titanfall2";
} else {
- console.log("Game not in:", data_array[0]);
+ console.error("Game not in:", data_array[0]);
}
}
}
@@ -70,7 +72,7 @@ module.exports = async () => {
// searches VDF files
for (let i = 0; i < vdf_files.length; i++) {
if (! fs.existsSync(vdf_files[i])) {continue}
- console.log("Searching VDF file at:", vdf_files[i]);
+ console.info("Searching VDF file at:", vdf_files[i]);
let data = fs.readFileSync(vdf_files[i]);
let read_vdf = readvdf(data.toString());
diff --git a/src/modules/launch.js b/src/modules/launch.js
index 82de109..af9939b 100644
--- a/src/modules/launch.js
+++ b/src/modules/launch.js
@@ -6,6 +6,8 @@ const lang = require("../lang");
const win = require("./window");
const settings = require("./settings");
+console = require("./console");
+
// launches the game
//
// either Northstar or Vanilla. Linux support is not currently a thing,
@@ -25,11 +27,11 @@ function launch(game_version) {
// launch the requested game version
switch(game_version) {
case "vanilla":
- console.log(lang("general.launching"), "Vanilla...");
+ console.info(lang("general.launching"), "Vanilla...");
exec("Titanfall2.exe", {cwd: settings.gamepath});
break;
default:
- console.log(lang("general.launching"), "Northstar...");
+ console.info(lang("general.launching"), "Northstar...");
exec("NorthstarLauncher.exe", {cwd: settings.gamepath});
break;
}
diff --git a/src/modules/mods.js b/src/modules/mods.js
index 095e501..fc2a682 100644
--- a/src/modules/mods.js
+++ b/src/modules/mods.js
@@ -10,6 +10,8 @@ const win = require("./window");
const version = require("./version");
const settings = require("./settings");
+console = require("./console");
+
const cli = require("../cli");
const lang = require("../lang");
@@ -33,7 +35,7 @@ mods.list = () => {
// make sure Northstar is actually installed
if (version.northstar() == "unknown") {
win.log(lang("general.notinstalled"));
- console.log("error: " + lang("general.notinstalled"));
+ console.error("error: " + lang("general.notinstalled"));
cli.exit(1);
return false;
}
@@ -124,7 +126,7 @@ mods.get = (mod) => {
// make sure Northstar is actually installed
if (version.northstar() == "unknown") {
win.log(lang("general.notinstalled"));
- console.log("error: " + lang("general.notinstalled"));
+ console.error("error: " + lang("general.notinstalled"));
cli.exit(1);
return false;
}
@@ -258,20 +260,20 @@ mods.install = (mod, opts) => {
if (version.northstar() == "unknown") {
win.log(lang("general.notinstalled"));
- console.log("error: " + lang("general.notinstalled"));
+ console.error("error: " + lang("general.notinstalled"));
cli.exit(1);
return false;
}
let notamod = () => {
win.log(lang("gui.mods.notamod"));
- console.log("error: " + lang("cli.mods.notamod"));
+ console.error("error: " + lang("cli.mods.notamod"));
cli.exit(1);
return false;
}
let installed = () => {
- console.log(lang("cli.mods.installed"));
+ console.ok(lang("cli.mods.installed"));
cli.exit();
win.log(lang("gui.mods.installedmod"));
@@ -505,7 +507,7 @@ mods.remove = (mod) => {
// make sure Northstar is actually installed
if (version.northstar() == "unknown") {
win.log(lang("general.notinstalled"));
- console.log("error: " + lang("general.notinstalled"));
+ console.error("error: " + lang("general.notinstalled"));
cli.exit(1);
return false;
}
@@ -521,7 +523,7 @@ mods.remove = (mod) => {
let mod_name = mods.get(mod).FolderName;
if (! mod_name) {
- console.log("error: " + lang("cli.mods.cantfind"));
+ console.error("error: " + lang("cli.mods.cantfind"));
cli.exit(1);
return;
}
@@ -544,7 +546,7 @@ mods.remove = (mod) => {
// actually remove the mod itself
fs.rmSync(path_to_mod, {recursive: true});
- console.log(lang("cli.mods.removed"));
+ console.ok(lang("cli.mods.removed"));
cli.exit();
ipcMain.emit("gui-getmods"); // send updated list to renderer
@@ -569,7 +571,7 @@ mods.toggle = (mod, fork) => {
// make sure Northstar is actually installed
if (version.northstar() == "unknown") {
win.log(lang("general.notinstalled"));
- console.log("error: " + lang("general.notinstalled"));
+ console.error("error: " + lang("general.notinstalled"));
cli.exit(1);
return false;
}
@@ -581,7 +583,7 @@ mods.toggle = (mod, fork) => {
mods.toggle(modlist[i].Name, true); // enable mod
}
- console.log(lang("cli.mods.toggledall"));
+ console.ok(lang("cli.mods.toggledall"));
cli.exit(0);
return
}
@@ -590,7 +592,7 @@ mods.toggle = (mod, fork) => {
mods.modfile.toggle(mod);
if (! fork) {
- console.log(lang("cli.mods.toggled"));
+ console.ok(lang("cli.mods.toggled"));
cli.exit();
}
diff --git a/src/modules/settings.js b/src/modules/settings.js
index 76326cc..3b60d7f 100644
--- a/src/modules/settings.js
+++ b/src/modules/settings.js
@@ -5,6 +5,8 @@ const app = require("electron").app;
const json = require("./json");
const lang = require("../lang");
+console = require("./console");
+
var invalid_settings = false;
// base settings
@@ -47,7 +49,7 @@ if (fs.existsSync("viper.json")) {
settings.nsargs = fs.readFileSync(args, "utf8");
}
} else {
- console.log(lang("general.missingpath"));
+ console.error(lang("general.missingpath"));
}
// as to not have to do the same one liner a million times, this
diff --git a/src/modules/update.js b/src/modules/update.js
index e57faf6..02d38c6 100644
--- a/src/modules/update.js
+++ b/src/modules/update.js
@@ -12,6 +12,8 @@ const requests = require("./requests");
const gamepath = require("./gamepath");
const is_running = require("./is_running");
+console = require("./console");
+
const unzip = require("unzipper");
const { https } = require("follow-redirects");
@@ -57,23 +59,23 @@ update.northstar_autoupdate = () => {
async function _checkForUpdates() {
is_auto_updating = true;
- console.log(lang("cli.autoupdates.checking"));
+ console.info(lang("cli.autoupdates.checking"));
// checks if NS is outdated
if (await northstar_update_available()) {
- console.log(lang("cli.autoupdates.available"));
+ console.ok(lang("cli.autoupdates.available"));
if (await is_running.game()) {
- console.log(lang("general.autoupdates.gamerunning"));
+ console.error(lang("general.autoupdates.gamerunning"));
new Notification({
title: lang("gui.nsupdate.gaming.title"),
body: lang("gui.nsupdate.gaming.body")
}).show();
} else {
- console.log(lang("cli.autoupdates.updatingns"));
+ console.status(lang("cli.autoupdates.updatingns"));
update.northstar();
}
} else {
- console.log(lang("cli.autoupdates.noupdate"));
+ console.info(lang("cli.autoupdates.noupdate"));
}
setTimeout(
@@ -150,14 +152,14 @@ update.viper = (autoinstall) => {
// unzip module does not support excluding files directly.
update.northstar = async () => {
if (await is_running.game()) {
- console.log(lang("general.autoupdates.gamerunning"));
+ console.error(lang("general.autoupdates.gamerunning"));
return false;
}
if (! gamepath.exists()) {return}
ipcMain.emit("ns-update-event", "cli.update.checking");
- console.log(lang("cli.update.checking"));
+ console.info(lang("cli.update.checking"));
let ns_version = version.northstar();
const latest_version = await requests.getLatestNsVersion();
@@ -170,14 +172,14 @@ update.northstar = async () => {
// Makes sure it is not already the latest version
if (! await northstar_update_available()) {
ipcMain.emit("ns-update-event", "cli.update.uptodate.short");
- console.log(lang("cli.update.uptodate"), ns_version);
+ console.ok(lang("cli.update.uptodate"), ns_version);
win.log(lang("gui.update.uptodate"));
cli.exit();
return;
} else {
if (ns_version != "unknown") {
- console.log(lang("cli.update.current"), ns_version);
+ console.info(lang("cli.update.current"), ns_version);
};
}
@@ -188,11 +190,11 @@ update.northstar = async () => {
// cancel out if zip can't be retrieved and or found
if (res.statusCode !== 200) {
ipcMain.emit("ns-update-event", "cli.update.uptodate.short");
- console.log(lang("cli.update.uptodate"), ns_version);
+ console.ok(lang("cli.update.uptodate"), ns_version);
return false;
}
- console.log(lang("cli.update.downloading") + ":", latest_version);
+ console.info(lang("cli.update.downloading") + ":", latest_version);
ipcMain.emit("ns-update-event", "cli.update.downloading");
let tmp = path.dirname(settings.zip);
@@ -225,7 +227,7 @@ update.northstar = async () => {
win.log(lang("gui.update.extracting"));
ipcMain.emit("ns-update-event", "gui.update.extracting");
- console.log(lang("cli.update.downloaddone"));
+ console.ok(lang("cli.update.downloaddone"));
// extracts the zip, this is the part where we're actually
// installing Northstar.
extract.pipe(unzip.Extract({path: settings.gamepath}))
@@ -249,7 +251,7 @@ update.northstar = async () => {
ipcMain.emit("get-version");
ipcMain.emit("ns-update-event", "cli.update.uptodate.short");
win.log(lang("gui.update.finished"));
- console.log(lang("cli.update.finished"));
+ console.ok(lang("cli.update.finished"));
cli.exit();
})
})