mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -04:00
Clearer population toggle in cities
This commit is contained in:
parent
775055902f
commit
e4c7a2698f
@ -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)
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user