Multiple selected units are more obvious on-map

This commit is contained in:
Yair Morgenstern 2020-09-11 17:09:50 +03:00
parent f63005ad3c
commit 5a44d7e098
2 changed files with 72 additions and 60 deletions

View File

@ -307,9 +307,10 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap
updateTilegroupsForSelectedCity(city, playerViewableTilePositions)
}
unitTable.selectedUnit != null -> {
val unit = unitTable.selectedUnit!!
for (unit in unitTable.selectedUnits) {
updateTilegroupsForSelectedUnit(unit, playerViewableTilePositions)
}
}
unitActionOverlay != null -> {
unitActionOverlay!!.remove()
unitActionOverlay = null

View File

@ -107,6 +107,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
}
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!!
var nameLabelText = unit.name.tr()
@ -116,7 +117,6 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
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()
unitDescriptionTable.defaults().pad(2f)
unitDescriptionTable.add(ImageGetter.getStatIcon("Movement")).size(20f)
@ -151,6 +151,12 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
if (unit.promotions.promotions.size != promotionsTable.children.size) // The unit has been promoted! Reload promotions!
selectedUnitHasChanged = true
}
else { // multiple selected units
unitNameLabel.setText("")
unitDescriptionTable.clear()
}
}
else if (selectedCity != null) {
separator.isVisible=true
val city = selectedCity!!
@ -178,6 +184,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
unitDescriptionTable.clearListeners()
if(selectedUnit!=null) {
if(selectedUnits.size==1) { // single selected unit
unitIconHolder.add(UnitGroup(selectedUnit!!, 30f)).pad(5f)
for (promotion in selectedUnit!!.promotions.promotions.sorted())
promotionsTable.add(ImageGetter.getPromotionIcon(promotion))
@ -187,7 +194,11 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
if (selectedUnit == null || selectedUnit!!.promotions.promotions.isEmpty()) return@onClick
UncivGame.Current.setScreen(PromotionPickerScreen(selectedUnit!!))
}
}
else { // multiple selected units
for (unit in selectedUnits)
unitIconHolder.add(UnitGroup(unit, 30f)).pad(5f)
}
}
pack()
@ -206,7 +217,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
fun tileSelected(selectedTile: TileInfo) {
val previouslySelectedUnit = selectedUnit
val previousNumberOfSelectedUnits = selectedUnits.size
if (selectedTile.isCityCenter()
&& (selectedTile.getOwner() == worldScreen.viewingCiv || worldScreen.viewingCiv.isSpectator())) {
@ -228,7 +239,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
isVisible = false
}
if (selectedUnit != previouslySelectedUnit)
if (selectedUnit != previouslySelectedUnit || selectedUnits.size != previousNumberOfSelectedUnits)
selectedUnitHasChanged = true
}