mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 14:24:43 -04: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.Label
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
|
import com.unciv.logic.battle.CityCombatant
|
||||||
import com.unciv.logic.city.CityConstructions
|
import com.unciv.logic.city.CityConstructions
|
||||||
import com.unciv.logic.city.CityInfo
|
import com.unciv.logic.city.CityInfo
|
||||||
import com.unciv.logic.city.PerpetualConstruction
|
import com.unciv.logic.city.PerpetualConstruction
|
||||||
@ -39,7 +40,6 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
|||||||
clear()
|
clear()
|
||||||
setButtonActions()
|
setButtonActions()
|
||||||
addAirUnitTable()
|
addAirUnitTable()
|
||||||
|
|
||||||
if (showAdditionalInfoTags && city.health < city.getMaxHealth().toFloat()) {
|
if (showAdditionalInfoTags && city.health < city.getMaxHealth().toFloat()) {
|
||||||
val healthBar = ImageGetter.getHealthBar(city.health.toFloat(), city.getMaxHealth().toFloat(), 100f)
|
val healthBar = ImageGetter.getHealthBar(city.health.toFloat(), city.getMaxHealth().toFloat(), 100f)
|
||||||
add(healthBar).row()
|
add(healthBar).row()
|
||||||
@ -54,6 +54,8 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
|||||||
add(influenceBar).row()
|
add(influenceBar).row()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pack()
|
pack()
|
||||||
setOrigin(Align.center)
|
setOrigin(Align.center)
|
||||||
centerX(tileGroup)
|
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,
|
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
|
// 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()) {
|
if (uncivGame.viewEntireMapForDebug || belongsToViewingCiv() || worldScreen.viewingCiv.isSpectator()) {
|
||||||
val constructionGroup = getConstructionGroup(city.cityConstructions)
|
val constructionGroup = getConstructionGroup(city.cityConstructions)
|
||||||
iconTable.add(constructionGroup)
|
iconTable.add(constructionGroup)
|
||||||
@ -243,6 +251,10 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
|||||||
nationIcon.color = secondaryColor
|
nationIcon.color = secondaryColor
|
||||||
iconTable.add(nationIcon).size(20f)
|
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
|
return iconTable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user