mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 15:01:09 -04:00
Memory and performance improvements for tileGroup imagelocation
This commit is contained in:
parent
77dd9f63f6
commit
a495e5c8fe
@ -203,8 +203,9 @@ open class TileGroup(var tileInfo: TileInfo, val tileSetStrings:TileSetStrings,
|
|||||||
crosshairImage.isVisible = true
|
crosshairImage.isVisible = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun getTileBaseImageLocations(viewingCiv: CivilizationInfo?): List<String> {
|
private fun getTileBaseImageLocations(viewingCiv: CivilizationInfo?): List<String> {
|
||||||
if (viewingCiv == null && !showEntireMap) return listOf(tileSetStrings.orFallback { hexagon } )
|
if (viewingCiv == null && !showEntireMap) return tileSetStrings.hexagonList
|
||||||
if (tileInfo.naturalWonder != null) return listOf(tileSetStrings.orFallback { getTile(tileInfo.naturalWonder!!) })
|
if (tileInfo.naturalWonder != null) return listOf(tileSetStrings.orFallback { getTile(tileInfo.naturalWonder!!) })
|
||||||
|
|
||||||
val shownImprovement = tileInfo.getShownImprovement(viewingCiv)
|
val shownImprovement = tileInfo.getShownImprovement(viewingCiv)
|
||||||
@ -213,10 +214,10 @@ open class TileGroup(var tileInfo: TileInfo, val tileSetStrings:TileSetStrings,
|
|||||||
val shouldShowResource = UncivGame.Current.settings.showPixelImprovements && tileInfo.resource != null &&
|
val shouldShowResource = UncivGame.Current.settings.showPixelImprovements && tileInfo.resource != null &&
|
||||||
(showEntireMap || viewingCiv == null || tileInfo.hasViewableResource(viewingCiv))
|
(showEntireMap || viewingCiv == null || tileInfo.hasViewableResource(viewingCiv))
|
||||||
|
|
||||||
var resourceAndImprovementSequence = sequenceOf<String?>()
|
val resourceAndImprovementSequence = sequence {
|
||||||
if (shouldShowResource) resourceAndImprovementSequence += sequenceOf(tileInfo.resource)
|
if (shouldShowResource) yield(tileInfo.resource)
|
||||||
if (shouldShowImprovement) resourceAndImprovementSequence += sequenceOf(shownImprovement)
|
if (shouldShowImprovement) yield(shownImprovement)
|
||||||
resourceAndImprovementSequence = resourceAndImprovementSequence.filterNotNull()
|
}.filterNotNull()
|
||||||
|
|
||||||
val terrainImages = (sequenceOf(tileInfo.baseTerrain) + tileInfo.terrainFeatures.asSequence()).filterNotNull()
|
val terrainImages = (sequenceOf(tileInfo.baseTerrain) + tileInfo.terrainFeatures.asSequence()).filterNotNull()
|
||||||
val allTogether = (terrainImages + resourceAndImprovementSequence).joinToString("+")
|
val allTogether = (terrainImages + resourceAndImprovementSequence).joinToString("+")
|
||||||
@ -296,7 +297,7 @@ open class TileGroup(var tileInfo: TileInfo, val tileSetStrings:TileSetStrings,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tileBaseImages.isEmpty()) { // Absolutely nothing! This is for the 'default' tileset
|
if (tileBaseImages.isEmpty()) { // Absolutely nothing! This is for the 'default' tileset
|
||||||
val image = ImageGetter.getImage(tileSetStrings.orFallback { hexagon })
|
val image = ImageGetter.getImage(tileSetStrings.hexagon)
|
||||||
tileBaseImages.add(image)
|
tileBaseImages.add(image)
|
||||||
baseLayerGroup.addActor(image)
|
baseLayerGroup.addActor(image)
|
||||||
setHexagonImageSize(image)
|
setHexagonImageSize(image)
|
||||||
|
@ -162,7 +162,7 @@ class TileGroupIcons(val tileGroup: TileGroup) {
|
|||||||
|
|
||||||
if (tileGroup.resourceImage != null) { // This could happen on any turn, since resources need certain techs to reveal them
|
if (tileGroup.resourceImage != null) { // This could happen on any turn, since resources need certain techs to reveal them
|
||||||
val shouldDisplayResource =
|
val shouldDisplayResource =
|
||||||
if (tileGroup.showEntireMap) tileGroup.tileInfo.resource != null
|
if (tileGroup.showEntireMap) showResourcesAndImprovements
|
||||||
else showResourcesAndImprovements
|
else showResourcesAndImprovements
|
||||||
&& tileGroup.tileInfo.hasViewableResource(UncivGame.Current.worldScreen.viewingCiv)
|
&& tileGroup.tileInfo.hasViewableResource(UncivGame.Current.worldScreen.viewingCiv)
|
||||||
tileGroup.resourceImage!!.isVisible = shouldDisplayResource
|
tileGroup.resourceImage!!.isVisible = shouldDisplayResource
|
||||||
|
@ -17,13 +17,14 @@ class TileSetStrings(tileSet: String = UncivGame.Current.settings.tileSet, fallb
|
|||||||
val tileSetLocation = "TileSets/$tileSet/"
|
val tileSetLocation = "TileSets/$tileSet/"
|
||||||
val tileSetConfig = TileSetCache[tileSet] ?: TileSetConfig()
|
val tileSetConfig = TileSetCache[tileSet] ?: TileSetConfig()
|
||||||
|
|
||||||
val hexagon = tileSetLocation + "Hexagon"
|
// 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 = tileSetLocation + "CrosshatchHexagon"
|
||||||
val cityOverlay = tileSetLocation + "CityOverlay"
|
val cityOverlay = tileSetLocation + "CityOverlay"
|
||||||
val roadsMap = RoadStatus.values()
|
val roadsMap = RoadStatus.values()
|
||||||
.filterNot { it == RoadStatus.None }
|
.filterNot { it == RoadStatus.None }
|
||||||
.map { it to tileSetLocation + it.name }
|
.associateWith { tileSetLocation + it.name }
|
||||||
.toMap()
|
|
||||||
val naturalWonderOverlay = tileSetLocation + "NaturalWonderOverlay"
|
val naturalWonderOverlay = tileSetLocation + "NaturalWonderOverlay"
|
||||||
|
|
||||||
val tilesLocation = tileSetLocation + "Tiles/"
|
val tilesLocation = tileSetLocation + "Tiles/"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user