diff --git a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt index f4a9c0d23..a4ea05c3e 100644 --- a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt @@ -1519,10 +1519,17 @@ class MainActivity : ComponentActivity() { }, "added-games-update").start() } + private val steamArtRefreshes = HashMap() + private fun refreshSteamGameArt(appId: Int) { + val version = (steamArtRefreshes[appId] ?: 0) + 1 + steamArtRefreshes[appId] = version Thread({ val fresh = com.droiddeck.launcher.frontend.Library.steamGames(this).firstOrNull { it.appId == appId } ?: return@Thread - ui.post { steamGames = steamGames.map { if (it.appId == appId && it.library != Library.ADDED) fresh else it } } + ui.post { + if (steamArtRefreshes[appId] != version) return@post + steamGames = steamGames.map { if (it.appId == appId && it.library != Library.ADDED) fresh else it } + } }, "steam-art-update").start() } @@ -1666,6 +1673,7 @@ class MainActivity : ComponentActivity() { else -> "Steam" } else null val scanGeneration = ++libraryScanGeneration + val artRefreshesAtStart = HashMap(steamArtRefreshes) if (shortcutPicker) shortcutLibraryScanning = true Thread({ val emus = Library.emulators(this) { id -> DesktopCatalog.installed(this, id) != null } @@ -1694,7 +1702,11 @@ class MainActivity : ComponentActivity() { } ui.post { if (scanGeneration == libraryScanGeneration) { - steamGames = all + val current = steamGames.filter { it.library != Library.ADDED }.associateBy { it.appId } + steamGames = all.map { g -> + val newer = current[g.appId] + if (newer != null && g.library != Library.ADDED && steamArtRefreshes[g.appId] != artRefreshesAtStart[g.appId]) g.withArt(newer.art, newer.hero, newer.icon) else g + } shortcutLibraryScanning = false handleGameLink(all) } diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGameArt.kt b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGameArt.kt index 846c7b5af..15486c2bd 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGameArt.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGameArt.kt @@ -40,10 +40,10 @@ object AddedGameArt { class Found(val items: List, val status: SteamGridDb.Status) - private val CHOSEN = Regex("""chosen-(\w+)\.(\w+)""") + private val CHOSEN = Regex("""chosen-(p|hero|logo|icon)(?:-\d+)?\.(\w+)""") internal fun chosen(cache: File, slot: Slot): File? = - cache.listFiles { f -> CHOSEN.matchEntire(f.name)?.groupValues?.get(1) == slot.key }?.firstOrNull() + cache.listFiles { f -> CHOSEN.matchEntire(f.name)?.groupValues?.get(1) == slot.key }?.maxWithOrNull(compareBy({ it.lastModified() }, { it.name })) private val IMAGE = listOf("png", "jpg", "jpeg") private val PORTRAIT = listOf("cover", "poster", "grid", "boxart", "capsule", "folder", "library_600x900", "portrait") @@ -147,7 +147,7 @@ object AddedGameArt { fun searchGames(context: Context, term: String): Found = sgdb(context) { SteamGridDb.search(it, term) } fun gameImages(context: Context, id: Int, slot: Slot): Found