Early WIP version of the mod manager
This commit is contained in:
5 files changed
+127
-5
No files matched your search
@@ -148,7 +148,7 @@ async fn download(
|
|||||||
url: String,
|
url: String,
|
||||||
name: String,
|
name: String,
|
||||||
hash: String,
|
hash: String,
|
||||||
download_type: i8
|
download_type: i8,
|
||||||
) -> String {
|
) -> String {
|
||||||
println!("[download] Starting download for '{}' from '{}'", name, url);
|
println!("[download] Starting download for '{}' from '{}'", name, url);
|
||||||
let _ = app.emit("download-start", format!("{}", name));
|
let _ = app.emit("download-start", format!("{}", name));
|
||||||
|
|||||||
@@ -387,6 +387,10 @@ export default function Installs () {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
setManagingVersion(entry)
|
||||||
|
setPopupMode(3)
|
||||||
|
setShowPopup(true)
|
||||||
|
setFadeOut(false)
|
||||||
}}
|
}}
|
||||||
hidden={!getVersionInfo(entry)?.modSupportDownload}
|
hidden={!getVersionInfo(entry)?.modSupportDownload}
|
||||||
>
|
>
|
||||||
|
|||||||
+7
-4
@@ -1,8 +1,8 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
|
import './Globals.css'
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||||
import Sidebar from '@/componets/Sidebar'
|
import Sidebar from '@/componets/Sidebar'
|
||||||
import './Globals.css'
|
|
||||||
import { DownloadProgress } from '@/types/DownloadProgress'
|
import { DownloadProgress } from '@/types/DownloadProgress'
|
||||||
import { invoke } from '@tauri-apps/api/core'
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||||
@@ -30,14 +30,15 @@ import {
|
|||||||
requestPermission
|
requestPermission
|
||||||
} from '@tauri-apps/plugin-notification'
|
} from '@tauri-apps/plugin-notification'
|
||||||
import { BaseDirectory, exists, remove } from '@tauri-apps/plugin-fs'
|
import { BaseDirectory, exists, remove } from '@tauri-apps/plugin-fs'
|
||||||
|
import { fetch } from '@tauri-apps/plugin-http'
|
||||||
|
import { verifySignature } from '@/lib/Util'
|
||||||
|
import { getCurrentWindow, UserAttentionType } from '@tauri-apps/api/window'
|
||||||
|
|
||||||
import VersionsDownloadPopup from '@/componets/popups/VersionsDownload'
|
import VersionsDownloadPopup from '@/componets/popups/VersionsDownload'
|
||||||
import GamesDownloadPopup from '@/componets/popups/GamesDownload'
|
import GamesDownloadPopup from '@/componets/popups/GamesDownload'
|
||||||
import DownloadsPopup from '@/componets/popups/Downloads'
|
import DownloadsPopup from '@/componets/popups/Downloads'
|
||||||
import ManageVersionPopup from '@/componets/popups/ManageVersion'
|
import ManageVersionPopup from '@/componets/popups/ManageVersion'
|
||||||
import { fetch } from '@tauri-apps/plugin-http'
|
import ModDownloadsPopup from '@/componets/popups/ModDownloads'
|
||||||
import { verifySignature } from '@/lib/Util'
|
|
||||||
import { getCurrentWindow, UserAttentionType } from '@tauri-apps/api/window'
|
|
||||||
|
|
||||||
const roboto = Roboto({
|
const roboto = Roboto({
|
||||||
subsets: ['latin']
|
subsets: ['latin']
|
||||||
@@ -717,6 +718,8 @@ export default function RootLayout ({
|
|||||||
<DownloadsPopup />
|
<DownloadsPopup />
|
||||||
) : popupMode === 2 ? (
|
) : popupMode === 2 ? (
|
||||||
<ManageVersionPopup />
|
<ManageVersionPopup />
|
||||||
|
) : popupMode === 3 ? (
|
||||||
|
<ModDownloadsPopup />
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,103 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import { useGlobal } from '@/app/GlobalProvider'
|
||||||
|
import { verifySignature } from '@/lib/Util'
|
||||||
|
import { Mod } from '@/types/Mod'
|
||||||
|
import { faDownload, faGlobe } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||||
|
import { arch, platform } from '@tauri-apps/plugin-os'
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
export default function ModDownloadsPopup () {
|
||||||
|
const { getGameInfo, getVersionInfo, managingVersion } = useGlobal()
|
||||||
|
|
||||||
|
const [mods, setMods] = useState<Mod[] | 0 | 1>(0)
|
||||||
|
const [tab, setTab] = useState<number>(0)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
;(async () => {
|
||||||
|
const response = await fetch(
|
||||||
|
`https://games.lncvrt.xyz/api/launcher/mods?platform=${platform()}&arch=${arch()}&version=${managingVersion}`
|
||||||
|
)
|
||||||
|
const signature = response.headers.get('x-signature') ?? ''
|
||||||
|
const data = await response.json()
|
||||||
|
if (await verifySignature(JSON.stringify(data), signature)) {
|
||||||
|
setMods(data as Mod[])
|
||||||
|
} else {
|
||||||
|
setMods(1)
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
}, [managingVersion])
|
||||||
|
|
||||||
|
if (!managingVersion) return <></>
|
||||||
|
|
||||||
|
const versionInfo = getVersionInfo(managingVersion)
|
||||||
|
const gameInfo = getGameInfo(versionInfo?.game)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<p className='text-xl text-center'>
|
||||||
|
{versionInfo?.displayName} Mod Manager
|
||||||
|
</p>
|
||||||
|
{typeof mods != 'number' ? (
|
||||||
|
<div className='flex flex-row justify-center items-center -mb-2.5 gap-1.5'>
|
||||||
|
<button
|
||||||
|
className={`button ${tab == 0 ? 'btntheme3' : 'btntheme2'}`}
|
||||||
|
onClick={() => setTab(0)}
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon icon={faDownload} />
|
||||||
|
Installed
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className={`button ${tab == 1 ? 'btntheme3' : 'btntheme2'}`}
|
||||||
|
onClick={() => setTab(1)}
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon icon={faGlobe} />
|
||||||
|
Download
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
<div className='popup-content h-full'>
|
||||||
|
{typeof mods == 'number' ? (
|
||||||
|
<p className='text-2xl flex justify-center items-center h-full'>
|
||||||
|
{mods == 0 ? 'Loading' : 'Failed to load mods'}
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
<div className='flex flex-col items-center justify-center gap-2 p-2'>
|
||||||
|
{tab == 0
|
||||||
|
? null
|
||||||
|
: mods.map(v => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={v.id}
|
||||||
|
className='bg-(--col3) border border-(--col5) rounded-lg w-full h-16 flex flex-row'
|
||||||
|
>
|
||||||
|
<div className='flex flex-col justify-center h-full px-3 w-fit'>
|
||||||
|
<p>
|
||||||
|
<span className='text-lg'>{v.name}</span>{' '}
|
||||||
|
<span className='text-green-300'>
|
||||||
|
v{v.latestVersion}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<p className='text-yellow-200'>
|
||||||
|
Made by {v.creators[0]}
|
||||||
|
{v.creators.length < 2
|
||||||
|
? ' + ' + v.creators.length + ' more'
|
||||||
|
: null}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className='flex flex-row items-center h-full gap-2 px-3 ml-auto'>
|
||||||
|
<p className='text-green-400'>
|
||||||
|
<FontAwesomeIcon icon={faDownload} /> {v.downloads}
|
||||||
|
</p>
|
||||||
|
<button className='button btntheme3'>Get</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
export interface Mod {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
description: string | null
|
||||||
|
creators: string[]
|
||||||
|
downloads: number
|
||||||
|
released: number
|
||||||
|
updated: number
|
||||||
|
latestVersion: string
|
||||||
|
latestDownload: number
|
||||||
|
changelog: string | null
|
||||||
|
}
|
||||||
Reference in new issue
Block a user