City labels are colored according to civ, and scale down when zooming in
This commit is contained in:
parent
8b176f062b
commit
39cc236fae
3 changed files with 33 additions and 18 deletions
|
@ -21,8 +21,8 @@ android {
|
|||
applicationId "com.unciv.game"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 26
|
||||
versionCode 35
|
||||
versionName "1.4.2"
|
||||
versionCode 36
|
||||
versionName "1.4.3"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
|
|
@ -2,7 +2,9 @@ package com.unciv.ui.tilegroups
|
|||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.Group
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.ui.UnCivGame
|
||||
import com.unciv.ui.cityscreen.CityScreen
|
||||
|
@ -12,7 +14,7 @@ import com.unciv.ui.utils.ImageGetter
|
|||
|
||||
|
||||
class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
||||
private var cityButton: TextButton? = null
|
||||
var cityButton: Table? = null
|
||||
private var unitImage: Group? = null
|
||||
|
||||
fun setIsViewable(isViewable: Boolean) {
|
||||
|
@ -29,30 +31,41 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
|
|||
override fun update() {
|
||||
super.update()
|
||||
|
||||
if (tileInfo.workingCity != null && populationImage == null) addPopulationIcon()
|
||||
if (tileInfo.workingCity == null && populationImage != null) removePopulationIcon()
|
||||
if (populationImage != null) removePopulationIcon()
|
||||
if (tileInfo.workingCity != null && !tileInfo.isCityCenter && populationImage == null) addPopulationIcon()
|
||||
|
||||
|
||||
val city = tileInfo.city
|
||||
if (tileInfo.isCityCenter) {
|
||||
val buttonScale = 0.7f
|
||||
if (city != null && tileInfo.isCityCenter) {
|
||||
if (cityButton == null) {
|
||||
cityButton = TextButton("", CameraStageBaseScreen.skin)
|
||||
cityButton!!.label.setFontScale(buttonScale)
|
||||
|
||||
cityButton!!.addClickListener { UnCivGame.Current.screen = CityScreen(city!!)}
|
||||
cityButton = Table()
|
||||
cityButton!!.background = ImageGetter.getDrawable("skin/civTableBackground.png")
|
||||
cityButton!!.isTransform=true
|
||||
|
||||
addActor(cityButton)
|
||||
zIndex = parent.children.size // so this tile is rendered over neighboring tiles
|
||||
}
|
||||
|
||||
val cityButtonText = city!!.name + " (" + city.population.population + ")"
|
||||
cityButton!!.setText(cityButtonText)
|
||||
cityButton!!.setSize(cityButton!!.prefWidth, cityButton!!.prefHeight)
|
||||
val cityButtonText = city.name + " (" + city.population.population + ")"
|
||||
val label = Label(cityButtonText, CameraStageBaseScreen.skin)
|
||||
val labelStyle = Label.LabelStyle(label.style)
|
||||
labelStyle.fontColor= city.civInfo.getCivilization().getColor()
|
||||
label.style=labelStyle
|
||||
label.addClickListener {
|
||||
UnCivGame.Current.screen = CityScreen(city)
|
||||
}
|
||||
|
||||
cityButton!!.run {
|
||||
clear()
|
||||
add(label).pad(5f)
|
||||
pack()
|
||||
setOrigin(Align.center)
|
||||
toFront()
|
||||
}
|
||||
|
||||
cityButton!!.setPosition(width/2 - cityButton!!.width / 2,
|
||||
height/2 - cityButton!!.height/2)
|
||||
|
||||
cityButton!!.setPosition((width - cityButton!!.width) / 2,
|
||||
height * 0.9f)
|
||||
cityButton!!.zIndex = cityButton!!.parent.children.size // so city button is rendered over everything else in this tile
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -74,6 +74,8 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||
val scale: Float = Math.sqrt((distance / initialDistance).toDouble()).toFloat() * lastScale
|
||||
if (scale < 1) return
|
||||
setScale(scale)
|
||||
for(tilegroup in tileGroups.values.filter { it.cityButton!=null })
|
||||
tilegroup.cityButton!!.setScale(1/scale)
|
||||
}
|
||||
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue