From 9b9b21fe28891971984502c851a009c99e8441fc Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 9 Apr 2019 22:38:47 +0300 Subject: [PATCH] Resolved #579 - When picking a construction and buying it, chosen construction reverts to previously chosen construction --- core/src/com/unciv/logic/city/CityConstructions.kt | 2 +- core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/com/unciv/logic/city/CityConstructions.kt b/core/src/com/unciv/logic/city/CityConstructions.kt index 707abefc42..ac3b176846 100644 --- a/core/src/com/unciv/logic/city/CityConstructions.kt +++ b/core/src/com/unciv/logic/city/CityConstructions.kt @@ -199,7 +199,7 @@ class CityConstructions { cityInfo.civInfo.gold -= getConstruction(buildingName).getGoldCost(cityInfo.civInfo.policies.adoptedPolicies) getConstruction(buildingName).postBuildEvent(this) if (currentConstruction == buildingName) { - currentConstruction="" + currentConstruction = "" chooseNextConstruction() } cityInfo.cityStats.update() diff --git a/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt b/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt index 1d86b8f53a..d4b650daa4 100644 --- a/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt +++ b/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt @@ -18,6 +18,7 @@ import com.unciv.ui.worldscreen.optionstable.YesNoPopupTable class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScreen.skin){ var constructionScrollPane:ScrollPane?=null + var lastConstruction = "" private fun getProductionButton(construction: String, buttonText: String, rejectionReason: String=""): Table { val pickProductionButton = Table() @@ -35,6 +36,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre if(rejectionReason=="") { pickProductionButton.onClick { + lastConstruction = cityScreen.city.cityConstructions.currentConstruction cityScreen.city.cityConstructions.currentConstruction = construction cityScreen.city.cityStats.update() cityScreen.update() @@ -131,7 +133,8 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre } private fun addCurrentConstructionTable(city: CityInfo) { - val construction = city.cityConstructions.getCurrentConstruction() + val cityConstructions = city.cityConstructions + val construction = cityConstructions.getCurrentConstruction() row() val purchaseConstructionButton: TextButton @@ -140,7 +143,9 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre purchaseConstructionButton = TextButton("Buy for [$buildingGoldCost] gold".tr(), CameraStageBaseScreen.skin) purchaseConstructionButton.onClick("coin") { YesNoPopupTable("Would you like to purchase [${construction.name}] for [$buildingGoldCost] gold?".tr(), { - city.cityConstructions.purchaseBuilding(construction.name) + cityConstructions.purchaseBuilding(construction.name) + if(lastConstruction!="" && cityConstructions.getConstruction(lastConstruction).isBuildable(cityConstructions)) + city.cityConstructions.currentConstruction = lastConstruction update() }, cityScreen) }