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.utils.Align
import com.unciv.logic.GameInfo
import com.unciv.logic.battle.CityCombatant
import com.unciv.logic.city.City
import com.unciv.logic.city.CityFlags
import com.unciv.models.stats.Stat
@ -46,8 +47,7 @@ enum class CityOverviewTabColumn : ISortableGridContentProvider<City, EmpireOver
.onClick {
actionContext.game.pushScreen(CityScreen(item))
}
override fun getTotalsActor(items: Iterable<City>) =
"{Total} ${items.count()}".toLabel()
override fun getTotalsActor(items: Iterable<City>) = "{Total} ${items.count()}".toLabel()
},
Status {
@ -69,7 +69,7 @@ enum class CityOverviewTabColumn : ISortableGridContentProvider<City, EmpireOver
// getImage is an ImageWithCustomSize, but setting size here fails - width is not respected
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 {
@ -81,7 +81,7 @@ enum class CityOverviewTabColumn : ISortableGridContentProvider<City, EmpireOver
if (construction.isEmpty()) return null
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 {
@ -97,30 +97,25 @@ enum class CityOverviewTabColumn : ISortableGridContentProvider<City, EmpireOver
override fun getEntryValue(item: City) = 0
override fun getEntryActor(item: City, iconSize: Float, actionContext: EmpireOverviewScreen) =
item.cityConstructions.getCityProductionTextForCityButton().toLabel()
override fun getTotalsActor(items: Iterable<City>) = null
override fun getTotalsActor(items: Iterable<City>) = null // an intended empty space
},
Population {
override fun getEntryValue(item: City) =
item.population.population
override fun getEntryValue(item: City) = item.population.population
},
Food {
override fun getTotalsActor(items: Iterable<City>) = null // an intended empty space
},
Food,
Gold,
Science,
Production{
override fun getTotalsActor(items: Iterable<City>) = null // an intended empty space
},
Production,
Culture,
Happiness {
override fun getEntryValue(item: City) =
item.cityStats.happinessList.values.sum().roundToInt()
item.cityStats.happinessList.values.sum().roundToInt()
},
Faith {
override fun isVisible(gameInfo: GameInfo) =
gameInfo.isReligionEnabled()
gameInfo.isReligionEnabled()
},
WLTK {
@ -172,7 +167,17 @@ enum class CityOverviewTabColumn : ISortableGridContentProvider<City, EmpireOver
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