Skip to content

[GOG]: don't check for notInstallable during library sync #3711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 30 additions & 31 deletions src/backend/storeManagers/gog/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,7 @@ export async function refresh(): Promise<ExecResult> {
continue
}

const product = await getProductApi(
game.external_id,
[],
credentials.access_token
).catch(() => null)

const unifiedObject = await gogToUnifiedInfo(gdbData, product?.data)
const unifiedObject = await gogToUnifiedInfo(gdbData)
if (unifiedObject.app_name) {
const oldData = library.get(unifiedObject.app_name)
if (oldData) {
Expand Down Expand Up @@ -575,6 +569,28 @@ export async function getInstallInfo(
`stdout = ${!!res.stdout} and res.abort = ${!!res.abort} in getInstallInfo`,
LogPrefix.Gog
)
if (res.stderr.includes("Game doesn't support content system api")) {
return {
game: {
app_name: appName,
title: gameData.title,
launch_options: [],
owned_dlc: [],
version: '',
branches: [],
buildId: ''
},
manifest: {
app_name: appName,
disk_size: 0,
download_size: 0,
languages: [],
versionEtag: '',
dependencies: [],
perLangSize: { '*': { download_size: 0, disk_size: 0 } }
}
}
}
return
}

Expand Down Expand Up @@ -921,29 +937,19 @@ export async function checkForGameUpdate(
* That way it will be easly accessible on frontend
*/
export async function gogToUnifiedInfo(
info: GamesDBData | undefined,
galaxyProductInfo: ProductsEndpointData | undefined
info: GamesDBData | undefined
): Promise<GameInfo> {
if (
!info ||
info.type === 'dlc' ||
!info.game.visible_in_library ||
(galaxyProductInfo &&
!galaxyProductInfo.is_installable &&
galaxyProductInfo.game_type !== 'game')
) {
if (!info || info.type !== 'game' || !info.game.visible_in_library) {
// @ts-expect-error TODO: Handle this somehow
return {}
}

const art_cover =
info.game?.logo?.url_format
?.replace('{formatter}', '')
.replace('{ext}', 'jpg') || `https:${galaxyProductInfo?.images.logo2x}`
const art_cover = info.game?.logo?.url_format
?.replace('{formatter}', '')
.replace('{ext}', 'jpg')

const object: GameInfo = {
runner: 'gog',
store_url: galaxyProductInfo?.links.product_card,
developer: info.game.developers.map((dev) => dev.name).join(', '),
app_name: String(info.external_id),
art_cover,
Expand All @@ -957,22 +963,15 @@ export async function gogToUnifiedInfo(
cloud_save_enabled: false,
extra: {
about: { description: info.summary['*'], shortDescription: '' },
reqs: [],
storeUrl: galaxyProductInfo?.links.product_card
reqs: []
},
folder_name: '',
install: {
is_dlc: false
},
installable:
(galaxyProductInfo?.content_system_compatibility.osx ||
galaxyProductInfo?.content_system_compatibility.windows ||
galaxyProductInfo?.content_system_compatibility.linux) ??
false,
is_installed: false,
namespace: galaxyProductInfo?.slug,
save_folder: '',
title: (galaxyProductInfo?.title ?? info.game.title['en-US'] ?? '').trim(),
title: (info.game.title['en-US'] ?? '').trim(),
canRunOffline: true,
is_mac_native: Boolean(
info.supported_operating_systems.find((os) => os.slug === 'osx')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ const DownloadSizeInfo = ({ gameInfo }: Props) => {
return null
}

if (gameInfo.installable !== undefined && !gameInfo.installable) {
return null
}

const downloadSize =
gameInstallInfo?.manifest?.download_size &&
size(Number(gameInstallInfo?.manifest?.download_size))
Expand Down
16 changes: 13 additions & 3 deletions src/frontend/screens/Game/GamePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export default React.memo(function GamePage(): JSX.Element | null {
const [progress, previousProgress] = hasProgress(appName)

const [extraInfo, setExtraInfo] = useState<ExtraInfo | null>(null)
const [notInstallable, setNotInstallable] = useState<boolean>(false)
const [gameInstallInfo, setGameInstallInfo] = useState<InstallInfo | null>(
null
)
Expand Down Expand Up @@ -142,8 +143,6 @@ export default React.memo(function GamePage(): JSX.Element | null {
const isInstallingWinetricksPackages = status === 'winetricks'
const isInstallingRedist = status === 'redist'
const notAvailable = !gameAvailable && gameInfo.is_installed
const notInstallable =
gameInfo.installable !== undefined && !gameInfo.installable
const notSupportedGame =
gameInfo.runner !== 'sideload' && gameInfo.thirdPartyManagedApp === 'Origin'
const isOffline = connectivity.status !== 'online'
Expand Down Expand Up @@ -172,6 +171,7 @@ export default React.memo(function GamePage(): JSX.Element | null {
if (gameInfo && status) {
const {
install,
is_installed,
is_linux_native = undefined,
is_mac_native = undefined
} = { ...gameInfo }
Expand All @@ -186,6 +186,7 @@ export default React.memo(function GamePage(): JSX.Element | null {

if (
runner !== 'sideload' &&
!is_installed &&
!notSupportedGame &&
!notInstallable &&
!isOffline
Expand All @@ -195,6 +196,13 @@ export default React.memo(function GamePage(): JSX.Element | null {
if (!info) {
throw 'Cannot get game info'
}
if (
info.manifest.disk_size === 0 &&
info.manifest.download_size === 0
) {
setNotInstallable(true)
return
}
setGameInstallInfo(info)
})
.catch((error) => {
Expand Down Expand Up @@ -381,7 +389,9 @@ export default React.memo(function GamePage(): JSX.Element | null {
/>
<Description />
<CloudSavesSync gameInfo={gameInfo} />
<DownloadSizeInfo gameInfo={gameInfo} />
{!notInstallable && (
<DownloadSizeInfo gameInfo={gameInfo} />
)}
<InstalledInfo gameInfo={gameInfo} />
<Scores gameInfo={gameInfo} />
<HLTB />
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/screens/Library/components/GameCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import StoreLogos from 'frontend/components/UI/StoreLogos'
import UninstallModal from 'frontend/components/UI/UninstallModal'
import { getCardStatus, getImageFormatting } from './constants'
import { hasStatus } from 'frontend/hooks/hasStatus'
import fallBackImage from 'frontend/assets/heroic_card.jpg'
import LibraryContext from '../../LibraryContext'

interface Card {
Expand Down Expand Up @@ -416,7 +417,7 @@ const GameCard = ({
<StoreLogos runner={runner} />
{justPlayed ? (
<CachedImage
src={art_cover}
src={art_cover || fallBackImage}
className="justPlayedImg"
alt={title}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,32 @@ export default function DownloadDialog({
selectedBuild,
branch
)

if (
gameInstallInfo?.manifest.disk_size === 0 &&
gameInstallInfo.manifest.download_size === 0
) {
showDialogModal({
showDialog: true,
title: t(
'label.game.not-installable-game',
'Game is NOT Installable'
),
message: t(
'status.gog-goodie',
"This game doesn't appear to be installable. Check downloadable content on https://gog.com/account"
),
buttons: [
{
text: tr('box.ok')
}
],
type: 'MESSAGE'
})
backdropClick()
return
}

setGameInstallInfo(gameInstallInfo)
setGettingInstallInfo(false)

Expand Down
Loading