Display city defense and health in cities overview tab (#13609)

* add city defense column in city overview

* apply reviewed changes

* fix totals row

* totals for garisson

* WLTK shows count of WLTK's

* test and apply reviewed change
This commit is contained in:
metablaster 2025-07-15 10:51:38 +02:00 committed by GitHub
parent cfcfb69e72
commit 29108d0adc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Actor import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.utils.Align import com.badlogic.gdx.utils.Align
import com.unciv.logic.GameInfo import com.unciv.logic.GameInfo
import com.unciv.logic.battle.CityCombatant
import com.unciv.logic.city.City import com.unciv.logic.city.City
import com.unciv.logic.city.CityFlags import com.unciv.logic.city.CityFlags
import com.unciv.models.stats.Stat import com.unciv.models.stats.Stat
@ -46,8 +47,7 @@ enum class CityOverviewTabColumn : ISortableGridContentProvider<City, EmpireOver
.onClick { .onClick {
actionContext.game.pushScreen(CityScreen(item)) actionContext.game.pushScreen(CityScreen(item))
} }
override fun getTotalsActor(items: Iterable<City>) = override fun getTotalsActor(items: Iterable<City>) = "{Total} ${items.count()}".toLabel()
"{Total} ${items.count()}".toLabel()
}, },
Status { Status {
@ -69,7 +69,7 @@ enum class CityOverviewTabColumn : ISortableGridContentProvider<City, EmpireOver
// getImage is an ImageWithCustomSize, but setting size here fails - width is not respected // getImage is an ImageWithCustomSize, but setting size here fails - width is not respected
return ImageGetter.getImage(iconPath).surroundWithCircle(iconSize * 0.7f, color = Color.CLEAR) return ImageGetter.getImage(iconPath).surroundWithCircle(iconSize * 0.7f, color = Color.CLEAR)
} }
override fun getTotalsActor(items: Iterable<City>) = null override fun getTotalsActor(items: Iterable<City>) = null // an intended empty space
}, },
ConstructionIcon { ConstructionIcon {
@ -81,7 +81,7 @@ enum class CityOverviewTabColumn : ISortableGridContentProvider<City, EmpireOver
if (construction.isEmpty()) return null if (construction.isEmpty()) return null
return ImageGetter.getConstructionPortrait(construction, iconSize * 0.8f) return ImageGetter.getConstructionPortrait(construction, iconSize * 0.8f)
} }
override fun getTotalsActor(items: Iterable<City>) = null override fun getTotalsActor(items: Iterable<City>) = null // an intended empty space
}, },
Construction { Construction {
@ -97,22 +97,17 @@ enum class CityOverviewTabColumn : ISortableGridContentProvider<City, EmpireOver
override fun getEntryValue(item: City) = 0 override fun getEntryValue(item: City) = 0
override fun getEntryActor(item: City, iconSize: Float, actionContext: EmpireOverviewScreen) = override fun getEntryActor(item: City, iconSize: Float, actionContext: EmpireOverviewScreen) =
item.cityConstructions.getCityProductionTextForCityButton().toLabel() item.cityConstructions.getCityProductionTextForCityButton().toLabel()
override fun getTotalsActor(items: Iterable<City>) = null override fun getTotalsActor(items: Iterable<City>) = null // an intended empty space
}, },
Population { Population {
override fun getEntryValue(item: City) = override fun getEntryValue(item: City) = item.population.population
item.population.population
}, },
Food { Food,
override fun getTotalsActor(items: Iterable<City>) = null // an intended empty space
},
Gold, Gold,
Science, Science,
Production{ Production,
override fun getTotalsActor(items: Iterable<City>) = null // an intended empty space
},
Culture, Culture,
Happiness { Happiness {
override fun getEntryValue(item: City) = override fun getEntryValue(item: City) =
@ -172,7 +167,17 @@ enum class CityOverviewTabColumn : ISortableGridContentProvider<City, EmpireOver
return unitIcon return unitIcon
} }
}, },
;
CityDefense {
override val headerTip = "City defense"
override val defaultSort get() = SortableGrid.SortDirection.Ascending
override fun getComparator() = compareBy<City>() { getEntryValue(it) }.thenBy { it.getMaxHealth() }
override fun getHeaderActor(iconSize: Float) = getCircledIcon("BuildingIcons/Walls", iconSize)
override fun getEntryValue(item: City) = CityCombatant(item).getDefendingStrength()
override fun getEntryActor(item: City, iconSize: Float, actionContext: EmpireOverviewScreen) =
"${getEntryValue(item)}/${item.getMaxHealth()}".toLabel()
override fun getTotalsActor(items: Iterable<City>) = null // an intended empty space
};
//endregion //endregion