diff --git a/src/app/GlobalProvider.tsx b/src/app/GlobalProvider.tsx index 48f2728..0e4bebc 100644 --- a/src/app/GlobalProvider.tsx +++ b/src/app/GlobalProvider.tsx @@ -42,6 +42,7 @@ type GlobalCtxType = { } | null viewingInfoFromDownloads: boolean version: string | null + downloadVersions: (list: string[]) => Promise } const GlobalCtx = createContext(null) diff --git a/src/app/componets/VersionUpdateWarning.tsx b/src/app/componets/VersionUpdateWarning.tsx new file mode 100644 index 0000000..edd8889 --- /dev/null +++ b/src/app/componets/VersionUpdateWarning.tsx @@ -0,0 +1,105 @@ +'use client' + +import { invoke } from '@tauri-apps/api/core' +import { useGlobal } from '../GlobalProvider' +import { BaseDirectory, exists, remove } from '@tauri-apps/plugin-fs' +import { writeVersionsConfig } from '../util/BazookaManager' +import { useState } from 'react' + +export default function VersionUpdateWarning () { + const [confirmed, setConfirmed] = useState<-1 | 0>(-1) + + const { + managingVersion, + setDownloadedVersionsConfig, + setManagingVersion, + setPopupMode, + setSelectedVersionList, + downloadVersions + } = useGlobal() + if (!managingVersion) return

Error

+ + return ( + <> +

Warning!

+
+

+ Before proceeding, please note that any modifications to the + installation directory (NOT THE SAVE DATA) will be completely + wiped/reset. +

+

+ If you do not want your installation directory wiped just yet, please + backup the files to another directory. When you click update, it will + be wiped. +

+

+ Updating will have the same effect as clicking the uninstall button + then installing again. +

+

Revisions are not a frequent thing and rarely ever happen.

+
+ + +
+
+ + ) +} diff --git a/src/app/game/page.tsx b/src/app/game/page.tsx index 55fd1f6..7015b5f 100644 --- a/src/app/game/page.tsx +++ b/src/app/game/page.tsx @@ -45,6 +45,21 @@ export default function Installs () { setCategory(-1) } + const needsRevisionUpdate = ( + lastRevision: number | undefined, + version: string + ) => { + if (!lastRevision) return false + return ( + lastRevision > 0 && + (downloadedVersionsConfig == undefined + ? 0 + : downloadedVersionsConfig?.list[version]) / + 1000 <= + lastRevision + ) + } + return (
@@ -203,17 +218,32 @@ export default function Installs () {
{ - if (normalConfig?.settings.useLegacyInteractButtons) return + if ( + normalConfig?.settings.useLegacyInteractButtons || + needsRevisionUpdate( + getVersionInfo(entry)?.lastRevision, + entry + ) + ) + return const verInfo = getVersionInfo(entry) if (verInfo == undefined) return const gameInfo = getGameInfo(verInfo.game) @@ -232,7 +262,14 @@ export default function Installs () { }} onContextMenu={e => { e.preventDefault() - if (normalConfig?.settings.useLegacyInteractButtons) return + if ( + normalConfig?.settings.useLegacyInteractButtons || + needsRevisionUpdate( + getVersionInfo(entry)?.lastRevision, + entry + ) + ) + return setManagingVersion(entry) setPopupMode(2) @@ -242,7 +279,7 @@ export default function Installs () { >

- {getVersionInfo(entry)?.displayName} + {getVersionInfo(entry)?.displayName}{' '}

@@ -272,6 +309,19 @@ export default function Installs () {

Uses wine

+
e.stopPropagation()} + hidden={ + !needsRevisionUpdate( + getVersionInfo(entry)?.lastRevision, + entry + ) + } + > + +

Needs revision update!

+
@@ -284,6 +334,10 @@ export default function Installs () { setShowPopup(true) setFadeOut(false) }} + hidden={needsRevisionUpdate( + getVersionInfo(entry)?.lastRevision, + entry + )} title='Click to view version info' > View Info @@ -291,7 +345,11 @@ export default function Installs () { +
diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 28130b8..4a12421 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -46,6 +46,7 @@ import { } from '@tauri-apps/plugin-notification' import VersionChangelog from './componets/VersionChangelog' import { BaseDirectory, exists, remove } from '@tauri-apps/plugin-fs' +import VersionUpdateWarning from './componets/VersionUpdateWarning' const roboto = Roboto({ subsets: ['latin'] @@ -394,28 +395,26 @@ export default function RootLayout ({ if (!serverVersionList || !downloadedVersionsConfig) return revisionCheck.current = true ;(async () => { - const newConfig = { - ...downloadedVersionsConfig, - list: { ...downloadedVersionsConfig.list } - } - const versionsToSelect: string[] = [] - for (const [key, value] of Object.entries( downloadedVersionsConfig.list )) { const verInfo = serverVersionList.versions.find(item => item.id === key) - if (!verInfo || value / 1000 <= verInfo.lastRevision) { - delete newConfig.list[key] - versionsToSelect.push(key) + if ( + !verInfo || + (verInfo.lastRevision > 0 && value / 1000 <= verInfo.lastRevision) + ) { + if ( + await exists('game/' + key + '/' + verInfo?.executable, { + baseDir: BaseDirectory.AppLocalData + }) + ) + await remove('game/' + key + '/' + verInfo?.executable, { + baseDir: BaseDirectory.AppLocalData, + recursive: true + }) } } - - setDownloadedVersionsConfig(newConfig) - writeVersionsConfig(newConfig) - setSelectedVersionList(prev => [...prev, ...versionsToSelect]) - - await downloadVersions(versionsToSelect) })() }, [serverVersionList, downloadedVersionsConfig, downloadVersions]) @@ -480,7 +479,8 @@ export default function RootLayout ({ setSelectedGame, getVersionsAmountData, viewingInfoFromDownloads, - version + version, + downloadVersions }} >
) + ) : popupMode === 5 ? ( + managingVersion && downloadedVersionsConfig ? ( + + ) : ( +

+ No version selected +

+ ) ) : null} {popupMode == 0 && selectedGame &&