Fix buy current construction (#1794)

This commit is contained in:
Federico Luongo 2020-01-27 22:59:40 +01:00 committed by Yair Morgenstern
parent d22b3acbb3
commit ea29f91519

View File

@ -99,7 +99,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
constructionsQueueTable.addSeparator() constructionsQueueTable.addSeparator()
if (currentConstruction != "") if (currentConstruction != "")
constructionsQueueTable.add(getQueueEntry(-1, currentConstruction, queue.isEmpty(), selectedQueueEntry == -1)) constructionsQueueTable.add(getQueueEntry(-1, currentConstruction, queue.isEmpty(), isSelectedCurrentConstruction()))
.expandX().fillX().row() .expandX().fillX().row()
else else
constructionsQueueTable.add("Pick a construction".toLabel()).pad(2f).row() constructionsQueueTable.add("Pick a construction".toLabel()).pad(2f).row()
@ -227,6 +227,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
return pickProductionButton return pickProductionButton
} }
private fun isSelectedQueueEntry(): Boolean = selectedQueueEntry > -2 private fun isSelectedQueueEntry(): Boolean = selectedQueueEntry > -2
private fun isSelectedCurrentConstruction(): Boolean = selectedQueueEntry == -1
private fun getQueueButton(construction: IConstruction?): TextButton { private fun getQueueButton(construction: IConstruction?): TextButton {
val city = cityScreen.city val city = cityScreen.city
@ -287,6 +288,9 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
YesNoPopup("Would you like to purchase [${construction.name}] for [$constructionGoldCost] gold?".tr(), { YesNoPopup("Would you like to purchase [${construction.name}] for [$constructionGoldCost] gold?".tr(), {
cityConstructions.purchaseConstruction(construction.name) cityConstructions.purchaseConstruction(construction.name)
if (isSelectedQueueEntry()) { if (isSelectedQueueEntry()) {
// currentConstruction is removed from the queue by purchaseConstruction
// to avoid conflicts with NextTurnAutomation
if (!isSelectedCurrentConstruction())
cityConstructions.removeFromQueue(selectedQueueEntry) cityConstructions.removeFromQueue(selectedQueueEntry)
selectedQueueEntry = -2 selectedQueueEntry = -2
cityScreen.selectedConstruction = null cityScreen.selectedConstruction = null