Skip to content

Commit

Permalink
show guide button for mods with non-default installation methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan200101 committed Jul 20, 2024
1 parent 6f60062 commit f8b3c9f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/app/js/browser.js
Original file line number Diff line number Diff line change
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 = () => {
browser.preview.set(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

0 comments on commit f8b3c9f

Please sign in to comment.