diff options
author | 0neGal <mail@0negal.com> | 2021-12-31 16:59:48 +0100 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2021-12-31 16:59:48 +0100 |
commit | 67b32b527aec8d36a4b6cca14677febc46f0e26d (patch) | |
tree | 47691134760f1cab6b9f7acbfb26a48d78326643 /src | |
parent | c5c63d6c8a81596d0dcf3e14e072ea14f4d0610c (diff) | |
parent | ba82a7e8e5bc90705649c859674caeb334996b81 (diff) | |
download | Viper-67b32b527aec8d36a4b6cca14677febc46f0e26d.tar.gz Viper-67b32b527aec8d36a4b6cca14677febc46f0e26d.zip |
Merge branch 'main' of 0neGal/viper into mod-support
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 | 8 | ||||
-rw-r--r-- | src/utils.js | 8 |
8 files changed, 56 insertions, 14 deletions
diff --git a/src/app/index.html b/src/app/index.html index 9b72ebb..ffc31a6 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 929483a..c6c9bb9 100644 --- a/src/app/main.css +++ b/src/app/main.css @@ -4,6 +4,7 @@ --foreground: #DDE2EB; --background: #4C515B; --boxbackground: #666E7F; + --subforeground: #AFAFAF; --btnforeground: var(--foreground); } @@ -34,6 +35,12 @@ body, button, input { nobr {white-space: nowrap} +.versions { + height: 15px; + font-size: 12px; + color: var(--subforeground); +} + .line { display: flex; margin-top: var(--padding); @@ -64,6 +71,8 @@ button, .text, .mod { padding: calc(var(--padding) / 3) var(--padding); } +#welcome {padding: 0px} + button { color: var(--btnforeground); -webkit-app-region: no-drag; diff --git a/src/app/main.js b/src/app/main.js index f512d4f..b0f0ebf 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -61,7 +61,12 @@ ipcRenderer.on("mods", (event, mods) => { } }) +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); @@ -40,12 +40,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 3f301ae..2a5ed2b 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, @@ -53,7 +53,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(); +}) ipcMain.on("getmods", (event) => { let mods = utils.mods.list(); diff --git a/src/lang/en.json b/src/lang/en.json index 523c6fa..23cb8fb 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 index c3e7027..26648c4 100644 --- a/src/lang/fr.json +++ b/src/lang/fr.json @@ -1,6 +1,7 @@ { "cli.help.help": "affiche ce message d'aide", "cli.help.debug": "affiche les outils de développement", + "cli.help.version": "retourne des informations sur la version du logiciel", "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", @@ -17,10 +18,17 @@ "cli.launch.linuxerror": "Le support du jeu sur Linux n'est pas encore implémenté.", "gui.welcome": "Bienvenue sur Viper !", + "gui.versions.viper": "Version de Viper", + "gui.versions.northstar": "Version de Northstar", "gui.exit": "Fermer", "gui.update": "Mise à jour", "gui.setpath": "Chemin du jeu", + "gui.update.downloading": "Téléchargement de la mise à jour...", + "gui.update.extracting": "Extraction des fichiers...", + "gui.update.finished": "Terminé, vous pouvez jouer !", + "gui.update.uptodate": "Déjà à jour !", + "gui.launch": "Jouer", "gui.launchvanilla": "Vanilla", "gui.launchnorthstar": "Northstar", diff --git a/src/utils.js b/src/utils.js index 8bc6440..ba710dc 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]); @@ -173,6 +174,7 @@ module.exports = { update, setpath, settings, + getNSVersion, setlang: (lang) => { settings.lang = lang; saveSettings(); |