aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app/index.html8
-rw-r--r--src/app/main.css7
-rw-r--r--src/app/main.js8
-rw-r--r--src/index.js13
-rw-r--r--src/lang/en.json2
-rw-r--r--src/utils.js10
6 files changed, 38 insertions, 10 deletions
diff --git a/src/app/index.html b/src/app/index.html
index 426b4c5..80f7701 100644
--- a/src/app/index.html
+++ b/src/app/index.html
@@ -6,7 +6,13 @@
<body>
<div class="lines">
<div class="line">
- <div class="text">%%gui.welcome%%</div>
+ <div class="text">
+ <div>%%gui.welcome%%</div>
+ <div class="versions">
+ <div id="vpversion"></div>
+ <div id="nsversion"></div>
+ </div>
+ </div>
<div class="buttons">
<button id="exit" onclick="exit()">%%gui.exit%%</button>
<button id="update" onclick="update()">%%gui.update%%</button>
diff --git a/src/app/main.css b/src/app/main.css
index f49cc98..cd6c001 100644
--- a/src/app/main.css
+++ b/src/app/main.css
@@ -1,6 +1,7 @@
:root {
--background: #4C515B;
--foreground: #DDE2EB;
+ --subforeground: #AFAFAF;
--btnforeground: var(--foreground);
}
@@ -68,3 +69,9 @@ button:active {
#setpath {background: #5E81AC}
#northstar {background: #C7777F}
#vanilla, #exit {background: #656E7F}
+
+.versions {
+ height: 15px;
+ font-size: 12px;
+ color: var(--subforeground);
+}
diff --git a/src/app/main.js b/src/app/main.js
index 9bafaa5..59b28f2 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -35,7 +35,13 @@ ipcRenderer.on("newpath", (event, newpath) => {
settings.gamepath = newpath;
})
+ipcRenderer.on("version", (event, versions) => {
+ vpversion.innerText = lang("gui.versions.viper") + ": " + versions.vp;
+ nsversion.innerText = lang("gui.versions.northstar") + ": " + versions.ns;
+});
+ipcRenderer.send("getversion");
+
setlang();
setInterval(() => {
ipcRenderer.send("setsize", document.querySelector(".lines").offsetHeight + 20);
-}, 150)
+}, 150);
diff --git a/src/index.js b/src/index.js
index 8343ba9..660d3a0 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,6 +1,6 @@
const fs = require("fs");
const path = require("path");
-const { app, dialog, ipcMain, BrowserWindow } = require("electron");
+const { app, dialog, ipcMain, BrowserWindow, ipcRenderer } = require("electron");
const Emitter = require("events");
const events = new Emitter();
@@ -17,7 +17,7 @@ function start() {
title: "Viper",
resizable: false,
titleBarStyle: "hidden",
- icon: path.join(__dirname, 'assets/icons/512x512.png'),
+ icon: path.join(__dirname, "assets/icons/512x512.png"),
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
@@ -44,7 +44,14 @@ ipcMain.on("setlang", (event, lang) => {utils.setlang(lang)})
ipcMain.on("launchVanilla", (event) => {utils.launch("vanilla")})
ipcMain.on("update", (event) => {utils.update()})
-ipcMain.on("setpathcli", (event) => {utils.setpath()})
+ipcMain.on("setpathcli", (event) => {utils.setpath()});
+
+ipcMain.on("getversion", () => {
+ win.webContents.send("version", {
+ ns: utils.getNSVersion(),
+ vp: "v" + require("../package.json").version
+ });
+});
process.chdir(app.getPath("appData"));
diff --git a/src/lang/en.json b/src/lang/en.json
index 9aaa778..3c5efa1 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -18,6 +18,8 @@
"cli.launch.linuxerror": "Launching the game is not currently supported on Linux",
"gui.welcome": "Welcome to Viper!",
+ "gui.versions.viper": "Viper version",
+ "gui.versions.northstar": "Northstar version",
"gui.exit": "Exit",
"gui.update": "Update",
"gui.setpath": "Game Path",
diff --git a/src/utils.js b/src/utils.js
index 7e9dbac..277c729 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -52,8 +52,8 @@ function saveSettings() {
fs.writeFileSync(app.getPath("appData") + "/viper.json", JSON.stringify(settings));
}
-function getInstalledVersion() {
- const versionFilePath = path.join(settings.gamepath, "ns_version.txt");
+function getNSVersion() {
+ var versionFilePath = path.join(settings.gamepath, "ns_version.txt");
if (fs.existsSync(versionFilePath)) {
return fs.readFileSync(versionFilePath, "utf8");
@@ -72,7 +72,7 @@ function update() {
}
console.log(lang("cli.update.checking"));
- const version = getInstalledVersion();
+ var version = getNSVersion();
request({
json: true,
@@ -101,8 +101,7 @@ function update() {
console.log(lang("cli.update.finished"));
fs.writeFileSync(path.join(settings.gamepath, "ns_version.txt"), tag);
-
- events.emit("updated");
+ ipcMain.emit("getversion");
for (let i = 0; i < settings.excludes.length; i++) {
let exclude = path.join(settings.gamepath + "/" + settings.excludes[i]);
@@ -142,6 +141,7 @@ module.exports = {
update,
setpath,
settings,
+ getNSVersion,
setlang: (lang) => {
settings.lang = lang;
saveSettings();