Replaced city connection icon, luxury resources now have a smiley next to them and strategic resources have a production symbol

This commit is contained in:
Yair Morgenstern
2018-08-27 17:17:14 +03:00
parent 0d630abc14
commit 5d3c7a3a5e
11 changed files with 434 additions and 223 deletions

View File

@ -26,6 +26,8 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo) : TileGroup(
if (improvementImage != null) improvementImage!!.setColor(1f, 1f, 1f, 0.5f)
if (resourceImage != null) resourceImage!!.setColor(1f, 1f, 1f, 0.5f)
if (cityImage != null) cityImage!!.setColor(1f, 1f, 1f, 0.5f)
if (civilianUnitImage != null) civilianUnitImage!!.setColor(1f, 1f, 1f, 0.5f)
if (militaryUnitImage!= null) militaryUnitImage!!.setColor(1f, 1f, 1f, 0.5f)
if (terrainFeatureImage!= null) terrainFeatureImage!!.setColor(1f, 1f, 1f, 0.5f)
updateYieldGroup()
}

View File

@ -1,6 +1,7 @@
package com.unciv.ui.tilegroups
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.Group
import com.badlogic.gdx.scenes.scene2d.ui.Image
import com.badlogic.gdx.utils.Align
@ -20,7 +21,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
protected var terrainFeatureImage:Image?=null
protected var cityImage:Image?=null
protected var resourceImage: Image? = null
protected var resourceImage: Actor? = null
protected var improvementImage: Image? =null
var populationImage: Image? = null
private val roadImages = HashMap<TileInfo, RoadImage>()
@ -301,17 +302,14 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
}
if(resourceImage==null && shouldDisplayResource) { // Need to add the resource image!
val fileName = "ResourceIcons/" + tileInfo.resource + "_(Civ5).png"
resourceImage = ImageGetter.getImage(fileName)
resourceImage!!.setSize(20f, 20f)
resourceImage = ImageGetter.getResourceImage(tileInfo.resource!!,20f)
resourceImage!!.center(this)
resourceImage!!.x -= 22 // left
resourceImage!!.y += 10 // top
resourceImage!!.x = resourceImage!!.x - 22 // left
resourceImage!!.y = resourceImage!!.y + 10 // top
addActor(resourceImage!!)
}
if(resourceImage!=null){
if(viewable) resourceImage!!.color= Color.WHITE
else resourceImage!!.color= Color.WHITE.cpy().apply { a=0.7f }
resourceImage!!.color= Color.WHITE.cpy().apply { a=0.7f }
}
}

View File

@ -73,10 +73,10 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
if (cityButton == null) {
cityButton = Table()
cityButton!!.background = ImageGetter.getDrawable("OtherIcons/civTableBackground.png")
cityButton!!.isTransform = true
cityButton!!.isTransform = true // If this is not set then the city button won't scale!
addActor(cityButton)
zIndex = parent.children.size // so this tile is rendered over neighboring tiles
toFront() // so this tile is rendered over neighboring tiles
}
val cityButtonText = city.name + " (" + city.population.population + ")"
@ -89,7 +89,7 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
cityButton!!.run {
clear()
if(viewable) {
if(viewable && city.health<city.getMaxHealth().toFloat()) {
val healthBarSize = 100f
val healthPercent = city.health / city.getMaxHealth().toFloat()
val healthBar = Table()
@ -107,15 +107,15 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
if(city.isBeingRazed){
val fireImage = ImageGetter.getImage("OtherIcons/Fire.png")
add(fireImage).size(20f).padLeft(5f)
add(fireImage).size(20f).pad(2f).padLeft(5f)
}
if(city.isCapital()){
val starImage = ImageGetter.getImage("OtherIcons/Star.png").apply { color = Color.LIGHT_GRAY}
add(starImage).size(20f).padLeft(5f)
add(starImage).size(20f).pad(2f).padLeft(5f)
}
else if (city.civInfo.isPlayerCivilization() && city.cityStats.isConnectedToCapital(RoadStatus.Road)){
val connectionImage = ImageGetter.getStatIcon("CityConnection")
add(connectionImage).size(20f).padLeft(5f)
add(connectionImage).size(20f).pad(2f).padLeft(5f)
}
else{add()} // this is so the health bar is always 2 columns wide
@ -130,5 +130,4 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
}
}
}

