Answered Questions are marked with color of player
This commit is contained in:
parent
6d5a150ee4
commit
6fb0bf1885
8 changed files with 28 additions and 22 deletions
11
game.json
11
game.json
|
@ -90,7 +90,12 @@
|
|||
],
|
||||
"players": [
|
||||
{
|
||||
"name": "P1"
|
||||
"name": "P1",
|
||||
"color": {
|
||||
"red": 255,
|
||||
"green": 0,
|
||||
"blue": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Playerererer"
|
||||
|
@ -99,6 +104,6 @@
|
|||
"name": "P3"
|
||||
}
|
||||
],
|
||||
"doubleAfter": 2,
|
||||
"endGameAfter": 1
|
||||
"doubleAfter": 4,
|
||||
"endGameAfter": 4
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.em
|
||||
import data.ColorData
|
||||
import data.toColor
|
||||
import data.toColorOrDefault
|
||||
|
||||
@Suppress("FunctionName")
|
||||
@Composable
|
||||
|
@ -21,7 +21,7 @@ fun GameHeader(title: String, color: ColorData?, onExit: () -> Unit) {
|
|||
.fillMaxWidth()
|
||||
) {
|
||||
Surface(
|
||||
color = color.toColor(),
|
||||
color = color.toColorOrDefault(),
|
||||
modifier = Modifier.fillMaxSize(1f)
|
||||
) {
|
||||
Column(
|
||||
|
|
|
@ -11,7 +11,7 @@ import androidx.compose.ui.graphics.Color
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.em
|
||||
import data.Player
|
||||
import data.toColor
|
||||
import data.toColorOrDefault
|
||||
|
||||
@Suppress("FunctionName")
|
||||
@Composable
|
||||
|
@ -21,7 +21,7 @@ fun PlayerCard(
|
|||
points: Long
|
||||
) {
|
||||
Surface(
|
||||
color = player.color.toColor(),
|
||||
color = player.color.toColorOrDefault(),
|
||||
modifier = Modifier.fillMaxHeight(maxHeightFraction)
|
||||
.fillMaxWidth()
|
||||
.padding(5.dp),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package components
|
||||
|
||||
import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.runtime.*
|
||||
|
@ -13,6 +14,7 @@ import components.questiondialog.QuestionDialogue
|
|||
import data.Player
|
||||
import data.QuestionData
|
||||
import data.Topic
|
||||
import data.toColorOrDefault
|
||||
|
||||
private fun Modifier.setButtonSize(heightFraction: Float) = this.fillMaxWidth(1f)
|
||||
.fillMaxHeight(heightFraction)
|
||||
|
@ -40,13 +42,15 @@ fun Question(
|
|||
var pointsButtonActive by remember { mutableStateOf(false) }
|
||||
|
||||
if (questionResolved.answered) {
|
||||
val player = questionResolved.player
|
||||
val borderStroke = player?.let { it.color.toColorOrDefault() } ?: Color.LightGray
|
||||
Surface(
|
||||
shape = MaterialTheme.shapes.small,
|
||||
modifier = Modifier
|
||||
.setButtonSize(heightFraction),
|
||||
color = Color.LightGray,
|
||||
border = BorderStroke(10.dp, borderStroke)
|
||||
) {
|
||||
val player = questionResolved.player
|
||||
if (player != null) {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
|
|
|
@ -9,10 +9,7 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.em
|
||||
import data.Player
|
||||
import data.QuestionData
|
||||
import data.Topic
|
||||
import data.toColor
|
||||
import data.*
|
||||
|
||||
@Composable
|
||||
@Suppress("FunctionName")
|
||||
|
@ -25,7 +22,7 @@ fun TopicRow(
|
|||
onPointsChange: (Player, Long) -> Unit,
|
||||
onResolveQuestion: (QuestionData, QuestionResolution) -> Unit
|
||||
) {
|
||||
val topicColor = topic.color.toColor()
|
||||
val topicColor = topic.color.toColorOrDefault()
|
||||
Column(
|
||||
modifier = Modifier.fillMaxHeight()
|
||||
.fillMaxWidth(columnFraction)
|
||||
|
|
|
@ -15,7 +15,7 @@ import androidx.compose.ui.unit.dp
|
|||
import androidx.compose.ui.unit.em
|
||||
import components.common.BorderBox
|
||||
import data.Player
|
||||
import data.toColor
|
||||
import data.toColorOrDefault
|
||||
|
||||
@Suppress("FunctionName")
|
||||
@Composable
|
||||
|
@ -29,7 +29,7 @@ fun EndCard(
|
|||
val firstPlayer = sortedPlayersPoints.first()
|
||||
.key
|
||||
BorderBox(
|
||||
borderColor = firstPlayer.color.toColor()
|
||||
borderColor = firstPlayer.color.toColorOrDefault()
|
||||
) {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
|
@ -71,7 +71,7 @@ fun HighScoreListEntry(
|
|||
fontSize: TextUnit
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier.border(border = BorderStroke(5.dp, player.color.toColor()))
|
||||
modifier = Modifier.border(border = BorderStroke(5.dp, player.color.toColorOrDefault()))
|
||||
.padding(10.dp),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
|
|
|
@ -12,10 +12,7 @@ import components.questiondialog.assets.HintText
|
|||
import components.questiondialog.buttons.DismissButton
|
||||
import components.questiondialog.player.DeferredDoubleQuestionDialogPlayer
|
||||
import components.questiondialog.player.QuestionDialogPlayer
|
||||
import data.ColorData
|
||||
import data.Player
|
||||
import data.QuestionData
|
||||
import data.toColor
|
||||
import data.*
|
||||
|
||||
@Suppress("FunctionName")
|
||||
@Composable
|
||||
|
@ -31,7 +28,7 @@ fun QuestionDialogButtons(
|
|||
val fontSize = 5.em
|
||||
var questionAnswered by remember { mutableStateOf(QuestionResolution(false, null)) }
|
||||
|
||||
BorderBox(borderColor = topicColor.toColor()) {
|
||||
BorderBox(borderColor = topicColor.toColorOrDefault()) {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth().fillMaxHeight(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
|
|
|
@ -11,4 +11,7 @@ class ColorData(
|
|||
val alpha: Int = 0xFF
|
||||
)
|
||||
|
||||
fun ColorData?.toColor() = this?.let { Color(it.red, it.green, it.blue, it.alpha) } ?: Color.Blue
|
||||
fun ColorData?.toColorOrNull() = this?.toColor()
|
||||
fun ColorData?.toColorOrDefault() = this?.toColor() ?: Color.Blue
|
||||
|
||||
fun ColorData.toColor() = Color(red, green, blue, alpha)
|
||||
|
|
Loading…
Reference in a new issue