Skip to content

Commit

Permalink
Better "close unit table" button - see #12591
Browse files Browse the repository at this point in the history
  • Loading branch information
yairm210 committed Dec 14, 2024
1 parent 6f535f5 commit 0f4f690
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core/src/com/unciv/ui/screens/worldscreen/unit/UnitTable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table() {
private val unitIconNameGroup = Table()
private val promotionsTable = Table().apply { defaults().padRight(5f) }
private val unitDescriptionTable = Table(BaseScreen.skin)
private val deselectUnitButton: Actor

val selectedUnit : MapUnit?
get() = selectedUnits.firstOrNull()
Expand Down Expand Up @@ -91,13 +92,13 @@ class UnitTable(val worldScreen: WorldScreen) : Table() {

promotionsTable.touchable = Touchable.enabled

val deselectUnitButton = getCloseButton(50f, 20f, Color.CLEAR, Color.RED) {
deselectUnitButton = getCloseButton(30f, 15f, Color.CLEAR, Color.RED) {
selectUnit()
worldScreen.shouldUpdate = true
this@UnitTable.isVisible = false
}
}.surroundWithCircle(30f, resizeActor = false, color = BaseScreen.clearColor).surroundWithThinCircle(Color.WHITE)
deselectUnitButton.keyShortcuts.clear() // This is the only place we don't want the BACK keyshortcut getCloseButton assigns
add(deselectUnitButton).left()
addActor(deselectUnitButton)

add(Table().apply {
val moveBetweenUnitsTable = Table().apply {
Expand Down Expand Up @@ -302,6 +303,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table() {
}

pack()
deselectUnitButton.setPosition(width - deselectUnitButton.width*3/4, height - deselectUnitButton.height*3/4)
bg.setSize(width-3f, height-3f)
bg.center(this)
selectedUnitHasChanged = false
Expand Down

0 comments on commit 0f4f690

Please sign in to comment.