View File

@ -3,9 +3,13 @@ package com.unciv.ui.utils
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.TextureAtlas
import com.badlogic.gdx.graphics.g2d.TextureRegion
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.Group
import com.badlogic.gdx.scenes.scene2d.ui.Image
import com.badlogic.gdx.scenes.scene2d.utils.Drawable
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.tile.ResourceType
object ImageGetter {
const val WhiteDot = "OtherIcons/whiteDot.png"
@ -69,4 +73,34 @@ object ImageGetter {
fun refreshAltas() {
atlas = TextureAtlas("game.atlas")
}
fun getResourceImage(resourceName: String, size:Float): Actor {
val group= Group()
val resource = GameBasics.TileResources[resourceName]!!
val circle = getImage("OtherIcons/Circle").apply { setSize(size,size) }
if(resource.food>0) circle.color= Color.GREEN.cpy().lerp(Color.WHITE,0.5f)
else if(resource.production>0) circle.color= Color.BROWN.cpy().lerp(Color.WHITE,0.5f)
else if(resource.gold>0) circle.color= Color.GOLD.cpy().lerp(Color.WHITE,0.5f)
group.setSize(size,size)
group.addActor(circle)
group.addActor(getImage("ResourceIcons/${resourceName}")
.apply { setSize(size*0.8f,size*0.8f); center(group) })
if(resource.resourceType==ResourceType.Luxury){
val happiness = getStatIcon("Happiness")
happiness.setSize(size/2,size/2)
happiness.x = group.width-happiness.width
// happiness.y = group.height-happiness.height
group.addActor(happiness)
}
if(resource.resourceType==ResourceType.Strategic){
val production = getStatIcon("Production")
production.setSize(size/2,size/2)
production.x = group.width-production.width
// production.y = group.height-production.height
group.addActor(production)
}
return group
return getImage("ResourceIcons/${resourceName}")
}
}

View File

@ -1,6 +1,7 @@
package com.unciv.ui.worldscreen
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.Group
import com.badlogic.gdx.scenes.scene2d.ui.Image
import com.badlogic.gdx.scenes.scene2d.ui.Label
@ -27,9 +28,9 @@ class WorldScreenTopBar(val screen: WorldScreen) : Table() {
private val happinessLabel = Label("Happiness:", labelSkin)
private val cultureLabel = Label("Culture:", labelSkin).setFontColor(colorFromRGB(210, 94, 210) )
private val resourceLabels = HashMap<String, Label>()
private val resourceImages = HashMap<String, Image>()
private val resourceImages = HashMap<String, Actor>()
private val happinessImage = Group()
// These are all to improve performance IE recude update time (was 150 ms on my phone, which is a lot!)
// These are all to improve performance IE reduce update time (was 150 ms on my phone, which is a lot!)
private val malcontentColor = Color.valueOf("ef5350")
val happinessColor = colorFromRGB(92, 194, 77)
val malcontentGroup = ImageGetter.getStatIcon("Malcontent")
@ -58,10 +59,9 @@ class WorldScreenTopBar(val screen: WorldScreen) : Table() {
val revealedStrategicResources = GameBasics.TileResources.values
.filter { it.resourceType == ResourceType.Strategic } // && civInfo.tech.isResearched(it.revealedBy!!) }
for (resource in revealedStrategicResources) {
val fileName = "ResourceIcons/${resource.name}_(Civ5).png"
val resourceImage = ImageGetter.getImage(fileName)
val resourceImage = ImageGetter.getResourceImage(resource.name,20f)
resourceImages.put(resource.name, resourceImage)
resourceTable.add(resourceImage).size(20f)
resourceTable.add(resourceImage)
val resourceLabel = Label("0", labelSkin)
resourceLabels.put(resource.name, resourceLabel)
resourceTable.add(resourceLabel)