mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-30 14:48:56 +07:00
More tilegroup performance improvements - Only run orFallback once per TileSetStrings and not for every tilegroup
We should probably have a dictionary of "original string to actual string" where orFallback only actually runs if the key isn't in the dictionary yet, otherwise it returns the stored value
This commit is contained in:
@ -123,9 +123,9 @@ open class TileGroup(var tileInfo: TileInfo, val tileSetStrings:TileSetStrings,
|
||||
touchable = Touchable.childrenOnly; setOrigin(Align.center) }
|
||||
|
||||
val highlightCrosshairFogLayerGroup = ActionlessGroup().apply { isTransform = false; setSize(groupSize, groupSize) }
|
||||
val highlightImage = ImageGetter.getImage(tileSetStrings.orFallback { getString(tileSetLocation, "Highlight") }) // for blue and red circles/emphasis on the tile
|
||||
private val crosshairImage = ImageGetter.getImage(tileSetStrings.orFallback { getString(tileSetLocation, "Crosshair") }) // for when a unit is targeted
|
||||
private val fogImage = ImageGetter.getImage(tileSetStrings.orFallback { crosshatchHexagon } )
|
||||
val highlightImage = ImageGetter.getImage(tileSetStrings.highlight) // for blue and red circles/emphasis on the tile
|
||||
private val crosshairImage = ImageGetter.getImage(tileSetStrings.crosshair) // for when a unit is targeted
|
||||
private val fogImage = ImageGetter.getImage(tileSetStrings.crosshatchHexagon )
|
||||
|
||||
/**
|
||||
* Class for representing an arrow to add to the map at this tile.
|
||||
@ -730,9 +730,9 @@ open class TileGroup(var tileInfo: TileInfo, val tileSetStrings:TileSetStrings,
|
||||
private var bottomLeftRiverImage :Image?=null
|
||||
|
||||
private fun updateRivers(displayBottomRight:Boolean, displayBottom:Boolean, displayBottomLeft:Boolean){
|
||||
bottomRightRiverImage = updateRiver(bottomRightRiverImage,displayBottomRight, tileSetStrings.orFallback { bottomRightRiver })
|
||||
bottomRiverImage = updateRiver(bottomRiverImage, displayBottom, tileSetStrings.orFallback { bottomRiver })
|
||||
bottomLeftRiverImage = updateRiver(bottomLeftRiverImage, displayBottomLeft, tileSetStrings.orFallback { bottomLeftRiver })
|
||||
bottomRightRiverImage = updateRiver(bottomRightRiverImage,displayBottomRight, tileSetStrings.bottomRightRiver)
|
||||
bottomRiverImage = updateRiver(bottomRiverImage, displayBottom, tileSetStrings.bottomRiver)
|
||||
bottomLeftRiverImage = updateRiver(bottomLeftRiverImage, displayBottomLeft, tileSetStrings.bottomLeftRiver)
|
||||
}
|
||||
|
||||
private fun updateRiver(currentImage:Image?, shouldDisplay:Boolean,imageName:String): Image? {
|
||||
|
@ -20,7 +20,9 @@ class TileSetStrings(tileSet: String = UncivGame.Current.settings.tileSet, fallb
|
||||
// These need to be by lazy since the orFallback expects a tileset, which it may not get.
|
||||
val hexagon: String by lazy { orFallback {tileSetLocation + "Hexagon"} }
|
||||
val hexagonList by lazy { listOf(hexagon) }
|
||||
val crosshatchHexagon = tileSetLocation + "CrosshatchHexagon"
|
||||
val crosshatchHexagon by lazy { orFallback { tileSetLocation + "CrosshatchHexagon" } }
|
||||
val crosshair by lazy { orFallback { getString(tileSetLocation, "Crosshair") } }
|
||||
val highlight by lazy { orFallback { getString(tileSetLocation, "Highlight") } }
|
||||
val cityOverlay = tileSetLocation + "CityOverlay"
|
||||
val roadsMap = RoadStatus.values()
|
||||
.filterNot { it == RoadStatus.None }
|
||||
@ -29,10 +31,9 @@ class TileSetStrings(tileSet: String = UncivGame.Current.settings.tileSet, fallb
|
||||
|
||||
val tilesLocation = tileSetLocation + "Tiles/"
|
||||
val cityTile = tilesLocation + "City"
|
||||
val bottomRightRiver = tilesLocation + "River-BottomRight"
|
||||
val bottomRiver = tilesLocation + "River-Bottom"
|
||||
val bottomLeftRiver = tilesLocation + "River-BottomLeft"
|
||||
|
||||
val bottomRightRiver by lazy { orFallback { tilesLocation + "River-BottomRight"} }
|
||||
val bottomRiver by lazy { orFallback { tilesLocation + "River-Bottom"} }
|
||||
val bottomLeftRiver by lazy { orFallback { tilesLocation + "River-BottomLeft"} }
|
||||
val unitsLocation = tileSetLocation + "Units/"
|
||||
val landUnit = unitsLocation + "LandUnit"
|
||||
val waterUnit = unitsLocation + "WaterUnit"
|
||||
|
Reference in New Issue
Block a user