From 7c47b32c689d3670eee44702698161dc9e30fea5 Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Sat, 14 Feb 2026 18:50:05 -0700 Subject: [PATCH] Merge view info & manage into one popup --- src/app/game/page.tsx | 147 +++++++----------- src/app/layout.tsx | 13 +- src/componets/popups/Downloads.tsx | 2 +- src/componets/popups/ManageVersion.tsx | 106 ------------- .../{VersionInfo.tsx => VersionVersion.tsx} | 111 +++++++++++-- src/componets/popups/VersionsDownload.tsx | 2 +- 6 files changed, 162 insertions(+), 219 deletions(-) delete mode 100644 src/componets/popups/ManageVersion.tsx rename src/componets/popups/{VersionInfo.tsx => VersionVersion.tsx} (51%) diff --git a/src/app/game/page.tsx b/src/app/game/page.tsx index ebe4749..e567ed7 100644 --- a/src/app/game/page.tsx +++ b/src/app/game/page.tsx @@ -8,7 +8,7 @@ import { useRouter, useSearchParams } from 'next/navigation' import { platform } from '@tauri-apps/plugin-os' import { faWarning } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { ask, message } from '@tauri-apps/plugin-dialog' +import { ask } from '@tauri-apps/plugin-dialog' import { BaseDirectory, exists, remove } from '@tauri-apps/plugin-fs' import { writeVersionsConfig } from '@/lib/BazookaManager' import { openFolder } from '@/lib/Util' @@ -226,10 +226,60 @@ export default function Installs () { entry ) ) { - await message( - "Can't launch game. Need revision update.", - { title: 'Error launching game', kind: 'error' } + const answer = await ask( + 'Before proceeding, if you do not want your installation directory wiped just yet, please backup the files to another directory. When you click "Yes", it will be wiped. Click "No" if you want to open the installation folder instead.', + { + title: 'Revision Update', + kind: 'warning' + } ) + if (answer) { + const answer2 = await ask( + 'Are you sure you want to update? If you did not read the last popup, please go back and read it.', + { + title: 'Revision Update', + kind: 'warning' + } + ) + if (!answer2) return + + //open downloads popup + setPopupMode(1) + setShowPopup(true) + setFadeOut(false) + + //uninstall + setDownloadedVersionsConfig(prev => { + if (!prev) return prev + const updatedList = Object.fromEntries( + Object.entries(prev.list).filter( + ([k]) => k !== entry + ) + ) + const updatedConfig = { + ...prev, + list: updatedList + } + writeVersionsConfig(updatedConfig) + return updatedConfig + }) + + if ( + await exists('game/' + entry, { + baseDir: BaseDirectory.AppLocalData + }) + ) + await remove('game/' + entry, { + baseDir: BaseDirectory.AppLocalData, + recursive: true + }) + + //reinstall + setSelectedVersionList([entry]) + downloadVersions([entry]) + } else { + openFolder(entry) + } return } const verInfo = getVersionInfo(entry) @@ -306,95 +356,6 @@ export default function Installs () {

Needs revision update!

- -
- - -
)) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index b55e670..56add8e 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -32,11 +32,10 @@ import { } from '@tauri-apps/plugin-notification' import { BaseDirectory, exists, remove } from '@tauri-apps/plugin-fs' -import DownloadsPopup from '@/componets/popups/Downloads' -import VersionInfoPopup from '@/componets/popups/VersionInfo' -import ManagingVersionPopup from '@/componets/popups/ManageVersion' -import GamesDownloadPopup from '@/componets/popups/GamesDownload' import VersionsDownloadPopup from '@/componets/popups/VersionsDownload' +import GamesDownloadPopup from '@/componets/popups/GamesDownload' +import DownloadsPopup from '@/componets/popups/Downloads' +import VersionVersionPopup from '@/componets/popups/VersionVersion' const roboto = Roboto({ subsets: ['latin'] @@ -172,8 +171,6 @@ export default function RootLayout ({ } else if (viewingInfoFromDownloads) { setViewingInfoFromDownloads(false) setPopupMode(0) - } else if (popupMode == 4) { - setPopupMode(3) } else { setFadeOut(true) setTimeout(() => setShowPopup(false), 200) @@ -565,9 +562,7 @@ export default function RootLayout ({ ) : popupMode === 1 ? ( ) : popupMode === 2 ? ( - - ) : popupMode === 3 ? ( - + ) : null} diff --git a/src/componets/popups/Downloads.tsx b/src/componets/popups/Downloads.tsx index eb9b040..3bf48aa 100644 --- a/src/componets/popups/Downloads.tsx +++ b/src/componets/popups/Downloads.tsx @@ -58,7 +58,7 @@ export default function DownloadsPopup () { v.hash_checking ? 'text-blue-300' : 'text-green-300' } inline-block w-full text-center`} > - {v.hash_checking ? 'Checking hash' : 'Finishing'} + {v.hash_checking ? 'Verifying file integerty' : 'Finishing'} ... ) : ( diff --git a/src/componets/popups/ManageVersion.tsx b/src/componets/popups/ManageVersion.tsx deleted file mode 100644 index 2316ccf..0000000 --- a/src/componets/popups/ManageVersion.tsx +++ /dev/null @@ -1,106 +0,0 @@ -import { useGlobal } from '@/app/GlobalProvider' -import { writeVersionsConfig } from '@/lib/BazookaManager' -import { openFolder } from '@/lib/Util' -import { BaseDirectory, exists, remove } from '@tauri-apps/plugin-fs' - -export default function ManageVersionPopup () { - const { - getVersionInfo, - managingVersion, - closePopup, - setDownloadedVersionsConfig, - setManagingVersion, - downloadVersions, - setSelectedVersionList, - setPopupMode - } = useGlobal() - if (!managingVersion) return <> - - return ( - <> -

- Manage {getVersionInfo(managingVersion)?.displayName} -

-
- - - -
- - ) -} diff --git a/src/componets/popups/VersionInfo.tsx b/src/componets/popups/VersionVersion.tsx similarity index 51% rename from src/componets/popups/VersionInfo.tsx rename to src/componets/popups/VersionVersion.tsx index 0e16643..1cae789 100644 --- a/src/componets/popups/VersionInfo.tsx +++ b/src/componets/popups/VersionVersion.tsx @@ -14,24 +14,34 @@ import { invoke } from '@tauri-apps/api/core' import { useEffect, useState } from 'react' import prettyBytes from 'pretty-bytes' import { message } from '@tauri-apps/plugin-dialog' +import { BaseDirectory, exists, remove } from '@tauri-apps/plugin-fs' +import { writeVersionsConfig } from '@/lib/BazookaManager' +import { openFolder } from '@/lib/Util' -export default function VersionInfoPopup () { +export default function VersionVersionPopup () { const { getGameInfo, getVersionInfo, managingVersion, downloadedVersionsConfig, - viewingInfoFromDownloads + viewingInfoFromDownloads, + setManagingVersion, + closePopup, + setDownloadedVersionsConfig, + setPopupMode, + setSelectedVersionList, + downloadVersions } = useGlobal() const [versionSize, setVersionSize] = useState(0) useEffect(() => { + if (viewingInfoFromDownloads) return invoke('folder_size', { version: managingVersion }).then(size => { setVersionSize(Number(size)) }) - }, [managingVersion, setVersionSize]) + }, [managingVersion, setVersionSize, viewingInfoFromDownloads]) if (!managingVersion || !downloadedVersionsConfig) return <> @@ -40,9 +50,7 @@ export default function VersionInfoPopup () { return ( <> -

- Viewing info for {versionInfo?.displayName} -

+

Viewing {versionInfo?.displayName}

- ) diff --git a/src/componets/popups/VersionsDownload.tsx b/src/componets/popups/VersionsDownload.tsx index bca45f2..0a94205 100644 --- a/src/componets/popups/VersionsDownload.tsx +++ b/src/componets/popups/VersionsDownload.tsx @@ -66,7 +66,7 @@ export default function VersionsDownloadPopup () { onClick={() => { setManagingVersion(v.id) setViewingInfoFromDownloads(true) - setPopupMode(3) + setPopupMode(2) }} title='Click to view version info' >