Stores: card art that does not fade to white, and real art for store games in Games

GOG's library drew the product's images.background, the store page's
fade-out backdrop, which ends in white on a card. The library now takes
the Galaxy library art from api.gog.com/v2/games (galaxyBackgroundImage,
boxArtImage), cached with the sync; the catalog's product-id filter was
tried and is ignored by the service. Epic cards prefer the DieselGameBox
images, Amazon the second background and never the logo. Cards draw over
a dark surface with a fade into the card at the foot.

On install the store's cover and hero are placed in the game folder as
opaque JPEGs under the names AddedGameArt looks for, so the Games tab and
the client's grid get real art for a store game.
This commit is contained in:
The412Banner committed 2026-10-08 17:32:09 -04:00
1 parent 61a9a48e70
commit 9f5a2f39cd
8 files changed
+110 -10

No files matched your search

@@ -0,0 +1,63 @@
package com.droiddeck.launcher.stores
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Canvas
import android.graphics.Color
import android.util.Log
import java.io.File
import java.net.HttpURLConnection
import java.net.URL
/**
* The store's art, placed in the game's folder under the names AddedGameArt already looks for -
* `cover.jpg` (the portrait capsule), `hero.jpg` and `header.jpg` (the wide art) - so a store game
* shows real art in the Games tab and the session's shortcuts writer copies it into the client's
* grid. Each image is decoded and re-encoded as an opaque JPEG over a dark ground: a store's PNG
* with an alpha fade would otherwise end in white, which is what the washed-out cards were.
*/
object StoreArt {
private const val TAG = "StoreArt"
/** Fetches what the sidecar names; a missing or unreadable image is skipped, never an error. Blocking. */
fun fetchInto(folder: File, sidecar: StoreGameSidecar) {
sidecar.cover?.let { place(it, File(folder, "cover.jpg")) }
val wide = sidecar.hero ?: return
if (place(wide, File(folder, "hero.jpg"))) {
val header = File(folder, "header.jpg")
if (!header.isFile) runCatching { File(folder, "hero.jpg").copyTo(header, overwrite = true) }
}
}
private fun place(url: String, dst: File): Boolean {
if (dst.isFile && dst.length() > 0) return true
val bytes = get(url) ?: return false
val bitmap = runCatching { BitmapFactory.decodeByteArray(bytes, 0, bytes.size) }.getOrNull() ?: return false
val opaque = Bitmap.createBitmap(bitmap.width, bitmap.height, Bitmap.Config.ARGB_8888)
Canvas(opaque).apply { drawColor(Color.rgb(0x12, 0x14, 0x17)); drawBitmap(bitmap, 0f, 0f, null) }
val tmp = File(dst.path + ".tmp")
return try {
tmp.outputStream().use { opaque.compress(Bitmap.CompressFormat.JPEG, 90, it) }
tmp.renameTo(dst)
} catch (e: Exception) {
Log.w(TAG, "${dst.name}: ${e.javaClass.simpleName}")
tmp.delete()
false
} finally {
bitmap.recycle(); opaque.recycle()
}
}
private fun get(url: String): ByteArray? {
var c: HttpURLConnection? = null
return try {
c = (URL(url).openConnection() as HttpURLConnection).apply { connectTimeout = 10_000; readTimeout = 20_000; setRequestProperty("User-Agent", StoreNet.BROWSER_UA) }
if (c.responseCode != 200) null else c.inputStream.use { it.readBytes() }
} catch (e: Exception) {
Log.w(TAG, "${StoreLog.redactUrl(url)}: ${e.javaClass.simpleName}")
null
} finally {
c?.disconnect()
}
}
}
@@ -30,6 +30,8 @@ object StoreInstalls {
val app = context.applicationContext
val withLauncher = StoreLaunch.writeLauncher(folder, sidecar)
withLauncher.copy(addToSteam = sidecar.addToSteam && SessionPrefs.gameStoresAddToSteam(app)).write(folder)
// The art first, so the listing written below already carries it for the client's grid.
StoreArt.fetchInto(folder, sidecar)
register(app)
}
@@ -88,12 +88,15 @@ public final class AmazonApiClient {
if (parentId.isEmpty()) parentId = product.optString("parentId", "");
JSONObject detail = product.optJSONObject("productDetail");
if (detail != null) {
// The opaque images only: the square icon, and for the wide card the second
// background (a plain key art) before the first (often faded) or the crown image.
game.artUrl = detail.optString("iconUrl", "");
JSONObject details = detail.optJSONObject("details");
if (details != null) {
if (game.artUrl.isEmpty()) game.artUrl = details.optString("logoUrl", "");
game.heroUrl = details.optString("backgroundUrl1", "");
if (game.heroUrl.isEmpty()) game.heroUrl = details.optString("backgroundUrl2", "");
if (game.artUrl.isEmpty()) game.artUrl = details.optString("pgCrownImageUrl", "");
game.heroUrl = details.optString("backgroundUrl2", "");
if (game.heroUrl.isEmpty()) game.heroUrl = details.optString("backgroundUrl1", "");
if (game.heroUrl.isEmpty()) game.heroUrl = details.optString("pgCrownImageUrl", "");
game.developer = details.optString("developer", "");
game.publisher = details.optString("publisher", "");
if (productType.isEmpty()) productType = details.optString("productType", "");
@@ -82,9 +82,12 @@ object EpicStoreCatalog {
val img = imgs.optJSONObject(k) ?: continue
val url = img.optString("url", "")
if (url.isBlank()) continue
// The opaque box images first; the logo variants are transparent and never used.
when (img.optString("type", "")) {
"DieselGameBox" -> wide = url
"OfferImageWide", "DieselStoreFrontWide" -> if (wide == null) wide = url
"OfferImageTall", "DieselStoreFrontTall", "DieselGameBoxTall" -> if (tall == null) tall = url
"DieselGameBoxTall" -> tall = url
"OfferImageTall", "DieselStoreFrontTall" -> if (tall == null) tall = url
"Thumbnail" -> if (thumb == null) thumb = url
}
}
@@ -26,7 +26,7 @@ object GogBackend : StoreBackend {
}
override fun signOut(context: Context) {
GogPrefs.get(context).edit().remove("library_cache").remove("library_synced_at").apply()
GogPrefs.get(context).edit().remove("library_cache").remove("library_cache_v2").remove("library_synced_at").apply()
}
override fun syncLibrary(context: Context, force: Boolean) {
@@ -19,7 +19,8 @@ import java.util.concurrent.atomic.AtomicBoolean
*/
object GogLibrary {
private const val TAG = "GogLibrary"
private const val CACHE_KEY = "library_cache"
// v2: the card art moved from the store page's backdrop to the Galaxy library art; an older cache is re-fetched.
private const val CACHE_KEY = "library_cache_v2"
private const val LAST_SYNC_KEY = "library_synced_at"
private const val THROTTLE_MS = 15L * 60L * 1000L
@@ -116,8 +117,21 @@ object GogLibrary {
var title = prod.optJSONObject("title")?.optString("*")
if (title.isNullOrEmpty()) title = prod.optString("title")
if (title.isNullOrEmpty()) return null
// Card art from the v2 game record, the way the Galaxy client draws its library: the dark
// Galaxy background for the wide card and the box art for the tall one. The product's
// `images.background` is the store page's fade-out backdrop (it ends in white on a
// card) and is never used; the logo or icon is the last resort.
val images = prod.optJSONObject("images")
var imageUrl = images?.optString("background", "") ?: ""
var imageUrl = ""
var boxArt = ""
runCatching {
val links = StoreNet.get("https://api.gog.com/v2/games/$id?locale=en-US")?.let { JSONObject(it).optJSONObject("_links") }
if (links != null) {
imageUrl = links.optJSONObject("galaxyBackgroundImage")?.optString("href", "").orEmpty()
boxArt = links.optJSONObject("boxArtImage")?.optString("href", "").orEmpty()
}
}
if (imageUrl.isEmpty()) imageUrl = images?.optString("logo2x", "") ?: ""
if (imageUrl.isEmpty()) imageUrl = images?.optString("icon", "") ?: ""
val desc = prod.optJSONObject("description")?.optString("lead", "") ?: ""
val developer = prod.optJSONObject("developers")?.optString("name", "") ?: prod.optString("developer", "")
@@ -149,11 +163,11 @@ object GogLibrary {
}
if (!hasWindowsBuild && !hasWindowsInstaller) return null
var verticalCover: String? = prefs.getString("vcover_$id", null)
var verticalCover: String? = boxArt.ifEmpty { prefs.getString("vcover_$id", null) }
if (verticalCover.isNullOrEmpty()) {
verticalCover = fetchVerticalCover(id).ifEmpty { StoreNet.sgdbPoster(title) }
if (verticalCover.isNotEmpty()) prefs.edit().putString("vcover_$id", verticalCover).apply()
}
if (!verticalCover.isNullOrEmpty()) prefs.edit().putString("vcover_$id", verticalCover).apply()
return GogGame(id, title, GogStoreCatalog.absolutize(imageUrl), desc, developer, category, generation, verticalCover?.ifEmpty { null })
} catch (_: Exception) {
return null
@@ -438,9 +438,13 @@ private fun GameCard(item: CatalogItem, store: Store, s: FrontEndState, a: Front
@Composable
internal fun CardArt(item: CatalogItem, modifier: Modifier) {
val url = item.imageUrl ?: item.tallImageUrl
Box(modifier.background(artBrush(hueOf(item.title)))) {
val colors = MaterialTheme.colorScheme
// A dark ground under the image, so art with transparency never ends in white, and a quiet
// fade into the card's surface at the foot.
Box(modifier.background(colors.surfaceVariant).then(if (url == null) Modifier.background(artBrush(hueOf(item.title))) else Modifier)) {
if (url != null) AsyncImage(model = url, contentDescription = null, contentScale = ContentScale.Crop, modifier = Modifier.matchParentSize())
else Text(item.title, fontSize = 10.sp, fontWeight = FontWeight.Black, color = Color.White, maxLines = 3, overflow = TextOverflow.Ellipsis, modifier = Modifier.align(Alignment.BottomStart).padding(6.dp))
Spacer(Modifier.matchParentSize().background(androidx.compose.ui.graphics.Brush.verticalGradient(0.6f to Color.Transparent, 1f to colors.surface.copy(alpha = 0.85f))))
}
}