diff --git a/src/app/main/Installs.css b/src/app/main/Installs.css deleted file mode 100644 index 1ad2404..0000000 --- a/src/app/main/Installs.css +++ /dev/null @@ -1,13 +0,0 @@ -@import "tailwindcss"; - -.downloads-container { - @apply flex justify-center; -} - -.downloads-scroll { - @apply bg-(--col1) border border-(--col3) rounded-lg overflow-y-auto w-full; -} - -.downloads-entry { - @apply flex justify-between items-center m-2 p-2 rounded-lg text-gray-200 text-lg transition-colors bg-(--col2) hover:bg-(--col3) border border-(--col4) hover:border-(--col5) cursor-pointer; -} diff --git a/src/app/main/game/page.tsx b/src/app/main/game/page.tsx index 24a37fc..b9b2124 100644 --- a/src/app/main/game/page.tsx +++ b/src/app/main/game/page.tsx @@ -1,6 +1,5 @@ 'use client' -import '../Installs.css' import { useEffect } from 'react' import { useGlobal } from '@/providers/GlobalProvider' import { useSearchParams } from 'next/navigation' @@ -11,7 +10,7 @@ import { ask } from '@tauri-apps/plugin-dialog' import { BaseDirectory, exists } from '@tauri-apps/plugin-fs' import { WebviewWindow } from '@tauri-apps/api/webviewWindow' -export default function Installs () { +export default function GamePage () { const { versionsList, serverVersionList, @@ -186,211 +185,204 @@ export default function Installs () { -
-
- {category == -1 && - Object.entries(game.categoryNames) - .filter(([key]) => { - const count = Object.keys(versionsList).filter(v => { - const info = serverVersionList?.versions.find( - vf => vf.id == v - ) - if (!info) return false - - if (platform() == 'linux' && info.wine && !linuxUseWine) - return false - - return info.game === id && info.category === Number(key) - }).length - - return count >= 1 - }) - .sort(([a], [b]) => Number(b) - Number(a)) - .map(([key, value]) => { - return ( -
setCategory(Number(key))} - > -
- {developerMode && ( -

- {key} -

- )} -

{value}

- -
e.stopPropagation()} - > -

- {(() => { - const count = - Object.keys(versionsList).filter(v => { - const info = serverVersionList?.versions.find( - vf => vf.id == v - ) - if (!info) return false - if ( - platform() == 'linux' && - info.wine && - !linuxUseWine - ) - return false - return ( - info.game === id && - info.category == Number(key) - ) - }).length ?? 0 - return `${count} install${count === 1 ? '' : 's'}` - })()} -

-
-
-
- ) - })} - {filteredVersions.length === 0 && - (category !== -1 || - Object.keys(versionsList).filter(v => { +
+ {category == -1 && + Object.entries(game.categoryNames) + .filter(([key]) => { + const count = Object.keys(versionsList).filter(v => { const info = serverVersionList?.versions.find(vf => vf.id == v) if (!info) return false if (platform() == 'linux' && info.wine && !linuxUseWine) return false - return info.game === id - }).length === 0) && ( -
-

No versions installed

-
- )} - {filteredVersions - .sort((a, b) => { - const infoA = serverVersionList?.versions.find(vf => vf.id == a) - const infoB = serverVersionList?.versions.find(vf => vf.id == b) - if (!infoA || !infoB) return 0 - return infoB.place - infoA.place - }) - .map(v => { - const versionInfo = serverVersionList?.versions.find( - vf => vf.id == v - ) - if (!versionInfo) return + return info.game === id && info.category === Number(key) + }).length + return count >= 1 + }) + .sort(([a], [b]) => Number(b) - Number(a)) + .map(([key, value]) => { return (
await launchGame(versionInfo)} - onContextMenu={e => { - e.preventDefault() - setManagingVersion(v) - setPopupMode(2) - setShowPopup(true) - setFadeOut(false) - }} + key={key} + className='main-entry' + title='Click to view category.' + onClick={() => setCategory(Number(key))} >
{developerMode && ( -

- {versionInfo.id} +

{key}

+ )} +

{value}

+ +
e.stopPropagation()} + > +

+ {(() => { + const count = + Object.keys(versionsList).filter(v => { + const info = serverVersionList?.versions.find( + vf => vf.id == v + ) + if (!info) return false + if ( + platform() == 'linux' && + info.wine && + !linuxUseWine + ) + return false + return ( + info.game === id && info.category == Number(key) + ) + }).length ?? 0 + return `${count} install${count === 1 ? '' : 's'}` + })()}

- )} -

{versionInfo.displayName}

- -
-
-

- Installed{' '} - {new Intl.DateTimeFormat(undefined).format( - versionsList[v] - )} -

-
- {platform() == 'linux' && - versionInfo.wine && - !needsRevisionUpdate(versionInfo.lastRevision, v) && ( -
- -

Uses wine

-
- )} - {needsRevisionUpdate(versionInfo.lastRevision, v) && ( -
- -

Needs revision update!

-
- )}
- {versionInfo.modSupportDownload && ( - - )}
) })} -
+ {filteredVersions.length === 0 && + (category !== -1 || + Object.keys(versionsList).filter(v => { + const info = serverVersionList?.versions.find(vf => vf.id == v) + if (!info) return false + + if (platform() == 'linux' && info.wine && !linuxUseWine) + return false + + return info.game === id + }).length === 0) && ( +
+

No versions installed

+
+ )} + {filteredVersions + .sort((a, b) => { + const infoA = serverVersionList?.versions.find(vf => vf.id == a) + const infoB = serverVersionList?.versions.find(vf => vf.id == b) + if (!infoA || !infoB) return 0 + return infoB.place - infoA.place + }) + .map(v => { + const versionInfo = serverVersionList?.versions.find( + vf => vf.id == v + ) + if (!versionInfo) return + + return ( +
await launchGame(versionInfo)} + onContextMenu={e => { + e.preventDefault() + setManagingVersion(v) + setPopupMode(2) + setShowPopup(true) + setFadeOut(false) + }} + > +
+ {developerMode && ( +

+ {versionInfo.id} +

+ )} +

{versionInfo.displayName}

+ +
+
+

+ Installed{' '} + {new Intl.DateTimeFormat(undefined).format( + versionsList[v] + )} +

+
+ {platform() == 'linux' && + versionInfo.wine && + !needsRevisionUpdate(versionInfo.lastRevision, v) && ( +
+ +

Uses wine

+
+ )} + {needsRevisionUpdate(versionInfo.lastRevision, v) && ( +
+ +

Needs revision update!

+
+ )} +
+ {versionInfo.modSupportDownload && ( + + )} +
+
+ ) + })}
) diff --git a/src/app/main/games/page.tsx b/src/app/main/games/page.tsx new file mode 100644 index 0000000..555a217 --- /dev/null +++ b/src/app/main/games/page.tsx @@ -0,0 +1,147 @@ +'use client' + +import { useEffect } from 'react' +import { useGlobal } from '@/providers/GlobalProvider' +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import { + faCheck, + faShieldHalved, + faWarning +} from '@fortawesome/free-solid-svg-icons' +import { platform } from '@tauri-apps/plugin-os' +import { useRouter } from 'next/navigation' + +export default function GamesPage () { + const { + versionsList, + serverVersionList, + showPopup, + setShowPopup, + setPopupMode, + setFadeOut, + setSelectedVersionList, + setSelectedGame, + setCategory, + setManagingGame, + developerMode + } = useGlobal() + + const router = useRouter() + + useEffect(() => { + if (!showPopup) return + setSelectedVersionList([]) + }, [setSelectedVersionList, showPopup]) + + const filteredGames = + serverVersionList?.games.filter(g => + serverVersionList.versions + .filter(v => v.game === g.id) + .some(v => Object.keys(versionsList).includes(v.id)) + ) ?? [] + + return ( +
+
+

Games

+ +
+
+ {filteredGames.length == 0 ? ( +
+

No games installed

+
+ ) : ( + filteredGames.map(i => ( +
{ + setCategory(-1) + router.push('/main/game?id=' + i.id) + }} + onContextMenu={e => { + e.preventDefault() + setManagingGame(i.id) + setPopupMode(5) + setShowPopup(true) + setFadeOut(false) + }} + > +
+ {developerMode && ( +

{i.id}

+ )} +

{i.name}

+ +
+
+

+ {(() => { + const gameVersions = ( + serverVersionList?.versions ?? [] + ).filter(v => v.game === i.id) + const installed = gameVersions.filter(v => + Object.keys(versionsList).includes(v.id) + ).length + return gameVersions.length + ? `${installed}/${gameVersions.length}` + : 'N/A' + })()}{' '} + versions installed +

+
+ {i.official ? ( +
+ +

Official

+
+ ) : ( +
+ +

{i.verified ? 'Verified' : 'Unverified'}

+
+ )} +
+
+
+ )) + )} +
+
+ ) +} diff --git a/src/app/main/layout.tsx b/src/app/main/layout.tsx index 1477c79..66c43d7 100644 --- a/src/app/main/layout.tsx +++ b/src/app/main/layout.tsx @@ -354,7 +354,7 @@ export default function RootLayout ({ } const closePopup = useCallback(() => { - if (popupMode == 0 && selectedGame && pathname === '/main') { + if (popupMode == 0 && selectedGame && pathname === '/main/games') { setSelectedGame(null) setSelectedVersionList([]) } else if (viewingInfoFromDownloads) { @@ -938,7 +938,7 @@ export default function RootLayout ({ icon={ (popupMode == 0 && selectedGame && - pathname === '/main') || + pathname === '/main/games') || viewingInfoFromDownloads || (popupMode == 3 && showModInfo) || popupMode == 4 diff --git a/src/app/main/page.tsx b/src/app/main/page.tsx deleted file mode 100644 index ca836b5..0000000 --- a/src/app/main/page.tsx +++ /dev/null @@ -1,150 +0,0 @@ -'use client' - -import './Installs.css' -import { useEffect } from 'react' -import { useGlobal } from '@/providers/GlobalProvider' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { - faCheck, - faShieldHalved, - faWarning -} from '@fortawesome/free-solid-svg-icons' -import { platform } from '@tauri-apps/plugin-os' -import { useRouter } from 'next/navigation' - -export default function Installs () { - const { - versionsList, - serverVersionList, - showPopup, - setShowPopup, - setPopupMode, - setFadeOut, - setSelectedVersionList, - setSelectedGame, - setCategory, - setManagingGame, - developerMode - } = useGlobal() - - const router = useRouter() - - useEffect(() => { - if (!showPopup) return - setSelectedVersionList([]) - }, [setSelectedVersionList, showPopup]) - - const filteredGames = - serverVersionList?.games.filter(g => - serverVersionList.versions - .filter(v => v.game === g.id) - .some(v => Object.keys(versionsList).includes(v.id)) - ) ?? [] - - return ( -
-
-

Games

- -
-
-
- {filteredGames.length == 0 ? ( -
-

No games installed

-
- ) : ( - filteredGames.map(i => ( -
{ - setCategory(-1) - router.push('/main/game?id=' + i.id) - }} - onContextMenu={e => { - e.preventDefault() - setManagingGame(i.id) - setPopupMode(5) - setShowPopup(true) - setFadeOut(false) - }} - > -
- {developerMode && ( -

{i.id}

- )} -

{i.name}

- -
-
-

- {(() => { - const gameVersions = ( - serverVersionList?.versions ?? [] - ).filter(v => v.game === i.id) - const installed = gameVersions.filter(v => - Object.keys(versionsList).includes(v.id) - ).length - return gameVersions.length - ? `${installed}/${gameVersions.length}` - : 'N/A' - })()}{' '} - versions installed -

-
- {i.official ? ( -
- -

Official

-
- ) : ( -
- -

{i.verified ? 'Verified' : 'Unverified'}

-
- )} -
-
-
- )) - )} -
-
-
- ) -} diff --git a/src/app/main/settings/page.tsx b/src/app/main/settings/page.tsx index d383eca..bf5d849 100644 --- a/src/app/main/settings/page.tsx +++ b/src/app/main/settings/page.tsx @@ -13,7 +13,7 @@ import { BaseDirectory, exists, readDir, remove } from '@tauri-apps/plugin-fs' import { openPath } from '@tauri-apps/plugin-opener' import { appLocalDataDir } from '@tauri-apps/api/path' -export default function Settings () { +export default function SettingsPage () { const { settings, versions, diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index dfd5d56..57a00ae 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -9,6 +9,7 @@ import { faDownload, faGamepad, faHexagonNodes, + faHome, faLayerGroup, faUser, faUserShield @@ -100,7 +101,16 @@ export default function Sidebar () { draggable={false} href='/main' className={`link relative flex items-center ${ - pathname === '/main' || pathname.startsWith('/main/game') + pathname === '/main' ? 'active' : '' + }`} + > + Home + +