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 (viewingCiv==null && !showEntireMap) return listOf(tileSetStrings.hexagon)
|
||||||
|
|
||||||
if (tileInfo.isCityCenter()) {
|
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))
|
if (ImageGetter.imageExists(terrainAndCity))
|
||||||
return listOf(terrainAndCity)
|
return listOf(terrainAndCity)
|
||||||
|
|
||||||
|
// val cityWithEra = tileSetStrings.getCityTile()
|
||||||
if (ImageGetter.imageExists(tileSetStrings.cityTile))
|
if (ImageGetter.imageExists(tileSetStrings.cityTile))
|
||||||
return listOf(tileSetStrings.cityTile)
|
return listOf(tileSetStrings.cityTile)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,53 +5,58 @@ import com.unciv.UncivGame
|
||||||
class TileSetStrings {
|
class TileSetStrings {
|
||||||
// this is so that when we have 100s of TileGroups, they won't all individually come up with all these strings themselves,
|
// 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)
|
// 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 hexagon = tileSetLocation + "Hexagon"
|
||||||
val crosshatchHexagon = tileSetLocation+"CrosshatchHexagon"
|
val crosshatchHexagon = tileSetLocation + "CrosshatchHexagon"
|
||||||
val cityOverlay = tileSetLocation+"CityOverlay"
|
val cityOverlay = tileSetLocation + "CityOverlay"
|
||||||
val railroad = tileSetLocation+"Railroad"
|
val railroad = tileSetLocation + "Railroad"
|
||||||
val naturalWonderOverlay = tileSetLocation+"NaturalWonderOverlay"
|
val naturalWonderOverlay = tileSetLocation + "NaturalWonderOverlay"
|
||||||
|
|
||||||
val tilesLocation = tileSetLocation+"Tiles/"
|
val tilesLocation = tileSetLocation + "Tiles/"
|
||||||
val cityTile = tilesLocation+"City"
|
val cityTile = tilesLocation + "City"
|
||||||
val bottomRightRiver = tilesLocation+"River-BottomRight"
|
val bottomRightRiver = tilesLocation + "River-BottomRight"
|
||||||
val bottomRiver = tilesLocation+"River-Bottom"
|
val bottomRiver = tilesLocation + "River-Bottom"
|
||||||
val bottomLeftRiver = tilesLocation+"River-BottomLeft"
|
val bottomLeftRiver = tilesLocation + "River-BottomLeft"
|
||||||
|
|
||||||
val unitsLocation = tileSetLocation+"Units/"
|
val unitsLocation = tileSetLocation + "Units/"
|
||||||
val landUnit = unitsLocation+"LandUnit"
|
val landUnit = unitsLocation + "LandUnit"
|
||||||
val waterUnit = unitsLocation+"WaterUnit"
|
val waterUnit = unitsLocation + "WaterUnit"
|
||||||
|
|
||||||
private val baseTerrainToTile = HashMap<String,String>()
|
// 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!
|
||||||
fun getTile(baseTerrain:String): String {
|
// In order to save on space, we have this function that gets several strings and returns their concat,
|
||||||
if(!baseTerrainToTile.containsKey(baseTerrain))
|
// but is able to retrieve the existing concat if it exists, letting us essentially save each string exactly once.
|
||||||
baseTerrainToTile[baseTerrain] = "$tilesLocation$baseTerrain"
|
private val hashmap = HashMap<Pair<String, String>, String>()
|
||||||
return baseTerrainToTile[baseTerrain]!!
|
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 getCityTile(baseTerrain: String?, era: String?): String {
|
||||||
fun getBaseTerrainOverlay(baseTerrain:String): String {
|
if (baseTerrain != null && era != null) getString(tilesLocation, baseTerrain, city, tag, era)
|
||||||
if(!baseTerrainToOverlay.containsKey(baseTerrain))
|
if (era != null) return getString(tilesLocation, city, tag, era)
|
||||||
baseTerrainToOverlay[baseTerrain] = "$tileSetLocation$baseTerrain"+"Overlay"
|
if (baseTerrain != null) return getString(tilesLocation, baseTerrain, "+", city)
|
||||||
return baseTerrainToOverlay[baseTerrain]!!
|
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