Code for era-based city images is go, the current era city images hide the rivers behind them so it's temporarily disabled

This commit is contained in:
Yair Morgenstern 2020-06-10 22:00:32 +03:00
parent 86d54bd3fe
commit 1961aa7245
7 changed files with 298 additions and 260 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 444 KiB

After

Width:  |  Height:  |  Size: 448 KiB

View file

@ -139,9 +139,21 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
if (viewingCiv==null && !showEntireMap) return listOf(tileSetStrings.hexagon)
if (tileInfo.isCityCenter()) {
val terrainAndCity = tileSetStrings.getCityTile(tileInfo.baseTerrain)
// Temporarily disabled until we can see the rivers behind the era cities =)
// val era = tileInfo.getOwner()!!.getEra()
// val terrainAndCityWithEra = tileSetStrings.getCityTile(tileInfo.baseTerrain, era)
// if (ImageGetter.imageExists(terrainAndCityWithEra))
// return listOf(terrainAndCityWithEra)
//
// val cityWithEra = tileSetStrings.getCityTile(null, era)
// if (ImageGetter.imageExists(cityWithEra))
// return listOf(cityWithEra)
val terrainAndCity = tileSetStrings.getCityTile(tileInfo.baseTerrain, null)
if (ImageGetter.imageExists(terrainAndCity))
return listOf(terrainAndCity)
// val cityWithEra = tileSetStrings.getCityTile()
if (ImageGetter.imageExists(tileSetStrings.cityTile))
return listOf(tileSetStrings.cityTile)
}

View file

@ -5,53 +5,58 @@ import com.unciv.UncivGame
class TileSetStrings {
// this is so that when we have 100s of TileGroups, they won't all individually come up with all these strings themselves,
// it gets pretty memory-intensive (10s of MBs which is a lot for lower-end phones)
val tileSetLocation = "TileSets/"+ UncivGame.Current.settings.tileSet +"/"
val tileSetLocation = "TileSets/" + UncivGame.Current.settings.tileSet + "/"
val hexagon = tileSetLocation+"Hexagon"
val crosshatchHexagon = tileSetLocation+"CrosshatchHexagon"
val cityOverlay = tileSetLocation+"CityOverlay"
val railroad = tileSetLocation+"Railroad"
val naturalWonderOverlay = tileSetLocation+"NaturalWonderOverlay"
val hexagon = tileSetLocation + "Hexagon"
val crosshatchHexagon = tileSetLocation + "CrosshatchHexagon"
val cityOverlay = tileSetLocation + "CityOverlay"
val railroad = tileSetLocation + "Railroad"
val naturalWonderOverlay = tileSetLocation + "NaturalWonderOverlay"
val tilesLocation = tileSetLocation+"Tiles/"
val cityTile = tilesLocation+"City"
val bottomRightRiver = tilesLocation+"River-BottomRight"
val bottomRiver = tilesLocation+"River-Bottom"
val bottomLeftRiver = tilesLocation+"River-BottomLeft"
val tilesLocation = tileSetLocation + "Tiles/"
val cityTile = tilesLocation + "City"
val bottomRightRiver = tilesLocation + "River-BottomRight"
val bottomRiver = tilesLocation + "River-Bottom"
val bottomLeftRiver = tilesLocation + "River-BottomLeft"
val unitsLocation = tileSetLocation+"Units/"
val landUnit = unitsLocation+"LandUnit"
val waterUnit = unitsLocation+"WaterUnit"
val unitsLocation = tileSetLocation + "Units/"
val landUnit = unitsLocation + "LandUnit"
val waterUnit = unitsLocation + "WaterUnit"
private val baseTerrainToTile = HashMap<String,String>()
fun getTile(baseTerrain:String): String {
if(!baseTerrainToTile.containsKey(baseTerrain))
baseTerrainToTile[baseTerrain] = "$tilesLocation$baseTerrain"
return baseTerrainToTile[baseTerrain]!!
// There aren't that many tile combinations, and so we end up joining the same strings over and over again.
// On large maps, this can end up as quite a lot of space, some tens of MB!
// In order to save on space, we have this function that gets several strings and returns their concat,
// but is able to retrieve the existing concat if it exists, letting us essentially save each string exactly once.
private val hashmap = HashMap<Pair<String, String>, String>()
fun getString(vararg strings: String): String {
var currentString = ""
for (str in strings) {
if (currentString == "") {
currentString = str
continue
}
val pair = Pair(currentString, str)
if (hashmap.containsKey(pair)) currentString = hashmap[pair]!!
else {
val newString = currentString + str
hashmap[pair] = newString
currentString = newString
}
}
return currentString
}
val overlay = "Overlay"
val city = "City"
val tag = "-"
fun getTile(baseTerrain: String) = getString(tilesLocation, baseTerrain)
fun getBaseTerrainOverlay(baseTerrain: String) = getString(tileSetLocation, baseTerrain, overlay)
fun getTerrainFeatureOverlay(terrainFeature: String) = getString(tilesLocation, terrainFeature, overlay)
private val baseTerrainToOverlay = HashMap<String,String>()
fun getBaseTerrainOverlay(baseTerrain:String): String {
if(!baseTerrainToOverlay.containsKey(baseTerrain))
baseTerrainToOverlay[baseTerrain] = "$tileSetLocation$baseTerrain"+"Overlay"
return baseTerrainToOverlay[baseTerrain]!!
fun getCityTile(baseTerrain: String?, era: String?): String {
if (baseTerrain != null && era != null) getString(tilesLocation, baseTerrain, city, tag, era)
if (era != null) return getString(tilesLocation, city, tag, era)
if (baseTerrain != null) return getString(tilesLocation, baseTerrain, "+", city)
else return cityTile
}
private val baseTerrainToCityTile = HashMap<String,String>()
fun getCityTile(baseTerrain:String): String {
if(!baseTerrainToCityTile.containsKey(baseTerrain))
baseTerrainToCityTile[baseTerrain] = "$tilesLocation$baseTerrain+City"
return baseTerrainToCityTile[baseTerrain]!!
}
private val terrainFeatureToOverlay = HashMap<String,String>()
fun getTerrainFeatureOverlay(terrainFeature:String): String {
if(!terrainFeatureToOverlay.containsKey(terrainFeature))
terrainFeatureToOverlay[terrainFeature] = tileSetLocation + terrainFeature +"Overlay"
return terrainFeatureToOverlay[terrainFeature]!!
}
}