Skip to content

Adapt amazon games metadata to new design #3742

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
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
17 changes: 10 additions & 7 deletions src/backend/storeManagers/gog/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -943,10 +943,14 @@ export async function gogToUnifiedInfo(
// @ts-expect-error TODO: Handle this somehow
return {}
}
const background = info.game.background?.url_format
.replace('{formatter}', '')
.replace('{ext}', 'webp')

const art_cover = info.game?.logo?.url_format
?.replace('{formatter}', '')
.replace('{ext}', 'jpg')
const art_cover =
info.game?.logo?.url_format
?.replace('{formatter}', '')
.replace('{ext}', 'jpg') ?? background

const icon = (
info.game?.square_icon.url_format || info.game?.icon?.url_format
Expand All @@ -963,14 +967,13 @@ export async function gogToUnifiedInfo(
info.game.vertical_cover?.url_format
.replace('{formatter}', '')
.replace('{ext}', 'jpg') || art_cover, // fallback to art_cover if undefined
art_background: info.game.background?.url_format
.replace('{formatter}', '')
.replace('{ext}', 'webp'),
art_background: background,
cloud_save_enabled: false,
art_icon: icon,
extra: {
about: { description: info.summary['*'], shortDescription: '' },
reqs: []
reqs: [],
genres: info.game.genres.map((genre) => genre.name['*'])
},
folder_name: '',
install: {
Expand Down
3 changes: 2 additions & 1 deletion src/backend/storeManagers/nile/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ export async function getExtraInfo(appName: string): Promise<ExtraInfo> {
description: info.description,
shortDescription: info.description
}
: undefined
: undefined,
releaseDate: info?.extra?.releaseDate
}
}

Expand Down
19 changes: 17 additions & 2 deletions src/backend/storeManagers/nile/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,15 @@ function loadGamesInAccount() {
const { product } = game
const { title, productDetail } = product
const {
details: { shortDescription, developer },
details: {
shortDescription,
developer,
genres,
releaseDate,
backgroundUrl1,
backgroundUrl2,
logoUrl
},
iconUrl
} = productDetail

Expand All @@ -66,7 +74,9 @@ function loadGamesInAccount() {
const safeFolderName = removeSpecialcharacters(title ?? '')
library.set(product.id, {
app_name: product.id,
art_cover: iconUrl,
art_cover: backgroundUrl2 || iconUrl,
art_logo: logoUrl,
art_background: backgroundUrl1 || backgroundUrl2,
art_square: iconUrl,
canRunOffline: true, // Amazon Games only has offline games
install: info
Expand All @@ -85,6 +95,11 @@ function loadGamesInAccount() {
title: title ?? '???',
description: shortDescription,
developer,
extra: {
reqs: [],
genres,
releaseDate
},
is_linux_native: false,
is_mac_native: false
})
Expand Down
1 change: 1 addition & 0 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export interface ExtraInfo {
releaseDate?: string
storeUrl?: string
changelog?: string
genres?: string[]
}

export type GameConfigVersion = 'auto' | 'v0' | 'v0.1'
Expand Down
26 changes: 19 additions & 7 deletions src/frontend/screens/Game/GamePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ export default React.memo(function GamePage(): JSX.Element | null {

const [progress, previousProgress] = hasProgress(appName)

const [extraInfo, setExtraInfo] = useState<ExtraInfo | null>(null)
const [extraInfo, setExtraInfo] = useState<ExtraInfo | null>(
gameInfo.extra || null
)
const [notInstallable, setNotInstallable] = useState<boolean>(false)
const [gameInstallInfo, setGameInstallInfo] = useState<InstallInfo | null>(
null
Expand Down Expand Up @@ -171,7 +173,6 @@ 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,7 +187,6 @@ export default React.memo(function GamePage(): JSX.Element | null {

if (
runner !== 'sideload' &&
!is_installed &&
!notSupportedGame &&
!notInstallable &&
!isOffline
Expand Down Expand Up @@ -361,7 +361,7 @@ export default React.memo(function GamePage(): JSX.Element | null {
<>
<GamePicture
art_square={art_square}
art_logo={art_logo}
art_logo={runner === 'nile' ? undefined : art_logo}
store={runner}
/>
<NavLink
Expand All @@ -381,7 +381,13 @@ export default React.memo(function GamePage(): JSX.Element | null {
<DotsMenu gameInfo={gameInfo} handleUpdate={handleUpdate} />
</div>
<div className="infoWrapper">
<Genres genres={wikiInfo?.pcgamingwiki?.genres || []} />
<Genres
genres={
gameInfo.extra?.genres ||
wikiInfo?.pcgamingwiki?.genres ||
[]
}
/>
<Developer gameInfo={gameInfo} />
<ReleaseDate
runnerDate={extraInfo?.releaseDate}
Expand Down Expand Up @@ -446,8 +452,14 @@ export default React.memo(function GamePage(): JSX.Element | null {
<div className="store-icon">
<StoreLogos runner={runner} />
</div>
<h1>{title}</h1>
<Genres genres={wikiInfo?.pcgamingwiki?.genres || []} />
<h1 style={{ opacity: art_logo ? 0 : 1 }}>{title}</h1>
<Genres
genres={
gameInfo.extra?.genres ||
wikiInfo?.pcgamingwiki?.genres ||
[]
}
/>
<Developer gameInfo={gameInfo} />
<ReleaseDate
runnerDate={extraInfo?.releaseDate}
Expand Down
4 changes: 3 additions & 1 deletion src/frontend/screens/Game/GamePicture/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
}

.gamePicture > .gameImg {
min-height: 250px;
height: 100%;
width: 100%;
border-radius: 0;
Expand All @@ -35,8 +36,9 @@

.gamePicture > .gameLogo {
position: absolute;
top: 50%;
top: 45%;
left: 50%;
transform: translate(-50%, -50%);
width: 50%;
z-index: 2;
}
2 changes: 1 addition & 1 deletion src/frontend/screens/Library/components/GameCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ const GameCard = ({
alt="cover"
/>
)}
{logo && (
{(justPlayed || runner !== 'nile') && logo && (
<CachedImage
alt="logo"
src={`${logo}?h=400&resize=1&w=300`}
Expand Down
Loading