mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-11 16:29:48 +07:00
Merge branch '3.6.7-patch2'
This commit is contained in:
@ -33,8 +33,8 @@ allprojects {
|
|||||||
version = '1.0.1'
|
version = '1.0.1'
|
||||||
ext {
|
ext {
|
||||||
appName = "Unciv"
|
appName = "Unciv"
|
||||||
appCodeNumber = 394
|
appCodeNumber = 395
|
||||||
appVersion = "3.6.7-patch1"
|
appVersion = "3.6.7-patch2"
|
||||||
|
|
||||||
gdxVersion = '1.9.10'
|
gdxVersion = '1.9.10'
|
||||||
roboVMVersion = '2.3.1'
|
roboVMVersion = '2.3.1'
|
||||||
|
@ -269,6 +269,34 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
|||||||
return button
|
return button
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun purchaseConstruction(construction: IConstruction) {
|
||||||
|
val city = cityScreen.city
|
||||||
|
val cityConstructions = city.cityConstructions
|
||||||
|
// We can't trust the isSelectedQueueEntry because that fails when we have the same unit as both the current construction and in the queue,
|
||||||
|
// and then we purchase the unit from the queue - see #2157
|
||||||
|
val constructionIsCurrentConstruction = construction.name==cityConstructions.currentConstruction
|
||||||
|
|
||||||
|
if (!cityConstructions.purchaseConstruction(construction.name)) {
|
||||||
|
Popup(cityScreen).apply {
|
||||||
|
add("No space available to place [${construction.name}] near [${city.name}]".tr()).row()
|
||||||
|
addCloseButton()
|
||||||
|
open()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (isSelectedQueueEntry()) {
|
||||||
|
// currentConstruction is removed from the queue by purchaseConstruction
|
||||||
|
// to avoid conflicts with NextTurnAutomation
|
||||||
|
if (!constructionIsCurrentConstruction && cityConstructions.constructionQueue[selectedQueueEntry] == construction.name)
|
||||||
|
cityConstructions.removeFromQueue(selectedQueueEntry)
|
||||||
|
selectedQueueEntry = -2
|
||||||
|
cityScreen.selectedConstruction = null
|
||||||
|
}
|
||||||
|
if (!construction.shouldBeDisplayed(cityConstructions)) cityScreen.selectedConstruction = null
|
||||||
|
cityScreen.update()
|
||||||
|
}
|
||||||
|
|
||||||
private fun getBuyButton(construction: IConstruction?): TextButton {
|
private fun getBuyButton(construction: IConstruction?): TextButton {
|
||||||
val city = cityScreen.city
|
val city = cityScreen.city
|
||||||
val cityConstructions = city.cityConstructions
|
val cityConstructions = city.cityConstructions
|
||||||
@ -282,28 +310,6 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
|||||||
button.setText("Buy".tr())
|
button.setText("Buy".tr())
|
||||||
button.disable()
|
button.disable()
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
fun purchaseConstruction() {
|
|
||||||
if (!cityConstructions.purchaseConstruction(construction.name)) {
|
|
||||||
Popup(cityScreen).apply {
|
|
||||||
add("No space available to place [${construction.name}] near [${city.name}]".tr()).row()
|
|
||||||
addCloseButton()
|
|
||||||
open()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (isSelectedQueueEntry()) {
|
|
||||||
// currentConstruction is removed from the queue by purchaseConstruction
|
|
||||||
// to avoid conflicts with NextTurnAutomation
|
|
||||||
if (!isSelectedCurrentConstruction() && cityConstructions.constructionQueue[selectedQueueEntry] == construction.name)
|
|
||||||
cityConstructions.removeFromQueue(selectedQueueEntry)
|
|
||||||
selectedQueueEntry = -2
|
|
||||||
cityScreen.selectedConstruction = null
|
|
||||||
}
|
|
||||||
if (!construction.shouldBeDisplayed(cityConstructions)) cityScreen.selectedConstruction = null
|
|
||||||
cityScreen.update()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val constructionGoldCost = construction.getGoldCost(city.civInfo)
|
val constructionGoldCost = construction.getGoldCost(city.civInfo)
|
||||||
button.setText("Buy".tr() + " " + constructionGoldCost)
|
button.setText("Buy".tr() + " " + constructionGoldCost)
|
||||||
button.add(ImageGetter.getStatIcon(Stat.Gold.name)).size(20f).padBottom(2f)
|
button.add(ImageGetter.getStatIcon(Stat.Gold.name)).size(20f).padBottom(2f)
|
||||||
@ -314,12 +320,11 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
|||||||
|
|
||||||
val purchasePrompt = "Currently you have [${city.civInfo.gold}] gold.".tr() + "\n\n" +
|
val purchasePrompt = "Currently you have [${city.civInfo.gold}] gold.".tr() + "\n\n" +
|
||||||
"Would you like to purchase [${construction.name}] for [$constructionGoldCost] gold?".tr()
|
"Would you like to purchase [${construction.name}] for [$constructionGoldCost] gold?".tr()
|
||||||
YesNoPopup(purchasePrompt, { purchaseConstruction() }, cityScreen, { cityScreen.update() }).open()
|
YesNoPopup(purchasePrompt, { purchaseConstruction(construction) }, cityScreen, { cityScreen.update() }).open()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (constructionGoldCost > city.civInfo.gold)
|
if (constructionGoldCost > city.civInfo.gold)
|
||||||
button.disable()
|
button.disable()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
button.labelCell.pad(5f)
|
button.labelCell.pad(5f)
|
||||||
|
Reference in New Issue
Block a user