Made sure that labels are rendered after each other in the city button, so save on texture switches between the font and the image textures

This commit is contained in:
Yair Morgenstern 2020-11-19 22:29:50 +02:00
parent 35554f3ec6
commit 2e668ddeb5
2 changed files with 15 additions and 4 deletions

View File

@ -216,14 +216,18 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
iconTable.add(connectionImage).size(20f).padLeft(5f)
}
iconTable.add(getPopulationGroup(uncivGame.viewEntireMapForDebug
val populationGroup = getPopulationGroup(uncivGame.viewEntireMapForDebug
|| belongsToViewingCiv()
|| worldScreen.viewingCiv.isSpectator())).padLeft(5f)
|| worldScreen.viewingCiv.isSpectator())
iconTable.add(populationGroup).padLeft(5f)
populationGroup.toBack()
val cityButtonText = city.name
val label = cityButtonText.toLabel(secondaryColor)
iconTable.add(label).padRight(20f).padLeft(20f) // sufficient horizontal padding
.fillY() // provide full-height clicking area
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
if (uncivGame.viewEntireMapForDebug || belongsToViewingCiv() || worldScreen.viewingCiv.isSpectator())
iconTable.add(getConstructionGroup(city.cityConstructions))
@ -309,6 +313,9 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
turnLabel.pack()
group.addActor(turnLabel)
turnLabel.toBack() // this is so both labels are rendered next to each other -
// this is important because when switching to a label, we switch out the texture we're using to use the font texture,
// so this has a direct impact on framerate!
turnLabel.x = growthBar.x + growthBar.width + 1
}

View File

@ -60,7 +60,9 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
protected var pixelCivilianUnitImageLocation = ""
protected var pixelCivilianUnitGroup = Group().apply { isTransform = false; setSize(groupSize, groupSize) }
class MiscLayerGroupClass:Group()
class MiscLayerGroupClass:Group(){
override fun draw(batch: Batch?, parentAlpha: Float) { super.draw(batch, parentAlpha) }
}
val miscLayerGroup = MiscLayerGroupClass().apply { isTransform = false; setSize(groupSize, groupSize) }
var resourceImage: Actor? = null
@ -70,7 +72,9 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
val icons = TileGroupIcons(this)
class UnitLayerGroupClass:Group()
class UnitLayerGroupClass:Group(){
override fun draw(batch: Batch?, parentAlpha: Float) { super.draw(batch, parentAlpha) }
}
val unitLayerGroup = UnitLayerGroupClass().apply { isTransform = false; setSize(groupSize, groupSize);touchable = Touchable.disabled }
val cityButtonLayerGroup = Group().apply { isTransform = true; setSize(groupSize, groupSize);