mirror of
https://github.com/Gabi-Zar/Silk-Fly-Launcher.git
synced 2026-04-17 05:26:04 +02:00
the latest mods from nexus is now on the online mods page
This commit is contained in:
36
main.js
36
main.js
@@ -27,8 +27,10 @@ const bepinexFiles = [
|
|||||||
let bepinexVersion
|
let bepinexVersion
|
||||||
let bepinexBackupVersion
|
let bepinexBackupVersion
|
||||||
|
|
||||||
|
let mainWindow
|
||||||
|
|
||||||
const createWindow = () => {
|
const createWindow = () => {
|
||||||
const win = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 1280,
|
width: 1280,
|
||||||
height: 720,
|
height: 720,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
@@ -36,7 +38,7 @@ const createWindow = () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
win.loadFile('renderer/index.html')
|
mainWindow.loadFile('renderer/index.html')
|
||||||
}
|
}
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
@@ -329,4 +331,32 @@ async function verifyNexusAPI() {
|
|||||||
if (await nexus.getValidationResult()) {
|
if (await nexus.getValidationResult()) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ipcMain.handle('get-latest-mods', async () => {
|
||||||
|
if (nexus == undefined) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
mods = await nexus.getLatestAdded()
|
||||||
|
return mods
|
||||||
|
})
|
||||||
|
|
||||||
|
ipcMain.handle('download-mod', async (event, link) => {
|
||||||
|
if (nexus == undefined) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const nexusWindow = new BrowserWindow({
|
||||||
|
width: 1080,
|
||||||
|
height: 720,
|
||||||
|
modal: true,
|
||||||
|
parent: mainWindow,
|
||||||
|
webPreferences: {
|
||||||
|
nodeIntegration: false,
|
||||||
|
contextIsolation: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
nexusWindow.loadURL(link)
|
||||||
|
})
|
||||||
@@ -34,5 +34,7 @@ contextBridge.exposeInMainWorld('bepinex', {
|
|||||||
})
|
})
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld('nexus', {
|
contextBridge.exposeInMainWorld('nexus', {
|
||||||
verifyAPI: () => ipcRenderer.invoke('verify-nexus-api')
|
verifyAPI: () => ipcRenderer.invoke('verify-nexus-api'),
|
||||||
|
getLatestMods: () => ipcRenderer.invoke('get-latest-mods'),
|
||||||
|
download: (link) => ipcRenderer.invoke('download-mod', link)
|
||||||
})
|
})
|
||||||
@@ -81,17 +81,21 @@
|
|||||||
<template id="mod-template">
|
<template id="mod-template">
|
||||||
<div class="mod-container">
|
<div class="mod-container">
|
||||||
<div class="mod-text">
|
<div class="mod-text">
|
||||||
<h3 id="mod-title">Mod Title</h3>
|
<div class="horizontal-div" >
|
||||||
<p id="mod-description">description</p>
|
<h3 id="mod-title">Unknown Title</h3>
|
||||||
<p class="transparent-text">V1.0.0 last update on 01/01/2026</p>
|
<p id="mod-author">Unknown author</p>
|
||||||
|
<p id="mod-endorsements-number">? likes</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="mod-actions">
|
<div class="mod-actions">
|
||||||
<button class="default-button" onclick="downloadMod()">Download</button>
|
<a href="https://google.com" class="default-button" id="download-mod-button">Download</a>
|
||||||
<a href="https://google.com" class="default-button" id="external-link">Website</a>
|
<a href="https://google.com" class="default-button" id="external-link">Website</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<img class="mod-icon" src="assets/placeholder_icon.png" alt="mod icon">
|
<img class="mod-icon" src="assets/placeholder_icon.png" alt="mod icon" id="mod-icon">
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -46,16 +46,62 @@ async function navigate(page) {
|
|||||||
const ModsContainer = onlineModsTemplateCopy.getElementById("mods-container")
|
const ModsContainer = onlineModsTemplateCopy.getElementById("mods-container")
|
||||||
view.appendChild(onlineModsTemplateCopy)
|
view.appendChild(onlineModsTemplateCopy)
|
||||||
|
|
||||||
for(let i = 0; i <= 10; i++) {
|
mods = await nexus.getLatestMods()
|
||||||
|
if (mods == undefined) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for(const mod of mods) {
|
||||||
|
if (mod.name == undefined) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
const modTemplateCopy = modTemplate.content.cloneNode(true)
|
const modTemplateCopy = modTemplate.content.cloneNode(true)
|
||||||
|
if (mod.name) {
|
||||||
|
const modTitleText = modTemplateCopy.getElementById("mod-title")
|
||||||
|
modTitleText.innerText = mod.name
|
||||||
|
}
|
||||||
|
if (mod.author) {
|
||||||
|
const modAuthorText = modTemplateCopy.getElementById("mod-author")
|
||||||
|
modAuthorText.innerText = `by ${mod.author}`
|
||||||
|
}
|
||||||
|
if (mod.endorsement_count) {
|
||||||
|
const modEndorsementsNumber = modTemplateCopy.getElementById("mod-endorsements-number")
|
||||||
|
if (mod.endorsement_count > 1) {
|
||||||
|
modEndorsementsNumber.innerText = `${mod.endorsement_count} likes`
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
modEndorsementsNumber.innerText = `${mod.endorsement_count} like`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mod.summary) {
|
||||||
|
const modDescriptionText = modTemplateCopy.getElementById("mod-description")
|
||||||
|
modDescriptionText.innerText = mod.summary
|
||||||
|
}
|
||||||
|
if (mod.picture_url) {
|
||||||
|
const modPicture = modTemplateCopy.getElementById("mod-icon")
|
||||||
|
modPicture.src = mod.picture_url
|
||||||
|
}
|
||||||
|
if (mod.version && mod.updated_timestamp) {
|
||||||
|
const modVersionText = modTemplateCopy.getElementById("mod-version")
|
||||||
|
modVersionText.innerText = `V${mod.version} last updated on ${mod.updated_time.slice(0, 10)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const modUrl = `https://www.nexusmods.com/hollowknightsilksong/mods/${mod.mod_id}`
|
||||||
|
|
||||||
const modLinkButton = modTemplateCopy.getElementById("external-link")
|
const modLinkButton = modTemplateCopy.getElementById("external-link")
|
||||||
|
modLinkButton.href = modUrl
|
||||||
modLinkButton.addEventListener('click', function(event) {
|
modLinkButton.addEventListener('click', function(event) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
const modLink = modLinkButton.href
|
const modLink = modLinkButton.href
|
||||||
electronAPI.openExternalLink(modLink)
|
electronAPI.openExternalLink(modLink)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
modDownloadButton = modTemplateCopy.getElementById("download-mod-button")
|
||||||
|
modDownloadButton.addEventListener('click', function(event) {
|
||||||
|
event.preventDefault()
|
||||||
|
const modDownloadLink = `${modUrl}?tab=files`
|
||||||
|
nexus.download(modDownloadLink)
|
||||||
|
})
|
||||||
|
|
||||||
ModsContainer.appendChild(modTemplateCopy)
|
ModsContainer.appendChild(modTemplateCopy)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -81,6 +127,7 @@ async function navigate(page) {
|
|||||||
view.appendChild(settingsTemplateCopy)
|
view.appendChild(settingsTemplateCopy)
|
||||||
setBepinexVersion()
|
setBepinexVersion()
|
||||||
verifyNexusAPI()
|
verifyNexusAPI()
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,10 +170,6 @@ async function importData() {
|
|||||||
document.getElementById("silksong-path-input").value = await files.loadSilksongPath()
|
document.getElementById("silksong-path-input").value = await files.loadSilksongPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function downloadMod() {
|
|
||||||
console.log("WIP")
|
|
||||||
}
|
|
||||||
|
|
||||||
async function installBepinex() {
|
async function installBepinex() {
|
||||||
await bepinex.install()
|
await bepinex.install()
|
||||||
setBepinexVersion()
|
setBepinexVersion()
|
||||||
|
|||||||
Reference in New Issue
Block a user