From 24c88313e8b44f8b23e7a450b0528ac952a21f5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=A4lz?= <1376279+dbaelz@users.noreply.github.com> Date: Sat, 23 May 2020 22:10:46 +0200 Subject: [PATCH] Add remove button for construction queue items (#2654) --- .../unciv/ui/cityscreen/ConstructionsTable.kt | 17 +++++++++++++++++ core/src/com/unciv/ui/utils/ImageGetter.kt | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt b/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt index ebb9d3a9cd..bfd878078d 100644 --- a/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt +++ b/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt @@ -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()) diff --git a/core/src/com/unciv/ui/utils/ImageGetter.kt b/core/src/com/unciv/ui/utils/ImageGetter.kt index 41815e655d..ddea4bfa71 100644 --- a/core/src/com/unciv/ui/utils/ImageGetter.kt +++ b/core/src/com/unciv/ui/utils/ImageGetter.kt @@ -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) }