voxels: move hard-coded English strings into resources (#ux-audit)
- Commit
f25d765eba104f78fe9adf243a824512da46a687- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-13 01:47 UTC (23 days ago)
- Parents
76fa5ff
Symptom: block/item names, catalog tabs, armor slot labels, status effect names, boss names, the elytra hint, the Jump/Up/Sneak buttons and the "Player 1a2b" join name were hard-coded English, so they could never be translated; the store listing also claimed 19 languages. Root cause: literals in ui/VoxelCatalog.kt (a 240-entry id -> name map), ui/Hotbar.kt (glide chip, boss name fallback, effect names), ui/InventoryScreen.kt (catalog tabs, armor labels), MainActivity (button labels) and MenuActivity (join-request name); and a stale count in metadata_data/games-voxels.md. Fix: - Block/item names: VoxelCatalog.kt now maps id -> R.string.block_<id> (242 new English strings) with a blockName(id) helper; every former blockNames[..] use goes through it. - New resources for catalog tabs, armor slots (+ "%1$s: empty"), effect names and the effect chip format, boss names (the engine still reports English keys; BossBar maps them), glide chip, Jump/Up/ Sneak/Sneaking, and "Player %1$s" (used for join requests and the online HUD; domain/NetStatus now returns only the id suffix). - The HUD overlays left in Hotbar.kt move to their own files (HealthOverlay, BossBar, GlideIndicator, DebugOverlay, HealthJson) so Hotbar.kt stays well under the ui file-length cap. - 13 of the 21 locale files are empty: they keep falling back to English. Nothing was machine-translated. - Store listing: "19 languages" -> "10 languages (English plus partial translations)" (English + ar, et, fr, it, iw, ja, ru, sv, zh-rCN); the module AGENTS.md says the same. User-visible effect: none in English; the whole game UI can now be translated. Verification: new BlockNamesTest checks every catalog id resolves to a non-blank name resource; existing UI tests still find the English labels.
Diff
games/voxels/AGENTS.md
diff --git a/games/voxels/AGENTS.md b/games/voxels/AGENTS.mdindex 93e6119d88..486d9279f0 100644--- a/games/voxels/AGENTS.md+++ b/games/voxels/AGENTS.md@@ -15,7 +15,7 @@ _Install: ./install games/voxels (dev by default)._ Host: `api.maproj.org` (Cloudflare FIRST_PARTY pins). Server checkout: `../location_share_server` (sibling of this repo root, `C:\Users\Vayun\Documents\code\location_share_server`). Live SSH: `ssh [email protected]`. Env template: `../location_share_server/.env.example` (copy to `.env`, never commit secrets). Full details: root `AGENTS.md` → "Backend server (outside this repo)". ## Overview-**Purpose:** Voxel sandbox on a hand-written Rust + Vulkan engine — infinite procedural worlds (25 biomes, villages), crafting/fishing/trading, saves, optional E2EE multiplayer through an untrusted relay. 19 languages.+**Purpose:** Voxel sandbox on a hand-written Rust + Vulkan engine — infinite procedural worlds (25 biomes, villages), crafting/fishing/trading, saves, optional E2EE multiplayer through an untrusted relay. English plus 9 partially translated locales (13 locale files are empty and fall back to English; never machine-translate). **NOT a standard MA game:** `ui/` is thin Compose chrome (menus, inventory, hotbar, joystick) over `VoxelSurfaceView`; the world, physics and rendering live in Rust behind `platform/VoxelsNative`. Multiplayer sync (`network/VoxelsSync`) reuses the everysync E2EE-relay pattern. **Entry points:** `MainActivity.kt` → `platform/MenuActivity.kt` (`parseJoinLink`-style world invites live here, mirroring everysync) → `ui/VoxelSurfaceView.kt` → `platform/VoxelsNative.kt` → `data/WorldManager.kt`. **Gotchas:**
games/voxels/src/main/java/com/vayunmathur/games/voxels/MainActivity.kt
diff --git a/games/voxels/src/main/java/com/vayunmathur/games/voxels/MainActivity.kt b/games/voxels/src/main/java/com/vayunmathur/games/voxels/MainActivity.ktindex fd14175cd9..5a865f7f57 100644--- a/games/voxels/src/main/java/com/vayunmathur/games/voxels/MainActivity.kt+++ b/games/voxels/src/main/java/com/vayunmathur/games/voxels/MainActivity.kt@@ -504,7 +504,7 @@ class MainActivity : ComponentActivity() { horizontalAlignment = Alignment.CenterHorizontally ) { HoldButton(- label = if (flying) "Up" else "Jump",+ label = stringResource(if (flying) R.string.up else R.string.jump), dimmed = !flying && sneaking, onPress = { if (VoxelsNative.isAvailable) try { VoxelsNative.setJump(true) } catch (_: Exception) {} }, onRelease = { if (VoxelsNative.isAvailable) try { VoxelsNative.setJump(false) } catch (_: Exception) {} },@@ -517,7 +517,7 @@ class MainActivity : ComponentActivity() { ) } else { HoldButton(- label = if (sneaking) "Sneaking" else "Sneak",+ label = stringResource(if (sneaking) R.string.sneaking else R.string.sneak), dimmed = sneaking, onPress = { sneaking = !sneaking
games/voxels/src/main/java/com/vayunmathur/games/voxels/domain/NetStatus.kt
diff --git a/games/voxels/src/main/java/com/vayunmathur/games/voxels/domain/NetStatus.kt b/games/voxels/src/main/java/com/vayunmathur/games/voxels/domain/NetStatus.ktindex 4b072e1fb0..12ba1590be 100644--- a/games/voxels/src/main/java/com/vayunmathur/games/voxels/domain/NetStatus.kt+++ b/games/voxels/src/main/java/com/vayunmathur/games/voxels/domain/NetStatus.kt@@ -39,7 +39,7 @@ data class PeerChanges(val joined: Set<String>, val left: Set<String>) fun peerChanges(before: Set<String>, after: Set<String>): PeerChanges = PeerChanges(joined = after - before, left = before - after) -/** Short display name for a device id, matching the join-request naming ("Player 1a2b"). */-fun playerLabel(deviceId: String): String = "Player " + deviceId.takeLast(PLAYER_SUFFIX)+/** The short id suffix players are known by ("1a2b" in "Player 1a2b"; the word is a UI string). */+fun playerSuffix(deviceId: String): String = deviceId.takeLast(PLAYER_SUFFIX) private const val PLAYER_SUFFIX = 4
games/voxels/src/main/java/com/vayunmathur/games/voxels/platform/MenuActivity.kt
diff --git a/games/voxels/src/main/java/com/vayunmathur/games/voxels/platform/MenuActivity.kt b/games/voxels/src/main/java/com/vayunmathur/games/voxels/platform/MenuActivity.ktindex ebeaaf409f..62e35a0319 100644--- a/games/voxels/src/main/java/com/vayunmathur/games/voxels/platform/MenuActivity.kt+++ b/games/voxels/src/main/java/com/vayunmathur/games/voxels/platform/MenuActivity.kt@@ -31,6 +31,7 @@ import com.vayunmathur.library.ui.DynamicTheme import com.vayunmathur.library.ui.Surface import com.vayunmathur.library.util.AppMessages import com.vayunmathur.library.util.rememberIsOnline+import com.vayunmathur.games.voxels.domain.playerSuffix import com.vayunmathur.games.voxels.network.JoinRequests import com.vayunmathur.games.voxels.network.VoxelsRoles import com.vayunmathur.games.voxels.network.VoxelsSync@@ -147,7 +148,7 @@ class MenuActivity : ComponentActivity() { val ok = withContext(Dispatchers.IO) { runCatching { VoxelsSync.init(ctx)- val myName = "Player " + VoxelsSync.deviceId.takeLast(4)+ val myName = getString(R.string.player_name, playerSuffix(VoxelsSync.deviceId)) VoxelsSync.sendJoinRequest(ownerId, worldId, VoxelsSync.deviceId, myName) }.getOrDefault(false) }
games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/BossBar.kt
diff --git a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/BossBar.kt b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/BossBar.ktnew file mode 100644index 0000000000..0a28b02709--- /dev/null+++ b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/BossBar.kt@@ -0,0 +1,44 @@+package com.vayunmathur.games.voxels.ui++import androidx.compose.foundation.background+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.fillMaxHeight+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.width+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.runtime.Composable+import androidx.compose.runtime.remember+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.unit.dp+import com.vayunmathur.games.voxels.R+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text++// The engine names its bosses in English (engine_part1.rs publish_ui); show the localized name.+private const val ENGINE_WITHER = "The Wither"+private const val ENGINE_DRAGON = "Ender Dragon"++@Composable+fun BossBar(healthJson: String, modifier: Modifier = Modifier) {+ val hj = remember(healthJson) { parseHealth(healthJson) }+ if (hj.boss < 0f) return+ val wither = hj.bossName == ENGINE_WITHER+ val textColor = if (wither) Color(0xFFBDBDBD) else Color(0xFFB388FF)+ val barColor = if (wither) Color(0xFF4A4A55) else Color(0xFF9B30FF)+ val name = when (hj.bossName) {+ ENGINE_WITHER -> R.string.boss_wither+ ENGINE_DRAGON -> R.string.boss_dragon+ else -> R.string.boss_generic+ }+ Column(modifier, horizontalAlignment = Alignment.CenterHorizontally) {+ Text(stringResource(name), color = textColor, style = MaterialTheme.typography.labelMedium)+ Box(Modifier.width(220.dp).height(7.dp).background(Color.Black.copy(0.6f), RoundedCornerShape(3.dp))) {+ Box(Modifier.fillMaxWidth(hj.boss.coerceIn(0f, 1f)).fillMaxHeight().background(barColor, RoundedCornerShape(3.dp)))+ }+ }+}
games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/DebugOverlay.kt
diff --git a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/DebugOverlay.kt b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/DebugOverlay.ktnew file mode 100644index 0000000000..2c2c957234--- /dev/null+++ b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/DebugOverlay.kt@@ -0,0 +1,20 @@+package com.vayunmathur.games.voxels.ui++import androidx.compose.foundation.background+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text++// Raw engine debug readout (fps, position, chunks); only shown when enabled in settings.+@Composable+fun DebugOverlay(debugJson: String, modifier: Modifier = Modifier) {+ Box(modifier = modifier.background(Color.Black.copy(alpha = 0.5f), RoundedCornerShape(6.dp)).padding(6.dp)) {+ Text(text = debugJson, style = MaterialTheme.typography.labelSmall, color = Color(0xFFB2FF59))+ }+}
games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/FurnaceScreen.kt
diff --git a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/FurnaceScreen.kt b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/FurnaceScreen.ktindex a4bceaa0fb..ea73590916 100644--- a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/FurnaceScreen.kt+++ b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/FurnaceScreen.kt@@ -117,7 +117,7 @@ fun FurnaceOverlay(smeltingJson: String, smeltJson: String, isBlast: Boolean, on horizontalArrangement = Arrangement.spacedBy(6.dp) ) { if (icon != null) Image(bitmap = icon, contentDescription = null, modifier = Modifier.size(26.dp), filterQuality = FilterQuality.None)- Text(blockNames[rec.outId] ?: "", color = Color.White.copy(0.95f), fontSize = 12.sp)+ Text(blockName(rec.outId) ?: "", color = Color.White.copy(0.95f), fontSize = 12.sp) } } }@@ -298,8 +298,8 @@ private fun TapSlot(slot: InvSlot, onTap: () -> Unit) { contentAlignment = Alignment.Center ) { if (slot.id != 0) {- if (icon != null) Image(bitmap = icon, contentDescription = blockNames[slot.id], modifier = Modifier.size(28.dp), filterQuality = FilterQuality.None)- else Text(blockNames[slot.id]?.take(2) ?: "", color = Color.White, fontSize = 10.sp)+ if (icon != null) Image(bitmap = icon, contentDescription = blockName(slot.id), modifier = Modifier.size(28.dp), filterQuality = FilterQuality.None)+ else Text(blockName(slot.id)?.take(2) ?: "", color = Color.White, fontSize = 10.sp) if (slot.count > 1 && !isDurabilityItem(slot.id)) { Box(Modifier.align(Alignment.BottomEnd)) { Text("${slot.count}", color = Color.White, fontSize = 10.sp) } }
games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/GlideIndicator.kt
diff --git a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/GlideIndicator.kt b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/GlideIndicator.ktnew file mode 100644index 0000000000..bcc5025459--- /dev/null+++ b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/GlideIndicator.kt@@ -0,0 +1,26 @@+package com.vayunmathur.games.voxels.ui++import androidx.compose.foundation.background+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.runtime.Composable+import androidx.compose.runtime.remember+import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.unit.dp+import com.vayunmathur.games.voxels.R+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text++// Small chip shown while an elytra is equipped: prompts to deploy, or confirms gliding.+@Composable+fun GlideIndicator(healthJson: String, modifier: Modifier = Modifier) {+ val hj = remember(healthJson) { parseHealth(healthJson) }+ if (!hj.elytra) return+ val (label, tint) = if (hj.gliding) R.string.glide_active to Color(0xFF7CE0FF) else R.string.glide_hint to Color.White.copy(0.75f)+ Box(modifier.background(Color.Black.copy(0.45f), RoundedCornerShape(6.dp)).padding(horizontal = 8.dp, vertical = 4.dp)) {+ Text(stringResource(label), color = tint, style = MaterialTheme.typography.labelMedium)+ }+}
games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/HealthJson.kt
diff --git a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/HealthJson.kt b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/HealthJson.ktnew file mode 100644index 0000000000..37b6e2cbe8--- /dev/null+++ b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/HealthJson.kt@@ -0,0 +1,19 @@+package com.vayunmathur.games.voxels.ui++import kotlinx.serialization.Serializable++/** One active status effect from the engine's health JSON. */+@Serializable+data class EffJson(val k: String = "", val amp: Int = 0, val t: Int = 0)++/** The engine's health/HUD JSON (see engine_part1.rs publish_ui). */+@Serializable+data class HealthJson(+ val hp: Float = 20f, val max: Float = 20f, val absorb: Float = 0f, val dead: Boolean = false,+ val estus: Int = 0, val effects: List<EffJson> = emptyList(), val boss: Float = -1f,+ val bossName: String = "", val elytra: Boolean = false, val gliding: Boolean = false,+)++/** Parses [json], falling back to defaults on anything malformed. */+internal fun parseHealth(json: String): HealthJson =+ try { voxelsJson.decodeFromString<HealthJson>(json) } catch (_: Exception) { HealthJson() }
games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/HealthOverlay.kt
diff --git a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/HealthOverlay.kt b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/HealthOverlay.ktnew file mode 100644index 0000000000..fed4da6ef1--- /dev/null+++ b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/HealthOverlay.kt@@ -0,0 +1,67 @@+package com.vayunmathur.games.voxels.ui++import androidx.compose.foundation.background+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.runtime.Composable+import androidx.compose.runtime.remember+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.res.stringResource+import com.vayunmathur.games.voxels.R+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text+import androidx.compose.ui.unit.dp+import androidx.compose.foundation.layout.Box++private val effectNames = mapOf(+ "regen" to R.string.effect_regen, "poison" to R.string.effect_poison, "resist" to R.string.effect_resist,+ "strength" to R.string.effect_strength, "speed" to R.string.effect_speed, "haste" to R.string.effect_haste,+ "absorb" to R.string.effect_absorb, "fireres" to R.string.effect_fireres, "night" to R.string.effect_night,+ "jump" to R.string.effect_jump, "slow" to R.string.effect_slow,+)+private val effectColors = mapOf(+ "regen" to Color(0xFFE573B5), "poison" to Color(0xFF6DA33A), "resist" to Color(0xFF9E9E9E),+ "strength" to Color(0xFF932423), "speed" to Color(0xFF7CAFC6), "haste" to Color(0xFFD9C043),+ "absorb" to Color(0xFFF2C15A), "fireres" to Color(0xFFE0913A),+ "night" to Color(0xFF3B3BA0), "jump" to Color(0xFF34A02C), "slow" to Color(0xFF5A6472)+)++private fun roman(n: Int) = when (n) { 0 -> ""; 1 -> " II"; 2 -> " III"; 3 -> " IV"; else -> " ${n + 1}" }++@Composable+fun HealthOverlay(healthJson: String, modifier: Modifier = Modifier) {+ val h = remember(healthJson) { parseHealth(healthJson) }+ Column(modifier, horizontalAlignment = Alignment.Start) {+ // Effects (above the hearts).+ if (h.effects.isNotEmpty()) {+ Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) {+ h.effects.forEach { e ->+ val name = effectNames[e.k]?.let { stringResource(it) } ?: e.k+ Box(Modifier.clip(RoundedCornerShape(4.dp)).background((effectColors[e.k] ?: Color.Gray).copy(alpha = 0.85f)).padding(horizontal = 5.dp, vertical = 1.dp)) {+ Text(stringResource(R.string.effect_chip, name + roman(e.amp), e.t), style = MaterialTheme.typography.labelSmall, color = Color.White)+ }+ }+ }+ }+ // Hearts (each = 2 HP); absorption shown as gold hearts appended.+ val totalHearts = (h.max / 2f).toInt().coerceIn(1, 30)+ Row {+ for (i in 0 until totalHearts) {+ val filled = h.hp / 2f - i+ val c = when { filled >= 1f -> Color(0xFFE23A45); filled >= 0.5f -> Color(0xFFEE8891); else -> Color(0xFF3A1516) }+ Text("♥", color = c, style = MaterialTheme.typography.bodyMedium)+ }+ val absHearts = (h.absorb / 2f).toInt().coerceIn(0, 10)+ for (i in 0 until absHearts) { Text("♥", color = Color(0xFFF2C15A), style = MaterialTheme.typography.bodyMedium) }+ }+ if (h.estus > 0) {+ Text(stringResource(R.string.estus, h.estus), color = Color(0xFFFFC957), style = MaterialTheme.typography.labelSmall)+ }+ }+}
games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/Hotbar.kt
diff --git a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/Hotbar.kt b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/Hotbar.ktindex 4b64e385ce..c9ee58d0e3 100644--- a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/Hotbar.kt+++ b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/Hotbar.kt@@ -1,21 +1,17 @@ package com.vayunmathur.games.voxels.ui -import androidx.compose.ui.res.stringResource-import com.vayunmathur.games.voxels.R import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box-import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size-import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.runtime.Composable import androidx.compose.runtime.remember@@ -212,10 +208,10 @@ fun Hotbar( ) { if (slot.id != 0) { if (iconBitmap != null) {- Image(bitmap = iconBitmap, contentDescription = blockNames[slot.id], modifier = Modifier.size(32.dp).clip(RoundedCornerShape(4.dp)), filterQuality = FilterQuality.None)+ Image(bitmap = iconBitmap, contentDescription = blockName(slot.id), modifier = Modifier.size(32.dp).clip(RoundedCornerShape(4.dp)), filterQuality = FilterQuality.None) } else { Box(Modifier.size(28.dp).background(Color(0xFF7A7A7A), RoundedCornerShape(3.dp)), contentAlignment = Alignment.Center) {- Text(text = blockNames[slot.id]?.take(2) ?: "${slot.id}", style = MaterialTheme.typography.labelSmall, color = Color.White)+ Text(text = blockName(slot.id)?.take(2) ?: "${slot.id}", style = MaterialTheme.typography.labelSmall, color = Color.White) } } if (slot.count > 1 && !isDurabilityItem(slot.id)) {@@ -237,93 +233,3 @@ fun Hotbar( ) { Text("…", color = Color.White, style = MaterialTheme.typography.titleLarge) } } }--@Serializable-data class EffJson(val k: String = "", val amp: Int = 0, val t: Int = 0)--@Serializable-data class HealthJson(val hp: Float = 20f, val max: Float = 20f, val absorb: Float = 0f, val dead: Boolean = false, val estus: Int = 0, val effects: List<EffJson> = emptyList(), val boss: Float = -1f, val bossName: String = "", val elytra: Boolean = false, val gliding: Boolean = false)--// Small chip shown while an elytra is equipped: prompts to deploy, or confirms gliding.-@Composable-fun GlideIndicator(healthJson: String, modifier: Modifier = Modifier) {- val hj = remember(healthJson) {- try { voxelsJson.decodeFromString<HealthJson>(healthJson) } catch (_: Exception) { HealthJson() }- }- if (!hj.elytra) return- val (label, tint) = if (hj.gliding) "Gliding" to Color(0xFF7CE0FF) else "Tap ▲ mid-air to glide" to Color.White.copy(0.75f)- Box(modifier.background(Color.Black.copy(0.45f), RoundedCornerShape(6.dp)).padding(horizontal = 8.dp, vertical = 4.dp)) {- Text(label, color = tint, style = MaterialTheme.typography.labelMedium)- }-}--@Composable-fun BossBar(healthJson: String, modifier: Modifier = Modifier) {- val hj = remember(healthJson) {- try { voxelsJson.decodeFromString<HealthJson>(healthJson) } catch (_: Exception) { HealthJson() }- }- if (hj.boss < 0f) return- val wither = hj.bossName == "The Wither"- val textColor = if (wither) Color(0xFFBDBDBD) else Color(0xFFB388FF)- val barColor = if (wither) Color(0xFF4A4A55) else Color(0xFF9B30FF)- Column(modifier, horizontalAlignment = Alignment.CenterHorizontally) {- Text(hj.bossName.ifEmpty { "Boss" }, color = textColor, style = MaterialTheme.typography.labelMedium)- Box(Modifier.width(220.dp).height(7.dp).background(Color.Black.copy(0.6f), RoundedCornerShape(3.dp))) {- Box(Modifier.fillMaxWidth(hj.boss.coerceIn(0f, 1f)).fillMaxHeight().background(barColor, RoundedCornerShape(3.dp)))- }- }-}--private val effectNames = mapOf(- "regen" to "Regen", "poison" to "Poison", "resist" to "Resist", "strength" to "Strength",- "speed" to "Speed", "haste" to "Haste", "absorb" to "Absorption", "fireres" to "Fire Res",- "night" to "Night Vis", "jump" to "Leaping", "slow" to "Slowness"-)-private val effectColors = mapOf(- "regen" to Color(0xFFE573B5), "poison" to Color(0xFF6DA33A), "resist" to Color(0xFF9E9E9E),- "strength" to Color(0xFF932423), "speed" to Color(0xFF7CAFC6), "haste" to Color(0xFFD9C043),- "absorb" to Color(0xFFF2C15A), "fireres" to Color(0xFFE0913A),- "night" to Color(0xFF3B3BA0), "jump" to Color(0xFF34A02C), "slow" to Color(0xFF5A6472)-)--private fun roman(n: Int) = when (n) { 0 -> ""; 1 -> " II"; 2 -> " III"; 3 -> " IV"; else -> " ${n + 1}" }--@Composable-fun HealthOverlay(healthJson: String, modifier: Modifier = Modifier) {- val h = remember(healthJson) {- try { voxelsJson.decodeFromString<HealthJson>(healthJson) } catch (_: Exception) { HealthJson() }- }- Column(modifier, horizontalAlignment = Alignment.Start) {- // Effects (above the hearts).- if (h.effects.isNotEmpty()) {- Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) {- h.effects.forEach { e ->- Box(Modifier.clip(RoundedCornerShape(4.dp)).background((effectColors[e.k] ?: Color.Gray).copy(alpha = 0.85f)).padding(horizontal = 5.dp, vertical = 1.dp)) {- Text("${effectNames[e.k] ?: e.k}${roman(e.amp)} ${e.t}s", style = MaterialTheme.typography.labelSmall, color = Color.White)- }- }- }- }- // Hearts (each = 2 HP); absorption shown as gold hearts appended.- val totalHearts = (h.max / 2f).toInt().coerceIn(1, 30)- Row {- for (i in 0 until totalHearts) {- val filled = h.hp / 2f - i- val c = when { filled >= 1f -> Color(0xFFE23A45); filled >= 0.5f -> Color(0xFFEE8891); else -> Color(0xFF3A1516) }- Text("♥", color = c, style = MaterialTheme.typography.bodyMedium)- }- val absHearts = (h.absorb / 2f).toInt().coerceIn(0, 10)- for (i in 0 until absHearts) { Text("♥", color = Color(0xFFF2C15A), style = MaterialTheme.typography.bodyMedium) }- }- if (h.estus > 0) {- Text(stringResource(R.string.estus, h.estus), color = Color(0xFFFFC957), style = MaterialTheme.typography.labelSmall)- }- }-}--@Composable-fun DebugOverlay(debugJson: String, modifier: Modifier = Modifier) {- Box(modifier = modifier.background(Color.Black.copy(alpha = 0.5f), RoundedCornerShape(6.dp)).padding(6.dp)) {- Text(text = debugJson, style = MaterialTheme.typography.labelSmall, color = Color(0xFFB2FF59))- }-}
games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/InventoryCrafting.kt
diff --git a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/InventoryCrafting.kt b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/InventoryCrafting.ktindex aa7e1add6a..a3d0df6e88 100644--- a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/InventoryCrafting.kt+++ b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/InventoryCrafting.kt@@ -90,7 +90,7 @@ internal fun CraftingTable(recipesJson: String) { ) } Text(- blockNames[rec.outId] ?: "",+ blockName(rec.outId) ?: "", color = Color.White.copy(if (rec.known) 0.95f else 0.4f), fontSize = 12.sp, ) }@@ -122,7 +122,7 @@ internal fun CraftingTable(recipesJson: String) { // A locked recipe says what opens it, so the tree reads as a path rather than a wall. if (r != null && !r.known) { Text(- stringResource(R.string.recipe_requires, blockNames[r.requires] ?: "?"),+ stringResource(R.string.recipe_requires, blockName(r.requires) ?: "?"), color = Color(0xFFD9B36C), fontSize = 12.sp, ) }
games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/InventoryScreen.kt
diff --git a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/InventoryScreen.kt b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/InventoryScreen.ktindex 2afabc8639..1cb0831e62 100644--- a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/InventoryScreen.kt+++ b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/InventoryScreen.kt@@ -137,14 +137,14 @@ fun InventoryOverlay( // 236 dp column, so the tab strip scrolls sideways. Column(Modifier.width(if (narrow) 160.dp else 236.dp).fillMaxHeight(), horizontalAlignment = Alignment.CenterHorizontally) { Row(Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()), horizontalArrangement = Arrangement.spacedBy(4.dp)) {- TabButton("Natural", catTab == 0) { catTab = 0 }- TabButton("Ores", catTab == 1) { catTab = 1 }- TabButton("Ocean", catTab == 3) { catTab = 3 }- TabButton("Items", catTab == 4) { catTab = 4 }- TabButton("Gear", catTab == 6) { catTab = 6 }+ TabButton(stringResource(R.string.catalog_natural), catTab == 0) { catTab = 0 }+ TabButton(stringResource(R.string.catalog_ores), catTab == 1) { catTab = 1 }+ TabButton(stringResource(R.string.catalog_ocean), catTab == 3) { catTab = 3 }+ TabButton(stringResource(R.string.catalog_items), catTab == 4) { catTab = 4 }+ TabButton(stringResource(R.string.catalog_gear), catTab == 6) { catTab = 6 } TabButton(stringResource(R.string.blessings), catTab == 5) { catTab = 5 }- TabButton("Music", catTab == 7) { catTab = 7 }- TabButton("Build", catTab == 2) { catTab = 2 }+ TabButton(stringResource(R.string.catalog_music), catTab == 7) { catTab = 7 }+ TabButton(stringResource(R.string.catalog_build), catTab == 2) { catTab = 2 } } Spacer(Modifier.height(8.dp)) val cat = when (catTab) { 0 -> catalogNatural; 1 -> catalogOres; 3 -> catalogOcean; 4 -> catalogItems; 5 -> catalogBlessings; 6 -> catalogGear; 7 -> catalogMusic; else -> catalogBuilding }@@ -197,7 +197,7 @@ private fun SlotBox(index: Int, slot: InvSlot, bounds: MutableMap<Int, Rect>, sl ) { if (slot.id != 0) { if (icon != null) Image(bitmap = icon, contentDescription = null, modifier = Modifier.size(slotSize * 0.65f), filterQuality = FilterQuality.None)- else Text(blockNames[slot.id]?.take(2) ?: "", color = Color.White, fontSize = 10.sp)+ else Text(blockName(slot.id)?.take(2) ?: "", color = Color.White, fontSize = 10.sp) if (slot.count > 1 && !isDurabilityItem(slot.id)) Box(Modifier.align(Alignment.BottomEnd)) { Text("${slot.count}", color = Color.White, fontSize = 10.sp) } if (isDurabilityItem(slot.id)) DurabilityBar(slot.id, slot.count, Modifier.align(Alignment.BottomCenter).padding(bottom = 2.dp)) }@@ -244,8 +244,8 @@ private fun CatalogGrid(ids: List<Int>, columns: Int, onPick: (Int) -> Unit) { .clickable { onPick(id) }, contentAlignment = Alignment.Center ) {- if (icon != null) Image(bitmap = icon, contentDescription = blockNames[id], modifier = Modifier.size(32.dp), filterQuality = FilterQuality.None)- else Text(blockNames[id]?.take(2) ?: "", color = Color.White, fontSize = 10.sp)+ if (icon != null) Image(bitmap = icon, contentDescription = blockName(id), modifier = Modifier.size(32.dp), filterQuality = FilterQuality.None)+ else Text(blockName(id)?.take(2) ?: "", color = Color.White, fontSize = 10.sp) } } }@@ -255,7 +255,7 @@ private fun CatalogGrid(ids: List<Int>, columns: Int, onPick: (Int) -> Unit) { @Composable private fun OutfitView(armor: List<InvSlot>) {- val labels = listOf("Helmet", "Chestplate", "Leggings", "Boots")+ val labels = listOf(R.string.armor_helmet, R.string.armor_chestplate, R.string.armor_leggings, R.string.armor_boots) Column(Modifier.padding(24.dp), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(12.dp)) { Text(stringResource(R.string.equipped_armor), color = Color.White, fontWeight = FontWeight.SemiBold, fontSize = 16.sp) Text(stringResource(R.string.hold_an_armor_piece_in_hand_to_equip_it), color = Color.White.copy(0.6f), fontSize = 12.sp)@@ -270,7 +270,7 @@ private fun OutfitView(armor: List<InvSlot>) { val icon = if (s.id != 0) rememberBlockIcon(s.id) else null if (icon != null) Image(bitmap = icon, contentDescription = null, modifier = Modifier.size(34.dp), filterQuality = FilterQuality.None) }- Text(if (s.id != 0) (blockNames[s.id] ?: "?") else "${labels[i]}: empty", color = Color.White.copy(if (s.id != 0) 0.95f else 0.5f))+ Text(if (s.id != 0) (blockName(s.id) ?: "?") else stringResource(R.string.armor_slot_empty, stringResource(labels[i])), color = Color.White.copy(if (s.id != 0) 0.95f else 0.5f)) } } }
games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/OnlineHud.kt
diff --git a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/OnlineHud.kt b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/OnlineHud.ktindex d30c1de635..c2b4d3d2f7 100644--- a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/OnlineHud.kt+++ b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/OnlineHud.kt@@ -20,7 +20,7 @@ import com.vayunmathur.games.voxels.R import com.vayunmathur.games.voxels.domain.NetFailure import com.vayunmathur.games.voxels.domain.NetStatus import com.vayunmathur.games.voxels.domain.peerChanges-import com.vayunmathur.games.voxels.domain.playerLabel+import com.vayunmathur.games.voxels.domain.playerSuffix import com.vayunmathur.library.ui.Text import kotlinx.coroutines.delay import org.json.JSONArray@@ -50,8 +50,8 @@ fun OnlineHud(status: NetStatus, peersJson: String, ownerDevice: String, isHost: if (before == null) return@LaunchedEffect val c = peerChanges(before, peers) val now = System.nanoTime()- c.joined.forEachIndexed { i, id -> notices += Notice(now + i, playerLabel(id), joined = true) }- c.left.forEachIndexed { i, id -> notices += Notice(now + 1000 + i, playerLabel(id), joined = false) }+ c.joined.forEachIndexed { i, id -> notices += Notice(now + i, playerSuffix(id), joined = true) }+ c.left.forEachIndexed { i, id -> notices += Notice(now + 1000 + i, playerSuffix(id), joined = false) } } Column(modifier.widthIn(max = 320.dp), horizontalAlignment = Alignment.End, verticalArrangement = Arrangement.spacedBy(4.dp)) { Chip(stringResource(R.string.players_online, peers.size + 1), Color(0x99000000))@@ -66,7 +66,8 @@ fun OnlineHud(status: NetStatus, peersJson: String, ownerDevice: String, isHost: is NetStatus.Failed -> Chip(stringResource(failureText(status.reason)), Color(0xCCB00020)) } for (n in notices) {- Chip(stringResource(if (n.joined) R.string.player_joined else R.string.player_left, n.player), Color(0x99000000))+ val who = stringResource(R.string.player_name, n.player)+ Chip(stringResource(if (n.joined) R.string.player_joined else R.string.player_left, who), Color(0x99000000)) LaunchedEffect(n.id) { delay(NOTICE_MS) notices.remove(n)
games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/StonecutterScreen.kt
diff --git a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/StonecutterScreen.kt b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/StonecutterScreen.ktindex a1c305584e..fc42b5b382 100644--- a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/StonecutterScreen.kt+++ b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/StonecutterScreen.kt@@ -112,7 +112,7 @@ fun StonecutterOverlay(cutsJson: String, inventoryJson: String, onClose: () -> U horizontalArrangement = Arrangement.spacedBy(6.dp) ) { if (icon != null) Image(bitmap = icon, contentDescription = null, modifier = Modifier.size(26.dp), filterQuality = FilterQuality.None)- Text(blockNames[id] ?: "", color = Color.White.copy(0.95f), fontSize = 12.sp)+ Text(blockName(id) ?: "", color = Color.White.copy(0.95f), fontSize = 12.sp) } } }@@ -136,7 +136,7 @@ fun StonecutterOverlay(cutsJson: String, inventoryJson: String, onClose: () -> U Box(Modifier.size(30.dp), contentAlignment = Alignment.Center) { if (icon != null) Image(bitmap = icon, contentDescription = null, modifier = Modifier.size(28.dp), filterQuality = FilterQuality.None) }- Text(blockNames[c.outId] ?: "", color = Color.White.copy(0.95f), fontSize = 13.sp)+ Text(blockName(c.outId) ?: "", color = Color.White.copy(0.95f), fontSize = 13.sp) Spacer(Modifier.weight(1f)) Text("×${c.outN}", color = Color.White.copy(0.7f), fontSize = 12.sp) }
games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/TradeScreen.kt
diff --git a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/TradeScreen.kt b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/TradeScreen.ktindex ee5fd61f1a..dbbd7a7b3c 100644--- a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/TradeScreen.kt+++ b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/TradeScreen.kt@@ -155,6 +155,6 @@ private fun ItemChip(id: Int, count: Int) { Box(Modifier.size(40.dp).clip(RoundedCornerShape(6.dp)).background(Color.Black.copy(0.4f)), contentAlignment = Alignment.Center) { if (icon != null) Image(bitmap = icon, contentDescription = null, modifier = Modifier.size(28.dp), filterQuality = FilterQuality.None) }- Text("${count}× ${blockNames[id] ?: id}", color = Color.White, fontSize = 12.sp)+ Text("${count}× ${blockName(id) ?: id}", color = Color.White, fontSize = 12.sp) } }
games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/VoxelCatalog.kt
diff --git a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/VoxelCatalog.kt b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/VoxelCatalog.ktindex 9e80eaacc8..46e1ec874e 100644--- a/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/VoxelCatalog.kt+++ b/games/voxels/src/main/java/com/vayunmathur/games/voxels/ui/VoxelCatalog.kt@@ -1,70 +1,83 @@ package com.vayunmathur.games.voxels.ui -val blockNames = mapOf(- 0 to "·", 1 to "Stone", 2 to "Dirt", 3 to "Grass", 4 to "Wood", 5 to "Leaves",- 6 to "Sand", 7 to "Glass", 8 to "Cobble", 9 to "Brick", 10 to "Planks", 11 to "Snow", 12 to "Water", 13 to "Bedrock",- 14 to "Gravel", 15 to "Mossy", 16 to "Diorite", 17 to "Pol. Diorite", 18 to "Coal Ore", 19 to "Iron Ore",- 20 to "Diamond Ore", 21 to "Redstone", 22 to "Emerald Ore", 23 to "Iron", 24 to "Diamond", 25 to "Emerald",- 26 to "Birch Log", 27 to "Birch Plank", 28 to "Birch Leaf", 29 to "Spruce Log", 30 to "Spruce Plank", 31 to "Spruce Leaf",- 32 to "Netherrack", 33 to "Bookshelf", 34 to "Crafting Table", 35 to "Furnace",- 36 to "Red Sand", 37 to "Red Sandstone", 38 to "Sandstone", 39 to "Podzol", 40 to "Coarse Dirt", 41 to "Mycelium",- 42 to "Packed Ice", 43 to "Ice", 44 to "Blue Ice", 45 to "Mud", 46 to "Rooted Dirt",- 47 to "Dark Oak Log", 48 to "Dark Oak Leaf", 49 to "Dark Oak Plank", 50 to "Acacia Log", 51 to "Jungle Log", 52 to "Jungle Plank",- 53 to "Granite Bricks", 54 to "Deepslate Bricks", 55 to "Nether Bricks", 56 to "End Stone Bricks", 57 to "Cobbled Deepslate",- 58 to "Hay Bale", 59 to "Farmland", 60 to "Packed Dirt",- 61 to "Tube Coral", 62 to "Brain Coral", 63 to "Bubble Coral", 64 to "Fire Coral", 65 to "Horn Coral",- 66 to "Kelp", 67 to "Sea Lantern", 68 to "Prismarine", 69 to "Dark Prismarine",- 70 to "Dripstone", 71 to "Moss Block", 72 to "Sculk", 73 to "Amethyst", 74 to "Calcite", 75 to "Tuff",- 76 to "Magma", 77 to "Glowstone", 78 to "Obsidian", 79 to "Clay", 80 to "Azalea Leaves", 81 to "Warding Stone",- // Items (128+): consumables + materials.- 1024 to "Estus Flask", 1025 to "Heart Container", 1026 to "Apple", 1027 to "Bread", 1028 to "Cooked Fish",- 1029 to "Golden Apple", 1030 to "Brownie", 1031 to "Carrot", 1032 to "Melon Slice", 1033 to "Leather", 1034 to "Gunpowder",- 1042 to "Baked Potato", 1043 to "Cookie", 1044 to "Cooked Salmon", 1045 to "Fried Egg", 1046 to "Cooked Rabbit",- 1047 to "Apple Empanada", 1048 to "Glow Berry Crumble", 1049 to "Choc-Chip Cookie",- 1050 to "Iron Ingot", 1051 to "Diamond", 1052 to "Emerald", 1053 to "Coal", 1054 to "Redstone", 1055 to "Stick",- // The Blessing pantheon (attunements, see blessing.rs).- 1056 to "Blessing of Clement", 1057 to "Blessing of Ares", 1058 to "Blessing of Yamm",- 1099 to "Blessing of Daedalus", 1100 to "Blessing of Icarus", 1101 to "Blessing of Yama",- 1102 to "Blessing of Talos", 1103 to "Blessing of the God King", 1104 to "Blessing of Arachnae",- 1105 to "Blessing of Prometheus", 1106 to "Blessing of Lu Ban", 1107 to "Blessing of Eros",- 1108 to "Blessing of Will", 1109 to "Blessing of Hyacinthus", 1110 to "Blessing of Aeolus",- 1111 to "Blessing of Cronus", 1112 to "Blessing of Demeter", 1113 to "Blessing of Glaucus",- 1114 to "Blessing of Apollo", 1115 to "Blessing of Artemis", 1116 to "Blessing of Warding",- 1117 to "Blessing of Paris",- 1141 to "Blessing of Athena", 1142 to "Blessing of Sekhmet", 1143 to "Blessing of Camazotz",- 1144 to "Blessing of Tangaroa", 1145 to "Blessing of Anubis",- // Matcha's kitchen.- 1118 to "Raw Meat", 1119 to "Cooked Meat", 1120 to "Ramen", 1121 to "Japanese Curry",- 1122 to "Green Curry", 1123 to "Gnocchi", 1124 to "Naan", 1125 to "Pupusa", 1126 to "Latke",- 1127 to "Bruschetta", 1128 to "French Toast", 1129 to "Sweet Berry Danish", 1130 to "Melon Sorbet",- 1131 to "Stroganoff",- // Matcha's bronze tier.- 97 to "Copper Ore", 98 to "Gold Ore", 99 to "Copper Block", 100 to "Gold Block", 101 to "Bronze Block",- 1132 to "Copper Ingot", 1133 to "Gold Ingot", 1134 to "Bronze Ingot",- 1135 to "Bronze Pickaxe", 1136 to "Bronze Sword",- 1137 to "Bronze Helmet", 1138 to "Bronze Chestplate", 1139 to "Bronze Leggings", 1140 to "Bronze Boots",- 1059 to "Wood Pickaxe", 1060 to "Wood Sword", 1061 to "Stone Pickaxe", 1062 to "Stone Sword",- 1063 to "Iron Pickaxe", 1064 to "Iron Sword", 1065 to "Diamond Pickaxe", 1066 to "Diamond Sword",- 1067 to "Iron Helmet", 1068 to "Iron Chestplate", 1069 to "Iron Leggings", 1070 to "Iron Boots",- 1071 to "Diamond Helmet", 1072 to "Diamond Chestplate", 1073 to "Diamond Leggings", 1074 to "Diamond Boots",- 82 to "Jukebox", 83 to "Chest", 84 to "Lava", 85 to "End Stone", 88 to "Beacon", 89 to "Purpur",- 1075 to "Disc: Golden", 1076 to "Disc: Lullaby", 1077 to "Disc: Forest", 1078 to "Disc: Deep Mining",- 1079 to "Disc: Winter", 1080 to "Disc: Piano", 1081 to "Disc: Gift",- 1082 to "Flint & Steel", 1083 to "Nether Star", 1084 to "Elytra", 1085 to "Firework Rocket",- 1086 to "Snowball", 1087 to "Ender Pearl",- // Matcha alloy tier.- 90 to "Silver Ore", 91 to "Sulfur Ore", 92 to "Cinnabar Ore",- 93 to "Silver Block", 94 to "Steel Block", 95 to "Adamant Block", 96 to "Blast Furnace",- 1088 to "Sulfur", 1089 to "Silver Ingot", 1090 to "Quicksilver", 1091 to "Steel Ingot", 1092 to "Adamant Ingot",- 1093 to "Adamant Pickaxe", 1094 to "Adamant Sword",- 1095 to "Adamant Helmet", 1096 to "Adamant Chestplate", 1097 to "Adamant Leggings", 1098 to "Adamant Boots",- // Matcha's building set: slabs and stairs, cut on a stonecutter.- 119 to "Wool", 120 to "Suspicious Sand", 1148 to "Shears", 1149 to "Fishing Rod", 1150 to "Raw Fish", 1151 to "Brush",- 121 to "Wheat Crop", 122 to "Carrot Crop", 123 to "Melon Crop", 1146 to "Wheat Seeds", 1147 to "Wheat",- 102 to "Stone Slab", 103 to "Stone Stairs", 104 to "Cobble Slab", 105 to "Cobble Stairs",- 106 to "Plank Slab", 107 to "Plank Stairs", 108 to "Brick Slab", 109 to "Brick Stairs",- 110 to "Sandstone Slab", 111 to "Sandstone Stairs",- 112 to "Deepslate Brick Slab", 113 to "Deepslate Brick Stairs",- 114 to "Nether Brick Slab", 115 to "Nether Brick Stairs",- 116 to "Purpur Slab", 117 to "Purpur Stairs", 118 to "Stonecutter"+import androidx.compose.runtime.Composable+import androidx.compose.ui.res.stringResource+import com.vayunmathur.games.voxels.R++// Block / item id -> its display name resource (values/strings.xml block_<id>), so names can be+// translated. Ids missing here have no name.+internal val blockNameRes: Map<Int, Int> = mapOf(+ 1 to R.string.block_1, 2 to R.string.block_2, 3 to R.string.block_3, 4 to R.string.block_4, 5 to R.string.block_5,+ 6 to R.string.block_6, 7 to R.string.block_7, 8 to R.string.block_8, 9 to R.string.block_9,+ 10 to R.string.block_10, 11 to R.string.block_11, 12 to R.string.block_12, 13 to R.string.block_13,+ 14 to R.string.block_14, 15 to R.string.block_15, 16 to R.string.block_16, 17 to R.string.block_17,+ 18 to R.string.block_18, 19 to R.string.block_19, 20 to R.string.block_20, 21 to R.string.block_21,+ 22 to R.string.block_22, 23 to R.string.block_23, 24 to R.string.block_24, 25 to R.string.block_25,+ 26 to R.string.block_26, 27 to R.string.block_27, 28 to R.string.block_28, 29 to R.string.block_29,+ 30 to R.string.block_30, 31 to R.string.block_31, 32 to R.string.block_32, 33 to R.string.block_33,+ 34 to R.string.block_34, 35 to R.string.block_35, 36 to R.string.block_36, 37 to R.string.block_37,+ 38 to R.string.block_38, 39 to R.string.block_39, 40 to R.string.block_40, 41 to R.string.block_41,+ 42 to R.string.block_42, 43 to R.string.block_43, 44 to R.string.block_44, 45 to R.string.block_45,+ 46 to R.string.block_46, 47 to R.string.block_47, 48 to R.string.block_48, 49 to R.string.block_49,+ 50 to R.string.block_50, 51 to R.string.block_51, 52 to R.string.block_52, 53 to R.string.block_53,+ 54 to R.string.block_54, 55 to R.string.block_55, 56 to R.string.block_56, 57 to R.string.block_57,+ 58 to R.string.block_58, 59 to R.string.block_59, 60 to R.string.block_60, 61 to R.string.block_61,+ 62 to R.string.block_62, 63 to R.string.block_63, 64 to R.string.block_64, 65 to R.string.block_65,+ 66 to R.string.block_66, 67 to R.string.block_67, 68 to R.string.block_68, 69 to R.string.block_69,+ 70 to R.string.block_70, 71 to R.string.block_71, 72 to R.string.block_72, 73 to R.string.block_73,+ 74 to R.string.block_74, 75 to R.string.block_75, 76 to R.string.block_76, 77 to R.string.block_77,+ 78 to R.string.block_78, 79 to R.string.block_79, 80 to R.string.block_80, 81 to R.string.block_81,+ 1024 to R.string.block_1024, 1025 to R.string.block_1025, 1026 to R.string.block_1026,+ 1027 to R.string.block_1027, 1028 to R.string.block_1028, 1029 to R.string.block_1029,+ 1030 to R.string.block_1030, 1031 to R.string.block_1031, 1032 to R.string.block_1032,+ 1033 to R.string.block_1033, 1034 to R.string.block_1034, 1042 to R.string.block_1042,+ 1043 to R.string.block_1043, 1044 to R.string.block_1044, 1045 to R.string.block_1045,+ 1046 to R.string.block_1046, 1047 to R.string.block_1047, 1048 to R.string.block_1048,+ 1049 to R.string.block_1049, 1050 to R.string.block_1050, 1051 to R.string.block_1051,+ 1052 to R.string.block_1052, 1053 to R.string.block_1053, 1054 to R.string.block_1054,+ 1055 to R.string.block_1055, 1056 to R.string.block_1056, 1057 to R.string.block_1057,+ 1058 to R.string.block_1058, 1099 to R.string.block_1099, 1100 to R.string.block_1100,+ 1101 to R.string.block_1101, 1102 to R.string.block_1102, 1103 to R.string.block_1103,+ 1104 to R.string.block_1104, 1105 to R.string.block_1105, 1106 to R.string.block_1106,+ 1107 to R.string.block_1107, 1108 to R.string.block_1108, 1109 to R.string.block_1109,+ 1110 to R.string.block_1110, 1111 to R.string.block_1111, 1112 to R.string.block_1112,+ 1113 to R.string.block_1113, 1114 to R.string.block_1114, 1115 to R.string.block_1115,+ 1116 to R.string.block_1116, 1117 to R.string.block_1117, 1141 to R.string.block_1141,+ 1142 to R.string.block_1142, 1143 to R.string.block_1143, 1144 to R.string.block_1144,+ 1145 to R.string.block_1145, 1118 to R.string.block_1118, 1119 to R.string.block_1119,+ 1120 to R.string.block_1120, 1121 to R.string.block_1121, 1122 to R.string.block_1122,+ 1123 to R.string.block_1123, 1124 to R.string.block_1124, 1125 to R.string.block_1125,+ 1126 to R.string.block_1126, 1127 to R.string.block_1127, 1128 to R.string.block_1128,+ 1129 to R.string.block_1129, 1130 to R.string.block_1130, 1131 to R.string.block_1131, 97 to R.string.block_97,+ 98 to R.string.block_98, 99 to R.string.block_99, 100 to R.string.block_100, 101 to R.string.block_101,+ 1132 to R.string.block_1132, 1133 to R.string.block_1133, 1134 to R.string.block_1134,+ 1135 to R.string.block_1135, 1136 to R.string.block_1136, 1137 to R.string.block_1137,+ 1138 to R.string.block_1138, 1139 to R.string.block_1139, 1140 to R.string.block_1140,+ 1059 to R.string.block_1059, 1060 to R.string.block_1060, 1061 to R.string.block_1061,+ 1062 to R.string.block_1062, 1063 to R.string.block_1063, 1064 to R.string.block_1064,+ 1065 to R.string.block_1065, 1066 to R.string.block_1066, 1067 to R.string.block_1067,+ 1068 to R.string.block_1068, 1069 to R.string.block_1069, 1070 to R.string.block_1070,+ 1071 to R.string.block_1071, 1072 to R.string.block_1072, 1073 to R.string.block_1073,+ 1074 to R.string.block_1074, 82 to R.string.block_82, 83 to R.string.block_83, 84 to R.string.block_84,+ 85 to R.string.block_85, 88 to R.string.block_88, 89 to R.string.block_89, 1075 to R.string.block_1075,+ 1076 to R.string.block_1076, 1077 to R.string.block_1077, 1078 to R.string.block_1078,+ 1079 to R.string.block_1079, 1080 to R.string.block_1080, 1081 to R.string.block_1081,+ 1082 to R.string.block_1082, 1083 to R.string.block_1083, 1084 to R.string.block_1084,+ 1085 to R.string.block_1085, 1086 to R.string.block_1086, 1087 to R.string.block_1087, 90 to R.string.block_90,+ 91 to R.string.block_91, 92 to R.string.block_92, 93 to R.string.block_93, 94 to R.string.block_94,+ 95 to R.string.block_95, 96 to R.string.block_96, 1088 to R.string.block_1088, 1089 to R.string.block_1089,+ 1090 to R.string.block_1090, 1091 to R.string.block_1091, 1092 to R.string.block_1092,+ 1093 to R.string.block_1093, 1094 to R.string.block_1094, 1095 to R.string.block_1095,+ 1096 to R.string.block_1096, 1097 to R.string.block_1097, 1098 to R.string.block_1098, 119 to R.string.block_119,+ 120 to R.string.block_120, 1148 to R.string.block_1148, 1149 to R.string.block_1149, 1150 to R.string.block_1150,+ 1151 to R.string.block_1151, 121 to R.string.block_121, 122 to R.string.block_122, 123 to R.string.block_123,+ 1146 to R.string.block_1146, 1147 to R.string.block_1147, 102 to R.string.block_102, 103 to R.string.block_103,+ 104 to R.string.block_104, 105 to R.string.block_105, 106 to R.string.block_106, 107 to R.string.block_107,+ 108 to R.string.block_108, 109 to R.string.block_109, 110 to R.string.block_110, 111 to R.string.block_111,+ 112 to R.string.block_112, 113 to R.string.block_113, 114 to R.string.block_114, 115 to R.string.block_115,+ 116 to R.string.block_116, 117 to R.string.block_117, 118 to R.string.block_118, )++/** Localized display name of block / item [id], or null when it has none. */+@Composable+internal fun blockName(id: Int): String? = blockNameRes[id]?.let { stringResource(it) }
games/voxels/src/main/res/values/strings.xml
diff --git a/games/voxels/src/main/res/values/strings.xml b/games/voxels/src/main/res/values/strings.xmlindex 12e99ea727..5ccc6e43fe 100644--- a/games/voxels/src/main/res/values/strings.xml+++ b/games/voxels/src/main/res/values/strings.xml@@ -133,4 +133,289 @@ <string name="loading_generating">Generating world…</string> <!-- Loading overlay while terrain meshes are being built. Sentence fragment --> <string name="loading_building">Building terrain…</string>+ <!-- HUD buttons. Verbs / states, keep short -->+ <string name="jump">Jump</string>+ <string name="up">Up</string>+ <string name="sneak">Sneak</string>+ <string name="sneaking">Sneaking</string>+ <!-- Elytra chip: gliding now. Fragment -->+ <string name="glide_active">Gliding</string>+ <!-- Elytra chip: how to start gliding. Instruction -->+ <string name="glide_hint">Tap ▲ mid-air to glide</string>+ <!-- Boss bar names. Nouns -->+ <string name="boss_dragon">Ender Dragon</string>+ <string name="boss_wither">The Wither</string>+ <string name="boss_generic">Boss</string>+ <!-- Status-effect chips: %1$s = effect name (with level), %2$d = seconds left. -->+ <string name="effect_chip">%1$s %2$ds</string>+ <string name="effect_regen">Regen</string>+ <string name="effect_poison">Poison</string>+ <string name="effect_resist">Resist</string>+ <string name="effect_strength">Strength</string>+ <string name="effect_speed">Speed</string>+ <string name="effect_haste">Haste</string>+ <string name="effect_absorb">Absorption</string>+ <string name="effect_fireres">Fire Res</string>+ <string name="effect_night">Night Vis</string>+ <string name="effect_jump">Leaping</string>+ <string name="effect_slow">Slowness</string>+ <!-- Creative catalog tabs. Nouns, keep short -->+ <string name="catalog_natural">Natural</string>+ <string name="catalog_ores">Ores</string>+ <string name="catalog_ocean">Ocean</string>+ <string name="catalog_items">Items</string>+ <string name="catalog_gear">Gear</string>+ <string name="catalog_music">Music</string>+ <string name="catalog_build">Build</string>+ <!-- Outfit tab armor slots; armor_slot_empty: %1$s = slot name. -->+ <string name="armor_helmet">Helmet</string>+ <string name="armor_chestplate">Chestplate</string>+ <string name="armor_leggings">Leggings</string>+ <string name="armor_boots">Boots</string>+ <string name="armor_slot_empty">%1$s: empty</string>+ <!-- A player's display name; %1$s = short device id. -->+ <string name="player_name">Player %1$s</string>+ <!-- Block and item names (catalog, hotbar, crafting, trades). Nouns -->+ <string name="block_1">Stone</string>+ <string name="block_2">Dirt</string>+ <string name="block_3">Grass</string>+ <string name="block_4">Wood</string>+ <string name="block_5">Leaves</string>+ <string name="block_6">Sand</string>+ <string name="block_7">Glass</string>+ <string name="block_8">Cobble</string>+ <string name="block_9">Brick</string>+ <string name="block_10">Planks</string>+ <string name="block_11">Snow</string>+ <string name="block_12">Water</string>+ <string name="block_13">Bedrock</string>+ <string name="block_14">Gravel</string>+ <string name="block_15">Mossy</string>+ <string name="block_16">Diorite</string>+ <string name="block_17">Pol. Diorite</string>+ <string name="block_18">Coal Ore</string>+ <string name="block_19">Iron Ore</string>+ <string name="block_20">Diamond Ore</string>+ <string name="block_21">Redstone</string>+ <string name="block_22">Emerald Ore</string>+ <string name="block_23">Iron</string>+ <string name="block_24">Diamond</string>+ <string name="block_25">Emerald</string>+ <string name="block_26">Birch Log</string>+ <string name="block_27">Birch Plank</string>+ <string name="block_28">Birch Leaf</string>+ <string name="block_29">Spruce Log</string>+ <string name="block_30">Spruce Plank</string>+ <string name="block_31">Spruce Leaf</string>+ <string name="block_32">Netherrack</string>+ <string name="block_33">Bookshelf</string>+ <string name="block_34">Crafting Table</string>+ <string name="block_35">Furnace</string>+ <string name="block_36">Red Sand</string>+ <string name="block_37">Red Sandstone</string>+ <string name="block_38">Sandstone</string>+ <string name="block_39">Podzol</string>+ <string name="block_40">Coarse Dirt</string>+ <string name="block_41">Mycelium</string>+ <string name="block_42">Packed Ice</string>+ <string name="block_43">Ice</string>+ <string name="block_44">Blue Ice</string>+ <string name="block_45">Mud</string>+ <string name="block_46">Rooted Dirt</string>+ <string name="block_47">Dark Oak Log</string>+ <string name="block_48">Dark Oak Leaf</string>+ <string name="block_49">Dark Oak Plank</string>+ <string name="block_50">Acacia Log</string>+ <string name="block_51">Jungle Log</string>+ <string name="block_52">Jungle Plank</string>+ <string name="block_53">Granite Bricks</string>+ <string name="block_54">Deepslate Bricks</string>+ <string name="block_55">Nether Bricks</string>+ <string name="block_56">End Stone Bricks</string>+ <string name="block_57">Cobbled Deepslate</string>+ <string name="block_58">Hay Bale</string>+ <string name="block_59">Farmland</string>+ <string name="block_60">Packed Dirt</string>+ <string name="block_61">Tube Coral</string>+ <string name="block_62">Brain Coral</string>+ <string name="block_63">Bubble Coral</string>+ <string name="block_64">Fire Coral</string>+ <string name="block_65">Horn Coral</string>+ <string name="block_66">Kelp</string>+ <string name="block_67">Sea Lantern</string>+ <string name="block_68">Prismarine</string>+ <string name="block_69">Dark Prismarine</string>+ <string name="block_70">Dripstone</string>+ <string name="block_71">Moss Block</string>+ <string name="block_72">Sculk</string>+ <string name="block_73">Amethyst</string>+ <string name="block_74">Calcite</string>+ <string name="block_75">Tuff</string>+ <string name="block_76">Magma</string>+ <string name="block_77">Glowstone</string>+ <string name="block_78">Obsidian</string>+ <string name="block_79">Clay</string>+ <string name="block_80">Azalea Leaves</string>+ <string name="block_81">Warding Stone</string>+ <string name="block_1024">Estus Flask</string>+ <string name="block_1025">Heart Container</string>+ <string name="block_1026">Apple</string>+ <string name="block_1027">Bread</string>+ <string name="block_1028">Cooked Fish</string>+ <string name="block_1029">Golden Apple</string>+ <string name="block_1030">Brownie</string>+ <string name="block_1031">Carrot</string>+ <string name="block_1032">Melon Slice</string>+ <string name="block_1033">Leather</string>+ <string name="block_1034">Gunpowder</string>+ <string name="block_1042">Baked Potato</string>+ <string name="block_1043">Cookie</string>+ <string name="block_1044">Cooked Salmon</string>+ <string name="block_1045">Fried Egg</string>+ <string name="block_1046">Cooked Rabbit</string>+ <string name="block_1047">Apple Empanada</string>+ <string name="block_1048">Glow Berry Crumble</string>+ <string name="block_1049">Choc-Chip Cookie</string>+ <string name="block_1050">Iron Ingot</string>+ <string name="block_1051">Diamond</string>+ <string name="block_1052">Emerald</string>+ <string name="block_1053">Coal</string>+ <string name="block_1054">Redstone</string>+ <string name="block_1055">Stick</string>+ <string name="block_1056">Blessing of Clement</string>+ <string name="block_1057">Blessing of Ares</string>+ <string name="block_1058">Blessing of Yamm</string>+ <string name="block_1099">Blessing of Daedalus</string>+ <string name="block_1100">Blessing of Icarus</string>+ <string name="block_1101">Blessing of Yama</string>+ <string name="block_1102">Blessing of Talos</string>+ <string name="block_1103">Blessing of the God King</string>+ <string name="block_1104">Blessing of Arachnae</string>+ <string name="block_1105">Blessing of Prometheus</string>+ <string name="block_1106">Blessing of Lu Ban</string>+ <string name="block_1107">Blessing of Eros</string>+ <string name="block_1108">Blessing of Will</string>+ <string name="block_1109">Blessing of Hyacinthus</string>+ <string name="block_1110">Blessing of Aeolus</string>+ <string name="block_1111">Blessing of Cronus</string>+ <string name="block_1112">Blessing of Demeter</string>+ <string name="block_1113">Blessing of Glaucus</string>+ <string name="block_1114">Blessing of Apollo</string>+ <string name="block_1115">Blessing of Artemis</string>+ <string name="block_1116">Blessing of Warding</string>+ <string name="block_1117">Blessing of Paris</string>+ <string name="block_1141">Blessing of Athena</string>+ <string name="block_1142">Blessing of Sekhmet</string>+ <string name="block_1143">Blessing of Camazotz</string>+ <string name="block_1144">Blessing of Tangaroa</string>+ <string name="block_1145">Blessing of Anubis</string>+ <string name="block_1118">Raw Meat</string>+ <string name="block_1119">Cooked Meat</string>+ <string name="block_1120">Ramen</string>+ <string name="block_1121">Japanese Curry</string>+ <string name="block_1122">Green Curry</string>+ <string name="block_1123">Gnocchi</string>+ <string name="block_1124">Naan</string>+ <string name="block_1125">Pupusa</string>+ <string name="block_1126">Latke</string>+ <string name="block_1127">Bruschetta</string>+ <string name="block_1128">French Toast</string>+ <string name="block_1129">Sweet Berry Danish</string>+ <string name="block_1130">Melon Sorbet</string>+ <string name="block_1131">Stroganoff</string>+ <string name="block_97">Copper Ore</string>+ <string name="block_98">Gold Ore</string>+ <string name="block_99">Copper Block</string>+ <string name="block_100">Gold Block</string>+ <string name="block_101">Bronze Block</string>+ <string name="block_1132">Copper Ingot</string>+ <string name="block_1133">Gold Ingot</string>+ <string name="block_1134">Bronze Ingot</string>+ <string name="block_1135">Bronze Pickaxe</string>+ <string name="block_1136">Bronze Sword</string>+ <string name="block_1137">Bronze Helmet</string>+ <string name="block_1138">Bronze Chestplate</string>+ <string name="block_1139">Bronze Leggings</string>+ <string name="block_1140">Bronze Boots</string>+ <string name="block_1059">Wood Pickaxe</string>+ <string name="block_1060">Wood Sword</string>+ <string name="block_1061">Stone Pickaxe</string>+ <string name="block_1062">Stone Sword</string>+ <string name="block_1063">Iron Pickaxe</string>+ <string name="block_1064">Iron Sword</string>+ <string name="block_1065">Diamond Pickaxe</string>+ <string name="block_1066">Diamond Sword</string>+ <string name="block_1067">Iron Helmet</string>+ <string name="block_1068">Iron Chestplate</string>+ <string name="block_1069">Iron Leggings</string>+ <string name="block_1070">Iron Boots</string>+ <string name="block_1071">Diamond Helmet</string>+ <string name="block_1072">Diamond Chestplate</string>+ <string name="block_1073">Diamond Leggings</string>+ <string name="block_1074">Diamond Boots</string>+ <string name="block_82">Jukebox</string>+ <string name="block_83">Chest</string>+ <string name="block_84">Lava</string>+ <string name="block_85">End Stone</string>+ <string name="block_88">Beacon</string>+ <string name="block_89">Purpur</string>+ <string name="block_1075">Disc: Golden</string>+ <string name="block_1076">Disc: Lullaby</string>+ <string name="block_1077">Disc: Forest</string>+ <string name="block_1078">Disc: Deep Mining</string>+ <string name="block_1079">Disc: Winter</string>+ <string name="block_1080">Disc: Piano</string>+ <string name="block_1081">Disc: Gift</string>+ <string name="block_1082">Flint & Steel</string>+ <string name="block_1083">Nether Star</string>+ <string name="block_1084">Elytra</string>+ <string name="block_1085">Firework Rocket</string>+ <string name="block_1086">Snowball</string>+ <string name="block_1087">Ender Pearl</string>+ <string name="block_90">Silver Ore</string>+ <string name="block_91">Sulfur Ore</string>+ <string name="block_92">Cinnabar Ore</string>+ <string name="block_93">Silver Block</string>+ <string name="block_94">Steel Block</string>+ <string name="block_95">Adamant Block</string>+ <string name="block_96">Blast Furnace</string>+ <string name="block_1088">Sulfur</string>+ <string name="block_1089">Silver Ingot</string>+ <string name="block_1090">Quicksilver</string>+ <string name="block_1091">Steel Ingot</string>+ <string name="block_1092">Adamant Ingot</string>+ <string name="block_1093">Adamant Pickaxe</string>+ <string name="block_1094">Adamant Sword</string>+ <string name="block_1095">Adamant Helmet</string>+ <string name="block_1096">Adamant Chestplate</string>+ <string name="block_1097">Adamant Leggings</string>+ <string name="block_1098">Adamant Boots</string>+ <string name="block_119">Wool</string>+ <string name="block_120">Suspicious Sand</string>+ <string name="block_1148">Shears</string>+ <string name="block_1149">Fishing Rod</string>+ <string name="block_1150">Raw Fish</string>+ <string name="block_1151">Brush</string>+ <string name="block_121">Wheat Crop</string>+ <string name="block_122">Carrot Crop</string>+ <string name="block_123">Melon Crop</string>+ <string name="block_1146">Wheat Seeds</string>+ <string name="block_1147">Wheat</string>+ <string name="block_102">Stone Slab</string>+ <string name="block_103">Stone Stairs</string>+ <string name="block_104">Cobble Slab</string>+ <string name="block_105">Cobble Stairs</string>+ <string name="block_106">Plank Slab</string>+ <string name="block_107">Plank Stairs</string>+ <string name="block_108">Brick Slab</string>+ <string name="block_109">Brick Stairs</string>+ <string name="block_110">Sandstone Slab</string>+ <string name="block_111">Sandstone Stairs</string>+ <string name="block_112">Deepslate Brick Slab</string>+ <string name="block_113">Deepslate Brick Stairs</string>+ <string name="block_114">Nether Brick Slab</string>+ <string name="block_115">Nether Brick Stairs</string>+ <string name="block_116">Purpur Slab</string>+ <string name="block_117">Purpur Stairs</string>+ <string name="block_118">Stonecutter</string> </resources>
games/voxels/src/test/java/com/vayunmathur/games/voxels/domain/NetStatusTest.kt
diff --git a/games/voxels/src/test/java/com/vayunmathur/games/voxels/domain/NetStatusTest.kt b/games/voxels/src/test/java/com/vayunmathur/games/voxels/domain/NetStatusTest.ktindex 9150307859..e129b7bb6d 100644--- a/games/voxels/src/test/java/com/vayunmathur/games/voxels/domain/NetStatusTest.kt+++ b/games/voxels/src/test/java/com/vayunmathur/games/voxels/domain/NetStatusTest.kt@@ -18,6 +18,6 @@ class NetStatusTest { } @Test fun `players are labelled by their id suffix`() {- assertEquals("Player 9f3e", playerLabel("0123-4567-9f3e"))+ assertEquals("9f3e", playerSuffix("0123-4567-9f3e")) } }
games/voxels/src/test/java/com/vayunmathur/games/voxels/ui/BlockNamesTest.kt
diff --git a/games/voxels/src/test/java/com/vayunmathur/games/voxels/ui/BlockNamesTest.kt b/games/voxels/src/test/java/com/vayunmathur/games/voxels/ui/BlockNamesTest.ktnew file mode 100644index 0000000000..96e0a90af0--- /dev/null+++ b/games/voxels/src/test/java/com/vayunmathur/games/voxels/ui/BlockNamesTest.kt@@ -0,0 +1,20 @@+package com.vayunmathur.games.voxels.ui++import android.content.Context+import androidx.test.core.app.ApplicationProvider+import org.junit.runner.RunWith+import org.robolectric.RobolectricTestRunner+import kotlin.test.Test+import kotlin.test.assertTrue++@RunWith(RobolectricTestRunner::class)+class BlockNamesTest {+ // Names now come from string resources so they can be translated; every catalog entry needs one.+ @Test fun `every catalog block and item has a translatable name`() {+ val ctx = ApplicationProvider.getApplicationContext<Context>()+ val all = catalogNatural + catalogOres + catalogOcean + catalogItems + catalogBlessings + catalogGear ++ catalogMusic + catalogBuilding+ val missing = all.filter { id -> blockNameRes[id]?.let { ctx.getString(it).isNotBlank() } != true }+ assertTrue(missing.isEmpty(), "no name resource for ids $missing")+ }+}
games/voxels/src/test/java/com/vayunmathur/games/voxels/ui/VoxelLogicTest.kt
diff --git a/games/voxels/src/test/java/com/vayunmathur/games/voxels/ui/VoxelLogicTest.kt b/games/voxels/src/test/java/com/vayunmathur/games/voxels/ui/VoxelLogicTest.ktindex 16a52a70ac..74772db521 100644--- a/games/voxels/src/test/java/com/vayunmathur/games/voxels/ui/VoxelLogicTest.kt+++ b/games/voxels/src/test/java/com/vayunmathur/games/voxels/ui/VoxelLogicTest.kt@@ -43,13 +43,15 @@ class VoxelLogicTest { } @Test fun `catalog names blocks items and blessings`() {- assertEquals("Stone", blockNames[1])- assertEquals("Diamond Ore", blockNames[20])- assertEquals("Apple", blockNames[1026])- assertEquals("Blessing of Athena", blockNames[1141])- assertEquals("Fishing Rod", blockNames[1149])- assertEquals(null, blockNames[99999])- assertTrue(blockNames.values.all { it.isNotBlank() })+ val ctx = androidx.test.core.app.ApplicationProvider.getApplicationContext<android.content.Context>()+ fun name(id: Int) = blockNameRes[id]?.let { ctx.getString(it) }+ assertEquals("Stone", name(1))+ assertEquals("Diamond Ore", name(20))+ assertEquals("Apple", name(1026))+ assertEquals("Blessing of Athena", name(1141))+ assertEquals("Fishing Rod", name(1149))+ assertEquals(null, name(99999))+ assertTrue(blockNameRes.values.all { ctx.getString(it).isNotBlank() }) } @Test fun `roles gate editing`() {
metadata_data/games-voxels.md
diff --git a/metadata_data/games-voxels.md b/metadata_data/games-voxels.mdindex 5f28389a7f..1ef22c7c1e 100644--- a/metadata_data/games-voxels.md+++ b/metadata_data/games-voxels.md@@ -4,7 +4,7 @@ Features: - Infinite procedurally generated world with 25 biomes and villages - Native Rust engine on a hand-written Vulkan backend - Block placement and destruction, crafting, fishing, and villager trading-- World saves, achievements, and 19 languages+- World saves, achievements, and 10 languages (English plus partial translations) - Optional shared online worlds, end-to-end encrypted through an untrusted relay Internet only used for: optional online multiplayer worlds