From 8226304097ff4cd0f2f537d79210038d9adc9d92 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 5 Nov 2019 12:51:05 +0200 Subject: [PATCH] Better Civ icons --- .../src/com/unciv/ui/utils/CameraStageBaseScreen.kt | 4 ++-- core/src/com/unciv/ui/utils/IconCircleGroup.kt | 8 ++++---- core/src/com/unciv/ui/utils/ImageGetter.kt | 13 ++++++------- core/src/com/unciv/ui/worldscreen/Minimap.kt | 8 ++++---- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt index 1235298be6..4a751d8e92 100644 --- a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt +++ b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt @@ -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{ diff --git a/core/src/com/unciv/ui/utils/IconCircleGroup.kt b/core/src/com/unciv/ui/utils/IconCircleGroup.kt index ae48dac2b1..3d38da3bc9 100644 --- a/core/src/com/unciv/ui/utils/IconCircleGroup.kt +++ b/core/src/com/unciv/ui/utils/IconCircleGroup.kt @@ -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) } } \ No newline at end of file diff --git a/core/src/com/unciv/ui/utils/ImageGetter.kt b/core/src/com/unciv/ui/utils/ImageGetter.kt index 696cb24e32..ce0862683c 100644 --- a/core/src/com/unciv/ui/utils/ImageGetter.kt +++ b/core/src/com/unciv/ui/utils/ImageGetter.kt @@ -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") diff --git a/core/src/com/unciv/ui/worldscreen/Minimap.kt b/core/src/com/unciv/ui/worldscreen/Minimap.kt index 6af1b9fa7f..d2cf09e5b5 100644 --- a/core/src/com/unciv/ui/worldscreen/Minimap.kt +++ b/core/src/com/unciv/ui/worldscreen/Minimap.kt @@ -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)