diff options
author | Joffrey Bion <joffrey.bion@booking.com> | 2020-05-21 13:46:30 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@booking.com> | 2020-05-21 13:58:28 +0200 |
commit | 4f3eec40a87c5e4f52fc89238642dd7a17650540 (patch) | |
tree | c910270b5477975100bfd82852d784409346f334 /sw-ui/src/main/kotlin/org/luxons | |
parent | Prevent bots with already used names (diff) | |
download | seven-wonders-4f3eec40a87c5e4f52fc89238642dd7a17650540.tar.gz seven-wonders-4f3eec40a87c5e4f52fc89238642dd7a17650540.tar.bz2 seven-wonders-4f3eec40a87c5e4f52fc89238642dd7a17650540.zip |
Allow custom player icons
Diffstat (limited to 'sw-ui/src/main/kotlin/org/luxons')
-rw-r--r-- | sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialPlayerList.kt | 15 | ||||
-rw-r--r-- | sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt | 2 |
2 files changed, 10 insertions, 7 deletions
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialPlayerList.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialPlayerList.kt index 0c1a5570..60962927 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialPlayerList.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialPlayerList.kt @@ -1,10 +1,10 @@ package org.luxons.sevenwonders.ui.components.lobby -import com.palantir.blueprintjs.IconName import com.palantir.blueprintjs.Intent import com.palantir.blueprintjs.bpIcon import kotlinx.css.* import org.luxons.sevenwonders.model.api.PlayerDTO +import org.luxons.sevenwonders.model.api.actions.Icon import react.RBuilder import react.ReactElement import react.dom.* @@ -67,7 +67,11 @@ private fun RBuilder.playerItem(player: PlayerDTO, isMe: Boolean): ReactElement alignItems = Align.center } val title = if (player.isGameOwner) "Game owner" else null - userIcon(isMe = isMe, isOwner = player.isGameOwner, title = title) + val icon = player.icon ?: when { + player.isGameOwner -> Icon("badge") + else -> Icon("user") + } + userIcon(isMe = isMe, icon = icon, title = title) styledH5 { css { margin = "0" @@ -83,7 +87,7 @@ private fun RBuilder.playerPlaceholder(): ReactElement = styledDiv { alignItems = Align.center opacity = 0.3 } - userIcon(isMe = false, isOwner = false, title = "Waiting for player...") + userIcon(isMe = false, icon = Icon("user"), title = "Waiting for player...") styledH5 { css { margin = "0" @@ -92,8 +96,7 @@ private fun RBuilder.playerPlaceholder(): ReactElement = styledDiv { } } -private fun RBuilder.userIcon(isMe: Boolean, isOwner: Boolean, title: String?): ReactElement { - val iconName: IconName = if (isOwner) "badge" else "user" +private fun RBuilder.userIcon(isMe: Boolean, icon: Icon, title: String?): ReactElement { val intent: Intent = if (isMe) Intent.WARNING else Intent.NONE - return bpIcon(name = iconName, intent = intent, size = 50, title = title) + return bpIcon(name = icon.name, intent = intent, size = 50, title = title) } diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt index 36c0848e..45cc474b 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt @@ -30,7 +30,7 @@ suspend fun SwSagaContext.rootSaga() = coroutineScope { serverErrorSaga(session) } - val player = session.chooseName(action.playerName) + val player = session.chooseName(action.playerName, null) dispatch(SetCurrentPlayerAction(player)) routerSaga(Route.GAME_BROWSER) { |