mirror of
https://github.com/Gabi-Zar/Silk-Fly-Launcher.git
synced 2026-06-15 03:47:11 +02:00
Add the ability to update BepInEx
This commit is contained in:
16
main.js
16
main.js
@@ -208,9 +208,13 @@ function saveBepinexVersion(version) {
|
||||
}
|
||||
|
||||
ipcMain.handle("load-bepinex-version", () => {
|
||||
return loadBepinexVersion();
|
||||
});
|
||||
|
||||
function loadBepinexVersion() {
|
||||
bepinexVersion = bepinexStore.get("bepinex-version");
|
||||
return bepinexVersion;
|
||||
});
|
||||
}
|
||||
|
||||
function saveBepinexBackupVersion(version) {
|
||||
bepinexBackupVersion = version;
|
||||
@@ -377,8 +381,6 @@ async function installBepinex() {
|
||||
saveBepinexVersion(bepinexBackupVersion);
|
||||
saveBepinexBackupVersion(undefined);
|
||||
} else {
|
||||
mainWindow.webContents.send("showToast", "Installing Bepinex from Github");
|
||||
|
||||
const GITHUB_URL = "https://api.github.com/repos/bepinex/bepinex/releases/latest";
|
||||
|
||||
const res = await fetch(GITHUB_URL, {
|
||||
@@ -397,6 +399,14 @@ async function installBepinex() {
|
||||
|
||||
const release = await res.json();
|
||||
|
||||
if (loadBepinexVersion() == release.tag_name) {
|
||||
mainWindow.webContents.send("showToast", "No new BepInEx update.");
|
||||
return;
|
||||
}
|
||||
mainWindow.webContents.send("showToast", "Installing Bepinex from Github");
|
||||
|
||||
await uninstallBepinex();
|
||||
|
||||
let asset;
|
||||
if (process.platform === "win32") {
|
||||
asset = release.assets.find((a) => a.name.endsWith(".zip") && a.name.toLowerCase().includes("win_x64"));
|
||||
|
||||
@@ -281,7 +281,7 @@
|
||||
<p class="transparent-text" id="bepinex-version-text"></p>
|
||||
<br />
|
||||
<div class="horizontal-div">
|
||||
<button class="default-button" onclick="installBepinex()">Install</button>
|
||||
<button id="install-bepinex-button" class="default-button" onclick="installBepinex()">Install</button>
|
||||
<button class="important-button" onclick="uninstallBepinex()">Uninstall</button>
|
||||
<button class="default-button" onclick="backupBepinex()">Backup</button>
|
||||
<button class="important-button" onclick="deleteBepinexBackup()">Delete Backup</button>
|
||||
|
||||
@@ -589,6 +589,7 @@ async function deleteBepinexBackup() {
|
||||
|
||||
async function setBepinexVersion() {
|
||||
const bepinexVersionText = document.getElementById("bepinex-version-text");
|
||||
const bepinexInstallButton = document.getElementById("install-bepinex-button");
|
||||
if (bepinexVersionText == undefined) {
|
||||
return;
|
||||
}
|
||||
@@ -601,8 +602,10 @@ async function setBepinexVersion() {
|
||||
} else {
|
||||
bepinexVersionText.innerText = `BepInEx ${bepinexBackupVersion} is backed up`;
|
||||
}
|
||||
bepinexInstallButton.innerText = "Install";
|
||||
} else {
|
||||
bepinexVersionText.innerText = `BepInEx ${bepinexVersion} is installed`;
|
||||
bepinexInstallButton.innerText = "Update";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user