mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-21 05:09:25 +07:00
Better Civ icons
This commit is contained in:
@ -134,8 +134,8 @@ fun Actor.onClick(function: () -> Unit): Actor {
|
||||
return this
|
||||
}
|
||||
|
||||
fun Actor.surroundWithCircle(size:Float): IconCircleGroup {
|
||||
return IconCircleGroup(size,this)
|
||||
fun Actor.surroundWithCircle(size:Float,resizeActor:Boolean=true): IconCircleGroup {
|
||||
return IconCircleGroup(size,this,resizeActor)
|
||||
}
|
||||
|
||||
fun Actor.addBorder(size:Float,color:Color):Table{
|
||||
|
@ -3,14 +3,14 @@ package com.unciv.ui.utils
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||
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) }
|
||||
init {
|
||||
isTransform=false // performance helper - nothing here is rotated or scaled
|
||||
setSize(size, size)
|
||||
addActor(circle)
|
||||
image.setSize(size * 0.75f, size * 0.75f)
|
||||
image.center(this)
|
||||
addActor(image)
|
||||
if(resizeActor) actor.setSize(size * 0.75f, size * 0.75f)
|
||||
actor.center(this)
|
||||
addActor(actor)
|
||||
}
|
||||
}
|
@ -85,19 +85,18 @@ object ImageGetter {
|
||||
}
|
||||
|
||||
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
|
||||
if(nationIconExists(civIconName)){
|
||||
val cityStateIcon = getNationIcon(civIconName)
|
||||
cityStateIcon.setSize(size*0.7f,size*0.7f)
|
||||
cityStateIcon.center(civIndicator)
|
||||
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")
|
||||
|
@ -116,20 +116,20 @@ class MinimapHolder(tileMapHolder: TileMapHolder): Table(){
|
||||
|
||||
val populationImage = ImageGetter.getStatIcon("Population").surroundWithCircle(40f)
|
||||
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 {
|
||||
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
|
||||
}
|
||||
toggleIconTable.add(populationImage).row()
|
||||
|
||||
val resourceImage = ImageGetter.getResourceImage("Cattle",30f).surroundWithCircle(40f)
|
||||
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 {
|
||||
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
|
||||
}
|
||||
toggleIconTable.add(resourceImage)
|
||||
|
Reference in New Issue
Block a user