diff --git a/core/src/com/unciv/ui/cityscreen/CityScreen.kt b/core/src/com/unciv/ui/cityscreen/CityScreen.kt index 2cabee20e0..13cba2884a 100644 --- a/core/src/com/unciv/ui/cityscreen/CityScreen.kt +++ b/core/src/com/unciv/ui/cityscreen/CityScreen.kt @@ -186,30 +186,9 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() { for (tileGroup in cityTileGroups) { val tileInfo = tileGroup.tileInfo - // this needs to happen on update, because we can buy tiles, which changes the definition of the bought tiles... - var shouldToggleTilesWorked = false - when { - tileInfo.getCity()!=city -> // outside of city - if(city.canAcquireTile(tileInfo)){ - tileGroup.addAcquirableIcon() - tileGroup.yieldGroup.isVisible = false - } else { - tileGroup.setColor(0f, 0f, 0f, 0.3f) - tileGroup.yieldGroup.isVisible = false - } - - tileInfo !in tilesInRange -> // within city but not close enough to be workable - tileGroup.yieldGroup.isVisible = false - - !tileInfo.isCityCenter() && tileGroup.populationImage==null -> { // workable - tileGroup.addPopulationIcon() - shouldToggleTilesWorked=true - } - } - tileGroup.onClick { selectedTile = tileInfo - if (shouldToggleTilesWorked) { + if (tileGroup.isWorkable) { if (!tileInfo.isWorked() && city.population.getFreePopulation() > 0) city.workedTiles.add(tileInfo.position) else if (tileInfo.isWorked()) city.workedTiles.remove(tileInfo.position) diff --git a/core/src/com/unciv/ui/cityscreen/CityTileGroup.kt b/core/src/com/unciv/ui/cityscreen/CityTileGroup.kt index 37c6bda098..add21df0b8 100644 --- a/core/src/com/unciv/ui/cityscreen/CityTileGroup.kt +++ b/core/src/com/unciv/ui/cityscreen/CityTileGroup.kt @@ -11,6 +11,7 @@ import com.unciv.ui.utils.centerX class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo) : TileGroup(tileInfo) { + var isWorkable = false init { isTransform=false // performance helper - nothing here is rotated or scaled @@ -20,7 +21,6 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo) : TileGroup( addActor(populationImage) } - } fun update() { @@ -31,12 +31,33 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo) : TileGroup( || (!tileInfo.hasEnemySubmarine()) super.update(canSeeTile,true, showSubmarine) - updatePopulationImage() + // this needs to happen on update, because we can buy tiles, which changes the definition of the bought tiles... + when { + tileInfo.getCity()!=city -> { // outside of city + baseLayerGroup.color.a = 0.3f + yieldGroup.isVisible = false + if (city.canAcquireTile(tileInfo)) + addAcquirableIcon() + } + + tileInfo !in city.getTilesInRange() -> { // within city but not close enough to be workable + yieldGroup.isVisible = false + baseLayerGroup.color.a = 0.5f + } + + !tileInfo.isCityCenter() && populationImage==null -> { // workable + addPopulationIcon() + isWorkable=true + } + } + + featureLayerGroup.color.a=0.5f 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) + updatePopulationImage() updateYieldGroup() } @@ -47,6 +68,13 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo) : TileGroup( yieldGroup.toFront() yieldGroup.centerX(this) yieldGroup.y= height * 0.25f - yieldGroup.height / 2 + + if (tileInfo.isWorked() || city.canAcquireTile(tileInfo)) { + yieldGroup.color = Color.WHITE + } + else if(!tileInfo.isCityCenter()){ + yieldGroup.color = Color.GRAY.cpy().apply { a=0.5f } + } } private fun updatePopulationImage() { @@ -59,12 +87,11 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo) : TileGroup( populationImage!!.color = Color.WHITE } else if(!tileInfo.isCityCenter()){ - populationImage!!.color = Color.GRAY.cpy().apply { a=0.5f } + populationImage!!.color = Color.GRAY.cpy() } populationImage!!.toFront() } } - } \ No newline at end of file