mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-19 16:57:38 +07:00
Resolved #9494 - Pillaged improvements have a visual indication on the icon
This commit is contained in:
parent
7602aa4d0d
commit
688872b5b1
@ -88,7 +88,7 @@ class TileLayerMisc(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, si
|
||||
|
||||
private var workedIcon: Actor? = null
|
||||
|
||||
private var improvementName: String? = null
|
||||
private var improvementPlusPillagedID: String? = null
|
||||
var improvementIcon: Actor? = null
|
||||
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) {
|
||||
// If improvement has changed, force new icon next time it is needed
|
||||
val improvementToShow = tile().getShownImprovement(viewingCiv)
|
||||
if (improvementName != improvementToShow) {
|
||||
improvementName = improvementToShow
|
||||
val newImprovementPlusPillagedID = if (improvementToShow==null) null
|
||||
else if (tile().improvementIsPillaged) "$improvementToShow-Pillaged"
|
||||
else improvementToShow
|
||||
|
||||
if (improvementPlusPillagedID != newImprovementPlusPillagedID) {
|
||||
improvementPlusPillagedID = newImprovementPlusPillagedID
|
||||
improvementIcon?.remove()
|
||||
improvementIcon = null
|
||||
}
|
||||
|
||||
// Get new icon when needed
|
||||
if (improvementName != null && show && improvementIcon == null) {
|
||||
val icon = ImageGetter.getImprovementPortrait(improvementName!!, dim = false)
|
||||
if (improvementPlusPillagedID != null && show && improvementIcon == null) {
|
||||
val icon = ImageGetter.getImprovementPortrait(improvementToShow!!, dim = false, isPillaged = tile().improvementIsPillaged)
|
||||
icon.center(tileGroup)
|
||||
icon.x -= 22 // left
|
||||
icon.y -= 12 // bottom
|
||||
|
@ -264,8 +264,8 @@ object ImageGetter {
|
||||
return PortraitTech(techName, circleSize)
|
||||
}
|
||||
|
||||
fun getImprovementPortrait(improvementName: String, size: Float = 20f, dim: Boolean = false): Portrait {
|
||||
return PortraitImprovement(improvementName, size, dim)
|
||||
fun getImprovementPortrait(improvementName: String, size: Float = 20f, dim: Boolean = false, isPillaged: Boolean = false): Portrait {
|
||||
return PortraitImprovement(improvementName, size, dim, isPillaged)
|
||||
}
|
||||
|
||||
fun getUnitActionPortrait(actionName: String, size: Float = 20f): Portrait {
|
||||
|
@ -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 {
|
||||
if (dim) {
|
||||
image.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 {
|
||||
|
Loading…
Reference in New Issue
Block a user