summaryrefslogtreecommitdiff
path: root/composeApp/src/commonMain/kotlin/coffee/liz/abstractionengine/ui/ArcadeControls.kt
diff options
context:
space:
mode:
authorElizabeth Hunt <me@liz.coffee>2025-10-23 21:59:37 -0700
committerElizabeth Hunt <me@liz.coffee>2025-10-24 20:00:58 -0700
commit64f825465de9fa30c4dfe2707067efdb96110db8 (patch)
tree5241385e316e2f4ceede5018603103d71be75202 /composeApp/src/commonMain/kotlin/coffee/liz/abstractionengine/ui/ArcadeControls.kt
downloadabstraction-engine-kt-64f825465de9fa30c4dfe2707067efdb96110db8.tar.gz
abstraction-engine-kt-64f825465de9fa30c4dfe2707067efdb96110db8.zip
Init
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.kt130
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()
+ }
+ )
+ }
+ }
+ }
+ }
+ }
+}