diff --git a/core/src/com/unciv/ui/cityscreen/CitizenManagementTable.kt b/core/src/com/unciv/ui/cityscreen/CitizenManagementTable.kt index 5c20a5c80e..c97054c8ff 100644 --- a/core/src/com/unciv/ui/cityscreen/CitizenManagementTable.kt +++ b/core/src/com/unciv/ui/cityscreen/CitizenManagementTable.kt @@ -21,9 +21,12 @@ class CitizenManagementTable(val cityScreen: CityScreen) : Table(BaseScreen.skin val resetLabel = "Reset Citizens".toLabel() val resetCell = Table() resetCell.add(resetLabel).pad(5f) - if (cityScreen.canChangeState) { + if (cityScreen.canCityBeChanged()) { resetCell.touchable = Touchable.enabled - resetCell.onClick { city.reassignPopulation(true); cityScreen.update() } + resetCell.onClick { + city.reassignPopulation(true) + cityScreen.update() + } } resetCell.background = ImageGetter.getBackground(colorButton) add(resetCell).colspan(2).growX().pad(3f) @@ -32,9 +35,13 @@ class CitizenManagementTable(val cityScreen: CityScreen) : Table(BaseScreen.skin val avoidLabel = "Avoid Growth".toLabel() val avoidCell = Table() avoidCell.add(avoidLabel).pad(5f) - if (cityScreen.canChangeState) { + if (cityScreen.canCityBeChanged()) { avoidCell.touchable = Touchable.enabled - avoidCell.onClick { city.avoidGrowth = !city.avoidGrowth; city.reassignPopulation(); cityScreen.update() } + avoidCell.onClick { + city.avoidGrowth = !city.avoidGrowth + city.reassignPopulation() + cityScreen.update() + } } avoidCell.background = ImageGetter.getBackground(if (city.avoidGrowth) colorSelected else colorButton) add(avoidCell).colspan(2).growX().pad(3f) @@ -47,10 +54,12 @@ class CitizenManagementTable(val cityScreen: CityScreen) : Table(BaseScreen.skin val label = focus.label.toLabel() val cell = Table() cell.add(label).pad(5f) - if (cityScreen.canChangeState) { + if (cityScreen.canCityBeChanged()) { cell.touchable = Touchable.enabled cell.onClick { - city.cityAIFocus = focus; city.reassignPopulation(); cityScreen.update() + city.cityAIFocus = focus + city.reassignPopulation() + cityScreen.update() } } cell.background = ImageGetter.getBackground(if (city.cityAIFocus == focus) colorSelected else colorButton) diff --git a/core/src/com/unciv/ui/cityscreen/CityConstructionsTable.kt b/core/src/com/unciv/ui/cityscreen/CityConstructionsTable.kt index b7b2461431..776d77f166 100644 --- a/core/src/com/unciv/ui/cityscreen/CityConstructionsTable.kt +++ b/core/src/com/unciv/ui/cityscreen/CityConstructionsTable.kt @@ -371,7 +371,7 @@ class CityConstructionsTable(private val cityScreen: CityScreen) { if (isSelectedQueueEntry()) { button = "Remove from queue".toTextButton() - if (!cityScreen.canChangeState || city.isPuppet) + if (!cityScreen.canCityBeChanged()) button.disable() else { button.onClick { @@ -561,7 +561,7 @@ class CityConstructionsTable(private val cityScreen: CityScreen) { private fun getRaisePriorityButton(constructionQueueIndex: Int, name: String, city: CityInfo): Table { val tab = Table() tab.add(ImageGetter.getArrowImage(Align.top).apply { color = Color.BLACK }.surroundWithCircle(40f)) - if (cityScreen.canChangeState && !city.isPuppet) { + if (cityScreen.canCityBeChanged()) { tab.touchable = Touchable.enabled tab.onClick { tab.touchable = Touchable.disabled @@ -577,7 +577,7 @@ class CityConstructionsTable(private val cityScreen: CityScreen) { private fun getLowerPriorityButton(constructionQueueIndex: Int, name: String, city: CityInfo): Table { val tab = Table() tab.add(ImageGetter.getArrowImage(Align.bottom).apply { color = Color.BLACK }.surroundWithCircle(40f)) - if (cityScreen.canChangeState && !city.isPuppet) { + if (cityScreen.canCityBeChanged()) { tab.touchable = Touchable.enabled tab.onClick { tab.touchable = Touchable.disabled @@ -593,7 +593,7 @@ class CityConstructionsTable(private val cityScreen: CityScreen) { private fun getRemoveFromQueueButton(constructionQueueIndex: Int, city: CityInfo): Table { val tab = Table() tab.add(ImageGetter.getImage("OtherIcons/Stop").surroundWithCircle(40f)) - if (cityScreen.canChangeState && !city.isPuppet) { + if (cityScreen.canCityBeChanged()) { tab.touchable = Touchable.enabled tab.onClick { tab.touchable = Touchable.disabled diff --git a/core/src/com/unciv/ui/cityscreen/CityScreen.kt b/core/src/com/unciv/ui/cityscreen/CityScreen.kt index 8e289932b7..418b5ce0ca 100644 --- a/core/src/com/unciv/ui/cityscreen/CityScreen.kt +++ b/core/src/com/unciv/ui/cityscreen/CityScreen.kt @@ -191,6 +191,10 @@ class CityScreen( } } + fun canCityBeChanged(): Boolean { + return canChangeState && !city.isPuppet + } + private fun updateTileGroups() { fun isExistingImprovementValuable(tileInfo: TileInfo, improvementToPlace: TileImprovement): Boolean { if (tileInfo.improvement == null) return false diff --git a/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt b/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt index 3b66a7d3ce..1e982505d4 100644 --- a/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt +++ b/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt @@ -56,7 +56,7 @@ class CityStatsTable(val cityScreen: CityScreen): Table() { val icon = Table() if (cityInfo.cityAIFocus.stat == stat) { icon.add(ImageGetter.getStatIcon(stat.name).surroundWithCircle(27f, false, color = selected)) - if (cityScreen.canChangeState) { + if (cityScreen.canCityBeChanged()) { icon.onClick { cityInfo.cityAIFocus = CityFocus.NoFocus cityInfo.reassignPopulation(); cityScreen.update() @@ -64,7 +64,7 @@ class CityStatsTable(val cityScreen: CityScreen): Table() { } } else { icon.add(ImageGetter.getStatIcon(stat.name).surroundWithCircle(27f, false, color = Color.CLEAR)) - if (cityScreen.canChangeState) { + if (cityScreen.canCityBeChanged()) { icon.onClick { cityInfo.cityAIFocus = cityInfo.cityAIFocus.safeValueOf(stat) cityInfo.reassignPopulation(); cityScreen.update() diff --git a/core/src/com/unciv/ui/cityscreen/SpecialistAllocationTable.kt b/core/src/com/unciv/ui/cityscreen/SpecialistAllocationTable.kt index 878becbb35..f2a495c332 100644 --- a/core/src/com/unciv/ui/cityscreen/SpecialistAllocationTable.kt +++ b/core/src/com/unciv/ui/cityscreen/SpecialistAllocationTable.kt @@ -18,7 +18,7 @@ class SpecialistAllocationTable(val cityScreen: CityScreen) : Table(BaseScreen.s // Auto/Manual Specialists Toggle // Color of "color" coming from Skin.json that's loaded into BaseScreen // 5 columns: unassignButton, AllocationTable, assignButton, SeparatorVertical, SpecialistsStatsTabe - if (cityScreen.canChangeState) { + if (cityScreen.canCityBeChanged()) { if (cityInfo.manualSpecialists) { val manualSpecialists = "Manual Specialists".toLabel() .addBorder(5f, BaseScreen.skin.get("color", Color::class.java))