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:
parent
86d54bd3fe
commit
1961aa7245
7 changed files with 298 additions and 260 deletions
BIN
android/Images/TileSets/FantasyHex/Tiles/City-Ancient era.png
Normal file
BIN
android/Images/TileSets/FantasyHex/Tiles/City-Ancient era.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
android/Images/TileSets/FantasyHex/Tiles/City-Classical era.png
Normal file
BIN
android/Images/TileSets/FantasyHex/Tiles/City-Classical era.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
android/Images/TileSets/FantasyHex/Tiles/City-Medieval era.png
Normal file
BIN
android/Images/TileSets/FantasyHex/Tiles/City-Medieval era.png
Normal file
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 |
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -23,35 +23,40 @@ class TileSetStrings {
|
|||
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]!!
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue