Katan HUD: compact landscape layout for phone heights

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WrH771kLJmTHnEfcmV2YDx
This commit is contained in:
Claude
2026-10-24 16:58:58 +00:00
parent fae031d2b5
commit ccf8d5a1ba
@@ -101,7 +101,7 @@ fun HudBuildColumn(
onDrag: (Offset) -> Unit, onDrag: (Offset) -> Unit,
onDragEnd: () -> Unit, onDragEnd: () -> Unit,
) { ) {
Column(modifier, verticalArrangement = Arrangement.spacedBy(6.dp), horizontalAlignment = Alignment.CenterHorizontally) { Column(modifier, verticalArrangement = Arrangement.spacedBy(3.dp), horizontalAlignment = Alignment.CenterHorizontally) {
kinds.forEach { kind -> kinds.forEach { kind ->
BuildChip(kind, enabled = kind in canBuild, armed = armed == kind, onTap, onDragStart, onDrag, onDragEnd) BuildChip(kind, enabled = kind in canBuild, armed = armed == kind, onTap, onDragStart, onDrag, onDragEnd)
} }
@@ -127,7 +127,7 @@ private fun BuildChip(
Column(horizontalAlignment = Alignment.CenterHorizontally) { Column(horizontalAlignment = Alignment.CenterHorizontally) {
Box( Box(
modifier = Modifier modifier = Modifier
.size(52.dp) .size(46.dp)
.clip(shape) .clip(shape)
.background( .background(
when { when {
@@ -183,7 +183,7 @@ object CatanHudGlyphs {
} }
} }
/** ✓ over ✗: confirm or cancel a staged placement. Always laid out; enabled only while something is staged. */ /** ✓ beside ✗: confirm or cancel a staged placement. Always laid out; enabled only while something is staged. */
@Composable @Composable
fun HudConfirmButtons( fun HudConfirmButtons(
staged: Boolean, staged: Boolean,
@@ -191,9 +191,9 @@ fun HudConfirmButtons(
onConfirm: () -> Unit, onConfirm: () -> Unit,
onCancel: () -> Unit, onCancel: () -> Unit,
) { ) {
Column(modifier, verticalArrangement = Arrangement.spacedBy(8.dp), horizontalAlignment = Alignment.CenterHorizontally) { Row(modifier, horizontalArrangement = Arrangement.spacedBy(6.dp), verticalAlignment = Alignment.Bottom) {
HudRoundButton("✓", caption = CatanText.CONFIRM_BUILD, enabled = staged, tint = Color(0xFF2E7D32), onClick = onConfirm) HudRoundButton("✓", caption = CatanText.CONFIRM_BUILD, enabled = staged, tint = Color(0xFF2E7D32), diameter = 48.dp, onClick = onConfirm)
HudRoundButton("✕", caption = CatanText.CANCEL_BUILD, enabled = staged, tint = Color(0xFFC62828), onClick = onCancel) HudRoundButton("✕", caption = CatanText.CANCEL_BUILD, enabled = staged, tint = Color(0xFFC62828), diameter = 48.dp, onClick = onCancel)
} }
} }
@@ -309,23 +309,24 @@ fun CatanHud(
onProgress: () -> Unit, onProgress: () -> Unit,
board: @Composable (Modifier) -> Unit, board: @Composable (Modifier) -> Unit,
) { ) {
Column(Modifier.fillMaxSize(), verticalArrangement = Arrangement.spacedBy(4.dp)) { Column(Modifier.fillMaxSize(), verticalArrangement = Arrangement.spacedBy(2.dp)) {
HudPlayerStrip(state, seats, pointsOf, style) HudPlayerStrip(state, seats, pointsOf, style)
Box(Modifier.weight(1f).fillMaxWidth()) { Box(Modifier.weight(1f).fillMaxWidth()) {
ZoomPanBox(Modifier.fillMaxSize().padding(start = 76.dp, end = 76.dp, top = 52.dp, bottom = 96.dp)) { // The island fills the whole area; controls float over its sea margin.
ZoomPanBox(Modifier.fillMaxSize().padding(start = 64.dp, end = 64.dp, top = 30.dp, bottom = 44.dp)) {
board(Modifier.onGloballyPositioned(onBoardCoords)) board(Modifier.onGloballyPositioned(onBoardCoords))
} }
// What is going on, and the dice. Two lines, always. // What is going on, and the dice. Two lines, always.
Row( Row(
Modifier.align(Alignment.TopCenter).fillMaxWidth().padding(horizontal = 8.dp) Modifier.align(Alignment.TopCenter).padding(horizontal = 64.dp)
.clip(RoundedCornerShape(12.dp)) .clip(RoundedCornerShape(10.dp))
.background(MaterialTheme.colorScheme.surface.copy(alpha = 0.78f)) .background(MaterialTheme.colorScheme.surface.copy(alpha = 0.8f))
.padding(horizontal = 10.dp, vertical = 2.dp), .padding(horizontal = 8.dp, vertical = 1.dp),
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp),
) { ) {
androidx.compose.material3.Text( Text(
text = notice ?: prompt, text = notice ?: prompt,
style = MaterialTheme.typography.bodySmall, style = MaterialTheme.typography.bodySmall,
color = if (notice != null) MaterialTheme.colorScheme.error else Color.Unspecified, color = if (notice != null) MaterialTheme.colorScheme.error else Color.Unspecified,
@@ -341,32 +342,39 @@ fun CatanHud(
kinds = actions.buildKinds, kinds = actions.buildKinds,
canBuild = actions.canBuild, canBuild = actions.canBuild,
armed = building, armed = building,
modifier = Modifier.align(Alignment.CenterStart).padding(start = 8.dp, top = 40.dp), modifier = Modifier.align(Alignment.CenterStart).padding(start = 6.dp),
onTap = onArm, onTap = onArm,
onDragStart = onDragStart, onDragStart = onDragStart,
onDrag = onDrag, onDrag = onDrag,
onDragEnd = onDragEnd, onDragEnd = onDragEnd,
) )
// Right, middle: place or cancel the lined-up piece. // Right, middle: the card actions.
HudConfirmButtons( Column(
staged = staged != null, Modifier.align(Alignment.CenterEnd).padding(end = 6.dp),
modifier = Modifier.align(Alignment.CenterEnd).padding(end = 8.dp, top = 40.dp), verticalArrangement = Arrangement.spacedBy(4.dp),
onConfirm = onConfirm, horizontalAlignment = Alignment.CenterHorizontally,
onCancel = onCancelStaged, ) {
) if (actions.ck) {
HudRoundButton("⬆", caption = CatanText.IMPROVE, enabled = actions.canImprove, diameter = 44.dp, onClick = onImprove)
HudRoundButton("🂠", caption = CatanText.CARDS_SHORT, enabled = actions.canPlayProgress, diameter = 44.dp, onClick = onProgress)
} else {
HudRoundButton("+", caption = CatanText.BUY_SHORT, enabled = actions.canBuyCard, diameter = 44.dp, onClick = onBuyCard)
HudRoundButton("🂠", caption = CatanText.CARDS_SHORT, enabled = actions.canPlayCard, diameter = 44.dp, onClick = onPlayCard)
}
}
// Bottom centre: your cards. // Bottom centre: your cards.
Box( Box(
Modifier.align(Alignment.BottomCenter).padding(bottom = 10.dp, start = 120.dp, end = 250.dp) Modifier.align(Alignment.BottomCenter).padding(bottom = 4.dp, start = 80.dp, end = 270.dp)
.clip(RoundedCornerShape(14.dp)) .clip(RoundedCornerShape(12.dp))
.background(MaterialTheme.colorScheme.surface.copy(alpha = 0.85f)) .background(MaterialTheme.colorScheme.surface.copy(alpha = 0.85f))
.horizontalScroll(rememberScrollState()) .horizontalScroll(rememberScrollState())
.padding(8.dp), .padding(6.dp),
) { CatanHand(state, localSeat) } ) { CatanHand(state, localSeat) }
// Bottom left: the log. // Bottom left: the log.
Column(Modifier.align(Alignment.BottomStart).padding(start = 8.dp, bottom = 10.dp)) { Column(Modifier.align(Alignment.BottomStart).padding(start = 6.dp, bottom = 4.dp)) {
if (showLog) { if (showLog) {
Surface( Surface(
modifier = Modifier.padding(bottom = 6.dp), modifier = Modifier.padding(bottom = 6.dp),
@@ -377,28 +385,18 @@ fun CatanHud(
CatanLog(state, Modifier.padding(8.dp).height(150.dp).width(260.dp)) CatanLog(state, Modifier.padding(8.dp).height(150.dp).width(260.dp))
} }
} }
HudRoundButton("☰", caption = CatanText.LOG_BUTTON, diameter = 44.dp, onClick = onToggleLog) HudRoundButton("☰", caption = CatanText.LOG_BUTTON, diameter = 40.dp, onClick = onToggleLog)
} }
// Bottom right: the turn button, trade, and the card actions. // Bottom right: place / cancel a lined-up piece, trade, and the turn button.
Column( Row(
Modifier.align(Alignment.BottomEnd).padding(end = 8.dp, bottom = 10.dp), Modifier.align(Alignment.BottomEnd).padding(end = 6.dp, bottom = 4.dp),
horizontalAlignment = Alignment.End, horizontalArrangement = Arrangement.spacedBy(6.dp),
verticalArrangement = Arrangement.spacedBy(4.dp), verticalAlignment = Alignment.Bottom,
) { ) {
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { HudConfirmButtons(staged = staged != null, onConfirm = onConfirm, onCancel = onCancelStaged)
if (actions.ck) { HudRoundButton("⇄", caption = CatanText.TRADE, enabled = actions.canTrade, diameter = 48.dp, onClick = onTrade)
HudRoundButton("⬆", caption = CatanText.IMPROVE, enabled = actions.canImprove, diameter = 44.dp, onClick = onImprove) PrimaryTurnButton(actions, onRoll, onEndTurn, onEndFreeRoads, onEndSmith, onRepickSetup)
HudRoundButton("🂠", caption = CatanText.CARDS_SHORT, enabled = actions.canPlayProgress, diameter = 44.dp, onClick = onProgress)
} else {
HudRoundButton("+", caption = CatanText.BUY_SHORT, enabled = actions.canBuyCard, diameter = 44.dp, onClick = onBuyCard)
HudRoundButton("🂠", caption = CatanText.CARDS_SHORT, enabled = actions.canPlayCard, diameter = 44.dp, onClick = onPlayCard)
}
}
Row(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.Bottom) {
HudRoundButton("⇄", caption = CatanText.TRADE, enabled = actions.canTrade, diameter = 56.dp, onClick = onTrade)
PrimaryTurnButton(actions, onRoll, onEndTurn, onEndFreeRoads, onEndSmith, onRepickSetup)
}
} }
if (dragKind != null && dragAt == null) HudPill(CatanText.DRAG_HINT, Modifier.align(Alignment.TopCenter)) if (dragKind != null && dragAt == null) HudPill(CatanText.DRAG_HINT, Modifier.align(Alignment.TopCenter))
@@ -428,7 +426,7 @@ private fun PrimaryTurnButton(
private data class Quad(val glyph: String, val caption: String, val enabled: Boolean, val click: () -> Unit) private data class Quad(val glyph: String, val caption: String, val enabled: Boolean, val click: () -> Unit)
/** Everyone's colour, name, points and card count in one row across the top. */ /** Everyone's colour, name, points and card count in one thin row across the top. */
@Composable @Composable
private fun HudPlayerStrip( private fun HudPlayerStrip(
state: org.prolibertate.games.game.catan.CatanState, state: org.prolibertate.games.game.catan.CatanState,
@@ -436,17 +434,25 @@ private fun HudPlayerStrip(
pointsOf: (Int) -> Int, pointsOf: (Int) -> Int,
style: CatanStyle, style: CatanStyle,
) { ) {
Row(Modifier.fillMaxWidth().padding(horizontal = 6.dp), horizontalArrangement = Arrangement.spacedBy(6.dp)) { Row(Modifier.fillMaxWidth().padding(horizontal = 6.dp, vertical = 2.dp), horizontalArrangement = Arrangement.spacedBy(6.dp)) {
(0 until state.playerCount).forEach { seat -> (0 until state.playerCount).forEach { seat ->
CatanPlayerCard( val onTurn = seat == state.turn
state = state, val shape = RoundedCornerShape(10.dp)
seat = seat, Row(
seats = seats, Modifier.weight(1f)
points = pointsOf(seat), .clip(shape)
modifier = Modifier.weight(1f), .background(MaterialTheme.colorScheme.surfaceVariant)
style = style, .border(if (onTurn) 2.dp else 1.dp, if (onTurn) MaterialTheme.colorScheme.primary else Color(0x33000000), shape)
compact = true, .padding(horizontal = 8.dp, vertical = 4.dp),
) verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(6.dp),
) {
Box(
Modifier.size(14.dp).clip(CircleShape).background(style.seats[seat]).border(1.dp, style.pieceOutline, CircleShape),
)
Text(seats.label(seat), fontSize = 12.sp, fontWeight = FontWeight.Bold, maxLines = 1, modifier = Modifier.weight(1f))
Text("${pointsOf(seat)} VP · ${state.resourceCount(seat)}🂠", fontSize = 12.sp, maxLines = 1)
}
} }
} }
} }