diff --git a/core/src/com/unciv/ui/tilegroups/TileGroup.kt b/core/src/com/unciv/ui/tilegroups/TileGroup.kt index 89ce3a45..e7c65fda 100644 --- a/core/src/com/unciv/ui/tilegroups/TileGroup.kt +++ b/core/src/com/unciv/ui/tilegroups/TileGroup.kt @@ -333,7 +333,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() { } - private fun getUnitImage(unit: MapUnit, size: Float): Group { + fun getUnitImage(unit: MapUnit, size: Float): Group { val unitBaseImage = ImageGetter.getUnitIcon(unit.name, unit.civInfo.getNation().getSecondaryColor()) .apply { setSize(20f, 20f) } diff --git a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt index ea24f6a0..d7b615b2 100644 --- a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt +++ b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt @@ -15,6 +15,7 @@ import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.map.TileInfo import com.unciv.logic.map.TileMap import com.unciv.models.gamebasics.unit.UnitType +import com.unciv.ui.tilegroups.TileGroup import com.unciv.ui.tilegroups.WorldTileGroup import com.unciv.ui.utils.* @@ -44,14 +45,19 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap: val selectedUnit = worldScreen.bottomBar.unitTable.selectedUnit if(selectedUnit!=null && selectedUnit.getTile()!=tileInfo && selectedUnit.canMoveTo(tileInfo) && selectedUnit.movementAlgs().canReach(tileInfo)) { - val size = 40f + val size = 60f val moveHereGroup = Group().apply { width = size;height = size; } moveHereGroup.addActor(ImageGetter.getImage("OtherIcons/Circle").apply { width = size; height = size }) moveHereGroup.addActor(ImageGetter.getStatIcon("Movement").apply { width = size / 2; height = size / 2; center(moveHereGroup) }) + val turnsToGetThere = selectedUnit.movementAlgs().getShortestPath(tileInfo).size val numberCircle = ImageGetter.getImage("OtherIcons/Circle").apply { width = size/2; height = size/2;color= Color.BLUE } moveHereGroup.addActor(numberCircle) - moveHereGroup.addActor(Label(turnsToGetThere.toString(),CameraStageBaseScreen.skin).apply { center(numberCircle) }) + moveHereGroup.addActor(Label(turnsToGetThere.toString(),CameraStageBaseScreen.skin).apply { center(numberCircle); setFontColor(Color.WHITE) }) + + val unitIcon = TileGroup(TileInfo()).getUnitImage(selectedUnit,size/3) + unitIcon.y = size-unitIcon.height + moveHereGroup.addActor(unitIcon) if(selectedUnit.currentMovement>0) moveHereGroup.onClick { diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt index 3b544611..0498fb7c 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt @@ -5,12 +5,14 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table import com.unciv.logic.map.MapUnit import com.unciv.logic.map.TileInfo import com.unciv.models.gamebasics.unit.UnitType +import com.unciv.ui.tilegroups.TileGroup import com.unciv.ui.utils.* import com.unciv.ui.worldscreen.WorldScreen class UnitTable(val worldScreen: WorldScreen) : Table(){ private val prevIdleUnitButton = IdleUnitButton(this,worldScreen.tileMapHolder,true) private val nextIdleUnitButton = IdleUnitButton(this,worldScreen.tileMapHolder,false) + private val unitIconHolder=Table() private val unitNameLabel = Label("",CameraStageBaseScreen.skin) private val promotionsTable = Table() private val unitDescriptionLabel = Label("",CameraStageBaseScreen.skin) @@ -26,6 +28,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){ add(Table().apply { add(prevIdleUnitButton) + add(unitIconHolder) add(unitNameLabel).pad(5f) add(nextIdleUnitButton) }).colspan(2).row() @@ -82,14 +85,18 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){ else { unitNameLabel.setText("") unitDescriptionLabel.setText("") + unitIconHolder.clear() } if(!selectedUnitHasChanged) return + unitIconHolder.clear() promotionsTable.clear() unitDescriptionLabel.clearListeners() if(selectedUnit!=null) { + + unitIconHolder.add(TileGroup(TileInfo()).getUnitImage(selectedUnit!!,20f)).pad(5f) for(promotion in selectedUnit!!.promotions.promotions) promotionsTable.add(ImageGetter.getPromotionIcon(promotion)).size(20f)