diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/app/browser.js | 78 | ||||
-rw-r--r-- | src/app/icons/check.png | bin | 0 -> 373 bytes | |||
-rw-r--r-- | src/app/icons/filter.png | bin | 0 -> 1074 bytes | |||
-rw-r--r-- | src/app/index.html | 12 | ||||
-rw-r--r-- | src/app/main.css | 47 | ||||
-rw-r--r-- | src/cli.js | 21 | ||||
-rw-r--r-- | src/index.js | 8 | ||||
-rw-r--r-- | src/lang/en.json | 6 | ||||
-rw-r--r-- | src/lang/es.json | 6 | ||||
-rw-r--r-- | src/lang/fr.json | 6 | ||||
-rw-r--r-- | src/utils.js | 2 |
11 files changed, 169 insertions, 17 deletions
diff --git a/src/app/browser.js b/src/app/browser.js index 8a8c6e4..40670bc 100644 --- a/src/app/browser.js +++ b/src/app/browser.js @@ -4,6 +4,58 @@ var packages = []; var Browser = { maxentries: 50, + filters: { + get: () => { + let filtered = []; + let unfiltered = []; + let checks = browser.querySelectorAll("#filters .check"); + + for (let i = 0; i < checks.length; i++) { + if (! checks[i].classList.contains("checked")) { + filtered.push(checks[i].getAttribute("value")); + } else { + unfiltered.push(checks[i].getAttribute("value")); + } + } + + return { + filtered, + unfiltered + }; + }, + isfiltered: (categories) => { + let filtered = Browser.filters.get().filtered; + let unfiltered = Browser.filters.get().unfiltered; + let state = false; + if (categories.length == 0) {return true} + for (let i = 0; i < categories.length; i++) { + if (filtered.includes(categories[i])) { + state = true; + continue + } else if (unfiltered.includes(categories[i])) { + state = false; + continue + } + + state = true; + } + + return state; + }, + toggle: (state) => { + if (state == false) { + filters.classList.remove("shown"); + return + } + + filters.classList.toggle("shown"); + let filterRect = filter.getBoundingClientRect(); + let spacing = parseInt(getComputedStyle(filters).getPropertyValue("--spacing")); + + filters.style.top = filterRect.bottom - spacing; + filters.style.right = filterRect.right - filterRect.left + filterRect.width; + }, + }, toggle: (state) => { if (state) { browser.scrollTo(0, 0); @@ -16,6 +68,7 @@ var Browser = { return } else if (! state) { if (state != undefined) { + Browser.filters.toggle(false); overlay.classList.remove("shown") browser.classList.remove("shown") return @@ -38,11 +91,14 @@ var Browser = { } for (let i in packages) { - if (i == Browser.maxentries) {Browser.endoflist();break} new BrowserElFromObj(packages[i]); } }, loading: (string) => { + if (Browser.filters.get().unfiltered.length == 0) { + string = lang("gui.browser.noresults"); + } + if (string) { browserEntries.innerHTML = `<div class="loading">${string}</div>`; } @@ -52,6 +108,7 @@ var Browser = { } }, endoflist: () => { + if (browserEntries.querySelector(".message")) {return} browserEntries.innerHTML += `<div class="message">${lang('gui.browser.endoflist')}</div>` }, search: (string) => { @@ -59,12 +116,11 @@ var Browser = { let res = fuse.search(string); if (res.length < 1) { - Browser.loading("No results...") + Browser.loading(lang("gui.browser.noresults")) return } for (let i = 0; i < res.length; i++) { - if (i == Browser.maxentries) {Browser.endoflist();break} new BrowserElFromObj(res[i].item); } }, @@ -114,11 +170,17 @@ function BrowserElFromObj(obj) { url: pkg.package_url, download: pkg.download_url, version: pkg.version_number, + categories: pkg.categories, description: pkg.description }) } function BrowserEl(properties) { + if (Browser.filters.isfiltered(properties.categories)) {return} + + let entries = browser.querySelectorAll(".el").length; + if (entries == Browser.maxentries) {Browser.endoflist();return} + properties = { title: "No name", version: "1.0.0", @@ -243,6 +305,7 @@ function normalize(items) { let searchtimeout; let searchstr = ""; search.addEventListener("keyup", () => { + Browser.filters.toggle(false); clearTimeout(searchtimeout); if (searchstr != search.value) { @@ -258,3 +321,12 @@ search.addEventListener("keyup", () => { }, 500) } }) + +browser.addEventListener("scroll", () => { + Browser.filters.toggle(false); +}) + +let checks = document.querySelectorAll(".check"); +for (let i = 0; i < checks.length; i++) { + checks[i].setAttribute("onclick", "this.classList.toggle('checked');Browser.loadfront();search.value = ''") +} diff --git a/src/app/icons/check.png b/src/app/icons/check.png Binary files differnew file mode 100644 index 0000000..6c7f43f --- /dev/null +++ b/src/app/icons/check.png diff --git a/src/app/icons/filter.png b/src/app/icons/filter.png Binary files differnew file mode 100644 index 0000000..ade45ef --- /dev/null +++ b/src/app/icons/filter.png diff --git a/src/app/index.html b/src/app/index.html index ac1e276..8ad5ecf 100644 --- a/src/app/index.html +++ b/src/app/index.html @@ -86,8 +86,20 @@ </div> <div class="popup" id="browser"> + <div class="overlay" id="filters"> + <div class="checks"> + <div class="check checked" value="Mods">%%gui.browser.filter.mods%%</div> + <div class="check checked" value="Skins">%%gui.browser.filter.skins%%</div> + <div class="check checked" value="Client-side">%%gui.browser.filter.client%%</div> + <div class="check" value="Server-side">%%gui.browser.filter.server%%</div> + </div> + </div> + <div class="misc"> <input id="search" placeholder="%%gui.browser.search%%"> + <button id="filter" onclick="Browser.filters.toggle()"> + <img src="icons/filter.png"> + </button> <button id="close" onclick="Browser.toggle(false)"> <img src="icons/close.png"> </button> diff --git a/src/app/main.css b/src/app/main.css index 18afc41..3f542ec 100644 --- a/src/app/main.css +++ b/src/app/main.css @@ -236,6 +236,53 @@ button { justify-content: space-between; } +.popup .overlay { + z-index: 1; + color: white; + opacity: 0.0; + position: fixed; + pointer-events: none; + transform: scale(0.9); + background: var(--selbg); + backdrop-filter: blur(15px); + transition: 0.15s ease-in-out; + padding: calc(var(--spacing) / 2); + border-radius: calc(var(--spacing) / 2); +} + +.popup .overlay.shown { + opacity: 1.0; + pointer-events: all; + transform: scale(1.0); +} + +.checks { +} + +.check { + display:flex; + cursor: pointer; +} + +.check::before { + width: 1em; + height: 1em; + content: " "; + background-size: 75%; + filter: brightness(1.3); + background-position: center; + background-repeat: no-repeat; + transition: 0.15s ease-in-out; + background-color: var(--selbg); + margin-right: calc(var(--spacing) / 3); + border-radius: calc(var(--spacing) / 4); +} + +.check.checked::before { + background-color: rgb(var(--red)); + background-image: url(icons/check.png); +} + .option .text {font-weight: 600} .option .text .desc { opacity: 0.8; @@ -43,18 +43,19 @@ async function init() { // --help menu/argument if (cli.hasSwitch("help")) { console.log(`options: - --help ${lang("cli.help.help")} - --debug ${lang("cli.help.debug")} - --version ${lang("cli.help.version")} + --help ${lang("cli.help.help")} + --debug ${lang("cli.help.debug")} + --version ${lang("cli.help.version")} - --cli ${lang("cli.help.cli")} - --update ${lang("cli.help.update")} - --updatevp ${lang("cli.help.updatevp")} - --setpath ${lang("cli.help.setpath")} + --cli ${lang("cli.help.cli")} + --update ${lang("cli.help.update")} + --updatevp ${lang("cli.help.updatevp")} + --setpath ${lang("cli.help.setpath")} + --no-vp-updates ${lang("cli.help.novpupdates")} - --installmod ${lang("cli.help.installmod")} - --removemod ${lang("cli.help.removemod")} - --togglemod ${lang("cli.help.togglemod")}`) + --installmod ${lang("cli.help.installmod")} + --removemod ${lang("cli.help.removemod")} + --togglemod ${lang("cli.help.togglemod")}`) // In the future --setpath should be able to understand // relative paths, instead of just absolute ones. exit(); diff --git a/src/index.js b/src/index.js index 265e13d..752410e 100644 --- a/src/index.js +++ b/src/index.js @@ -56,7 +56,7 @@ function start() { ipcMain.on("savesettings", (event, obj) => {utils.saveSettings(obj)}) ipcMain.on("can-autoupdate", (event) => { - if (! require("electron-updater").autoUpdater.isUpdaterActive()) { + if (! require("electron-updater").autoUpdater.isUpdaterActive() || cli.hasParam("no-vp-updates")) { win.webContents.send("cant-autoupdate") } }) @@ -66,7 +66,11 @@ function start() { }); if (utils.settings.autoupdate) { - utils.updatevp(false) + if (cli.hasParam("no-vp-updates")) { + utils.handleNorthstarUpdating(); + } else { + utils.updatevp(false) + } } else { utils.handleNorthstarUpdating(); } diff --git a/src/lang/en.json b/src/lang/en.json index 47e18c0..8defc7d 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -6,6 +6,7 @@ "cli.help.update": "updates Northstar from your set game path", "cli.help.setpath": "sets your game path", "cli.help.updatevp": "updates Viper itself, if supported.", + "cli.help.novpupdates": "overwrites viper.json and disables Viper updates", "cli.help.installmod": "installs a mod, folder or zip", "cli.help.removemod": "removes a mod", "cli.help.togglemod": "toggles a mod", @@ -72,6 +73,11 @@ "gui.browser.reinstall": "Re-Install", "gui.browser.loading": "Loading mods...", "gui.browser.endoflist": "Maximum packages has been loaded.<br>Use the search for finding other packages!", + "gui.browser.noresults": "No results...", + "gui.browser.filter.mods": "Mods", + "gui.browser.filter.skins": "Skins", + "gui.browser.filter.client": "Client-side", + "gui.browser.filter.server": "Server-side", "gui.settings.save": "Save", "gui.settings.discard": "Discard", diff --git a/src/lang/es.json b/src/lang/es.json index b570a8d..a5b3685 100644 --- a/src/lang/es.json +++ b/src/lang/es.json @@ -6,6 +6,7 @@ "cli.help.update": "actualiza Northstar desde la ruta de juego establecida", "cli.help.setpath": "establece la ruta del juego", "cli.help.updatevp": "actualiza Viper si es soportado", + "cli.help.novpupdates": "sobrescribe viper.json y deshabilita las actualizaciones de Viper", "cli.help.installmod": "instala una modificación, desde una carpeta o zip", "cli.help.removemod": "remueve una modificación", "cli.help.togglemod": "alterna el estado de la modificación", @@ -72,6 +73,11 @@ "gui.browser.reinstall": "Re-Instalar", "gui.browser.loading": "Cargando modificaciones...", "gui.browser.endoflist": "Se ha cargado el máximo de paquetes.<br>¡Usa la búsqueda para encontrar otros paquetes!", + "gui.browser.noresults": "Sin resultados...", + "gui.browser.filter.mods": "Modificaciones", + "gui.browser.filter.skins": "Skins", + "gui.browser.filter.client": "Del lado del cliente", + "gui.browser.filter.server": "Del lado del servidor", "gui.settings.save": "Guardar", "gui.settings.discard": "Descartar", diff --git a/src/lang/fr.json b/src/lang/fr.json index 86ec763..c1797e4 100644 --- a/src/lang/fr.json +++ b/src/lang/fr.json @@ -6,6 +6,7 @@ "cli.help.update": "met à jour Northstar sur le chemin du jeu précisé", "cli.help.setpath": "enregistre le chemin du client de jeu", "cli.help.updatevp": "met à jour le client Viper, si le format actuel le permet.", + "cli.help.novpupdates": "écrase viper.json et désactive les mises à jour de Viper", "cli.help.installmod": "Installe un mod, dossier ou zip", "cli.help.removemod": "Supprime un mod", "cli.help.togglemod": "Active/désactive un mod", @@ -72,6 +73,11 @@ "gui.browser.reinstall": "Réinstaller", "gui.browser.loading": "Chargement des mods...", "gui.browser.endoflist": "Fin de la liste de mods.<br>Utilisez la barre de recherche pour en trouver davantage !", + "gui.browser.noresults": "Pas de résultat", + "gui.browser.filter.mods": "Mods", + "gui.browser.filter.skins": "Skins", + "gui.browser.filter.client": "Côté client", + "gui.browser.filter.server": "Côté serveur", "gui.settings.save": "Sauvegarder", "gui.settings.discard": "Annuler", diff --git a/src/utils.js b/src/utils.js index 57c0289..7c1c22b 100644 --- a/src/utils.js +++ b/src/utils.js @@ -769,8 +769,6 @@ setInterval(() => { ipcMain.emit("guigetmods"); }, 1500) -console.log(findgame()) - module.exports = { mods, lang, |