mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-03 22:22:51 +07:00
Added city strength label to city button
This commit is contained in:
parent
c7334a461f
commit
c90a79363d
@ -10,6 +10,7 @@ import com.badlogic.gdx.scenes.scene2d.actions.Actions
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.logic.battle.CityCombatant
|
||||
import com.unciv.logic.city.CityConstructions
|
||||
import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.city.PerpetualConstruction
|
||||
@ -39,7 +40,6 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
||||
clear()
|
||||
setButtonActions()
|
||||
addAirUnitTable()
|
||||
|
||||
if (showAdditionalInfoTags && city.health < city.getMaxHealth().toFloat()) {
|
||||
val healthBar = ImageGetter.getHealthBar(city.health.toFloat(), city.getMaxHealth().toFloat(), 100f)
|
||||
add(healthBar).row()
|
||||
@ -54,6 +54,8 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
||||
add(influenceBar).row()
|
||||
}
|
||||
|
||||
|
||||
|
||||
pack()
|
||||
setOrigin(Align.center)
|
||||
centerX(tileGroup)
|
||||
@ -228,6 +230,12 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
||||
label.toBack() // this is so the label is rendered right before the population group,
|
||||
// so we save the font texture and avoid another texture switch
|
||||
|
||||
// City strength is added NOT inside the table, but rather - top-center to it
|
||||
val cityStrength = CityCombatant(city).getCityStrength()
|
||||
val cityStrengthLabel = "${Fonts.strength}$cityStrength".toLabel(city.civInfo.nation.getInnerColor(), 10)
|
||||
iconTable.addActor(cityStrengthLabel) // We create this here to we can .toBack() it as well.
|
||||
cityStrengthLabel.toBack()
|
||||
|
||||
if (uncivGame.viewEntireMapForDebug || belongsToViewingCiv() || worldScreen.viewingCiv.isSpectator()) {
|
||||
val constructionGroup = getConstructionGroup(city.cityConstructions)
|
||||
iconTable.add(constructionGroup)
|
||||
@ -243,6 +251,10 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
||||
nationIcon.color = secondaryColor
|
||||
iconTable.add(nationIcon).size(20f)
|
||||
}
|
||||
|
||||
iconTable.pack()
|
||||
cityStrengthLabel.x = label.x // so it'll be aligned right above the city name
|
||||
cityStrengthLabel.setY(iconTable.height, Align.top)
|
||||
return iconTable
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user