mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
fix(battlenet): use the right artwork for each game (#2092)
* fix(battlenet): use the right artwork for each game World of Warcraft: Forever took retail art and its logo from a loose name lookup, and only fetched its own art when the Store tab was opened. Shop pages also supplied trailer stills and seasonal promos. Each game now has chosen Blizzard key art with the shop page as a fallback, installed games fetch their art without opening the store, and lookups by name must match exactly. Art found by the old lookup is fetched again once. * fix(battlenet): keep cached art if the new art cannot be fetched Classic's variants fetch through the shared title, and a failing chosen image falls back to the shop page.
This commit is contained in:
1 parent
5cf69732ef
commit
f1c1ca59fe
7 files changed
+146
-19
No files matched your search
@@ -66,8 +66,10 @@ object BattleNet {
|
||||
|
||||
private const val COVER_RETRY_MS = 24 * 3600_000L
|
||||
|
||||
internal fun artTitle(title: Title) = TITLES.firstOrNull { it.code == title.code } ?: title
|
||||
|
||||
private fun coverDir(context: Context, title: Title) =
|
||||
File(context.filesDir, "battlenet-art/${(TITLES.firstOrNull { it.code == title.code } ?: title).uid}")
|
||||
File(context.filesDir, "battlenet-art/${artTitle(title).uid}")
|
||||
|
||||
fun cover(context: Context, title: Title): File? = art(context, title).cover
|
||||
|
||||
@@ -79,7 +81,7 @@ object BattleNet {
|
||||
var got = false
|
||||
for (title in titles) {
|
||||
val dir = coverDir(context, title)
|
||||
val tried = File(dir, ".tried")
|
||||
val tried = File(dir, ".tried-2")
|
||||
val wide = File(dir, BLIZZARD)
|
||||
val done = File(dir, "p.jpg").isFile && (title.shop == null || wide.isFile)
|
||||
if (done || System.currentTimeMillis() - tried.lastModified() < COVER_RETRY_MS) continue
|
||||
@@ -87,11 +89,15 @@ object BattleNet {
|
||||
if (title.steam != null && runCatching { art.download(title.steam.toString(), dir) }.getOrDefault(false)) got = true
|
||||
if (title.shop != null && !wide.isFile) {
|
||||
val cover = File(dir, BLIZZARD_COVER).takeUnless { File(dir, "p.jpg").isFile }
|
||||
if (runCatching { com.droiddeck.launcher.stores.battlenet.BlizzardArt.fetch(title.shop, wide, cover) }
|
||||
.onFailure { Log.w(TAG, "Blizzard art for ${title.uid}: ${it.javaClass.simpleName}") }.getOrDefault(false)) got = true
|
||||
if (runCatching { com.droiddeck.launcher.stores.battlenet.BlizzardArt.fetch(title.code, title.shop, wide, cover) }
|
||||
.onFailure { Log.w(TAG, "Blizzard art for ${title.uid}: ${it.javaClass.simpleName}") }.getOrDefault(false)) {
|
||||
got = true
|
||||
File(dir, OLD_BLIZZARD).delete()
|
||||
File(dir, OLD_BLIZZARD_COVER).delete()
|
||||
}
|
||||
}
|
||||
if (!File(dir, "p.jpg").isFile && !File(dir, BLIZZARD_COVER).isFile && key.isNotEmpty()) {
|
||||
val id = runCatching { com.droiddeck.launcher.frontend.SteamGridDb.gameId(key, title.steam, title.name) }.getOrNull()
|
||||
val id = runCatching { com.droiddeck.launcher.frontend.SteamGridDb.exactGameId(key, title.steam, title.name) }.getOrNull()
|
||||
if (id != null && runCatching { com.droiddeck.launcher.frontend.SteamGridDb.download(key, id, dir) }.getOrDefault(false)) got = true
|
||||
}
|
||||
runCatching { tried.writeText("") ; tried.setLastModified(System.currentTimeMillis()) }
|
||||
@@ -111,13 +117,15 @@ object BattleNet {
|
||||
|
||||
class Art(val cover: File?, val header: File?)
|
||||
|
||||
private const val BLIZZARD = "blizzard.jpg"
|
||||
private const val BLIZZARD_COVER = "p-blizzard.jpg"
|
||||
private const val BLIZZARD = "blizzard-2.jpg"
|
||||
private const val BLIZZARD_COVER = "p-blizzard-2.jpg"
|
||||
private const val OLD_BLIZZARD = "blizzard.jpg"
|
||||
private const val OLD_BLIZZARD_COVER = "p-blizzard.jpg"
|
||||
|
||||
fun art(context: Context, title: Title): Art {
|
||||
val dir = coverDir(context, title)
|
||||
fun first(vararg names: String) = names.map { File(dir, it) }.firstOrNull { it.isFile }
|
||||
return Art(first("p.jpg", BLIZZARD_COVER), first(BLIZZARD, "header.jpg"))
|
||||
return Art(first("p.jpg", BLIZZARD_COVER, OLD_BLIZZARD_COVER), first(BLIZZARD, OLD_BLIZZARD, "header.jpg"))
|
||||
}
|
||||
|
||||
fun prefix(context: Context) = File(LinuxRuntime.rootDir(context), "root/.local/share/Steam/steamapps/compatdata/$APP_ID")
|
||||
|
||||
Reference in new issue
Block a user