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

View File

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