diff options
author | 0neGal <mail@0negal.com> | 2022-01-19 23:51:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-19 23:51:26 +0100 |
commit | 057b60f4843798441ad441370381b87299d5ad7f (patch) | |
tree | ef0ac85051f0abb8b0febfc507ad5c71a5e7e3e8 /src/app | |
parent | 962265ffbe3aa0a9c2084d370c914c0265ee6bd9 (diff) | |
parent | ae7de46f4748c800097f0f3c700e6525d7d7cc4f (diff) | |
download | Viper-057b60f4843798441ad441370381b87299d5ad7f.tar.gz Viper-057b60f4843798441ad441370381b87299d5ad7f.zip |
Merge branch 'main' into enabledmods
Diffstat (limited to 'src/app')
-rw-r--r-- | src/app/icons/minimize.png | bin | 0 -> 981 bytes | |||
-rw-r--r-- | src/app/index.html | 10 | ||||
-rw-r--r-- | src/app/lang.js | 9 | ||||
-rw-r--r-- | src/app/launcher.js | 5 | ||||
-rw-r--r-- | src/app/main.css | 24 | ||||
-rw-r--r-- | src/app/main.js | 22 |
6 files changed, 56 insertions, 14 deletions
diff --git a/src/app/icons/minimize.png b/src/app/icons/minimize.png Binary files differnew file mode 100644 index 0000000..4169e28 --- /dev/null +++ b/src/app/icons/minimize.png diff --git a/src/app/index.html b/src/app/index.html index 8ebffff..fe383a0 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -8,7 +8,10 @@ <body> <div id="bgHolder"></div> - <div id="close" onclick="ipcRenderer.send('exit')"></div> + <div id="winbtns"> + <div id="minimize" onclick="ipcRenderer.send('minimize')"></div> + <div id="close" onclick="ipcRenderer.send('exit')"></div> + </div> <nav class="gamesContainer"> <button id="vpBtn" onclick="page(0)"></button> @@ -40,8 +43,9 @@ </ul> <h2>%%viper.menu.info.credits%%</h2> <ul> - <li>"Titanfall|2 + Northstar" logo: <a href="https://www.steamgriddb.com/logo/47851">Aftonstjarma</a></li> - <li>Viper logo: Imply#9781</li> + <li>Viper Logo: Imply#9781</li> + <li>Viper Background: <a href="https://www.reddit.com/r/titanfall/comments/fwuh2x/take_to_the_skies">Uber Panzerhund</a></li> + <li>Titanfall+Northstar Logo: <a href="https://www.steamgriddb.com/logo/47851">Aftonstjarma</a></li> </ul> </div> </div> diff --git a/src/app/lang.js b/src/app/lang.js index 5cc9708..6fdcd8d 100644 --- a/src/app/lang.js +++ b/src/app/lang.js @@ -1,12 +1,19 @@ +// Replaces strings in the HTML will language strings properly. This +// searches for %%<string>%%, aka, %%gui.exit%% will be replaced with +// "Exit", this works without issues. function setlang() { + // Finds %%%% strings html = document.body.innerHTML.split("%%"); for (let i = 0; i < html.length; i++) { + // Simply checks to make sure it is actually a lang string. if (html[i][0] != " " && html[i][html[i].length - 1] != " ") { + // Replaces it with it's string html[i] = lang(html[i]) } } - + + // Replaces the original HTML with the translated/replaced HTML document.body.innerHTML = html.join(""); } diff --git a/src/app/launcher.js b/src/app/launcher.js index 2c8d123..60c0d18 100644 --- a/src/app/launcher.js +++ b/src/app/launcher.js @@ -1,5 +1,7 @@ const markdown = require("marked").parse; +// Changes the main page +// This is the tabs in the sidebar function page(page) { let pages = document.querySelectorAll(".mainContainer .contentContainer") let btns = document.querySelectorAll(".gamesContainer button") @@ -18,6 +20,7 @@ function page(page) { }; page(0) +// Updates the Viper release notes ipcRenderer.on("vp-notes", (event, response) => { let content = ""; @@ -28,11 +31,13 @@ ipcRenderer.on("vp-notes", (event, response) => { vpReleaseNotes.innerHTML = markdown(content); }); + async function loadVpReleases() { ipcRenderer.send("get-vp-notes"); }; loadVpReleases(); +// Updates the Northstar release notes ipcRenderer.on("ns-notes", (event, response) => { let content = ""; diff --git a/src/app/main.css b/src/app/main.css index 3907461..de0db46 100644 --- a/src/app/main.css +++ b/src/app/main.css @@ -26,25 +26,33 @@ background: var(--red); } -.playBtn, .gamesContainer button, #close { +.playBtn, .gamesContainer button, #winbtns div { cursor: pointer; } -#close { +#winbtns { z-index: 1; + display: flex; + position: fixed; + top: var(--padding); + right: calc(var(--padding) / 2); +} + +#winbtns div { width: 25px; opacity: 0.6; height: 25px; - position: fixed; - top: var(--padding); - right: var(--padding); + position: relative; background-size: contain; transition: 0.25s ease-in-out; - background-image: url("icons/close.png"); + margin-right: calc(var(--padding) / 2); } -#close:hover {opacity: 1.0} -#close:active {transform: scale(0.98)} +#winbtns #close {background-image: url("icons/close.png")} +#winbtns #minimize {background-image: url("icons/minimize.png")} + +#winbtns div:hover {opacity: 1.0} +#winbtns div:active {transform: scale(0.98)} body { margin: 0; diff --git a/src/app/main.js b/src/app/main.js index 893572a..5f0cc9a 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -5,6 +5,7 @@ const { ipcRenderer, shell } = require("electron"); const lang = require("../lang"); let shouldInstallNorthstar = false; +// Base settings var settings = { gamepath: "", autoupdate: true, @@ -16,8 +17,10 @@ var settings = { ] } +// Sets the lang to the system default ipcRenderer.send("setlang", settings.lang); +// Loads the settings if (fs.existsSync("viper.json")) { settings = {...settings, ...JSON.parse(fs.readFileSync("viper.json", "utf8"))}; settings.zip = path.join(settings.gamepath + "/northstar.zip"); @@ -38,11 +41,11 @@ function update() {ipcRenderer.send("update")} // Reports to the main process about game path status. // @param {boolean} value is game path loaded - function setpath(value = false) { ipcRenderer.send("setpath", value); } +// Tells the main process to launch or install Northstar function launch() { if (shouldInstallNorthstar) { update(); @@ -51,17 +54,23 @@ function launch() { ipcRenderer.send("launch"); } } + +// Tells the main process to launch the vanilla game function launchVanilla() {ipcRenderer.send("launchVanilla")} +// In conjunction with utils.js' winLog(), it'll send log messages in +// the devTools from utils.js function log(msg) { console.log(msg); - // welcome.innerHTML = msg; } +// Disables or enables certain buttons when for example +// updating/installing Northstar. function setButtons(state) { playNsBtn.disabled = !state; } +// Frontend part of updating Northstar ipcRenderer.on("ns-update-event", (event, key) => { document.getElementById("update").innerText = `(${lang(key)})`; console.log(key); @@ -90,6 +99,7 @@ function select(entry) { } } +// Mod selection function selected(all) { let selected = ""; if (all) { @@ -138,17 +148,21 @@ function selected(all) { } } +// Tells the main process to install a mod function installmod() { ipcRenderer.send("installmod") } +// Frontend part of settings a new game path ipcRenderer.on("newpath", (event, newpath) => { settings.gamepath = newpath; }) +// Continuation of log() ipcRenderer.on("log", (event, msg) => {log(msg)}) ipcRenderer.on("alert", (event, msg) => {alert(msg)}) +// Updates the installed mods ipcRenderer.on("mods", (event, mods) => { modcount.innerHTML = `${lang("gui.mods.count")} ${mods.all.length}`; modsdiv.innerHTML = ""; @@ -169,6 +183,7 @@ ipcRenderer.on("mods", (event, mods) => { select(lastselected); }) +// Updates version numbers ipcRenderer.on("version", (event, versions) => { vpversion.innerText = versions.vp; nsversion.innerText = versions.ns; @@ -187,17 +202,20 @@ ipcRenderer.on("version", (event, versions) => { } }); ipcRenderer.send("getversion"); +// When an update is available it'll ask the user about it ipcRenderer.on("updateavailable", () => { if (confirm(lang("gui.update.available"))) { ipcRenderer.send("updatenow"); } }) +// Error out when no game path is set ipcRenderer.on("nopathselected", () => { alert(lang("gui.gamepath.must")); exit(); }); +// Error out when game path is wrong ipcRenderer.on("wrongpath", () => { alert(lang("gui.gamepath.wrong")); setpath(false); |