From d970632b20921cc07055d23cd3c0a2016e45c157 Mon Sep 17 00:00:00 2001 From: apk Date: Wed, 10 Mar 2021 12:04:08 -0500 Subject: [PATCH] UnitTable.kt modifications to place cancel, previous idle unit and next idle unit below unit information This was made in order to prevent previous idle unit and next idle unit keys' positions to change depending on how big the unit info box is. --- .../unciv/ui/worldscreen/unit/UnitTable.kt | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt index 278bc4f264..946f0ba34f 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt @@ -36,6 +36,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){ if (!append) selectedUnits.clear() selectedCity = null if (unit != null) selectedUnits.add(unit) + //println(unit.toString()) } var selectedCity : CityInfo? = null @@ -53,26 +54,14 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){ promotionsTable.touchable=Touchable.enabled - add(VerticalGroup().apply { - pad(5f) - - deselectUnitButton.add(ImageGetter.getImage("OtherIcons/Close")).size(20f).pad(10f) - deselectUnitButton.pack() - deselectUnitButton.touchable = Touchable.enabled - deselectUnitButton.onClick { selectUnit(); worldScreen.shouldUpdate=true; this@UnitTable.isVisible=false } - addActor(deselectUnitButton) - }).left() - add(Table().apply { - val moveBetweenUnitsTable = Table().apply { - add(prevIdleUnitButton) + val unitNameAndLabel = Table().apply { add(unitIconHolder) add(unitNameLabel).pad(5f) - add(nextIdleUnitButton) } - add(moveBetweenUnitsTable).colspan(2).fill().row() + add(unitNameAndLabel) - separator= addSeparator().actor!! + separator = addSeparator().actor!! add(promotionsTable).colspan(2).row() add(unitDescriptionTable) touchable = Touchable.enabled @@ -81,6 +70,20 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){ worldScreen.mapHolder.setCenterPosition(it, false, false) } } + + addSeparator().actor!! + add(Table().apply { + deselectUnitButton.add(ImageGetter.getImage("OtherIcons/Close")).size(20f).pad(10f) + deselectUnitButton.pack() + deselectUnitButton.touchable = Touchable.enabled + deselectUnitButton.onClick { selectUnit(); worldScreen.shouldUpdate=true; this@UnitTable.isVisible=false } + add(deselectUnitButton) + val idleUnitsSwitcher = Table().apply { + add(prevIdleUnitButton).left() + add(nextIdleUnitButton).left() + } + add(idleUnitsSwitcher).left() + }).left() }).expand() } @@ -106,7 +109,8 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){ nextIdleUnitButton.disable() } - if(selectedUnit!=null) { // set texts - this is valid even when it's the same unit, because movement points and health change + if(selectedUnit!=null) { // set texts - this is valid even when it's the same unit, because + // movement points and health change if(selectedUnits.size==1) { //single selected unit separator.isVisible = true val unit = selectedUnit!! @@ -114,7 +118,9 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){ if (unit.health < 100) nameLabelText += " (" + unit.health + ")" if (nameLabelText != unitNameLabel.text.toString()) { unitNameLabel.setText(nameLabelText) - selectedUnitHasChanged = true // We need to reload the health bar of the unit in the icon - happens e.g. when picking the Heal Instantly promotion + selectedUnitHasChanged = true // We need to reload the health bar of the unit in + // the icon - happens e.g. when picking the + // Heal Instantly promotion } unitDescriptionTable.clear()