@@ -36,7 +36,7 @@ import ru.nsu.ccfit.zuev.osu.online.OnlineManager
3636import ru.nsu.ccfit.zuev.osuplus.R
3737
3838class RoomPlayerCard : UILinearContainer () {
39- private val teamColorBar: UIBox
39+ private val teamColorBar: UIButton
4040 private val playerButton: RoomPlayerButton
4141
4242 init {
@@ -45,11 +45,11 @@ class RoomPlayerCard : UILinearContainer() {
4545 padding = Vec4 (12f , 8f )
4646 spacing = 12f
4747
48- teamColorBar = UIBox ().apply {
48+ teamColorBar = UIButton ().apply {
49+ applyTheme = {}
4950 relativeSizeAxes = Axes .X
5051 width = 0.025f
5152 height = FillParent
52- cornerRadius = 12f
5353 }
5454
5555 playerButton = RoomPlayerButton ()
@@ -64,13 +64,19 @@ class RoomPlayerCard : UILinearContainer() {
6464 attachChild(teamColorBar, 0 )
6565 }
6666
67- teamColorBar.color = when (player.team) {
67+ teamColorBar.background?. color = when (player.team) {
6868 Blue -> Color4 (" #1E62E8" ) * 0.8f
6969 Red -> Color4 (" #E34444" ) * 0.8f
7070 null -> Theme .current.accentColor * 0.6f
7171 }
72- } else if (teamColorBar.hasParent()) {
73- detachChild(teamColorBar)
72+
73+ if (player.id == OnlineManager .getInstance().userId) {
74+ teamColorBar.onActionUp = { showTeamDropdown() }
75+ } else {
76+ teamColorBar.onActionUp = null
77+ }
78+ } else {
79+ teamColorBar.detachSelf()
7480 }
7581 }
7682
@@ -79,6 +85,28 @@ class RoomPlayerCard : UILinearContainer() {
7985 playerButton.bannerJob?.cancel()
8086 }
8187
88+ private fun showTeamDropdown () {
89+ UIDropdown (teamColorBar).apply dropdown@{
90+ width = 100f
91+
92+ addButton {
93+ text = " Red"
94+ onActionUp = {
95+ RoomAPI .setPlayerTeam(Red )
96+ this @dropdown.hide()
97+ }
98+ }
99+
100+ addButton {
101+ text = " Blue"
102+ onActionUp = {
103+ RoomAPI .setPlayerTeam(Blue )
104+ this @dropdown.hide()
105+ }
106+ }
107+ }.show()
108+ }
109+
82110 private class RoomPlayerButton : UIButton () {
83111
84112 private lateinit var nameText: CompoundText
0 commit comments