diff --git a/src/main/kotlin/GameBoard.kt b/src/main/kotlin/GameBoard.kt index 01dec4e..356b613 100644 --- a/src/main/kotlin/GameBoard.kt +++ b/src/main/kotlin/GameBoard.kt @@ -23,16 +23,14 @@ fun GameBoard( onDisableReviewMode: () -> Unit, onPointsChange: (Player, Long) -> Unit, onQuestionDone: (QuestionData, QuestionResolution) -> Unit, + onExit: () -> Unit ) { Column(modifier = Modifier.fillMaxHeight().fillMaxWidth()) { - Row( - modifier = Modifier.fillMaxHeight(0.2f) - ) { - GameHeader( - title = gameData.title, - color = gameData.headerColor - ) - } + GameHeader( + title = gameData.title, + color = gameData.headerColor, + onExit = onExit + ) Spacer(modifier = Modifier.height(5.dp)) Row( modifier = Modifier.fillMaxHeight() diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt index 0e3176d..68f24ec 100644 --- a/src/main/kotlin/Main.kt +++ b/src/main/kotlin/Main.kt @@ -112,8 +112,12 @@ val gameData = Game( @OptIn(ExperimentalSerializationApi::class) val gameJson = Json.encodeToString(gameData) +fun main() { + graphicalApplication() +} + @OptIn(ExperimentalSerializationApi::class) -fun main() = application { +fun graphicalApplication() = application { // TODO: Read Game from JSON println(gameJson) Window( @@ -164,7 +168,8 @@ fun main() = application { }, onQuestionDone = { question, questionResolution -> questionsResolved[question] = questionResolution - } + }, + onExit = ::exitApplication ) } else { EndCard( diff --git a/src/main/kotlin/components/GameHeader.kt b/src/main/kotlin/components/GameHeader.kt index 8dca44e..6bfc4ec 100644 --- a/src/main/kotlin/components/GameHeader.kt +++ b/src/main/kotlin/components/GameHeader.kt @@ -1,8 +1,8 @@ package components -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.* +import androidx.compose.material.Button +import androidx.compose.material.ButtonDefaults import androidx.compose.material.Surface import androidx.compose.material.Text import androidx.compose.runtime.Composable @@ -15,16 +15,32 @@ import data.toColor @Suppress("FunctionName") @Composable -fun GameHeader(title: String, color: ColorData?) { - Surface( - color = color.toColor(), - modifier = Modifier.fillMaxSize(1f) +fun GameHeader(title: String, color: ColorData?, onExit: () -> Unit) { + Row( + modifier = Modifier.fillMaxHeight(0.2f) + .fillMaxWidth() ) { - Column( - verticalArrangement = Arrangement.Center, - horizontalAlignment = Alignment.CenterHorizontally + Surface( + color = color.toColor(), + modifier = Modifier.fillMaxSize(1f) ) { - Text(text = title, color = Color.LightGray, fontSize = 8.em) + Column( + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally, + modifier = Modifier.fillMaxWidth(0.9f) + .fillMaxHeight() + ) { + Text(text = title, color = Color.LightGray, fontSize = 8.em) + } + Column( + verticalArrangement = Arrangement.Top, + horizontalAlignment = Alignment.End, + modifier = Modifier.fillMaxSize() + ) { + Button(onClick = onExit, colors = ButtonDefaults.buttonColors(Color.Red)) { + Text(text = "X", color = Color.LightGray) + } + } } } } diff --git a/src/main/kotlin/components/questiondialog/QuestionDialog.kt b/src/main/kotlin/components/questiondialog/QuestionDialog.kt index ef547d0..220acf6 100644 --- a/src/main/kotlin/components/questiondialog/QuestionDialog.kt +++ b/src/main/kotlin/components/questiondialog/QuestionDialog.kt @@ -30,7 +30,8 @@ fun QuestionDialogue( onDismissRequest = { }, buttons = { QuestionDialogButtons( - topic = topic, + topic = topic.topic, + topicColor = topic.color, questionData = questionData, players = players, onPointsChange = onPointsChange, diff --git a/src/main/kotlin/components/questiondialog/QuestionDialogContent.kt b/src/main/kotlin/components/questiondialog/QuestionDialogContent.kt index bcaac9b..b89d7b1 100644 --- a/src/main/kotlin/components/questiondialog/QuestionDialogContent.kt +++ b/src/main/kotlin/components/questiondialog/QuestionDialogContent.kt @@ -13,15 +13,13 @@ import components.questiondialog.assets.HintText import components.questiondialog.buttons.DismissButton import components.questiondialog.player.DeferredDoubleQuestionDialogPlayer import components.questiondialog.player.QuestionDialogPlayer -import data.Player -import data.QuestionData -import data.Topic -import data.toColor +import data.* @Suppress("FunctionName") @Composable fun QuestionDialogButtons( - topic: Topic, + topic: String, + topicColor: ColorData?, questionData: QuestionData, players: List, onPointsChange: (Player, Long) -> Unit, @@ -34,7 +32,7 @@ fun QuestionDialogButtons( Box( modifier = Modifier.fillMaxHeight().fillMaxWidth() .border( - border = BorderStroke(150.dp, topic.color.toColor()) + border = BorderStroke(150.dp, topicColor.toColor()) ) .padding(150.dp), contentAlignment = Alignment.Center, @@ -45,7 +43,7 @@ fun QuestionDialogButtons( verticalArrangement = Arrangement.SpaceAround ) { HintText( - topicName = topic.topic, + topicName = topic, points = questionData.actualUsagePoints(secondRoundDouble), deferredDouble = questionData.isDeferredDouble, hint = questionData.hint