Use NinePatch in getRoundedEdgeTableBackground (#3080)
BIN
android/Images/OtherIcons/buttonBackground.png
Normal file
After Width: | Height: | Size: 612 B |
Before Width: | Height: | Size: 902 B After Width: | Height: | Size: 431 B |
Before Width: | Height: | Size: 882 KiB After Width: | Height: | Size: 898 KiB |
Before Width: | Height: | Size: 496 KiB After Width: | Height: | Size: 483 KiB |
|
@ -545,6 +545,12 @@ class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPa
|
|||
backgroundColor = civ.nation.getOuterColor()
|
||||
labelColor = civ.nation.getInnerColor()
|
||||
} else {
|
||||
civGroup.add(
|
||||
"?".toLabel(Color.WHITE)
|
||||
.apply { this.setAlignment(Align.center) }
|
||||
.surroundWithCircle(27f).apply { circle.color = Color.BLACK }
|
||||
.surroundWithCircle(30f, false).apply { circle.color = Color.WHITE }
|
||||
)
|
||||
backgroundColor = Color.DARK_GRAY
|
||||
labelText = "???"
|
||||
}
|
||||
|
@ -553,7 +559,7 @@ class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPa
|
|||
val label = labelText.toLabel(labelColor)
|
||||
label.setAlignment(Align.center)
|
||||
|
||||
civGroup.add(label).pad(10f)
|
||||
civGroup.add(label).padLeft(10f)
|
||||
civGroup.pack()
|
||||
return civGroup
|
||||
}
|
||||
|
|
|
@ -15,8 +15,7 @@ class TechButton(techName:String, private val techManager: TechManager, isWorldS
|
|||
|
||||
init {
|
||||
touchable = Touchable.enabled
|
||||
defaults().pad(10f)
|
||||
background = ImageGetter.getRoundedEdgeTableBackground()
|
||||
background = ImageGetter.getRoundedEdgeTableBackground(null,false)
|
||||
if (ImageGetter.techIconExists(techName))
|
||||
add(ImageGetter.getTechIconGroup(techName, 60f))
|
||||
|
||||
|
@ -26,7 +25,7 @@ class TechButton(techName:String, private val techManager: TechManager, isWorldS
|
|||
|
||||
if (isWorldScreen) {
|
||||
val percentComplete = (techCost - remainingTech) / techCost.toFloat()
|
||||
add(ImageGetter.getProgressBarVertical(2f, 50f, percentComplete, Color.BLUE, Color.WHITE))
|
||||
add(ImageGetter.getProgressBarVertical(2f, 50f, percentComplete, Color.BLUE, Color.WHITE)).pad(10f)
|
||||
rightSide.add(text).padBottom(5f).row()
|
||||
}
|
||||
else rightSide.add(text).height(25f).padBottom(5f).row()
|
||||
|
@ -70,8 +69,6 @@ class TechButton(techName:String, private val techManager: TechManager, isWorldS
|
|||
.apply { color = Color.BLACK }.surroundWithCircle(techIconSize))
|
||||
|
||||
if (isWorldScreen) rightSide.add(techEnabledIcons)
|
||||
else rightSide.add(techEnabledIcons)
|
||||
.width(techEnabledIcons.children.size * (techIconSize+6f))
|
||||
.minWidth(150f)
|
||||
else rightSide.add(techEnabledIcons).width(225f)
|
||||
}
|
||||
}
|
|
@ -128,7 +128,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
|||
|
||||
techNameToButton[tech.name] = techButton
|
||||
techButton.onClick { selectTechnology(tech, false) }
|
||||
techTable.add(techButton)
|
||||
techTable.add(techButton).fillX()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,8 +117,8 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
|||
private fun addAirUnitTable() {
|
||||
if (!showAdditionalInfoTags || tileGroup.tileInfo.airUnits.isEmpty()) return
|
||||
val secondarycolor = city.civInfo.nation.getInnerColor()
|
||||
val airUnitTable = Table().apply { defaults().pad(5f) }
|
||||
airUnitTable.background = ImageGetter.getRoundedEdgeTableBackground(city.civInfo.nation.getOuterColor())
|
||||
val airUnitTable = Table()
|
||||
airUnitTable.background = ImageGetter.getRoundedEdgeTableBackground(city.civInfo.nation.getOuterColor(),false)
|
||||
val aircraftImage = ImageGetter.getImage("OtherIcons/Aircraft")
|
||||
aircraftImage.color = secondarycolor
|
||||
airUnitTable.add(aircraftImage).size(15f)
|
||||
|
@ -175,49 +175,49 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
|||
|
||||
if (city.isInResistance()) {
|
||||
val resistanceImage = ImageGetter.getImage("StatIcons/Resistance")
|
||||
iconTable.add(resistanceImage).size(20f).pad(2f).padLeft(5f)
|
||||
iconTable.add(resistanceImage).size(20f).padLeft(5f)
|
||||
}
|
||||
|
||||
if (city.isPuppet) {
|
||||
val puppetImage = ImageGetter.getImage("OtherIcons/Puppet")
|
||||
puppetImage.color = secondaryColor
|
||||
iconTable.add(puppetImage).size(20f).pad(2f).padLeft(5f)
|
||||
iconTable.add(puppetImage).size(20f).padLeft(5f)
|
||||
}
|
||||
|
||||
if (city.isBeingRazed) {
|
||||
val fireImage = ImageGetter.getImage("OtherIcons/Fire")
|
||||
iconTable.add(fireImage).size(20f).pad(2f).padLeft(5f)
|
||||
iconTable.add(fireImage).size(20f).padLeft(5f)
|
||||
}
|
||||
if (city.isCapital()) {
|
||||
if (city.civInfo.isCityState()) {
|
||||
val cityStateImage = ImageGetter.getNationIcon("CityState")
|
||||
.apply { color = secondaryColor }
|
||||
iconTable.add(cityStateImage).size(20f).pad(2f).padLeft(10f)
|
||||
iconTable.add(cityStateImage).size(20f).padLeft(5f)
|
||||
} else {
|
||||
val starImage = ImageGetter.getImage("OtherIcons/Star").apply { color = Color.LIGHT_GRAY }
|
||||
iconTable.add(starImage).size(20f).pad(2f).padLeft(10f)
|
||||
iconTable.add(starImage).size(20f).padLeft(5f)
|
||||
}
|
||||
} else if (belongsToViewingCiv() && city.isConnectedToCapital()) {
|
||||
val connectionImage = ImageGetter.getStatIcon("CityConnection")
|
||||
connectionImage.color = secondaryColor
|
||||
iconTable.add(connectionImage).size(20f).pad(2f).padLeft(5f)
|
||||
iconTable.add(connectionImage).size(20f).padLeft(5f)
|
||||
}
|
||||
|
||||
iconTable.add(getPopulationGroup(uncivGame.viewEntireMapForDebug
|
||||
|| belongsToViewingCiv()
|
||||
|| worldScreen.viewingCiv.isSpectator())).padLeft(10f)
|
||||
|| worldScreen.viewingCiv.isSpectator())).padLeft(5f)
|
||||
|
||||
val cityButtonText = city.name
|
||||
val label = cityButtonText.toLabel(secondaryColor)
|
||||
iconTable.add(label).pad(10f) // sufficient horizontal padding
|
||||
iconTable.add(label).padRight(20f).padLeft(20f) // sufficient horizontal padding
|
||||
.fillY() // provide full-height clicking area
|
||||
|
||||
if (uncivGame.viewEntireMapForDebug || belongsToViewingCiv() || worldScreen.viewingCiv.isSpectator())
|
||||
iconTable.add(getConstructionGroup(city.cityConstructions)).padRight(10f).padLeft(10f)
|
||||
iconTable.add(getConstructionGroup(city.cityConstructions))
|
||||
else if (city.civInfo.isMajorCiv()) {
|
||||
val nationIcon = ImageGetter.getNationIcon(city.civInfo.nation.name)
|
||||
nationIcon.color = secondaryColor
|
||||
iconTable.add(nationIcon).size(20f).padRight(10f)
|
||||
iconTable.add(nationIcon).size(20f)
|
||||
}
|
||||
return iconTable
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
|||
|
||||
val groupHeight = 25f
|
||||
var groupWidth = populationLabel.width
|
||||
if (showGrowth) groupWidth += 20f
|
||||
if (showGrowth) groupWidth += 12f
|
||||
group.setSize(groupWidth, groupHeight)
|
||||
|
||||
if (showGrowth) {
|
||||
|
@ -276,30 +276,34 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
|||
group.addActor(growthBar)
|
||||
|
||||
val turnLabel : Label
|
||||
if (city.isGrowing()) {
|
||||
val turnsToGrowth = city.getNumTurnsToNewPopulation()
|
||||
if (turnsToGrowth != null) {
|
||||
if (turnsToGrowth < 100) {
|
||||
turnLabel = turnsToGrowth.toString().toLabel()
|
||||
when {
|
||||
city.isGrowing() -> {
|
||||
val turnsToGrowth = city.getNumTurnsToNewPopulation()
|
||||
turnLabel = if (turnsToGrowth != null) {
|
||||
if (turnsToGrowth < 100) {
|
||||
turnsToGrowth.toString().toLabel()
|
||||
} else {
|
||||
"∞".toLabel()
|
||||
}
|
||||
} else {
|
||||
turnLabel = "∞".toLabel()
|
||||
"∞".toLabel()
|
||||
}
|
||||
} else {
|
||||
}
|
||||
city.isStarving() -> {
|
||||
val turnsToStarvation = city.getNumTurnsToStarvation()
|
||||
turnLabel = if (turnsToStarvation != null) {
|
||||
if (turnsToStarvation < 100) {
|
||||
turnsToStarvation.toString().toLabel()
|
||||
} else {
|
||||
"∞".toLabel()
|
||||
}
|
||||
} else {
|
||||
"∞".toLabel()
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
turnLabel = "∞".toLabel()
|
||||
}
|
||||
} else if (city.isStarving()) {
|
||||
val turnsToStarvation = city.getNumTurnsToStarvation()
|
||||
if (turnsToStarvation != null) {
|
||||
if (turnsToStarvation < 100) {
|
||||
turnLabel = turnsToStarvation.toString().toLabel()
|
||||
} else {
|
||||
turnLabel = "∞".toLabel()
|
||||
}
|
||||
} else {
|
||||
turnLabel = "∞".toLabel()
|
||||
}
|
||||
} else {
|
||||
turnLabel = "∞".toLabel()
|
||||
}
|
||||
turnLabel.color = city.civInfo.nation.getInnerColor()
|
||||
turnLabel.setFontSize(14)
|
||||
|
@ -315,9 +319,11 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
|||
}
|
||||
|
||||
private fun getConstructionGroup(cityConstructions: CityConstructions): Group {
|
||||
val cityCurrentConstruction = cityConstructions.getCurrentConstruction()
|
||||
val group= Group()
|
||||
val groupHeight = 25f
|
||||
group.setSize(40f,groupHeight)
|
||||
val groupWidth = if(cityCurrentConstruction is PerpetualConstruction) 15f else 40f
|
||||
group.setSize(groupWidth,groupHeight)
|
||||
|
||||
val circle = ImageGetter.getCircle()
|
||||
circle.setSize(25f,25f)
|
||||
|
@ -334,10 +340,9 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
|
|||
group.addActor(image)
|
||||
|
||||
val secondaryColor = cityConstructions.cityInfo.civInfo.nation.getInnerColor()
|
||||
val cityCurrentConstruction = cityConstructions.getCurrentConstruction()
|
||||
if(cityCurrentConstruction !is PerpetualConstruction) {
|
||||
val turnsToConstruction = cityConstructions.turnsToConstruction(cityCurrentConstruction.name)
|
||||
val label = turnsToConstruction.toString().toLabel(secondaryColor,14)
|
||||
val label = (if(turnsToConstruction < 100) turnsToConstruction.toString() else "∞").toLabel(secondaryColor,14)
|
||||
label.pack()
|
||||
group.addActor(label)
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.unciv.ui.utils
|
|||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.NinePatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||
|
@ -10,6 +11,7 @@ import com.badlogic.gdx.scenes.scene2d.Group
|
|||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.Constants
|
||||
|
@ -87,10 +89,10 @@ object ImageGetter {
|
|||
else return textureRegionDrawables[whiteDotLocation]!!
|
||||
}
|
||||
|
||||
fun getRoundedEdgeTableBackground(tintColor: Color?=null): Drawable? {
|
||||
val drawable = getDrawable("OtherIcons/civTableBackground")
|
||||
drawable.minHeight=0f
|
||||
drawable.minWidth=0f
|
||||
fun getRoundedEdgeTableBackground(tintColor: Color?=null, isButton: Boolean =true): NinePatchDrawable {
|
||||
val drawable =if(isButton) NinePatchDrawable(NinePatch(getDrawable("OtherIcons/buttonBackground").region,20,20,20,20)).apply {
|
||||
setPadding(0f,10f,0f,10f)
|
||||
} else NinePatchDrawable(NinePatch(getDrawable("OtherIcons/civTableBackground").region,12,12,12,12))
|
||||
if(tintColor==null) return drawable
|
||||
return drawable.tint(tintColor)
|
||||
}
|
||||
|
|
|
@ -189,10 +189,10 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
|||
dominationVictoryColumn.addSeparator()
|
||||
|
||||
for (civ in majorCivs.filter { !it.isDefeated() })
|
||||
dominationVictoryColumn.add(EmpireOverviewScreen.getCivGroup(civ, "", playerCivInfo)).row()
|
||||
dominationVictoryColumn.add(EmpireOverviewScreen.getCivGroup(civ, "", playerCivInfo)).fillX().row()
|
||||
|
||||
for (civ in majorCivs.filter { it.isDefeated() })
|
||||
dominationVictoryColumn.add(EmpireOverviewScreen.getCivGroup(civ, "", playerCivInfo)).row()
|
||||
dominationVictoryColumn.add(EmpireOverviewScreen.getCivGroup(civ, "", playerCivInfo)).fillX().row()
|
||||
|
||||
return dominationVictoryColumn
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
|||
|
||||
for (entry in civsToBranchesCompleted) {
|
||||
val civToBranchesHaveCompleted= EmpireOverviewScreen.getCivGroup(entry.civ, " - " + entry.branchesCompleted, playerCivInfo)
|
||||
policyVictoryColumn.add(civToBranchesHaveCompleted).row()
|
||||
policyVictoryColumn.add(civToBranchesHaveCompleted).fillX().row()
|
||||
}
|
||||
return policyVictoryColumn
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
|||
|
||||
for (entry in civsToPartsRemaining) {
|
||||
val civToPartsBeRemaining=(EmpireOverviewScreen.getCivGroup(entry.civ, " - " + entry.partsRemaining, playerCivInfo))
|
||||
scientificVictoryColumn.add(civToPartsBeRemaining).row()
|
||||
scientificVictoryColumn.add(civToPartsBeRemaining).fillX().row()
|
||||
}
|
||||
return scientificVictoryColumn
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
|||
column.addSeparator()
|
||||
|
||||
for (civ in majorCivs.sortedByDescending { it.getStatForRanking(category) }) {
|
||||
column.add(EmpireOverviewScreen.getCivGroup(civ, " : " + civ.getStatForRanking(category).toString(), playerCivInfo)).row()
|
||||
column.add(EmpireOverviewScreen.getCivGroup(civ, " : " + civ.getStatForRanking(category).toString(), playerCivInfo)).fillX().row()
|
||||
}
|
||||
|
||||
civRankingsTable.add(column)
|
||||
|
|
|
@ -34,9 +34,9 @@ class NotificationsScroll(internal val worldScreen: WorldScreen) : ScrollPane(nu
|
|||
val listItem = Table()
|
||||
|
||||
listItem.add(ImageGetter.getCircle()
|
||||
.apply { color=notification.color }).size(10f).pad(5f)
|
||||
listItem.background = ImageGetter.getRoundedEdgeTableBackground()
|
||||
listItem.add(label).pad(5f).padRight(10f)
|
||||
.apply { color=notification.color }).size(10f).padRight(5f)
|
||||
listItem.background = ImageGetter.getRoundedEdgeTableBackground(null, false)
|
||||
listItem.add(label)
|
||||
|
||||
// using a large click area with no gap in between each message item.
|
||||
// this avoids accidentally clicking in between the messages, resulting in a map click
|
||||
|
|