summaryrefslogtreecommitdiff
path: root/sw-ui-kt/src/main/kotlin
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@booking.com>2020-04-04 19:52:52 +0200
committerJoffrey Bion <joffrey.bion@booking.com>2020-04-04 19:52:52 +0200
commitb1e5a54876e19b4abde12d452cd35665b7ea78c4 (patch)
tree1c8f1841dd633ac10950b6df28555536108bea7b /sw-ui-kt/src/main/kotlin
parentAdd UI for prepared move and cancellation (diff)
downloadseven-wonders-b1e5a54876e19b4abde12d452cd35665b7ea78c4.tar.gz
seven-wonders-b1e5a54876e19b4abde12d452cd35665b7ea78c4.tar.bz2
seven-wonders-b1e5a54876e19b4abde12d452cd35665b7ea78c4.zip
Refactoring in GameScene.kt
Diffstat (limited to 'sw-ui-kt/src/main/kotlin')
-rw-r--r--sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt56
1 files changed, 30 insertions, 26 deletions
diff --git a/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt b/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt
index 2551b43c..d54a0240 100644
--- a/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt
+++ b/sw-ui-kt/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt
@@ -74,10 +74,16 @@ private class GameScene(props: GameSceneProps) : RComponent<GameSceneProps, RSta
}
}
- private fun RBuilder.sayReadyButton(block: StyledDOMBuilder<DIV>.() -> Unit = {}): ReactElement {
+ private fun RBuilder.sayReadyButton(): ReactElement {
val isReady = props.playerIsReady
val intent = if (isReady) Intent.SUCCESS else Intent.PRIMARY
return styledDiv {
+ css {
+ position = Position.absolute
+ bottom = 6.rem
+ left = 50.pct
+ transform { translate(tx = (-50).pct) }
+ }
bpButtonGroup {
bpButton(
large = true,
@@ -88,6 +94,7 @@ private class GameScene(props: GameSceneProps) : RComponent<GameSceneProps, RSta
) {
+"READY"
}
+ // not really a button, but nice for style
bpButton(
large = true,
icon = "people",
@@ -97,7 +104,6 @@ private class GameScene(props: GameSceneProps) : RComponent<GameSceneProps, RSta
+"${props.players.count { it.isReady }}/${props.players.size}"
}
}
- block()
}
}
@@ -118,37 +124,35 @@ private class GameScene(props: GameSceneProps) : RComponent<GameSceneProps, RSta
}
val card = props.preparedCard
if (card != null) {
- bpOverlay(isOpen = true, onClose = props.unprepareMove) {
- styledDiv {
- css { +GlobalStyles.fixedCenter }
- cardImage(card)
- styledDiv {
- css {
- position = Position.absolute
- top = 0.px
- right = 0.px
- }
- bpButton(
- icon = "cross",
- title = "Cancel prepared move",
- small = true,
- intent = Intent.DANGER, onClick = { props.unprepareMove() }
- )
- }
- }
- }
+ preparedMove(card)
}
if (turnInfo.action == Action.SAY_READY) {
- sayReadyButton {
+ sayReadyButton()
+ }
+ productionBar(gold = board.gold, production = board.production)
+ }
+ }
+
+ private fun RBuilder.preparedMove(card: HandCard) {
+ bpOverlay(isOpen = true, onClose = props.unprepareMove) {
+ styledDiv {
+ css { +GlobalStyles.fixedCenter }
+ cardImage(card)
+ styledDiv {
css {
position = Position.absolute
- bottom = 6.rem
- left = 50.pct
- transform { translate(tx = (-50).pct) }
+ top = 0.px
+ right = 0.px
}
+ bpButton(
+ icon = "cross",
+ title = "Cancel prepared move",
+ small = true,
+ intent = Intent.DANGER,
+ onClick = { props.unprepareMove() }
+ )
}
}
- productionBar(gold = board.gold, production = board.production)
}
}
}
bgstack15