mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 05:14:32 -04:00
Disable state-changing buttons for puppet cities (#6975)
This commit is contained in:
parent
f1e3e1b094
commit
97ed9cd668
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user