diff options
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | src/app/index.html | 2 | ||||
-rw-r--r-- | src/app/main.css | 15 | ||||
-rw-r--r-- | src/app/main.js | 23 | ||||
-rw-r--r-- | src/index.js | 8 | ||||
-rw-r--r-- | src/lang/en.json | 8 | ||||
-rw-r--r-- | src/lang/fr.json | 3 | ||||
-rw-r--r-- | src/utils.js | 21 |
8 files changed, 63 insertions, 21 deletions
@@ -22,6 +22,8 @@ $ npm run start This'll launch it with the Electron build installed by `npm`. +Additionally, if you really want to, you can build Viper with `npm run build` and it'll then build the Windows installer and AppImage, however the whole build process and everything related to it is still being worked on which is why we don't have official releases yet. + ## What can it do specifically? Currently Viper is capable of: @@ -34,4 +36,4 @@ Besides this I've been considering adding some easy to use VPK modding tools so ## Credits -All credits for logos go to Imply#9781.
\ No newline at end of file +All credits for logos go to Imply#9781. diff --git a/src/app/index.html b/src/app/index.html index 80f7701..f5d92e0 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -7,7 +7,7 @@ <div class="lines"> <div class="line"> <div class="text"> - <div>%%gui.welcome%%</div> + <div class="text" id="welcome">%%gui.welcome%%</div> <div class="versions"> <div id="vpversion"></div> <div id="nsversion"></div> diff --git a/src/app/main.css b/src/app/main.css index cd6c001..aa36c5b 100644 --- a/src/app/main.css +++ b/src/app/main.css @@ -1,4 +1,5 @@ :root { + --disabled: #656E7F; --background: #4C515B; --foreground: #DDE2EB; --subforeground: #AFAFAF; @@ -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; @@ -65,13 +72,9 @@ button:active { transform: scale(0.95); } + #update {background: #81A1C1} #setpath {background: #5E81AC} #northstar {background: #C7777F} #vanilla, #exit {background: #656E7F} - -.versions { - height: 15px; - font-size: 12px; - color: var(--subforeground); -} +button:disabled {background: var(--disabled) !important; opacity: 0.5}
\ No newline at end of file diff --git a/src/app/main.js b/src/app/main.js index 59b28f2..a33ef72 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -20,7 +20,7 @@ if (fs.existsSync("viper.json")) { settings = {...settings, ...JSON.parse(fs.readFileSync("viper.json", "utf8"))}; settings.zip = path.join(settings.gamepath + "/northstar.zip"); } else { - alert(lang("gui.missinggamepath")); + alert(lang("general.missinggamepath")); setpath(); } @@ -31,15 +31,32 @@ function setpath() {ipcRenderer.send("setpath")} function launch() {ipcRenderer.send("launch")} function launchVanilla() {ipcRenderer.send("launchVanilla")} +function log(msg) { + console.log(msg); + welcome.innerHTML = msg; +} + +function setButtons(state) { + let buttons = document.querySelectorAll("button"); + + for (let i = 0; i < buttons.length; i++) { + buttons[i].disabled = !state; + } +} + +ipcRenderer.on("ns-updated", () => {setButtons(true)}) +ipcRenderer.on("ns-updating", () => {setButtons(false)}) + ipcRenderer.on("newpath", (event, newpath) => { settings.gamepath = 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"); +}); ipcRenderer.send("getversion"); setlang(); setInterval(() => { diff --git a/src/index.js b/src/index.js index 063e4df..198bc74 100644 --- a/src/index.js +++ b/src/index.js @@ -29,14 +29,18 @@ function start() { win.removeMenu(); win.loadFile(__dirname + "/app/index.html"); - ipcMain.on("exit", (event) => {process.exit(0)}) - ipcMain.on("setpath", (event) => {utils.setpath(win)}) + ipcMain.on("exit", () => {process.exit(0)}) + ipcMain.on("setpath", () => {utils.setpath(win)}) ipcMain.on("setsize", (event, height) => { win.setSize(width, height); if (! win.isVisible()) { win.show(); } }) + + ipcMain.on("ns-updated", () => {win.webContents.send("ns-updated")}) + ipcMain.on("ns-updating", () => {win.webContents.send("ns-updating")}) + ipcMain.on("winLog", (event, ...args) => {win.webContents.send("log", ...args)}) } ipcMain.on("launch", (event) => {utils.launch()}) diff --git a/src/lang/en.json b/src/lang/en.json index 3c5efa1..8f388ae 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -9,7 +9,7 @@ "cli.setpath.noarg": "No argument provided for --setpath", "cli.update.current": "Current version:", - "cli.update.downloading": "Downloading:", + "cli.update.downloading": "Downloading", "cli.update.checking": "Checking for updates...", "cli.update.downloaddone": "Download done! Extracting...", "cli.update.finished": "Installation/Update finished!", @@ -24,12 +24,16 @@ "gui.update": "Update", "gui.setpath": "Game Path", + "gui.update.downloading": "Downloading...", + "gui.update.extracting": "Extracting update...", + "gui.update.finished": "Done! Ready to play!", + "gui.update.uptodate": "Already up to date!", + "gui.launch": "Launch", "gui.launchvanilla": "Vanilla", "gui.launchnorthstar": "Northstar", "gui.selectpath": "Please select the path!", - "gui.missinggamepath": "Game path is not set!", "general.launching": "Launching", diff --git a/src/lang/fr.json b/src/lang/fr.json index 0dd9f99..c3e7027 100644 --- a/src/lang/fr.json +++ b/src/lang/fr.json @@ -8,7 +8,7 @@ "cli.setpath.noarg": "Aucun argument donné à --setpath", "cli.update.current": "Version actuelle :", - "cli.update.downloading": "Téléchargement en cours :", + "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 !", @@ -26,7 +26,6 @@ "gui.launchnorthstar": "Northstar", "gui.selectpath": "Veuillez sélectionner le dossier où se trouve le client Titanfall 2.", - "gui.missinggamepath": "Le chemin du client n'est pas défini !", "general.launching": "Lancement", diff --git a/src/utils.js b/src/utils.js index 277c729..06acbdf 100644 --- a/src/utils.js +++ b/src/utils.js @@ -29,7 +29,7 @@ if (fs.existsSync("viper.json")) { settings = {...settings, ...JSON.parse(fs.readFileSync("viper.json", "utf8"))}; settings.zip = path.join(settings.gamepath + "/northstar.zip"); } else { - console.log(lang("gui.missinggamepath")); + console.log(lang("general.missinggamepath")); } function setpath(win) { @@ -71,6 +71,7 @@ function update() { } } + ipcMain.emit("ns-updating"); console.log(lang("cli.update.checking")); var version = getNSVersion(); @@ -82,12 +83,17 @@ function update() { var tag = body["tag_name"]; if (version === tag) { + ipcMain.emit("ns-updated"); console.log(lang("cli.update.uptodate"), version); + + winLog(lang("gui.update.uptodate")); return; } else { if (version != "unknown") { console.log(lang("cli.update.current"), version); - }; console.log(lang("cli.update.downloading"), tag); + }; console.log(lang("cli.update.downloading") + ":", tag); + + winLog(lang("gui.update.downloading")); } https.get(body.assets[0].browser_download_url, (res) => { @@ -95,11 +101,10 @@ function update() { res.pipe(stream); stream.on("finish", () => { stream.close(); + winLog(lang("gui.update.extracting")); console.log(lang("cli.update.downloaddone")); fs.createReadStream(settings.zip).pipe(unzip.Extract({path: settings.gamepath})) .on("finish", () => { - console.log(lang("cli.update.finished")); - fs.writeFileSync(path.join(settings.gamepath, "ns_version.txt"), tag); ipcMain.emit("getversion"); @@ -110,6 +115,9 @@ function update() { } } + ipcMain.emit("ns-updated"); + winLog(lang("gui.update.finished")); + console.log(lang("cli.update.finished")); cli.exit(); }); }) @@ -136,7 +144,12 @@ function launch(version) { } } +function winLog(msg) { + ipcMain.emit("winLog", msg, msg); +} + module.exports = { + winLog, launch, update, setpath, |