mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 14:24:43 -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) {
|
for (tileGroup in cityTileGroups) {
|
||||||
val tileInfo = tileGroup.tileInfo
|
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 {
|
tileGroup.onClick {
|
||||||
selectedTile = tileInfo
|
selectedTile = tileInfo
|
||||||
if (shouldToggleTilesWorked) {
|
if (tileGroup.isWorkable) {
|
||||||
if (!tileInfo.isWorked() && city.population.getFreePopulation() > 0)
|
if (!tileInfo.isWorked() && city.population.getFreePopulation() > 0)
|
||||||
city.workedTiles.add(tileInfo.position)
|
city.workedTiles.add(tileInfo.position)
|
||||||
else if (tileInfo.isWorked()) city.workedTiles.remove(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) {
|
class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo) : TileGroup(tileInfo) {
|
||||||
|
|
||||||
|
var isWorkable = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
isTransform=false // performance helper - nothing here is rotated or scaled
|
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)
|
addActor(populationImage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun update() {
|
fun update() {
|
||||||
@ -31,12 +31,33 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo) : TileGroup(
|
|||||||
|| (!tileInfo.hasEnemySubmarine())
|
|| (!tileInfo.hasEnemySubmarine())
|
||||||
super.update(canSeeTile,true, showSubmarine)
|
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 (improvementImage != null) improvementImage!!.setColor(1f, 1f, 1f, 0.5f)
|
||||||
if (resourceImage != null) resourceImage!!.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 (cityImage != null) cityImage!!.setColor(1f, 1f, 1f, 0.5f)
|
||||||
if (civilianUnitImage != null) civilianUnitImage!!.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)
|
if (militaryUnitImage!= null) militaryUnitImage!!.setColor(1f, 1f, 1f, 0.5f)
|
||||||
|
updatePopulationImage()
|
||||||
updateYieldGroup()
|
updateYieldGroup()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +68,13 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo) : TileGroup(
|
|||||||
yieldGroup.toFront()
|
yieldGroup.toFront()
|
||||||
yieldGroup.centerX(this)
|
yieldGroup.centerX(this)
|
||||||
yieldGroup.y= height * 0.25f - yieldGroup.height / 2
|
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() {
|
private fun updatePopulationImage() {
|
||||||
@ -59,12 +87,11 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo) : TileGroup(
|
|||||||
populationImage!!.color = Color.WHITE
|
populationImage!!.color = Color.WHITE
|
||||||
}
|
}
|
||||||
else if(!tileInfo.isCityCenter()){
|
else if(!tileInfo.isCityCenter()){
|
||||||
populationImage!!.color = Color.GRAY.cpy().apply { a=0.5f }
|
populationImage!!.color = Color.GRAY.cpy()
|
||||||
}
|
}
|
||||||
|
|
||||||
populationImage!!.toFront()
|
populationImage!!.toFront()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user