diff options
author | 0neGal <mail@0negal.com> | 2021-12-31 15:40:32 +0100 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2021-12-31 15:40:32 +0100 |
commit | 4f798d07731668f0e850b7d348de74bf6f422de0 (patch) | |
tree | 8e530838e0bf8826f48dd570d17ca917c22e622e /src | |
parent | c8fec42e085ef255a01f62c5010e2d41bb7eb05f (diff) | |
parent | 10c786da5be323c0b2e7042e79bcee8849e25ef4 (diff) | |
download | Viper-4f798d07731668f0e850b7d348de74bf6f422de0.tar.gz Viper-4f798d07731668f0e850b7d348de74bf6f422de0.zip |
Merge branch 'Alystrasz-feat/version-indicator'
Diffstat (limited to 'src')
-rw-r--r-- | src/app/index.html | 8 | ||||
-rw-r--r-- | src/app/main.css | 9 | ||||
-rw-r--r-- | src/app/main.js | 7 | ||||
-rw-r--r-- | src/cli.js | 7 | ||||
-rw-r--r-- | src/index.js | 21 | ||||
-rw-r--r-- | src/lang/en.json | 2 | ||||
-rw-r--r-- | src/lang/fr.json | 33 | ||||
-rw-r--r-- | src/utils.js | 8 |
8 files changed, 48 insertions, 47 deletions
diff --git a/src/app/index.html b/src/app/index.html index dc65d67..f5d92e0 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" id="welcome">%%gui.welcome%%</div> + <div class="text"> + <div class="text" id="welcome">%%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 377e1f8..c2ca627 100644 --- a/src/app/main.css +++ b/src/app/main.css @@ -2,6 +2,7 @@ --disabled: #656E7F; --background: #4C515B; --foreground: #DDE2EB; + --subforeground: #AFAFAF; --btnforeground: var(--foreground); } @@ -31,6 +32,12 @@ body, button, input { nobr {white-space: nowrap} +.versions { + height: 15px; + font-size: 12px; + color: var(--subforeground); +} + .line { display: flex; margin-top: 15px; @@ -55,6 +62,8 @@ button, .text { transition: 0.2s ease-in-out; } +#welcome {padding: 0px} + button { margin-bottom: 10px; color: var(--btnforeground); diff --git a/src/app/main.js b/src/app/main.js index 809b5c8..a33ef72 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -53,7 +53,12 @@ ipcRenderer.on("newpath", (event, newpath) => { ipcRenderer.on("log", (event, msg) => {log(msg)}) +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); @@ -39,12 +39,7 @@ async function init() { } if (cli.hasSwitch("update")) {ipcMain.emit("update")} - if (cli.hasSwitch("version")) { - console.log("Viper: v" + require("../package.json").version); - console.log("Node: " + process.version); - console.log("Electron: v" + process.versions.electron); - exit(); - } + if (cli.hasSwitch("version")) {ipcMain.emit("versioncli")} if (cli.hasSwitch("setpath")) { if (cli.getSwitchValue("setpath") != "") { diff --git a/src/index.js b/src/index.js index c99e367..198bc74 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, @@ -48,7 +48,22 @@ 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 + }); +}); + +ipcMain.on("versioncli", () => { + console.log("Viper: v" + require("../package.json").version); + console.log("Northstar: " + utils.getNSVersion()); + console.log("Node: " + process.version); + console.log("Electron: v" + process.versions.electron); + cli.exit(); +}) process.chdir(app.getPath("appData")); diff --git a/src/lang/en.json b/src/lang/en.json index e30d576..8f388ae 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/lang/fr.json b/src/lang/fr.json deleted file mode 100644 index c3e7027..0000000 --- a/src/lang/fr.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "cli.help.help": "affiche ce message d'aide", - "cli.help.debug": "affiche les outils de développement", - "cli.help.cli": "force l'activation de la CLI", - "cli.help.update": "met à jour Northstar sur le chemin du jeu précisé", - "cli.help.setpath": "enregistre le chemin du client de jeu", - - "cli.setpath.noarg": "Aucun argument donné à --setpath", - - "cli.update.current": "Version actuelle :", - "cli.update.downloading": "Téléchargement en cours ", - "cli.update.checking": "Vérification des mises à jour ...", - "cli.update.downloaddone": "Téléchargement terminé ! Extraction des fichiers...", - "cli.update.finished": "Mise à jour terminée !", - "cli.update.uptodate": "La dernière version (%s) est déjà installée.", - - "cli.launch.linuxerror": "Le support du jeu sur Linux n'est pas encore implémenté.", - - "gui.welcome": "Bienvenue sur Viper !", - "gui.exit": "Fermer", - "gui.update": "Mise à jour", - "gui.setpath": "Chemin du jeu", - - "gui.launch": "Jouer", - "gui.launchvanilla": "Vanilla", - "gui.launchnorthstar": "Northstar", - - "gui.selectpath": "Veuillez sélectionner le dossier où se trouve le client Titanfall 2.", - - - "general.launching": "Lancement", - "general.missingpath": "Le chemin du client n'est pas défini !" -} diff --git a/src/utils.js b/src/utils.js index b4ff04d..06acbdf 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"); @@ -73,7 +73,7 @@ function update() { ipcMain.emit("ns-updating"); console.log(lang("cli.update.checking")); - const version = getInstalledVersion(); + var version = getNSVersion(); request({ json: true, @@ -106,6 +106,7 @@ function update() { fs.createReadStream(settings.zip).pipe(unzip.Extract({path: settings.gamepath})) .on("finish", () => { fs.writeFileSync(path.join(settings.gamepath, "ns_version.txt"), tag); + ipcMain.emit("getversion"); for (let i = 0; i < settings.excludes.length; i++) { let exclude = path.join(settings.gamepath + "/" + settings.excludes[i]); @@ -153,6 +154,7 @@ module.exports = { update, setpath, settings, + getNSVersion, setlang: (lang) => { settings.lang = lang; saveSettings(); |