From 223da7f531c35ce354a400f5eadb8a9c08b4876c Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 19 Nov 2020 23:04:09 +0200 Subject: [PATCH] More framerate improvement tricks - this was more than enough to offset the harm of the building and unit images, and went the other way! The framerate started out before the image games as ~17-18 on the tested game, dropped to ~14-15 with the image changes, and is now at ~20-21~ --- .../src/com/unciv/ui/tilegroups/CityButton.kt | 1 - core/src/com/unciv/ui/tilegroups/TileGroup.kt | 2 +- .../unciv/ui/worldscreen/WorldMapHolder.kt | 20 +++++++++++-------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/core/src/com/unciv/ui/tilegroups/CityButton.kt b/core/src/com/unciv/ui/tilegroups/CityButton.kt index 6afa7563a9..aae22ca240 100644 --- a/core/src/com/unciv/ui/tilegroups/CityButton.kt +++ b/core/src/com/unciv/ui/tilegroups/CityButton.kt @@ -25,7 +25,6 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab val uncivGame = worldScreen.game init { - isTransform = true // If this is not set then the city button won't scale! touchable = Touchable.disabled } diff --git a/core/src/com/unciv/ui/tilegroups/TileGroup.kt b/core/src/com/unciv/ui/tilegroups/TileGroup.kt index 784371f0b5..f680ce69a9 100644 --- a/core/src/com/unciv/ui/tilegroups/TileGroup.kt +++ b/core/src/com/unciv/ui/tilegroups/TileGroup.kt @@ -77,7 +77,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) } val unitLayerGroup = UnitLayerGroupClass().apply { isTransform = false; setSize(groupSize, groupSize);touchable = Touchable.disabled } - val cityButtonLayerGroup = Group().apply { isTransform = true; setSize(groupSize, groupSize); + val cityButtonLayerGroup = Group().apply { setSize(groupSize, groupSize); touchable = Touchable.childrenOnly; setOrigin(Align.center) } val circleCrosshairFogLayerGroup = Group().apply { isTransform = false; setSize(groupSize, groupSize) } diff --git a/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt b/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt index 27780304c9..a7e3eb9237 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt @@ -460,16 +460,20 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap worldScreen.shouldUpdate=true } - override fun zoom(zoomScale:Float){ + override fun zoom(zoomScale:Float) { super.zoom(zoomScale) - val scale = 1/scaleX // don't use zoomScale itself, in case it was out of bounds and not applied - if(scale < 1 && scale > 0.5f) - for(tileGroup in tileGroups.values) - tileGroup.cityButtonLayerGroup.setScale(scale) + val scale = 1 / scaleX // don't use zoomScale itself, in case it was out of bounds and not applied + if (scale >= 1) + for (tileGroup in tileGroups.values) + tileGroup.cityButtonLayerGroup.isTransform = false // to save on rendering time to improve framerate + if (scale < 1 && scale > 0.5f) + for (tileGroup in tileGroups.values) { + tileGroup.cityButtonLayerGroup.isTransform = true + tileGroup.cityButtonLayerGroup.setScale(scale) + } } // For debugging purposes - override fun draw(batch: Batch?, parentAlpha: Float) { - super.draw(batch, parentAlpha) - } + override fun draw(batch: Batch?, parentAlpha: Float) { super.draw(batch, parentAlpha) } + override fun act(delta: Float) { super.act(delta) } } \ No newline at end of file