From 31adc14156c2a9c4357a127809512b89e6fe587e Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Tue, 27 Jan 2026 10:08:41 -0700 Subject: [PATCH] Add subcategory support --- src/app/game/page.tsx | 121 +++++++++++++++++++++++++++++------ src/app/types/Game.ts | 1 + src/app/types/GameVersion.ts | 2 + 3 files changed, 106 insertions(+), 18 deletions(-) diff --git a/src/app/game/page.tsx b/src/app/game/page.tsx index afa54cd..05d3e57 100644 --- a/src/app/game/page.tsx +++ b/src/app/game/page.tsx @@ -22,10 +22,17 @@ export default function Installs () { setManagingVersion, getVersionInfo, getGameInfo, - setSelectedGame + setSelectedGame, + serverVersionList } = useGlobal() const params = useSearchParams() + const [category, setCategory] = useState(-1) + + const id = Number(params.get('id') || 0) + if (!id) return

Invalid game

+ const game = serverVersionList?.games.find(g => g.id === id) + if (!game) return

Invalid game

useEffect(() => { if (!showPopup) return @@ -36,18 +43,30 @@ export default function Installs () {

Installs

- +
+ + +
- {downloadedVersionsConfig && - downloadedVersionsConfig.list.filter(v => { + {category == -1 && + Object.entries(game.subcategoryNames).map(([key, value]) => { + return ( +
{ + if (normalConfig?.settings.useLegacyInteractButtons) return + setCategory(Number(key)) + }} + > +
+

{value}

+ +
e.stopPropagation()} + > +

+ {(() => { + const count = + downloadedVersionsConfig?.list.filter(v => { + const info = getVersionInfo(v) + if (!info) return false + if ( + platform() === 'linux' && + info.wine && + !normalConfig?.settings.useWineOnUnixWhenNeeded + ) + return false + return ( + info.game === id && + info.subcategory == Number(key) + ) + }).length ?? 0 + return `${count} install${count === 1 ? '' : 's'}` + })()} +

+
+ + +
+
+ ) + })} + {downloadedVersionsConfig?.list.filter(v => { const info = getVersionInfo(v) if (!info) return false - return info.game === Number(params.get('id') || 0) + return info.game === id }).length != 0 ? ( - downloadedVersionsConfig.list + downloadedVersionsConfig?.list .sort((a, b) => { const infoA = getVersionInfo(a) const infoB = getVersionInfo(b) @@ -79,7 +159,12 @@ export default function Installs () { !normalConfig?.settings.useWineOnUnixWhenNeeded ) return false - return info.game === Number(params.get('id') || 0) + return ( + info.game === id && + (category == -1 + ? info.subcategory == -1 + : info.subcategory == category) + ) }) .map((entry, i) => (
} diff --git a/src/app/types/GameVersion.ts b/src/app/types/GameVersion.ts index 6f488b5..590294d 100644 --- a/src/app/types/GameVersion.ts +++ b/src/app/types/GameVersion.ts @@ -10,4 +10,6 @@ export interface GameVersion { place: number changelog: string wine: number | undefined + subcategory: number + lastRevision: number }