diff --git a/android/assets/OtherIcons/Stop.png b/android/assets/OtherIcons/Stop.png new file mode 100644 index 0000000000..11e8562a64 Binary files /dev/null and b/android/assets/OtherIcons/Stop.png differ diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index 1561c7e899..7b9e45ff7b 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -1,18 +1,13 @@ package com.unciv.ui.worldscreen.unit -import com.badlogic.gdx.scenes.scene2d.ui.TextButton -import com.unciv.UnCivGame import com.unciv.logic.automation.WorkerAutomation import com.unciv.logic.map.MapUnit import com.unciv.logic.map.TileInfo import com.unciv.logic.map.UnitType import com.unciv.models.gamebasics.Building import com.unciv.models.gamebasics.GameBasics -import com.unciv.ui.cityscreen.addClickListener import com.unciv.ui.pickerscreens.ImprovementPickerScreen import com.unciv.ui.pickerscreens.TechPickerScreen -import com.unciv.ui.utils.CameraStageBaseScreen -import com.unciv.ui.utils.disable import com.unciv.ui.worldscreen.WorldScreen import java.util.* @@ -27,9 +22,6 @@ class UnitActions { } } - fun getUnitActionButtons(unit:MapUnit,worldScreen: WorldScreen): List { - return getUnitActions(unit, worldScreen).map { getUnitActionButton(it) } - } fun getUnitActions(unit:MapUnit,worldScreen: WorldScreen): List { val tile = unit.getTile() @@ -70,10 +62,7 @@ class UnitActions { } if (unit.name == "Worker") { - val improvementButtonText: String - if (tile.improvementInProgress == null) improvementButtonText = "Construct\r\nimprovement" - else improvementButtonText = tile.improvementInProgress!! + "\r\nin progress" - actionList += UnitAction(improvementButtonText, + actionList += UnitAction("Construct improvement", { worldScreen.game.screen = ImprovementPickerScreen(tile) }, unit.currentMovement != 0f && !tile.isCityCenter() || GameBasics.TileImprovements.values.any { tile.canBuildImprovement(it, unit.civInfo) }) @@ -144,11 +133,5 @@ class UnitActions { return actionList } - private fun getUnitActionButton(unitAction: UnitAction): TextButton { - val actionButton = TextButton(unitAction.name, CameraStageBaseScreen.skin) - actionButton.addClickListener({ unitAction.action(); UnCivGame.Current.worldScreen!!.update() }) - if (!unitAction.canAct) actionButton.disable() - return actionButton - } } diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt index 2147fe772e..2a183e546b 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt @@ -1,10 +1,16 @@ package com.unciv.ui.worldscreen.unit import com.badlogic.gdx.graphics.Color +import com.badlogic.gdx.scenes.scene2d.ui.Button import com.badlogic.gdx.scenes.scene2d.ui.Image +import com.badlogic.gdx.scenes.scene2d.ui.Label import com.badlogic.gdx.scenes.scene2d.ui.Table +import com.unciv.UnCivGame import com.unciv.logic.map.MapUnit +import com.unciv.ui.cityscreen.addClickListener +import com.unciv.ui.utils.CameraStageBaseScreen import com.unciv.ui.utils.ImageGetter +import com.unciv.ui.utils.disable import com.unciv.ui.worldscreen.WorldScreen class UnitActionsTable(val worldScreen: WorldScreen) : Table(){ @@ -13,7 +19,19 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table(){ when(unitAction){ "Move unit" -> return ImageGetter.getStatIcon("Movement") "Stop movement"-> return ImageGetter.getStatIcon("Movement").apply { color= Color.RED } - + "Fortify" -> return ImageGetter.getImage("UnitIcons/Shield.png").apply { color= Color.BLACK } + "Construct improvement" -> return ImageGetter.getImage("UnitIcons/Worker.png") + "Automate" -> return ImageGetter.getImage("UnitIcons/Great Engineer.png") + "Stop automation" -> return ImageGetter.getImage("OtherIcons/Stop.png") + "Found city" -> return ImageGetter.getImage("UnitIcons/Settler.png") + "Discover Technology" -> return ImageGetter.getImage("UnitIcons/Great Scientist.png") + "Construct Academy" -> return ImageGetter.getImage("ImprovementIcons/Academy_(Civ5).png") + "Start Golden Age" -> return ImageGetter.getImage("UnitIcons/Great Artist.png") + "Construct Landmark" -> return ImageGetter.getImage("ImprovementIcons/Landmark_(Civ5).png") + "Hurry Wonder" -> return ImageGetter.getImage("UnitIcons/Great Engineer.png") + "Construct Manufactory" -> return ImageGetter.getImage("ImprovementIcons/Manufactory_(Civ5).png") + "Conduct Trade Mission" -> return ImageGetter.getImage("UnitIcons/Great Merchant.png") + "Construct Customs House" -> return ImageGetter.getImage("ImprovementIcons/Customs_house_(Civ5).png") else -> return ImageGetter.getImage("StatIcons/Star.png") } } @@ -21,9 +39,21 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table(){ fun update(unit: MapUnit?){ clear() if (unit == null) return - for (button in UnitActions().getUnitActionButtons(unit, worldScreen)) + for (button in UnitActions().getUnitActions(unit, worldScreen).map { getUnitActionButton(it) }) add(button).colspan(2).pad(5f) .size(button.width * worldScreen.buttonScale, button.height * worldScreen.buttonScale).row() pack() } + + + private fun getUnitActionButton(unitAction: UnitAction): Button { + val actionButton = Button(CameraStageBaseScreen.skin) + actionButton.add(getIconForUnitAction(unitAction.name)).size(20f).pad(5f) + actionButton.add(Label(unitAction.name,CameraStageBaseScreen.skin) + .apply { style= Label.LabelStyle(style); style.fontColor = Color.WHITE }) + actionButton.pack() + actionButton.addClickListener({ unitAction.action(); UnCivGame.Current.worldScreen!!.update() }) + if (!unitAction.canAct) actionButton.disable() + return actionButton + } } \ No newline at end of file