From f78f9c2fada7e34768d7306e47f489ea6a0e324a Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 26 May 2019 16:16:42 +0300 Subject: [PATCH] Resolved #803 - Heal Instantly didn't update health in unit icon --- .../unciv/ui/pickerscreens/PromotionPickerScreen.kt | 1 + core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt index fc70f7615f..462cff7c0f 100644 --- a/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt @@ -28,6 +28,7 @@ class PromotionPickerScreen(mapUnit: MapUnit) : PickerScreen() { if(mapUnit.promotions.canBePromoted()) game.screen = PromotionPickerScreen(mapUnit) else game.setWorldScreen() dispose() + game.worldScreen.shouldUpdate=true } rightSideButton.setText("Pick promotion".tr()) diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt index dbeac8e6d0..f4f24b1b65 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt @@ -2,7 +2,10 @@ package com.unciv.ui.worldscreen.unit import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.scenes.scene2d.Touchable -import com.badlogic.gdx.scenes.scene2d.ui.* +import com.badlogic.gdx.scenes.scene2d.ui.Image +import com.badlogic.gdx.scenes.scene2d.ui.Label +import com.badlogic.gdx.scenes.scene2d.ui.Table +import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup import com.unciv.UnCivGame import com.unciv.logic.battle.CityCombatant import com.unciv.logic.city.CityInfo @@ -108,7 +111,11 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){ val unit = selectedUnit!! var nameLabelText = unit.name.tr() if(unit.health<100) nameLabelText+=" ("+unit.health+")" - unitNameLabel.setText(nameLabelText) + 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 + } + unitDescriptionTable.clear() unitDescriptionTable.defaults().pad(2f)