Add the ability to download mods from Nexus, add mod data saving, and allow mods to be saved even if BepInEx is not installed.

This commit is contained in:
2026-02-19 00:41:02 +01:00
parent 0366210841
commit 72ff22861b
4 changed files with 221 additions and 20 deletions

View File

@@ -106,6 +106,26 @@
<div class="mods-container" id="mods-container"></div>
</template>
<template id="installed-mod-template">
<div class="mod-container">
<div class="mod-text">
<div class="horizontal-div">
<h3 id="mod-title">Unknown Title</h3>
<p id="mod-author">Unknown author</p>
</div>
<p id="mod-description">No description provided</p>
<p class="transparent-text" id="mod-version">V1.0.0 last update on 01/01/2026</p>
<div class="horizontal-div">
<a href="www.nexusmods.com/hollowknightsilksong/mods" class="default-button" id="uninstall-mod-button">Uninstall</a>
<a href="www.nexusmods.com/hollowknightsilksong/mods" class="default-button" id="external-link">Website</a>
</div>
</div>
<img class="mod-icon" src="assets/placeholder_icon.png" alt="mod icon" id="mod-icon" />
</div>
</template>
<template id="mod-template">
<div class="mod-container">
<div class="mod-text">

View File

@@ -6,6 +6,7 @@ const HomeTemplate = document.getElementById("home-template");
const installedModsTemplate = document.getElementById("installed-mods-template");
const onlineModsTemplate = document.getElementById("online-mods-template");
const settingsTemplate = document.getElementById("settings-template");
const installedModTemplate = document.getElementById("installed-mod-template");
const modTemplate = document.getElementById("mod-template");
let oldPage;
@@ -50,6 +51,9 @@ async function navigate(page) {
if (oldPage == page) {
return;
}
if (page == "refresh") {
page = oldPage;
}
oldPage = page;
view.replaceChildren();
@@ -63,6 +67,7 @@ async function navigate(page) {
case "mods-installed":
title.innerText = "Installed Mods";
const installedModsTemplateCopy = installedModsTemplate.content.cloneNode(true);
const installedModsContainer = installedModsTemplateCopy.getElementById("mods-container");
const searchFormInstalled = installedModsTemplateCopy.getElementById("search-form");
searchFormInstalled.addEventListener("submit", async function (event) {
@@ -70,6 +75,56 @@ async function navigate(page) {
});
view.appendChild(installedModsTemplateCopy);
const modsInfo = await files.loadInstalledModsInfo();
if (modsInfo == []) {
break;
}
for (const modInfo of modsInfo) {
const installedModTemplateCopy = installedModTemplate.content.cloneNode(true);
if (modInfo.name) {
const modTitleText = installedModTemplateCopy.getElementById("mod-title");
modTitleText.innerText = modInfo.name;
}
if (modInfo.author) {
const modAuthorText = installedModTemplateCopy.getElementById("mod-author");
modAuthorText.innerText = `by ${modInfo.author}`;
}
if (modInfo.summary) {
const modDescriptionText = installedModTemplateCopy.getElementById("mod-description");
modDescriptionText.innerText = modInfo.summary;
}
if (modInfo.picture_url) {
const modPicture = installedModTemplateCopy.getElementById("mod-icon");
modPicture.src = modInfo.picture_url;
}
if (modInfo.version && modInfo.updated_time) {
const modVersionText = installedModTemplateCopy.getElementById("mod-version");
modVersionText.innerText = `V${modInfo.version} last updated on ${modInfo.updated_time.slice(0, 10)}`;
}
const modUrl = `https://www.nexusmods.com/hollowknightsilksong/mods/${modInfo.mod_id}`;
const modLinkButton = installedModTemplateCopy.getElementById("external-link");
modLinkButton.href = modUrl;
modLinkButton.addEventListener("click", function (event) {
event.preventDefault();
const modLink = modLinkButton.href;
electronAPI.openExternalLink(modLink);
});
modDownloadButton = installedModTemplateCopy.getElementById("uninstall-mod-button");
modDownloadButton.addEventListener("click", async function (event) {
event.preventDefault();
await nexus.uninstall(modInfo.mod_id);
navigate("refresh");
});
installedModsContainer.appendChild(installedModTemplateCopy);
}
break;
case "mods-online":