mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 23:40:01 +07:00
Old borders now disappear when borders expand
This commit is contained in:
@ -2,7 +2,6 @@ package com.unciv.ui.tilegroups
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.scenes.scene2d.Group
|
import com.badlogic.gdx.scenes.scene2d.Group
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Container
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||||
import com.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
@ -22,8 +21,9 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
private var improvementType: String? = null
|
private var improvementType: String? = null
|
||||||
var populationImage: Image? = null
|
var populationImage: Image? = null
|
||||||
private var roadImages = HashMap<String, Image>()
|
private var roadImages = HashMap<String, Image>()
|
||||||
|
private var borderImages = ArrayList<Image>()
|
||||||
|
|
||||||
protected var cityButton: Container<TextButton>? = null
|
public var cityButton: TextButton? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val groupSize = 50f
|
val groupSize = 50f
|
||||||
@ -158,10 +158,11 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Borders
|
||||||
if(tileInfo.owner!=null){
|
if(tileInfo.owner!=null){
|
||||||
|
for(border in borderImages) border.remove()
|
||||||
for (neighbor in tileInfo.neighbors.filter { it.owner!=tileInfo.owner }){
|
for (neighbor in tileInfo.neighbors.filter { it.owner!=tileInfo.owner }){
|
||||||
val image = ImageGetter.getImage(ImageGetter.WhiteDot)
|
val image = ImageGetter.getImage(ImageGetter.WhiteDot)
|
||||||
// roadImages[neighbor.position.toString()] = image
|
|
||||||
|
|
||||||
val relativeHexPosition = tileInfo.position.cpy().sub(neighbor.position)
|
val relativeHexPosition = tileInfo.position.cpy().sub(neighbor.position)
|
||||||
val relativeWorldPosition = HexMath.Hex2WorldCoords(relativeHexPosition)
|
val relativeWorldPosition = HexMath.Hex2WorldCoords(relativeHexPosition)
|
||||||
@ -179,6 +180,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
|||||||
image.setOrigin(image.width/2, image.height/2) // This is so that the rotation is calculated from the middle of the road and not the edge
|
image.setOrigin(image.width/2, image.height/2) // This is so that the rotation is calculated from the middle of the road and not the edge
|
||||||
image.rotation = (90 + 180 / Math.PI * Math.atan2(relativeWorldPosition.y.toDouble(), relativeWorldPosition.x.toDouble())).toFloat()
|
image.rotation = (90 + 180 / Math.PI * Math.atan2(relativeWorldPosition.y.toDouble(), relativeWorldPosition.x.toDouble())).toFloat()
|
||||||
addActor(image)
|
addActor(image)
|
||||||
|
borderImages.add(image)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.unciv.ui.tilegroups
|
package com.unciv.ui.tilegroups
|
||||||
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Container
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.ui.cityscreen.CityScreen
|
import com.unciv.ui.cityscreen.CityScreen
|
||||||
@ -32,23 +31,19 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
|||||||
if (tileInfo.isCityCenter) {
|
if (tileInfo.isCityCenter) {
|
||||||
val buttonScale = 0.7f
|
val buttonScale = 0.7f
|
||||||
if (cityButton == null) {
|
if (cityButton == null) {
|
||||||
cityButton = Container()
|
cityButton = TextButton("", CameraStageBaseScreen.skin)
|
||||||
cityButton!!.actor = TextButton("", CameraStageBaseScreen.skin)
|
cityButton!!.label.setFontScale(buttonScale)
|
||||||
|
|
||||||
cityButton!!.actor.label.setFontScale(buttonScale)
|
|
||||||
|
|
||||||
val game = worldScreen.game
|
val game = worldScreen.game
|
||||||
cityButton!!.actor.addClickListener { game.screen = CityScreen(city!!)
|
cityButton!!.addClickListener { game.screen = CityScreen(city!!)}
|
||||||
}
|
|
||||||
|
|
||||||
addActor(cityButton!!)
|
addActor(cityButton)
|
||||||
zIndex = parent.children.size // so this tile is rendered over neighboring tiles
|
zIndex = parent.children.size // so this tile is rendered over neighboring tiles
|
||||||
}
|
}
|
||||||
|
|
||||||
val cityButtonText = city!!.name + " (" + city.population.population + ")"
|
val cityButtonText = city!!.name + " (" + city.population.population + ")"
|
||||||
val button = cityButton!!.actor
|
cityButton!!.setText(cityButtonText)
|
||||||
button.setText(cityButtonText)
|
cityButton!!.setSize(cityButton!!.prefWidth, cityButton!!.prefHeight)
|
||||||
button.setSize(button.prefWidth, button.prefHeight)
|
|
||||||
|
|
||||||
cityButton!!.setPosition((width - cityButton!!.width) / 2,
|
cityButton!!.setPosition((width - cityButton!!.width) / 2,
|
||||||
height * 0.9f)
|
height * 0.9f)
|
||||||
|
@ -72,7 +72,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
lastInitialDistance = initialDistance
|
lastInitialDistance = initialDistance
|
||||||
lastScale = scaleX
|
lastScale = scaleX
|
||||||
}
|
}
|
||||||
val scale = Math.sqrt((distance / initialDistance).toDouble()).toFloat() * lastScale
|
val scale: Float = Math.sqrt((distance / initialDistance).toDouble()).toFloat() * lastScale
|
||||||
if (scale < 1) return
|
if (scale < 1) return
|
||||||
setScale(scale)
|
setScale(scale)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user