diff --git a/src/components/composables/GameSelectionComposable.ts b/src/components/composables/GameSelectionComposable.ts index c84fac4c5..8b5337175 100644 --- a/src/components/composables/GameSelectionComposable.ts +++ b/src/components/composables/GameSelectionComposable.ts @@ -10,12 +10,14 @@ import ProviderUtils from '../../providers/generic/ProviderUtils'; import R2Error from '../../model/errors/R2Error'; import { getStore } from '../../providers/generic/store/StoreProvider'; import { State } from '../../store'; +import { getInstalledSteamAppIds } from '../../r2mm/manager/SteamLibraryScanner'; export function useGameSelectionComposable() { const store = getStore(); const router = useRouter(); const favourites = ref([]); + const installedAppIds = ref>(new Set()); const selectedGame = ref(null); const selectedPlatform = ref(null); const filterText = ref(''); @@ -26,18 +28,9 @@ export function useGameSelectionComposable() { const isSettingDefaultPlatform = ref(false); const gameList = computed(() => { - return GameManager.gameList.sort((a, b) => { - if (favourites.value.includes(a.settingsIdentifier)) { - if (favourites.value.includes(b.settingsIdentifier)) { - return a.displayName.toLowerCase().localeCompare(b.displayName.toLowerCase()); - } else { - return -1; - } - } else if (favourites.value.includes(b.settingsIdentifier)) { - return 1; - } - return a.displayName.toLowerCase().localeCompare(b.displayName.toLowerCase()); - }); + return GameManager.gameList.sort((a, b) => + a.displayName.toLowerCase().localeCompare(b.displayName.toLowerCase()) + ); }); const matchesSearch = (game: Game): boolean => { @@ -66,10 +59,21 @@ export function useGameSelectionComposable() { .filter((value: Game) => favourites.value.includes(value.settingsIdentifier)); }); + const installedGameList = computed(() => { + return filteredGameList.value + .filter((value: Game) => !hiddenGameList.value.includes(value)) + .filter((value: Game) => value.storePlatformMetadata.some( + p => [Platform.STEAM, Platform.STEAM_DIRECT].includes(p.storePlatform) + && p.storeIdentifier != null + && installedAppIds.value.has(String(p.storeIdentifier)) + )); + }); + const nonFavouriteGameList = computed(() => { return filteredGameList.value .filter((value: Game) => !hiddenGameList.value.includes(value)) - .filter((value: Game) => !favourites.value.includes(value.settingsIdentifier)); + .filter((value: Game) => !favourites.value.includes(value.settingsIdentifier)) + .filter((value: Game) => !installedGameList.value.includes(value)); }); function isFavourited(game: Game): boolean { @@ -145,6 +149,7 @@ export function useGameSelectionComposable() { settings.value = await ManagerSettings.getSingleton(GameManager.defaultGame); const globalSettings = settings.value.getContext().global; favourites.value = globalSettings.favouriteGames || []; + installedAppIds.value = await getInstalledSteamAppIds(); const lastGame = GameManager.findByFolderName(globalSettings.lastSelectedGame); if (lastGame) markAsSelectedGame(lastGame); @@ -190,6 +195,7 @@ export function useGameSelectionComposable() { isSettingDefaultPlatform, hiddenGameList, favouriteGameList, + installedGameList, nonFavouriteGameList, isFavourited, isGameSelected, diff --git a/src/components/game-selection/GameSelectionList.vue b/src/components/game-selection/GameSelectionList.vue index c50da063a..8093fe088 100644 --- a/src/components/game-selection/GameSelectionList.vue +++ b/src/components/game-selection/GameSelectionList.vue @@ -13,6 +13,15 @@ @click="markAsSelectedGame(game)" @toggle-favourite="toggleFavourite(game)" /> + -