Resolved #579 - When picking a construction and buying it, chosen construction reverts to previously chosen construction

This commit is contained in:
Yair Morgenstern
2019-04-09 22:38:47 +03:00
parent 70fd2be955
commit 9b9b21fe28
2 changed files with 8 additions and 3 deletions

View File

@ -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()

View File

@ -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)
}