Construction table: ordering change (Civ 5) + add/remove on double-click (#8163)

Co-authored-by: tunerzinc@gmail.com <vfylfhby>
This commit is contained in:
vegeta1k95 2022-12-17 20:04:04 +01:00 committed by GitHub
parent b44ac9eaa4
commit 0380773560
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -264,9 +264,9 @@ class CityConstructionsTable(private val cityScreen: CityScreen) {
clear()
defaults().left().bottom()
addCategory("Units", units, maxButtonWidth)
addCategory("Buildings", buildableBuildings, maxButtonWidth)
addCategory("Wonders", buildableWonders, maxButtonWidth)
addCategory("National Wonders", buildableNationalWonders, maxButtonWidth)
addCategory("Buildings", buildableBuildings, maxButtonWidth)
addCategory("Other", specialConstructions, maxButtonWidth)
pack()
}
@ -322,8 +322,14 @@ class CityConstructionsTable(private val cityScreen: CityScreen) {
table.touchable = Touchable.enabled
table.onClick {
cityScreen.selectConstruction(constructionName)
selectedQueueEntry = constructionQueueIndex
if (selectedQueueEntry == constructionQueueIndex) {
city.cityConstructions.removeFromQueue(constructionQueueIndex, false)
selectedQueueEntry = -1
cityScreen.clearSelection()
} else {
cityScreen.selectConstruction(constructionName)
selectedQueueEntry = constructionQueueIndex
}
cityScreen.update()
}
return table
@ -381,7 +387,11 @@ class CityConstructionsTable(private val cityScreen: CityScreen) {
.colspan(pickConstructionButton.columns).fillX().left().padTop(2f)
}
pickConstructionButton.onClick {
cityScreen.selectConstruction(construction)
if (cityScreen.selectedConstruction == construction) {
addConstructionToQueue(construction, cityScreen.city.cityConstructions)
} else {
cityScreen.selectConstruction(construction)
}
selectedQueueEntry = -1
cityScreen.update()
}