Better Civ icons

This commit is contained in:
Yair Morgenstern
2019-11-05 12:51:05 +02:00
parent 1e403442f7
commit 8226304097
4 changed files with 16 additions and 17 deletions

View File

@ -134,8 +134,8 @@ fun Actor.onClick(function: () -> Unit): Actor {
return this return this
} }
fun Actor.surroundWithCircle(size:Float): IconCircleGroup { fun Actor.surroundWithCircle(size:Float,resizeActor:Boolean=true): IconCircleGroup {
return IconCircleGroup(size,this) return IconCircleGroup(size,this,resizeActor)
} }
fun Actor.addBorder(size:Float,color:Color):Table{ fun Actor.addBorder(size:Float,color:Color):Table{

View File

@ -3,14 +3,14 @@ package com.unciv.ui.utils
import com.badlogic.gdx.scenes.scene2d.Actor import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.Group import com.badlogic.gdx.scenes.scene2d.Group
class IconCircleGroup(size:Float, val image: Actor): Group(){ class IconCircleGroup(size:Float, val actor: Actor, resizeActor:Boolean=true): Group(){
val circle = ImageGetter.getCircle().apply { setSize(size, size) } val circle = ImageGetter.getCircle().apply { setSize(size, size) }
init { init {
isTransform=false // performance helper - nothing here is rotated or scaled isTransform=false // performance helper - nothing here is rotated or scaled
setSize(size, size) setSize(size, size)
addActor(circle) addActor(circle)
image.setSize(size * 0.75f, size * 0.75f) if(resizeActor) actor.setSize(size * 0.75f, size * 0.75f)
image.center(this) actor.center(this)
addActor(image) addActor(actor)
} }
} }

View File

@ -85,19 +85,18 @@ object ImageGetter {
} }
fun getNationIndicator(nation: Nation, size:Float): IconCircleGroup { fun getNationIndicator(nation: Nation, size:Float): IconCircleGroup {
val civIndicator = getCircle().apply { color = nation.getOuterColor() }
.surroundWithCircle(size).apply { circle.color = nation.getInnerColor() }
val civIconName = if(nation.isCityState()) "CityState" else nation.name val civIconName = if(nation.isCityState()) "CityState" else nation.name
if(nationIconExists(civIconName)){ if(nationIconExists(civIconName)){
val cityStateIcon = getNationIcon(civIconName) val cityStateIcon = getNationIcon(civIconName)
cityStateIcon.setSize(size*0.7f,size*0.7f)
cityStateIcon.center(civIndicator)
cityStateIcon.color = nation.getInnerColor() cityStateIcon.color = nation.getInnerColor()
civIndicator.addActor(cityStateIcon) return cityStateIcon.surroundWithCircle(size*0.9f).apply { circle.color = nation.getOuterColor() }
.surroundWithCircle(size,false).apply { circle.color=nation.getInnerColor() }
} }
else{
return getCircle().apply { color = nation.getOuterColor() }
.surroundWithCircle(size).apply { circle.color = nation.getInnerColor() }
return civIndicator }
} }
fun nationIconExists(nation:String) = imageExists("NationIcons/$nation") fun nationIconExists(nation:String) = imageExists("NationIcons/$nation")

View File

@ -116,20 +116,20 @@ class MinimapHolder(tileMapHolder: TileMapHolder): Table(){
val populationImage = ImageGetter.getStatIcon("Population").surroundWithCircle(40f) val populationImage = ImageGetter.getStatIcon("Population").surroundWithCircle(40f)
populationImage.circle.color = Color.BLACK populationImage.circle.color = Color.BLACK
populationImage.image.color.a = if(settings.showWorkedTiles) 1f else 0.5f populationImage.actor.color.a = if(settings.showWorkedTiles) 1f else 0.5f
populationImage.onClick { populationImage.onClick {
settings.showWorkedTiles = !settings.showWorkedTiles settings.showWorkedTiles = !settings.showWorkedTiles
populationImage.image.color.a = if(settings.showWorkedTiles) 1f else 0.5f populationImage.actor.color.a = if(settings.showWorkedTiles) 1f else 0.5f
worldScreen.shouldUpdate=true worldScreen.shouldUpdate=true
} }
toggleIconTable.add(populationImage).row() toggleIconTable.add(populationImage).row()
val resourceImage = ImageGetter.getResourceImage("Cattle",30f).surroundWithCircle(40f) val resourceImage = ImageGetter.getResourceImage("Cattle",30f).surroundWithCircle(40f)
resourceImage.circle.color = Color.BLACK resourceImage.circle.color = Color.BLACK
resourceImage.image.color.a = if(settings.showResourcesAndImprovements) 1f else 0.5f resourceImage.actor.color.a = if(settings.showResourcesAndImprovements) 1f else 0.5f
resourceImage.onClick { resourceImage.onClick {
settings.showResourcesAndImprovements = !settings.showResourcesAndImprovements settings.showResourcesAndImprovements = !settings.showResourcesAndImprovements
resourceImage.image.color.a = if(settings.showResourcesAndImprovements) 1f else 0.5f resourceImage.actor.color.a = if(settings.showResourcesAndImprovements) 1f else 0.5f
worldScreen.shouldUpdate=true worldScreen.shouldUpdate=true
} }
toggleIconTable.add(resourceImage) toggleIconTable.add(resourceImage)