Skip to content

Commit

Permalink
Merge pull request #241 from Jan200101/PR/vp-disable
Browse files Browse the repository at this point in the history
feat: Handle VanillaPlus differently in the mod browser
  • Loading branch information
0neGal authored Aug 2, 2024
2 parents fe04a8e + 9c7c8ad commit 5d6ab8e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
29 changes: 20 additions & 9 deletions src/app/js/browser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Fuse = require("fuse.js");
const ipcRenderer = require("electron").ipcRenderer;
const { ipcRenderer, shell } = require("electron");

const lang = require("../../lang");

Expand Down Expand Up @@ -414,25 +414,38 @@ browser.mod_el = (properties) => {

let installicon = "downloads";
let installstr = lang("gui.browser.install");
let normalized_mods = [];
let installcallback = () => {};
let normalized_title = mods.normalize(properties.title)

for (let i = 0; i < mods.list().all; i++) {
normalized_mods.push(mods.normalize(mods_list[i].name));
let nondefault_install = {
"vanillaplus": "https://github.com/Zayveeo5e/NP.VanillaPlus/blob/main/README.md"
}

if (properties.pkg.local_version) {
if (normalized_title in nondefault_install) {
installicon = "open";
installstr = lang("gui.browser.guide");

installcallback = () => {
shell.openExternal(nondefault_install[normalized_title])
}
}
else if (properties.pkg.local_version) {
installicon = "redo";
installstr = lang("gui.browser.reinstall");

if (properties.pkg.has_update) {
installicon = "downloads";
installstr = lang("gui.browser.update");
}

installcallback = () => {
browser.install(properties);
}
}

let entry = document.createElement("div");
entry.classList.add("el");
entry.id = `mod-${mods.normalize(properties.title)}`;
entry.id = `mod-${normalized_title}`;

entry.innerHTML = `
<div class="image">
Expand All @@ -459,9 +472,7 @@ browser.mod_el = (properties) => {
</div>
`

entry.querySelector("button.install").addEventListener("click", () => {
browser.install(properties);
})
entry.querySelector("button.install").addEventListener("click", installcallback)

browserEntries.appendChild(entry);
}
Expand Down
1 change: 1 addition & 0 deletions src/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"server": "Server-seitig",
"skins": "Skins"
},
"guide": "Anleitung",
"info": "Info",
"install": "Installieren",
"load_more": "Lade mehr...",
Expand Down
1 change: 1 addition & 0 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"load_more": "Load more...",
"end_of_list": "All packages have been loaded.",
"no_results": "No results...",
"guide": "Guide",

"filter": {
"mods": "Mods",
Expand Down
3 changes: 2 additions & 1 deletion src/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"server": "Del lado del servidor",
"skins": "Skins"
},
"guide": "Guía",
"info": "Información",
"install": "Instalar",
"load_more": "Cargar más...",
Expand Down Expand Up @@ -286,4 +287,4 @@
"release": "Notas de la versión"
}
}
}
}
1 change: 1 addition & 0 deletions src/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"server": "Côté serveur",
"skins": "Skins"
},
"guide": "Guide",
"info": "Info",
"install": "Installer",
"load_more": "Charger plus de mods...",
Expand Down
1 change: 1 addition & 0 deletions src/lang/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"server": "服务器端",
"skins": "皮肤"
},
"guide": "安装指南",
"info": "详情",
"install": "安装",
"load_more": "加载更多...",
Expand Down

0 comments on commit 5d6ab8e

Please sign in to comment.