Resolved #9494 - Pillaged improvements have a visual indication on the icon

This commit is contained in:
Yair Morgenstern 2023-06-04 16:56:05 +03:00
parent 7602aa4d0d
commit 688872b5b1
3 changed files with 18 additions and 8 deletions

View File

@ -88,7 +88,7 @@ class TileLayerMisc(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, si
private var workedIcon: Actor? = null private var workedIcon: Actor? = null
private var improvementName: String? = null private var improvementPlusPillagedID: String? = null
var improvementIcon: Actor? = null var improvementIcon: Actor? = null
private set // Getter public for BattleTable to display as City Combatant private set // Getter public for BattleTable to display as City Combatant
@ -140,15 +140,19 @@ class TileLayerMisc(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, si
private fun updateImprovementIcon(viewingCiv: Civilization?, show: Boolean) { private fun updateImprovementIcon(viewingCiv: Civilization?, show: Boolean) {
// If improvement has changed, force new icon next time it is needed // If improvement has changed, force new icon next time it is needed
val improvementToShow = tile().getShownImprovement(viewingCiv) val improvementToShow = tile().getShownImprovement(viewingCiv)
if (improvementName != improvementToShow) { val newImprovementPlusPillagedID = if (improvementToShow==null) null
improvementName = improvementToShow else if (tile().improvementIsPillaged) "$improvementToShow-Pillaged"
else improvementToShow
if (improvementPlusPillagedID != newImprovementPlusPillagedID) {
improvementPlusPillagedID = newImprovementPlusPillagedID
improvementIcon?.remove() improvementIcon?.remove()
improvementIcon = null improvementIcon = null
} }
// Get new icon when needed // Get new icon when needed
if (improvementName != null && show && improvementIcon == null) { if (improvementPlusPillagedID != null && show && improvementIcon == null) {
val icon = ImageGetter.getImprovementPortrait(improvementName!!, dim = false) val icon = ImageGetter.getImprovementPortrait(improvementToShow!!, dim = false, isPillaged = tile().improvementIsPillaged)
icon.center(tileGroup) icon.center(tileGroup)
icon.x -= 22 // left icon.x -= 22 // left
icon.y -= 12 // bottom icon.y -= 12 // bottom

View File

@ -264,8 +264,8 @@ object ImageGetter {
return PortraitTech(techName, circleSize) return PortraitTech(techName, circleSize)
} }
fun getImprovementPortrait(improvementName: String, size: Float = 20f, dim: Boolean = false): Portrait { fun getImprovementPortrait(improvementName: String, size: Float = 20f, dim: Boolean = false, isPillaged: Boolean = false): Portrait {
return PortraitImprovement(improvementName, size, dim) return PortraitImprovement(improvementName, size, dim, isPillaged)
} }
fun getUnitActionPortrait(actionName: String, size: Float = 20f): Portrait { fun getUnitActionPortrait(actionName: String, size: Float = 20f): Portrait {

View File

@ -195,13 +195,19 @@ class PortraitUnitAction(name: String, size: Float) : Portrait(Type.UnitAction,
} }
} }
class PortraitImprovement(name: String, size: Float, dim: Boolean = false) : Portrait(Type.Improvement, name, size) { class PortraitImprovement(name: String, size: Float, dim: Boolean = false, isPillaged: Boolean = false) : Portrait(Type.Improvement, name, size) {
init { init {
if (dim) { if (dim) {
image.color.a = 0.7f image.color.a = 0.7f
background.color.a = 0.7f background.color.a = 0.7f
} }
if (isPillaged){
val pillagedIcon = ImageGetter.getImage("OtherIcons/Fire")
pillagedIcon.setSize(width/2, height/2)
pillagedIcon.setPosition(width, 0f, Align.bottomRight)
addActor(pillagedIcon)
}
} }
private fun getColorFromStats(stats: Stats): Color { private fun getColorFromStats(stats: Stats): Color {