Finish mod manager & Count downloads for mods
This commit is contained in:
2 files changed
+77
-5
No files matched your search
+3
-2
@@ -455,11 +455,12 @@ export default function RootLayout ({
|
|||||||
const downloadInfoRequest = await fetch(
|
const downloadInfoRequest = await fetch(
|
||||||
'https://games.lncvrt.xyz/api/launcher/download' +
|
'https://games.lncvrt.xyz/api/launcher/download' +
|
||||||
(downloadInfo.type == 0
|
(downloadInfo.type == 0
|
||||||
? '?gameId=' + info.id + '&downloadId=' + info.download
|
? '?versionId=' + info.id + '&downloadId=' + info.download
|
||||||
: '?downloadId=' +
|
: '?downloadId=' +
|
||||||
(downloadInfo.type == 1
|
(downloadInfo.type == 1
|
||||||
? info.modSupportDownload
|
? info.modSupportDownload
|
||||||
: downloadInfo.modDownload))
|
: downloadInfo.modDownload)) +
|
||||||
|
(downloadInfo.type == 2 ? '&modId=' + downloadInfo.modId : '')
|
||||||
)
|
)
|
||||||
const signature = downloadInfoRequest.headers.get('x-signature') ?? ''
|
const signature = downloadInfoRequest.headers.get('x-signature') ?? ''
|
||||||
const data = await downloadInfoRequest.json()
|
const data = await downloadInfoRequest.json()
|
||||||
|
|||||||
@@ -138,6 +138,14 @@ export default function ModDownloadsPopup () {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
.map(v => {
|
.map(v => {
|
||||||
|
const localVersion =
|
||||||
|
tab == 0
|
||||||
|
? Object.keys(
|
||||||
|
downloadedVersionsConfig?.mods?.[
|
||||||
|
versionInfo?.game + '-' + v.id
|
||||||
|
] ?? {}
|
||||||
|
)[0]
|
||||||
|
: null
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={v.id}
|
key={v.id}
|
||||||
@@ -146,8 +154,21 @@ export default function ModDownloadsPopup () {
|
|||||||
<div className='flex flex-col justify-center h-full px-3 w-fit'>
|
<div className='flex flex-col justify-center h-full px-3 w-fit'>
|
||||||
<p>
|
<p>
|
||||||
<span className='text-lg'>{v.name}</span>{' '}
|
<span className='text-lg'>{v.name}</span>{' '}
|
||||||
<span className='text-green-300'>
|
<span
|
||||||
v{v.latestVersion}
|
className={
|
||||||
|
tab != 0 || v.latestVersion == localVersion
|
||||||
|
? 'text-green-300'
|
||||||
|
: 'text-red-300'
|
||||||
|
}
|
||||||
|
>
|
||||||
|
v{tab == 0 ? localVersion : v.latestVersion}
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
className='text-green-300'
|
||||||
|
hidden={tab != 0 || v.latestVersion == localVersion}
|
||||||
|
>
|
||||||
|
{' '}
|
||||||
|
(available: v{v.latestVersion})
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<p className='text-yellow-200'>
|
<p className='text-yellow-200'>
|
||||||
@@ -161,6 +182,54 @@ export default function ModDownloadsPopup () {
|
|||||||
<p className='text-green-400' hidden={tab == 0}>
|
<p className='text-green-400' hidden={tab == 0}>
|
||||||
<FontAwesomeIcon icon={faDownload} /> {v.downloads}
|
<FontAwesomeIcon icon={faDownload} /> {v.downloads}
|
||||||
</p>
|
</p>
|
||||||
|
<button
|
||||||
|
className='button btntheme3'
|
||||||
|
onClick={async () => {
|
||||||
|
const path =
|
||||||
|
'game/' +
|
||||||
|
versionInfo?.id +
|
||||||
|
'/BepInEx/plugins/' +
|
||||||
|
v.id
|
||||||
|
if (
|
||||||
|
await exists(path, {
|
||||||
|
baseDir: BaseDirectory.AppLocalData
|
||||||
|
})
|
||||||
|
)
|
||||||
|
await remove(path, {
|
||||||
|
baseDir: BaseDirectory.AppLocalData,
|
||||||
|
recursive: true
|
||||||
|
})
|
||||||
|
setDownloadedVersionsConfig(prev => {
|
||||||
|
if (!prev) return prev
|
||||||
|
const updatedMods = Object.fromEntries(
|
||||||
|
Object.entries(prev.mods).filter(
|
||||||
|
([k]) => k !== versionInfo?.game + '-' + v.id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
const updatedConfig = {
|
||||||
|
...prev,
|
||||||
|
mods: updatedMods
|
||||||
|
}
|
||||||
|
writeVersionsConfig(updatedConfig)
|
||||||
|
return updatedConfig
|
||||||
|
})
|
||||||
|
|
||||||
|
downloadVersions([
|
||||||
|
{
|
||||||
|
id: managingVersion,
|
||||||
|
type: 2,
|
||||||
|
modDownload: v.latestDownload,
|
||||||
|
gameId: versionInfo?.game,
|
||||||
|
modId: v.id,
|
||||||
|
modVersion: v.latestVersion
|
||||||
|
}
|
||||||
|
])
|
||||||
|
}}
|
||||||
|
hidden={tab != 0 || v.latestVersion == localVersion}
|
||||||
|
disabled={downloadProgress.length != 0}
|
||||||
|
>
|
||||||
|
Update
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
className='button btntheme3'
|
className='button btntheme3'
|
||||||
onClick={() => setShowModInfo(v)}
|
onClick={() => setShowModInfo(v)}
|
||||||
@@ -197,7 +266,9 @@ export default function ModDownloadsPopup () {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className='flex flex-col p-2 bg-(--col3) border border-(--col5) rounded-lg h-full w-[calc(100%-16px)]'>
|
<div className='flex flex-col p-2 bg-(--col3) border border-(--col5) rounded-lg h-full w-[calc(100%-16px)]'>
|
||||||
{showModInfo.description ?? '(No description added)'}
|
{showModInfo.description
|
||||||
|
? atob(showModInfo.description)
|
||||||
|
: '(No description added)'}
|
||||||
</div>
|
</div>
|
||||||
<div className='flex flex-row h-fit w-full gap-2 justify-center my-2'>
|
<div className='flex flex-row h-fit w-full gap-2 justify-center my-2'>
|
||||||
{Object.keys(downloadedVersionsConfig?.mods ?? []).includes(
|
{Object.keys(downloadedVersionsConfig?.mods ?? []).includes(
|
||||||
|
|||||||
Reference in new issue
Block a user