mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-20 19:56:51 +01:00
perf(render): Converted improvement images to prerendered images
This commit is contained in:
parent
9ab656b55f
commit
0b19463883
|
|
@ -209,7 +209,7 @@ class TileLayerImprovement(tileGroup: TileGroup, size: Float) : TileLayer(tileGr
|
|||
|
||||
// Get new icon when needed
|
||||
if (improvementPlusPillagedID != null && show && improvementIcon == null) {
|
||||
val icon = ImageGetter.getImprovementPortrait(improvementToShow!!, dim = false, isPillaged = tile.improvementIsPillaged)
|
||||
val icon = ImageGetter.getImage(improvementToShow!!).apply { setSize(24f) }
|
||||
icon.center(tileGroup)
|
||||
icon.x -= 22 // left
|
||||
icon.y -= 12 // bottom
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ object ImageGetter {
|
|||
|
||||
setupStatImages()
|
||||
setupResourcePortraits()
|
||||
setupImprovementPortraits()
|
||||
}
|
||||
|
||||
private fun setupStatImages() {
|
||||
|
|
@ -116,6 +117,11 @@ object ImageGetter {
|
|||
packTexture(nameToActorList, 120)
|
||||
}
|
||||
|
||||
private fun setupImprovementPortraits() {
|
||||
val nameToActorList = ruleset.tileImprovements.values.map { it.name to getImprovementPortrait(it.name, 100f, borderSize = 10f) }
|
||||
packTexture(nameToActorList, 120)
|
||||
}
|
||||
|
||||
private fun packTexture(nameToActorList: List<Pair<String, Group>>, size: Int) {
|
||||
val pixmapPacker = PixmapPacker(2048, 2048, Pixmap.Format.RGBA8888, 2, false).apply { packToTexture = true }
|
||||
for ((name, actor) in nameToActorList) {
|
||||
|
|
@ -327,8 +333,8 @@ object ImageGetter {
|
|||
|
||||
fun getTechIconPortrait(techName: String, circleSize: Float): Group = PortraitTech(techName, circleSize)
|
||||
|
||||
fun getImprovementPortrait(improvementName: String, size: Float = 20f, dim: Boolean = false, isPillaged: Boolean = false): Portrait =
|
||||
PortraitImprovement(improvementName, size, dim, isPillaged)
|
||||
fun getImprovementPortrait(improvementName: String, size: Float = 20f, dim: Boolean = false, isPillaged: Boolean = false, borderSize: Float = 2f): Portrait =
|
||||
PortraitImprovement(improvementName, size, dim, isPillaged, borderSize)
|
||||
|
||||
fun getUnitActionPortrait(actionName: String, size: Float = 20f): Portrait = PortraitUnitAction(actionName, size)
|
||||
|
||||
|
|
|
|||
|
|
@ -183,7 +183,8 @@ class PortraitUnitAction(name: String, size: Float) : Portrait(Type.UnitAction,
|
|||
override fun getDefaultImageTint(): Color = ImageGetter.CHARCOAL
|
||||
}
|
||||
|
||||
class PortraitImprovement(name: String, size: Float, dim: Boolean = false, isPillaged: Boolean = false) : Portrait(Type.Improvement, name, size) {
|
||||
class PortraitImprovement(name: String, size: Float, dim: Boolean = false, isPillaged: Boolean = false, borderSize: Float = 2f)
|
||||
: Portrait(Type.Improvement, name, size, borderSize) {
|
||||
|
||||
init {
|
||||
if (dim) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user