diff --git a/core/src/com/unciv/ui/tilegroups/TileGroup.kt b/core/src/com/unciv/ui/tilegroups/TileGroup.kt index 707cf3cccb..cc1108d898 100644 --- a/core/src/com/unciv/ui/tilegroups/TileGroup.kt +++ b/core/src/com/unciv/ui/tilegroups/TileGroup.kt @@ -273,7 +273,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() { fun showCircle(color:Color){ circleImage.isVisible = true - val color = Color(color) + val color = color.cpy() color.a = 0.3f circleImage.color = color } diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index cb2027bbb0..a74ce8256e 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -9,6 +9,7 @@ import com.unciv.ui.pickerscreens.PolicyPickerScreen import com.unciv.ui.pickerscreens.TechPickerScreen import com.unciv.ui.utils.CameraStageBaseScreen import com.unciv.ui.utils.GameSaver +import com.unciv.ui.worldscreen.unit.UnitActionsTable class WorldScreen : CameraStageBaseScreen() { val gameInfo = game.gameInfo @@ -19,6 +20,7 @@ class WorldScreen : CameraStageBaseScreen() { internal var buttonScale = game.settings.buttonScale private val topBar = WorldScreenTopBar(this) val bottomBar = WorldScreenBottomBar(this) + val unitActionsTable = UnitActionsTable(this) private val techButton = TextButton("", CameraStageBaseScreen.skin) private val nextTurnButton = createNextTurnButton() @@ -48,6 +50,7 @@ class WorldScreen : CameraStageBaseScreen() { bottomBar.width = stage.width stage.addActor(bottomBar) + stage.addActor(unitActionsTable) update() @@ -65,13 +68,16 @@ class WorldScreen : CameraStageBaseScreen() { updateTechButton() bottomBar.update(tileMapHolder.selectedTile) // has to come before tilemapholder update because the tilemapholder actions depend on the selected unit! + + unitActionsTable.update(bottomBar.unitTable.selectedUnit) + unitActionsTable.y = bottomBar.height + tileMapHolder.updateTiles() topBar.update() notificationsScroll.update() notificationsScroll.width = stage.width/3 notificationsScroll.setPosition(stage.width - notificationsScroll.width - 5f, nextTurnButton.y - notificationsScroll.height - 5f) - } private fun updateTechButton() { diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreenBottomBar.kt b/core/src/com/unciv/ui/worldscreen/WorldScreenBottomBar.kt index d670231f89..e73d64e7d2 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreenBottomBar.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreenBottomBar.kt @@ -14,8 +14,8 @@ class WorldScreenBottomBar(val worldScreen: WorldScreen) : Table(){ init { add(unitTable).width(worldScreen.stage.width/3) - add(battleTable).width(worldScreen.stage.width/3).fill() - add(tileInfoTable).width(worldScreen.stage.width/3) + add(battleTable).width(worldScreen.stage.width/3).fill() // so that background fills entire middle third + add(tileInfoTable).width(worldScreen.stage.width/3).fill() val tileTableBackground = ImageGetter.getDrawable(ImageGetter.WhiteDot) .tint(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f)) diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt new file mode 100644 index 0000000000..2147fe772e --- /dev/null +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActionsTable.kt @@ -0,0 +1,29 @@ +package com.unciv.ui.worldscreen.unit + +import com.badlogic.gdx.graphics.Color +import com.badlogic.gdx.scenes.scene2d.ui.Image +import com.badlogic.gdx.scenes.scene2d.ui.Table +import com.unciv.logic.map.MapUnit +import com.unciv.ui.utils.ImageGetter +import com.unciv.ui.worldscreen.WorldScreen + +class UnitActionsTable(val worldScreen: WorldScreen) : Table(){ + + fun getIconForUnitAction(unitAction:String): Image { + when(unitAction){ + "Move unit" -> return ImageGetter.getStatIcon("Movement") + "Stop movement"-> return ImageGetter.getStatIcon("Movement").apply { color= Color.RED } + + else -> return ImageGetter.getImage("StatIcons/Star.png") + } + } + + fun update(unit: MapUnit?){ + clear() + if (unit == null) return + for (button in UnitActions().getUnitActionButtons(unit, worldScreen)) + add(button).colspan(2).pad(5f) + .size(button.width * worldScreen.buttonScale, button.height * worldScreen.buttonScale).row() + pack() + } +} \ No newline at end of file diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt index 0c5805eecc..547836e10d 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt @@ -16,12 +16,9 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){ var selectedUnit : MapUnit? = null var currentlyExecutingAction : String? = null - private val unitActionsTable = Table() - init { pad(20f) - //background = tileTableBackground add(Table().apply { add(prevIdleUnitButton) @@ -30,13 +27,12 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){ }).colspan(2) row() add(unitDescriptionLabel) - add(unitActionsTable) } fun update() { prevIdleUnitButton.update() nextIdleUnitButton.update() - unitActionsTable.clear() + if(selectedUnit!=null) { try{ selectedUnit!!.getTile()} @@ -61,18 +57,14 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){ unitDescriptionLabel.setText(unitLabelText) - for (button in UnitActions().getUnitActionButtons(selectedUnit!!, worldScreen)) - unitActionsTable.add(button).colspan(2).pad(5f) - .size(button.width * worldScreen.buttonScale, button.height * worldScreen.buttonScale).row() + } else { unitNameLabel.setText("") unitDescriptionLabel.setText("") } - unitActionsTable.pack() pack() - } fun tileSelected(selectedTile: TileInfo) { @@ -95,3 +87,4 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){ } } +