mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 22:06:05 -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 resetLabel = "Reset Citizens".toLabel()
|
||||||
val resetCell = Table()
|
val resetCell = Table()
|
||||||
resetCell.add(resetLabel).pad(5f)
|
resetCell.add(resetLabel).pad(5f)
|
||||||
if (cityScreen.canChangeState) {
|
if (cityScreen.canCityBeChanged()) {
|
||||||
resetCell.touchable = Touchable.enabled
|
resetCell.touchable = Touchable.enabled
|
||||||
resetCell.onClick { city.reassignPopulation(true); cityScreen.update() }
|
resetCell.onClick {
|
||||||
|
city.reassignPopulation(true)
|
||||||
|
cityScreen.update()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
resetCell.background = ImageGetter.getBackground(colorButton)
|
resetCell.background = ImageGetter.getBackground(colorButton)
|
||||||
add(resetCell).colspan(2).growX().pad(3f)
|
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 avoidLabel = "Avoid Growth".toLabel()
|
||||||
val avoidCell = Table()
|
val avoidCell = Table()
|
||||||
avoidCell.add(avoidLabel).pad(5f)
|
avoidCell.add(avoidLabel).pad(5f)
|
||||||
if (cityScreen.canChangeState) {
|
if (cityScreen.canCityBeChanged()) {
|
||||||
avoidCell.touchable = Touchable.enabled
|
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)
|
avoidCell.background = ImageGetter.getBackground(if (city.avoidGrowth) colorSelected else colorButton)
|
||||||
add(avoidCell).colspan(2).growX().pad(3f)
|
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 label = focus.label.toLabel()
|
||||||
val cell = Table()
|
val cell = Table()
|
||||||
cell.add(label).pad(5f)
|
cell.add(label).pad(5f)
|
||||||
if (cityScreen.canChangeState) {
|
if (cityScreen.canCityBeChanged()) {
|
||||||
cell.touchable = Touchable.enabled
|
cell.touchable = Touchable.enabled
|
||||||
cell.onClick {
|
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)
|
cell.background = ImageGetter.getBackground(if (city.cityAIFocus == focus) colorSelected else colorButton)
|
||||||
|
@ -371,7 +371,7 @@ class CityConstructionsTable(private val cityScreen: CityScreen) {
|
|||||||
|
|
||||||
if (isSelectedQueueEntry()) {
|
if (isSelectedQueueEntry()) {
|
||||||
button = "Remove from queue".toTextButton()
|
button = "Remove from queue".toTextButton()
|
||||||
if (!cityScreen.canChangeState || city.isPuppet)
|
if (!cityScreen.canCityBeChanged())
|
||||||
button.disable()
|
button.disable()
|
||||||
else {
|
else {
|
||||||
button.onClick {
|
button.onClick {
|
||||||
@ -561,7 +561,7 @@ class CityConstructionsTable(private val cityScreen: CityScreen) {
|
|||||||
private fun getRaisePriorityButton(constructionQueueIndex: Int, name: String, city: CityInfo): Table {
|
private fun getRaisePriorityButton(constructionQueueIndex: Int, name: String, city: CityInfo): Table {
|
||||||
val tab = Table()
|
val tab = Table()
|
||||||
tab.add(ImageGetter.getArrowImage(Align.top).apply { color = Color.BLACK }.surroundWithCircle(40f))
|
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.touchable = Touchable.enabled
|
||||||
tab.onClick {
|
tab.onClick {
|
||||||
tab.touchable = Touchable.disabled
|
tab.touchable = Touchable.disabled
|
||||||
@ -577,7 +577,7 @@ class CityConstructionsTable(private val cityScreen: CityScreen) {
|
|||||||
private fun getLowerPriorityButton(constructionQueueIndex: Int, name: String, city: CityInfo): Table {
|
private fun getLowerPriorityButton(constructionQueueIndex: Int, name: String, city: CityInfo): Table {
|
||||||
val tab = Table()
|
val tab = Table()
|
||||||
tab.add(ImageGetter.getArrowImage(Align.bottom).apply { color = Color.BLACK }.surroundWithCircle(40f))
|
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.touchable = Touchable.enabled
|
||||||
tab.onClick {
|
tab.onClick {
|
||||||
tab.touchable = Touchable.disabled
|
tab.touchable = Touchable.disabled
|
||||||
@ -593,7 +593,7 @@ class CityConstructionsTable(private val cityScreen: CityScreen) {
|
|||||||
private fun getRemoveFromQueueButton(constructionQueueIndex: Int, city: CityInfo): Table {
|
private fun getRemoveFromQueueButton(constructionQueueIndex: Int, city: CityInfo): Table {
|
||||||
val tab = Table()
|
val tab = Table()
|
||||||
tab.add(ImageGetter.getImage("OtherIcons/Stop").surroundWithCircle(40f))
|
tab.add(ImageGetter.getImage("OtherIcons/Stop").surroundWithCircle(40f))
|
||||||
if (cityScreen.canChangeState && !city.isPuppet) {
|
if (cityScreen.canCityBeChanged()) {
|
||||||
tab.touchable = Touchable.enabled
|
tab.touchable = Touchable.enabled
|
||||||
tab.onClick {
|
tab.onClick {
|
||||||
tab.touchable = Touchable.disabled
|
tab.touchable = Touchable.disabled
|
||||||
|
@ -191,6 +191,10 @@ class CityScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun canCityBeChanged(): Boolean {
|
||||||
|
return canChangeState && !city.isPuppet
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateTileGroups() {
|
private fun updateTileGroups() {
|
||||||
fun isExistingImprovementValuable(tileInfo: TileInfo, improvementToPlace: TileImprovement): Boolean {
|
fun isExistingImprovementValuable(tileInfo: TileInfo, improvementToPlace: TileImprovement): Boolean {
|
||||||
if (tileInfo.improvement == null) return false
|
if (tileInfo.improvement == null) return false
|
||||||
|
@ -56,7 +56,7 @@ class CityStatsTable(val cityScreen: CityScreen): Table() {
|
|||||||
val icon = Table()
|
val icon = Table()
|
||||||
if (cityInfo.cityAIFocus.stat == stat) {
|
if (cityInfo.cityAIFocus.stat == stat) {
|
||||||
icon.add(ImageGetter.getStatIcon(stat.name).surroundWithCircle(27f, false, color = selected))
|
icon.add(ImageGetter.getStatIcon(stat.name).surroundWithCircle(27f, false, color = selected))
|
||||||
if (cityScreen.canChangeState) {
|
if (cityScreen.canCityBeChanged()) {
|
||||||
icon.onClick {
|
icon.onClick {
|
||||||
cityInfo.cityAIFocus = CityFocus.NoFocus
|
cityInfo.cityAIFocus = CityFocus.NoFocus
|
||||||
cityInfo.reassignPopulation(); cityScreen.update()
|
cityInfo.reassignPopulation(); cityScreen.update()
|
||||||
@ -64,7 +64,7 @@ class CityStatsTable(val cityScreen: CityScreen): Table() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
icon.add(ImageGetter.getStatIcon(stat.name).surroundWithCircle(27f, false, color = Color.CLEAR))
|
icon.add(ImageGetter.getStatIcon(stat.name).surroundWithCircle(27f, false, color = Color.CLEAR))
|
||||||
if (cityScreen.canChangeState) {
|
if (cityScreen.canCityBeChanged()) {
|
||||||
icon.onClick {
|
icon.onClick {
|
||||||
cityInfo.cityAIFocus = cityInfo.cityAIFocus.safeValueOf(stat)
|
cityInfo.cityAIFocus = cityInfo.cityAIFocus.safeValueOf(stat)
|
||||||
cityInfo.reassignPopulation(); cityScreen.update()
|
cityInfo.reassignPopulation(); cityScreen.update()
|
||||||
|
@ -18,7 +18,7 @@ class SpecialistAllocationTable(val cityScreen: CityScreen) : Table(BaseScreen.s
|
|||||||
// Auto/Manual Specialists Toggle
|
// Auto/Manual Specialists Toggle
|
||||||
// Color of "color" coming from Skin.json that's loaded into BaseScreen
|
// Color of "color" coming from Skin.json that's loaded into BaseScreen
|
||||||
// 5 columns: unassignButton, AllocationTable, assignButton, SeparatorVertical, SpecialistsStatsTabe
|
// 5 columns: unassignButton, AllocationTable, assignButton, SeparatorVertical, SpecialistsStatsTabe
|
||||||
if (cityScreen.canChangeState) {
|
if (cityScreen.canCityBeChanged()) {
|
||||||
if (cityInfo.manualSpecialists) {
|
if (cityInfo.manualSpecialists) {
|
||||||
val manualSpecialists = "Manual Specialists".toLabel()
|
val manualSpecialists = "Manual Specialists".toLabel()
|
||||||
.addBorder(5f, BaseScreen.skin.get("color", Color::class.java))
|
.addBorder(5f, BaseScreen.skin.get("color", Color::class.java))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user