Add types to downloads, will be for modding stuff
This commit is contained in:
6 files changed
+33
-13
No files matched your search
@@ -42,7 +42,9 @@ type GlobalCtxType = {
|
|||||||
} | null
|
} | null
|
||||||
viewingInfoFromDownloads: boolean
|
viewingInfoFromDownloads: boolean
|
||||||
version: string | null
|
version: string | null
|
||||||
downloadVersions: (list: string[]) => Promise<void>
|
downloadVersions: (
|
||||||
|
list: Array<{ id: string; type: 0 | 1 | 2 }>
|
||||||
|
) => Promise<void>
|
||||||
category: number
|
category: number
|
||||||
setCategory: Dispatch<SetStateAction<number>>
|
setCategory: Dispatch<SetStateAction<number>>
|
||||||
downloadQueue: string[]
|
downloadQueue: string[]
|
||||||
|
|||||||
@@ -276,7 +276,12 @@ export default function Installs () {
|
|||||||
|
|
||||||
//reinstall
|
//reinstall
|
||||||
setSelectedVersionList([entry])
|
setSelectedVersionList([entry])
|
||||||
downloadVersions([entry])
|
downloadVersions([
|
||||||
|
{
|
||||||
|
id: entry,
|
||||||
|
type: 0
|
||||||
|
}
|
||||||
|
])
|
||||||
} else {
|
} else {
|
||||||
openFolder(entry)
|
openFolder(entry)
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-8
@@ -361,22 +361,22 @@ export default function RootLayout ({
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const downloadVersions = useCallback(
|
const downloadVersions = useCallback(
|
||||||
async (list: string[]): Promise<void> => {
|
async (list: Array<{ id: string; type: 0 | 1 | 2 }>): Promise<void> => {
|
||||||
if (list.length === 0) return
|
if (list.length === 0) return
|
||||||
setSelectedVersionList([])
|
setSelectedVersionList([])
|
||||||
|
|
||||||
const newVersions = list.filter(
|
const newVersions = list.filter(
|
||||||
version =>
|
item =>
|
||||||
!downloadQueue.includes(version) &&
|
!downloadQueue.includes(item.id) &&
|
||||||
!downloadProgress.some(d => d.version === version)
|
!downloadProgress.some(d => d.version === item.id)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (newVersions.length === 0) return
|
if (newVersions.length === 0) return
|
||||||
|
|
||||||
const newDownloads = newVersions.map(
|
const newDownloads = newVersions.map(
|
||||||
version =>
|
item =>
|
||||||
new DownloadProgress(
|
new DownloadProgress(
|
||||||
version,
|
item.id,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
false,
|
false,
|
||||||
@@ -393,12 +393,13 @@ export default function RootLayout ({
|
|||||||
0,
|
0,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null
|
null,
|
||||||
|
item.type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
setDownloadProgress(prev => [...prev, ...newDownloads])
|
setDownloadProgress(prev => [...prev, ...newDownloads])
|
||||||
setDownloadQueue(prev => [...prev, ...newVersions])
|
setDownloadQueue(prev => [...prev, ...newVersions.map(v => v.id)])
|
||||||
},
|
},
|
||||||
[downloadQueue, downloadProgress]
|
[downloadQueue, downloadProgress]
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -196,7 +196,12 @@ export default function ManageVersionPopup () {
|
|||||||
|
|
||||||
//reinstall
|
//reinstall
|
||||||
setSelectedVersionList([managingVersion])
|
setSelectedVersionList([managingVersion])
|
||||||
downloadVersions([managingVersion])
|
downloadVersions([
|
||||||
|
{
|
||||||
|
id: managingVersion,
|
||||||
|
type: 0
|
||||||
|
}
|
||||||
|
])
|
||||||
}}
|
}}
|
||||||
title="Click to reinstall this game. This will NOT remove any progress or any save files. This WILL uninstall any modifications to the game's executable files."
|
title="Click to reinstall this game. This will NOT remove any progress or any save files. This WILL uninstall any modifications to the game's executable files."
|
||||||
hidden={viewingInfoFromDownloads}
|
hidden={viewingInfoFromDownloads}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export default function VersionsDownloadPopup () {
|
|||||||
downloadVersions,
|
downloadVersions,
|
||||||
getGameInfo
|
getGameInfo
|
||||||
} = useGlobal()
|
} = useGlobal()
|
||||||
|
|
||||||
if (!selectedGame) return <></>
|
if (!selectedGame) return <></>
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -78,7 +79,12 @@ export default function VersionsDownloadPopup () {
|
|||||||
className='button btntheme1 w-fit mt-2 -mb-4'
|
className='button btntheme1 w-fit mt-2 -mb-4'
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (downloadedVersionsConfig) {
|
if (downloadedVersionsConfig) {
|
||||||
downloadVersions(selectedVersionList)
|
downloadVersions(
|
||||||
|
selectedVersionList.map(versionId => ({
|
||||||
|
id: versionId,
|
||||||
|
type: 0
|
||||||
|
}))
|
||||||
|
)
|
||||||
setPopupMode(1)
|
setPopupMode(1)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export class DownloadProgress {
|
|||||||
public unzipped: number,
|
public unzipped: number,
|
||||||
public url: string | null,
|
public url: string | null,
|
||||||
public executable: string | null,
|
public executable: string | null,
|
||||||
public hash: string | null
|
public hash: string | null,
|
||||||
|
public type: 0 | 1 | 2
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user