Add passthrough functions to all layers for perf work

This commit is contained in:
yairm210 2024-11-13 12:27:12 +02:00
parent 8e0115263b
commit 7b075bcf7c
8 changed files with 20 additions and 7 deletions

View File

@ -1,5 +1,6 @@
package com.unciv.ui.components.tilegroups.layers
import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.ui.Image
import com.unciv.logic.civilization.Civilization
@ -20,6 +21,7 @@ class TileLayerBorders(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
override fun act(delta: Float) {}
override fun hit(x: Float, y: Float, touchable: Boolean): Actor? = null
override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha)
private var previousTileOwner: Civilization? = null
private val borderSegments = HashMap<Tile, BorderSegment>()

View File

@ -1,5 +1,6 @@
package com.unciv.ui.components.tilegroups.layers
import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.ui.Image
import com.unciv.logic.civilization.Civilization
@ -22,6 +23,7 @@ class TileLayerFeatures(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup
override fun act(delta: Float) {}
override fun hit(x: Float, y: Float, touchable: Boolean): Actor? = null
override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha)
private fun updateRoadImages() {

View File

@ -1,6 +1,7 @@
package com.unciv.ui.components.tilegroups.layers
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.math.Vector2
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.ui.Image
@ -67,6 +68,8 @@ class TileLayerMisc(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup, si
}
}
override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha)
private val yields = YieldGroup().apply {
// Unlike resource or improvement this is created and added only once,
// It's the contents that get updated

View File

@ -1,6 +1,7 @@
package com.unciv.ui.components.tilegroups.layers
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.ui.Image
import com.unciv.Constants
@ -13,6 +14,7 @@ class TileLayerOverlay(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
override fun act(delta: Float) {}
override fun hit(x: Float, y: Float, touchable: Boolean): Actor? = null
override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha) // perf
private var highlight: Image? = null // for blue and red circles/emphasis on the tile
private var crosshair: Image? = null // for when a unit is targeted

View File

@ -1,6 +1,7 @@
package com.unciv.ui.components.tilegroups.layers
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.math.Vector2
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.ui.Image
@ -17,6 +18,7 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
override fun act(delta: Float) {}
override fun hit(x: Float, y: Float, touchable: Boolean): Actor? = null
override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha)
private val tileBaseImages: ArrayList<Image> = ArrayList()
private var tileImageIdentifiers = listOf<String>()

View File

@ -9,10 +9,10 @@ import com.unciv.logic.civilization.Civilization
import com.unciv.logic.map.mapunit.MapUnit
import com.unciv.models.ruleset.unique.LocalUniqueCache
import com.unciv.models.translations.tr
import com.unciv.ui.components.widgets.UnitIconGroup
import com.unciv.ui.components.extensions.center
import com.unciv.ui.components.extensions.toLabel
import com.unciv.ui.components.tilegroups.TileGroup
import com.unciv.ui.components.widgets.UnitIconGroup
import com.unciv.ui.images.ImageGetter
import com.unciv.ui.screens.basescreen.BaseScreen

View File

@ -21,6 +21,10 @@ class TileLayerUnitSprite(tileGroup: TileGroup, size: Float) : TileLayer(tileGro
override fun act(delta: Float) {}
override fun hit(x: Float, y: Float, touchable: Boolean): Actor? = null
override fun draw(batch: Batch?, parentAlpha: Float) {
if (civilianSlot.imageLocation.isEmpty() && militarySlot.imageLocation.isEmpty()) return
super.draw(batch, parentAlpha)
}
private var civilianSlot: UnitSpriteSlot = UnitSpriteSlot()
private var militarySlot: UnitSpriteSlot = UnitSpriteSlot()
@ -94,9 +98,4 @@ class TileLayerUnitSprite(tileGroup: TileGroup, size: Float) : TileLayer(tileGro
civilianSlot.imageLocation = ""
militarySlot.imageLocation = ""
}
override fun draw(batch: Batch?, parentAlpha: Float) {
if (civilianSlot.imageLocation.isEmpty() && militarySlot.imageLocation.isEmpty()) return
super.draw(batch, parentAlpha)
}
}

View File

@ -1,6 +1,7 @@
package com.unciv.ui.screens.worldscreen
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.Touchable
import com.badlogic.gdx.scenes.scene2d.actions.Actions
@ -490,11 +491,13 @@ class NotificationsScroll(
// Actions are blocked while update() is rebuilding the UI elements - to be safe from unexpected state changes
if (!blockAct) super.act(delta)
}
override fun draw(batch: Batch?, parentAlpha: Float) = super.draw(batch, parentAlpha)
}
private fun getUserSettingCheckDisabled(): Boolean {
val settingString = GUI.getSettings().notificationScroll
val setting = UserSetting.values().firstOrNull { it.name == settingString }
val setting = UserSetting.entries.firstOrNull { it.name == settingString }
?: UserSetting.default()
userSettingChanged = false
if (setting == userSetting)