mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-26 23:58:43 +07:00
Selected unit now has a white circle around it
This commit is contained in:
@ -16,9 +16,7 @@ import com.unciv.ui.utils.ImageGetter
|
||||
class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
||||
var cityButton: Table? = null
|
||||
private var unitImage: Group? = null
|
||||
//private var whiteCircleAroundUnit
|
||||
|
||||
private var circleImage = ImageGetter.getImage("UnitIcons/Circle.png")
|
||||
private var circleImage = ImageGetter.getImage("UnitIcons/Circle.png") // for blue and red circles on the tile
|
||||
|
||||
init{
|
||||
circleImage.width = 50f
|
||||
@ -29,10 +27,19 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
||||
circleImage.isVisible = false
|
||||
}
|
||||
|
||||
fun addWhiteCircleAroundUnit(){
|
||||
val whiteCircle = ImageGetter.getImage("UnitIcons/Circle.png")
|
||||
whiteCircle.setSize(25f,25f)
|
||||
whiteCircle.setPosition(unitImage!!.width/2 - whiteCircle.width/2,
|
||||
unitImage!!.height/2 - whiteCircle.height/2)
|
||||
unitImage!!.addActor(whiteCircle)
|
||||
whiteCircle.toBack()
|
||||
}
|
||||
|
||||
fun showCircle(color:Color){
|
||||
circleImage.isVisible = true
|
||||
color.a = 0.3f
|
||||
circleImage.setColor(color)
|
||||
circleImage.color = color
|
||||
}
|
||||
|
||||
fun hideCircle(){circleImage.isVisible=false}
|
||||
|
@ -16,7 +16,7 @@ import com.unciv.ui.utils.HexMath
|
||||
|
||||
class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap: TileMap, internal val civInfo: CivilizationInfo) : ScrollPane(null) {
|
||||
internal var selectedTile: TileInfo? = null
|
||||
val tileGroups = HashMap<String, WorldTileGroup>()
|
||||
val tileGroups = HashMap<TileInfo, WorldTileGroup>()
|
||||
|
||||
internal fun addTiles() {
|
||||
val allTiles = Group()
|
||||
@ -43,7 +43,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
||||
val groupSize = 50
|
||||
group.setPosition(worldScreen.stage.width / 2 + positionalVector.x * 0.8f * groupSize.toFloat(),
|
||||
worldScreen.stage.height / 2 + positionalVector.y * 0.8f * groupSize.toFloat())
|
||||
tileGroups[tileInfo.position.toString()] = group
|
||||
tileGroups[tileInfo] = group
|
||||
allTiles.addActor(group)
|
||||
topX = Math.max(topX, group.x + groupSize)
|
||||
topY = Math.max(topY, group.y + groupSize)
|
||||
@ -90,7 +90,6 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
||||
}
|
||||
|
||||
for (string in civInfo.getViewableTiles()
|
||||
.map { it.position.toString() }
|
||||
.filter { tileGroups.containsKey(it) }) {
|
||||
|
||||
tileGroups[string]!!.run {
|
||||
@ -101,10 +100,11 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
||||
|
||||
if(worldScreen.unitTable.currentlyExecutingAction!=null)
|
||||
for(tile: TileInfo in worldScreen.unitTable.getTilesForCurrentlyExecutingAction())
|
||||
tileGroups[tile.position.toString()]!!.showCircle(Color(0f,120/255f,215/255f,1f))
|
||||
tileGroups[tile]!!.showCircle(Color(0f,120/255f,215/255f,1f))
|
||||
|
||||
else if(worldScreen.unitTable.selectedUnit!=null){
|
||||
val unit = worldScreen.unitTable.selectedUnit!!
|
||||
tileGroups[unit.getTile()]!!.addWhiteCircleAroundUnit()
|
||||
val attackableTiles:List<TileInfo>
|
||||
when(unit.getBaseUnit().unitType){
|
||||
UnitType.Civilian -> return
|
||||
@ -113,7 +113,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
||||
}
|
||||
|
||||
for (tile in attackableTiles.filter { it.unit!=null && it.unit!!.owner != unit.owner })
|
||||
tileGroups[tile.position.toString()]!!.showCircle(Color(237/255f,41/255f,57/255f,1f))
|
||||
tileGroups[tile]!!.showCircle(Color(237/255f,41/255f,57/255f,1f))
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user