mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-30 06:39:17 +07:00
Resolved #579 - When picking a construction and buying it, chosen construction reverts to previously chosen construction
This commit is contained in:
@ -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()
|
||||
|
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user