From 9f5a2f39cdd0840a1696132122e86c119d24d82e Mon Sep 17 00:00:00 2001 From: The412Banner Date: Thu, 8 Oct 2026 17:32:09 -0400 Subject: [PATCH] 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. --- .../com/droiddeck/launcher/stores/StoreArt.kt | 63 +++++++++++++++++++ .../launcher/stores/StoreInstalls.kt | 2 + .../stores/amazon/AmazonApiClient.java | 9 ++- .../launcher/stores/epic/EpicStoreCatalog.kt | 5 +- .../launcher/stores/gog/GogBackend.kt | 2 +- .../launcher/stores/gog/GogLibrary.kt | 22 +++++-- .../com/droiddeck/launcher/ui/StoresPage.kt | 6 +- docs/progress-log.md | 11 ++++ 8 files changed, 110 insertions(+), 10 deletions(-) create mode 100644 app/src/main/java/com/droiddeck/launcher/stores/StoreArt.kt diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreArt.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreArt.kt new file mode 100644 index 000000000..4726c2db7 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreArt.kt @@ -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() + } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreInstalls.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreInstalls.kt index ef405f57e..3d190797b 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreInstalls.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreInstalls.kt @@ -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) } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/amazon/AmazonApiClient.java b/app/src/main/java/com/droiddeck/launcher/stores/amazon/AmazonApiClient.java index ff29a9ab9..bfe7a617d 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/amazon/AmazonApiClient.java +++ b/app/src/main/java/com/droiddeck/launcher/stores/amazon/AmazonApiClient.java @@ -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", ""); diff --git a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicStoreCatalog.kt b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicStoreCatalog.kt index baa91b6b6..371f50c34 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicStoreCatalog.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicStoreCatalog.kt @@ -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 } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogBackend.kt b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogBackend.kt index ff5456839..67300c10a 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogBackend.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogBackend.kt @@ -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) { diff --git a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogLibrary.kt b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogLibrary.kt index 38a0bbe43..04066a7fa 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogLibrary.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogLibrary.kt @@ -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 diff --git a/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt index 006a5e93c..907ca0539 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt @@ -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)))) } } diff --git a/docs/progress-log.md b/docs/progress-log.md index 03aa2b8e3..fa08e3e24 100644 --- a/docs/progress-log.md +++ b/docs/progress-log.md @@ -69,6 +69,17 @@ without it and Setup says "Stores engine not built"). redistributables in the prefix as for any shortcut), Epic's Denuvo ownership token and overlay, Amazon's SDK DLL deployment into the prefix (the prefix does not exist before the first launch), cloud saves, and the stores' social tabs - none of them in the preview. +- **Card art (device feedback on `61a9a48`, GOG › Library washed out to white):** the GOG library + had drawn the product's `images.background` - the store page's fade-out backdrop, white once its + alpha is gone. The library now takes `api.gog.com/v2/games/` `_links.galaxyBackgroundImage` + (the Galaxy client's dark 16:9 library art) and `boxArtImage` (the vertical cover), cached with + the sync (cache key bumped so old caches re-fetch); the catalog's `productId` filter was tried + and ignored by the service, so it is one call per owned game. Epic cards prefer `DieselGameBox` / + `DieselGameBoxTall` over the offer images; Amazon prefers `backgroundUrl2` and never the logo. + Cards draw over a dark surface with a fade into the card at the foot. On install `StoreArt` + places `cover.jpg`, `hero.jpg` and `header.jpg` in the game folder, re-encoded as opaque JPEGs + over a dark ground, under the names `AddedGameArt` looks for - so the Games tab and the client's + grid (through the listing) get real art for store games. - Status: compiles on CI with the JVM and python tests green; nothing device-tested yet - the sign-in pages, a real install, the shortcut landing in the client and the .bat launch under Proton are the first things to prove on hardware.