diff options
Diffstat (limited to 'composeApp/src/commonMain/kotlin/coffee/liz/abstractionengine/ui/ArcadeControls.kt')
| -rw-r--r-- | composeApp/src/commonMain/kotlin/coffee/liz/abstractionengine/ui/ArcadeControls.kt | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/composeApp/src/commonMain/kotlin/coffee/liz/abstractionengine/ui/ArcadeControls.kt b/composeApp/src/commonMain/kotlin/coffee/liz/abstractionengine/ui/ArcadeControls.kt new file mode 100644 index 0000000..f5b4839 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/coffee/liz/abstractionengine/ui/ArcadeControls.kt @@ -0,0 +1,130 @@ +package coffee.liz.abstractionengine.ui + +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.* +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp + +@Composable +fun ArcadeControls( + onDirectionPressed: (Direction) -> Unit, + onActionA: () -> Unit, + onActionB: () -> Unit, + modifier: Modifier = Modifier, + gameContent: @Composable BoxScope.() -> Unit = { + // Default placeholder content + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.spacedBy(16.dp) + ) { + Text( + text = "GAME AREA", + fontSize = 18.sp, + fontWeight = FontWeight.Bold, + fontFamily = FontFamily.Monospace, + color = MaterialTheme.colorScheme.onPrimary + ) + } + } +) { + var lastDirection by remember { mutableStateOf<Direction?>(null) } + var lastAction by remember { mutableStateOf<String?>(null) } + + Box(modifier = modifier.fillMaxSize()) { + // PCB background layer + PCBBackground() + + // Transparent casing overlay + Box( + modifier = Modifier + .fillMaxSize() + .background(Color(0x33000000)) + ) + + // Content + Column( + modifier = Modifier + .fillMaxSize() + .padding(16.dp), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.spacedBy(16.dp) + ) { + // Game area (square) + Box( + modifier = Modifier + .fillMaxWidth(0.95f) + .aspectRatio(1f) + .background( + color = GameBoyColors.ScreenGreen.copy(alpha = 0.85f), + shape = RoundedCornerShape(8.dp) + ) + .border(1.dp, MaterialTheme.colorScheme.outline, RoundedCornerShape(8.dp)) + .padding(8.dp), + contentAlignment = Alignment.Center, + content = gameContent + ) + + // Control panel + Box( + modifier = Modifier + .fillMaxWidth(0.95f) + .background( + color = MaterialTheme.colorScheme.surface.copy(alpha = 0.7f), + shape = RoundedCornerShape(16.dp) + ) + .border(1.dp, MaterialTheme.colorScheme.outline, RoundedCornerShape(16.dp)) + .padding(horizontal = 16.dp, vertical = 16.dp), + contentAlignment = Alignment.Center + ) { + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceEvenly, + verticalAlignment = Alignment.CenterVertically + ) { + // D-Pad on the left + DPad( + onDirectionPressed = { direction -> + lastDirection = direction + lastAction = null + onDirectionPressed(direction) + } + ) + + // Action buttons on the right + Row( + horizontalArrangement = Arrangement.spacedBy(12.dp) + ) { + ArcadeButton( + label = "B", + color = ArcadeButtonColor.YELLOW, + onClick = { + lastAction = "B" + lastDirection = null + onActionB() + } + ) + ArcadeButton( + label = "A", + color = ArcadeButtonColor.RED, + onClick = { + lastAction = "A" + lastDirection = null + onActionA() + } + ) + } + } + } + } + } +} |
