diff --git a/core/src/com/unciv/ui/tilegroups/TileGroup.kt b/core/src/com/unciv/ui/tilegroups/TileGroup.kt index 42b8a27b80..09311589a2 100644 --- a/core/src/com/unciv/ui/tilegroups/TileGroup.kt +++ b/core/src/com/unciv/ui/tilegroups/TileGroup.kt @@ -22,11 +22,16 @@ import kotlin.random.Random /** A lot of the render time was spent on snapshot arrays of the TileGroupMap's groups, in the act() function. * This class is to avoid the overhead of useless act() calls. */ -open class ActionlessGroup:Group(){ +open class ActionlessGroup(val checkHit:Boolean=false):Group() { override fun act(delta: Float) {} + override fun hit(x: Float, y: Float, touchable: Boolean): Actor? { + if (checkHit) + return super.hit(x, y, touchable) + return null + } } -open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) : ActionlessGroup() { +open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) : ActionlessGroup(true) { val groupSize = 54f /* @@ -88,8 +93,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) val unitLayerGroup = UnitLayerGroupClass().apply { isTransform = false; setSize(groupSize, groupSize);touchable = Touchable.disabled } val unitImageLayerGroup = UnitImageLayerGroupClass().apply { isTransform = false; setSize(groupSize, groupSize);touchable = Touchable.disabled } - - val cityButtonLayerGroup = Group().apply { setSize(groupSize, groupSize); + val cityButtonLayerGroup = Group().apply { isTransform = false; setSize(groupSize, groupSize); touchable = Touchable.childrenOnly; setOrigin(Align.center) } val circleCrosshairFogLayerGroup = ActionlessGroup().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 a7e3eb9237..77fd31f977 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldMapHolder.kt @@ -468,7 +468,10 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap 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 + // ONLY set those groups that have active citybuttons as transformable! + // This is massively framerate-improving! + if (tileGroup.cityButtonLayerGroup.hasChildren()) + tileGroup.cityButtonLayerGroup.isTransform = true tileGroup.cityButtonLayerGroup.setScale(scale) } }