From ea1c05d2d9317dbb629e3a1a9ff83058e2bd8ab0 Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Tue, 24 Mar 2026 17:10:15 -0700 Subject: [PATCH] Add view mod info mode --- src/app/GlobalProvider.tsx | 5 +- src/app/layout.tsx | 11 +-- src/componets/popups/ModDownloads.tsx | 108 ++++++++++++++++++++++++-- src/types/VersionsConfig.ts | 4 +- 4 files changed, 112 insertions(+), 16 deletions(-) diff --git a/src/app/GlobalProvider.tsx b/src/app/GlobalProvider.tsx index 219fc72..190ba42 100644 --- a/src/app/GlobalProvider.tsx +++ b/src/app/GlobalProvider.tsx @@ -13,6 +13,7 @@ import { NormalConfig } from '@/types/NormalConfig' import { ServerVersionsResponse } from '@/types/ServerVersionsResponse' import { GameVersion } from '@/types/GameVersion' import { Game } from '@/types/Game' +import { Mod } from '@/types/Mod' type GlobalCtxType = { serverVersionList: ServerVersionsResponse | null @@ -53,8 +54,8 @@ type GlobalCtxType = { getSpecialVersionsList(game?: number | undefined): GameVersion[] selectedGame: number | null setViewingInfoFromDownloads: Dispatch> - showModInfo: number - setShowModInfo: Dispatch> + showModInfo: Mod | null + setShowModInfo: Dispatch> } const GlobalCtx = createContext(null) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index de53d6a..b24be22 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -39,6 +39,7 @@ import GamesDownloadPopup from '@/componets/popups/GamesDownload' import DownloadsPopup from '@/componets/popups/Downloads' import ManageVersionPopup from '@/componets/popups/ManageVersion' import ModDownloadsPopup from '@/componets/popups/ModDownloads' +import { Mod } from '@/types/Mod' const roboto = Roboto({ subsets: ['latin'] @@ -78,7 +79,7 @@ export default function RootLayout ({ const [selectedGame, setSelectedGame] = useState(null) const [category, setCategory] = useState(-1) - const [showModInfo, setShowModInfo] = useState(-1) + const [showModInfo, setShowModInfo] = useState(null) const pathname = usePathname() const revisionCheck = useRef(false) @@ -175,8 +176,8 @@ export default function RootLayout ({ } else if (viewingInfoFromDownloads) { setViewingInfoFromDownloads(false) setPopupMode(0) - } else if (popupMode == 3 && showModInfo != -1) { - setShowModInfo(-1) + } else if (popupMode == 3 && showModInfo) { + setShowModInfo(null) } else { setFadeOut(true) setTimeout(() => setShowPopup(false), 200) @@ -687,7 +688,7 @@ export default function RootLayout ({ className={`popup-overlay ${fadeOut ? 'fade-out' : ''}`} onClick={(e: React.MouseEvent) => { if (e.target === e.currentTarget) { - if (showModInfo != -1) setShowModInfo(-1) + if (showModInfo) setShowModInfo(null) if (viewingInfoFromDownloads) { setPopupMode(0) setViewingInfoFromDownloads(false) @@ -710,7 +711,7 @@ export default function RootLayout ({ selectedGame && pathname === '/') || viewingInfoFromDownloads || - (popupMode == 3 && showModInfo != -1) + (popupMode == 3 && showModInfo) ? faChevronLeft : faXmark } diff --git a/src/componets/popups/ModDownloads.tsx b/src/componets/popups/ModDownloads.tsx index 4962594..6d9982b 100644 --- a/src/componets/popups/ModDownloads.tsx +++ b/src/componets/popups/ModDownloads.tsx @@ -4,17 +4,21 @@ import { useGlobal } from '@/app/GlobalProvider' import { verifySignature } from '@/lib/Util' import { Mod } from '@/types/Mod' import { + faArrowUpRightFromSquare, + faClock, + faCodeBranch, faDownload, faGlobe, + faPeopleGroup, faRefresh } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import { message } from '@tauri-apps/plugin-dialog' import { arch, platform } from '@tauri-apps/plugin-os' import { useEffect, useState } from 'react' export default function ModDownloadsPopup () { const { - getGameInfo, getVersionInfo, managingVersion, downloadedVersionsConfig, @@ -26,6 +30,7 @@ export default function ModDownloadsPopup () { const [tab, setTab] = useState(0) useEffect(() => { + if (!managingVersion) return ;(async () => { const response = await fetch( `https://games.lncvrt.xyz/api/launcher/mods?platform=${platform()}&arch=${arch()}&version=${managingVersion}` @@ -43,7 +48,6 @@ export default function ModDownloadsPopup () { if (!managingVersion) return <> const versionInfo = getVersionInfo(managingVersion) - const gameInfo = getGameInfo(versionInfo?.game) return ( <> @@ -62,14 +66,21 @@ export default function ModDownloadsPopup () { setMods(1) } }} - hidden={typeof mods == 'number' || showModInfo != -1} + hidden={typeof mods == 'number' || showModInfo != null} >

- {versionInfo?.displayName} Mod Manager + {!showModInfo + ? versionInfo?.displayName + ' Mod Manager' + : showModInfo.name + + ' by ' + + showModInfo.creators[0] + + (showModInfo.creators.length > 1 + ? ' + ' + (showModInfo.creators.length - 1) + ' more' + : '')}

- {typeof mods != 'number' && showModInfo == -1 ? ( + {typeof mods != 'number' && !showModInfo ? (
@@ -141,6 +152,89 @@ export default function ModDownloadsPopup () { ) })}
+ ) : ( +
+
+

+ {' '} + Downloads {showModInfo.downloads} +

+

+ Released{' '} + {new Intl.DateTimeFormat(undefined).format( + showModInfo.released * 1000 + )} +

+

+ Updated{' '} + {new Intl.DateTimeFormat(undefined).format( + showModInfo.updated * 1000 + )} +

+

+ Version{' '} + {showModInfo.latestVersion} +

+
+
+ {showModInfo.description ?? '(No description added)'} +
+
+ {Object.keys(downloadedVersionsConfig?.mods ?? []).includes( + String(showModInfo.id) + ) ? ( + + ) : ( + + )} + + +
+
)} diff --git a/src/types/VersionsConfig.ts b/src/types/VersionsConfig.ts index 39bce6d..3d0f644 100644 --- a/src/types/VersionsConfig.ts +++ b/src/types/VersionsConfig.ts @@ -1,14 +1,14 @@ export type VersionsConfigData = { version: string list: Record - mods: Record + mods: Record> } export class VersionsConfig { constructor ( public version: string, public list: Record = {}, - public mods: Record = {} + public mods: Record> = {} ) {} static import (data: VersionsConfigData) {