Modern Apps git

← Modern-Apps.git

alchemist: fix icons not visible

Commit
eb07b8c1bfcb2a4aa2975375d34824e162cc6dd0
Author
Vayun Mathur <[email protected]>
When
2026-05-07 03:57 UTC (7 months ago)
Parents
48e88ee

Diff

games/alchemist/src/main/assets/achievements.json
diff --git a/games/alchemist/src/main/assets/achievements.json b/games/alchemist/src/main/assets/achievements.jsonindex 92fb50a6cf..62deb165b2 100644--- a/games/alchemist/src/main/assets/achievements.json+++ b/games/alchemist/src/main/assets/achievements.json@@ -26,5 +26,10 @@     "name": "Omniscient",     "description": "Discover every single item in the game!",     "targetProgress": 720+  },+  {+    "id": "created_life",+    "name": "It's Alive!",+    "description": "Create Life."   } ]
games/alchemist/src/main/java/com/vayunmathur/games/alchemist/data/Alchemist.kt
diff --git a/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/data/Alchemist.kt b/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/data/Alchemist.ktindex 35a3312278..493e6d045d 100644--- a/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/data/Alchemist.kt+++ b/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/data/Alchemist.kt@@ -20,8 +20,8 @@ object Alchemist {             }         }.groupBy { it.inputs }.map { (inputs, outputs) -> AlchemyRecipe(inputs,             outputs.flatMap { it.outputs }) }-        val nonFinals = recipes.flatMap { it.outputs }.toSet()-        items = jsonItems.map { item -> AlchemyItem(item.id, item.name, item.id !in nonFinals) }+        val hasCombinations = recipes.flatMap { it.inputs }.toSet()+        items = jsonItems.map { item -> AlchemyItem(item.id, item.name, item.id !in hasCombinations) }         println(recipes)         println(items)     }
games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/DynamicAlchemyIcon.kt
diff --git a/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/DynamicAlchemyIcon.kt b/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/DynamicAlchemyIcon.ktindex a9349558be..3563fb3fd7 100644--- a/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/DynamicAlchemyIcon.kt+++ b/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/DynamicAlchemyIcon.kt@@ -3,6 +3,7 @@ package com.vayunmathur.games.alchemist.ui import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier@@ -16,24 +17,34 @@ import com.vayunmathur.games.alchemist.R fun DynamicAlchemyIcon(iconId: Long, modifier: Modifier = Modifier) {     val context = LocalContext.current     -    // 1. Construct the resource name string (e.g., "icon_1")+    // 1. Construct the resource name string (e.g., "icon_001")     val name = "icon_${iconId.toString().padStart(3, '0')}"     -    // 2. Look up the internal Android resource ID (the Int)-    val resId = remember(iconId) { context.resources.getIdentifier(-        name,           // The name of the file-        "drawable",     // The folder/type-        context.packageName // Your app's package-    ) }+    // 2. Look up the internal Android resource ID+    val resId = remember(iconId) { +        val id = context.resources.getIdentifier(+            name,+            "drawable",+            context.packageName+        )+        if (id == 0) {+            // Fallback to explicit package name+            context.resources.getIdentifier(+                name,+                "drawable",+                "com.vayunmathur.games.alchemist"+            )+        } else id+    }      if (resId != 0) {         Image(             painter = painterResource(id = resId),             contentDescription = stringResource(R.string.alchemy_icon_content_description, iconId),-            modifier = modifier+            modifier = modifier.fillMaxSize()         )     } else {         // Fallback if the icon ID doesn't exist-        Box(modifier = modifier.background(Color.Gray))+        Box(modifier = modifier.fillMaxSize())     } }\ No newline at end of file
games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/HomeScreen.kt
diff --git a/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/HomeScreen.kt b/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/HomeScreen.ktindex 5c67aba4f6..16f6939fe2 100644--- a/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/HomeScreen.kt+++ b/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/ui/HomeScreen.kt@@ -208,7 +208,6 @@ fun HomeScreen(backStack: NavBackStack<Route>, ds: DataStoreUtils, achievementsM                                 Modifier                                     .size(64.dp)                                     .clip(RoundedCornerShape(8.dp))-                                    .background(MaterialTheme.colorScheme.surface)                                     .combinedClickable(                                         onLongClick = {                                             contextMenuElementId = item.id
games/alchemist/src/main/java/com/vayunmathur/games/alchemist/util/AlchemistAchievementsManager.kt
diff --git a/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/util/AlchemistAchievementsManager.kt b/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/util/AlchemistAchievementsManager.ktindex fa64214ddd..4854086656 100644--- a/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/util/AlchemistAchievementsManager.kt+++ b/games/alchemist/src/main/java/com/vayunmathur/games/alchemist/util/AlchemistAchievementsManager.kt@@ -31,6 +31,9 @@ class AlchemistAchievementsManager(                 if (discoveredFinal) {                     onAchievementUnlocked("final_item")                 }+                if (itemIds.contains(44L)) {+                    onAchievementUnlocked("created_life")+                }             }         }     }
games/alchemist/src/main/res/raw/keep.xml
diff --git a/games/alchemist/src/main/res/raw/keep.xml b/games/alchemist/src/main/res/raw/keep.xmlnew file mode 100644index 0000000000..c192d03afa--- /dev/null+++ b/games/alchemist/src/main/res/raw/keep.xml@@ -0,0 +1,3 @@+<?xml version="1.0" encoding="utf-8"?>+<resources xmlns:tools="http://schemas.android.com/tools"+    tools:keep="@drawable/icon_*" />