From 18913caa6f2a237c09e293e2cad604251f497db3 Mon Sep 17 00:00:00 2001 From: Titouan BION Date: Sat, 20 Feb 2021 20:46:01 +0100 Subject: Replace ProductionBar by self BoardSummary Resolves #66 --- .../ui/components/game/BoardSummary.kt | 27 +++--- .../sevenwonders/ui/components/game/GameScene.kt | 26 +++++- .../luxons/sevenwonders/ui/components/game/Hand.kt | 5 +- .../ui/components/game/ProductionBar.kt | 98 ---------------------- 4 files changed, 45 insertions(+), 111 deletions(-) delete mode 100644 sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/ProductionBar.kt (limited to 'sw-ui') diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/BoardSummary.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/BoardSummary.kt index ee69622e..9573c12a 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/BoardSummary.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/BoardSummary.kt @@ -20,7 +20,8 @@ enum class BoardSummarySide( ) { LEFT(TokenCountPosition.RIGHT, Align.flexStart, PopoverPosition.RIGHT), TOP(TokenCountPosition.OVER, Align.flexStart, PopoverPosition.BOTTOM), - RIGHT(TokenCountPosition.LEFT, Align.flexEnd, PopoverPosition.LEFT) + RIGHT(TokenCountPosition.LEFT, Align.flexEnd, PopoverPosition.LEFT), + BOTTOM(TokenCountPosition.OVER, Align.flexStart, PopoverPosition.TOP), } fun RBuilder.boardSummaryWithPopover( @@ -35,7 +36,12 @@ fun RBuilder.boardSummaryWithPopover( position = boardSummarySide.popoverPosition, popoverClassName = popoverClass, ) { - boardSummary(player, board, boardSummarySide, block) + boardSummary( + player = player, + board = board, + side = boardSummarySide, + block = block, + ) } } @@ -47,10 +53,11 @@ private fun createFullBoardPreview(board: Board): ReactElement = buildElement { } } -private fun RBuilder.boardSummary( +fun RBuilder.boardSummary( player: PlayerDTO, board: Board, side: BoardSummarySide, + showPreparationStatus: Boolean = true, block: StyledDOMBuilder
.() -> Unit = {}, ) { styledDiv { @@ -67,21 +74,21 @@ private fun RBuilder.boardSummary( } } - topBar(player, side) + topBar(player, side, showPreparationStatus) styledHr { css { margin(vertical = 0.5.rem) width = 100.pct } } - bottomBar(side, board, player) + bottomBar(side, board, player, showPreparationStatus) block() } } -private fun RBuilder.topBar(player: PlayerDTO, side: BoardSummarySide) { +private fun RBuilder.topBar(player: PlayerDTO, side: BoardSummarySide, showPreparationStatus: Boolean) { val playerIconSize = 25 - if (side == BoardSummarySide.TOP) { + if (showPreparationStatus && side == BoardSummarySide.TOP) { styledDiv { css { display = Display.flex @@ -97,11 +104,11 @@ private fun RBuilder.topBar(player: PlayerDTO, side: BoardSummarySide) { } } -private fun RBuilder.bottomBar(side: BoardSummarySide, board: Board, player: PlayerDTO) { +private fun RBuilder.bottomBar(side: BoardSummarySide, board: Board, player: PlayerDTO, showPreparationStatus: Boolean) { styledDiv { css { display = Display.flex - flexDirection = if (side == BoardSummarySide.TOP) FlexDirection.row else FlexDirection.column + flexDirection = if (side == BoardSummarySide.TOP || side == BoardSummarySide.BOTTOM) FlexDirection.row else FlexDirection.column alignItems = side.alignment if (side != BoardSummarySide.TOP) { width = 100.pct @@ -111,7 +118,7 @@ private fun RBuilder.bottomBar(side: BoardSummarySide, board: Board, player: Pla generalCounts(board, tokenSize, side.tokenCountPosition) bpDivider() scienceTokens(board, tokenSize, side.tokenCountPosition) - if (side != BoardSummarySide.TOP) { + if (showPreparationStatus && side != BoardSummarySide.TOP) { bpDivider() styledDiv { css { diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt index 79e003cf..d26fc81d 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt @@ -89,7 +89,7 @@ private class GameScene(props: GameSceneProps) : RComponent) { - styledDiv { - css { - margin = "auto" - display = Display.flex - } - resources.forEach { - resourceWithCount(resourceType = it.type, count = it.count, imgSize = 3.rem) { - attrs { key = it.type.toString() } - css { marginLeft = 1.rem } - } - } - } -} - -private fun RBuilder.alternativeResources(resources: List>) { - styledDiv { - css { - margin = "auto" - display = Display.flex - } - resources.forEachIndexed { index, res -> - resourceChoice(types = res) { - attrs { - key = index.toString() - } - } - } - } -} - -private fun RBuilder.resourceChoice(types: Set, block: StyledDOMBuilder
.() -> Unit = {}) { - styledDiv { - css { - marginLeft = (1.5).rem - } - block() - for ((i, t) in types.withIndex()) { - resourceImage(resourceType = t, size = 3.rem) { - attrs { this.key = t.toString() } - } - if (i < types.indices.last) { - styledSpan { - css { choiceSeparatorStyle() } - +"/" - } - } - } - } -} - -private fun CSSBuilder.productionBarStyle() { - alignItems = Align.center - background = "linear-gradient(#eaeaea, #888 7%)" - bottom = 0.px - borderTop(width = 1.px, color = Color("#8b8b8b"), style = BorderStyle.solid) - boxShadow(blurRadius = 15.px, color = Color("#747474")) - display = Display.flex - height = (3.5).rem - width = 100.vw - position = Position.fixed - zIndex = 99 -} - -private fun CSSBuilder.choiceSeparatorStyle() { - fontSize = 2.rem - verticalAlign = VerticalAlign.middle - margin(all = 5.px) - color = Color("#c29929") - declarations["text-shadow"] = "0 0 1px black" -} -- cgit