Add remove button for construction queue items (#2654)

This commit is contained in:
Daniel Bälz
2020-05-23 22:10:46 +02:00
committed by GitHub
parent 2f43213616
commit 24c88313e8
2 changed files with 18 additions and 1 deletions

View File

@ -206,6 +206,8 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
table.add(getLowerPriorityButton(constructionQueueIndex, name, city)).right()
else table.add().right()
table.add(getRemoveFromQueueButton(constructionQueueIndex, city)).right()
table.touchable = Touchable.enabled
table.onClick {
cityScreen.selectedConstruction = cityConstructions.getConstruction(name)
@ -391,6 +393,21 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
return tab
}
private fun getRemoveFromQueueButton(constructionQueueIndex: Int, city: CityInfo): Table {
val tab = Table()
tab.add(ImageGetter.getImage("OtherIcons/Stop").surroundWithCircle(40f))
if (UncivGame.Current.worldScreen.isPlayersTurn && !city.isPuppet) {
tab.touchable = Touchable.enabled
tab.onClick {
tab.touchable = Touchable.disabled
city.cityConstructions.removeFromQueue(constructionQueueIndex,false)
cityScreen.selectedConstruction = null
cityScreen.update()
}
}
return tab
}
private fun getHeader(title: String): Table {
val headerTable = Table()
headerTable.background = ImageGetter.getBackground(ImageGetter.getBlue())

View File

@ -149,7 +149,7 @@ object ImageGetter {
fun getConstructionImage(construction: String): Image {
if(ruleset.buildings.containsKey(construction)) return getImage("BuildingIcons/$construction")
if(ruleset.units.containsKey(construction)) return getUnitIcon(construction)
if(construction=="Nothing") return getImage("OtherIcons/Stop")
if(construction=="Nothing") return getImage("OtherIcons/Sleep")
return getStatIcon(construction)
}