Merged all arrow images into one

Removed unnecessary filterNotNull from getTileBaseImageLocation
This commit is contained in:
Yair Morgenstern 2022-02-09 16:59:05 +02:00
parent 09ea1a869d
commit 13f052878b
8 changed files with 21 additions and 10 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 441 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 422 B

View File

@ -3,6 +3,7 @@ package com.unciv.models
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.utils.Align
import com.unciv.ui.utils.KeyCharAndCode
import com.unciv.ui.utils.ImageGetter
import com.unciv.Constants
@ -149,7 +150,7 @@ enum class UnitActionType(
// readability factories
private fun imageGetStopMove() = ImageGetter.getStatIcon("Movement").apply { color = Color.RED }
private fun imageGetPromote() = ImageGetter.getImage("OtherIcons/Star").apply { color = Color.GOLD }
private fun imageGetShowMore() = ImageGetter.getImage("OtherIcons/ArrowRight").apply { color = Color.BLACK }
private fun imageGetHideMore() = ImageGetter.getImage("OtherIcons/ArrowLeft").apply { color = Color.BLACK }
private fun imageGetShowMore() = ImageGetter.getArrowImage(Align.right).apply { color = Color.BLACK }
private fun imageGetHideMore() = ImageGetter.getArrowImage(Align.left).apply { color = Color.BLACK }
}
}

View File

@ -17,7 +17,6 @@ import com.unciv.models.stats.Stat
import com.unciv.models.translations.tr
import com.unciv.ui.utils.*
import com.unciv.ui.utils.UncivTooltip.Companion.addTooltip
import kotlin.concurrent.thread
import kotlin.math.max
import kotlin.math.min
import com.unciv.ui.utils.AutoScrollPane as ScrollPane
@ -531,7 +530,7 @@ class CityConstructionsTable(private val cityScreen: CityScreen) {
private fun getRaisePriorityButton(constructionQueueIndex: Int, name: String, city: CityInfo): Table {
val tab = Table()
tab.add(ImageGetter.getImage("OtherIcons/Up").surroundWithCircle(40f))
tab.add(ImageGetter.getArrowImage(Align.top).apply { color = Color.BLACK }.surroundWithCircle(40f))
if (cityScreen.canChangeState && !city.isPuppet) {
tab.touchable = Touchable.enabled
tab.onClick {
@ -548,7 +547,7 @@ class CityConstructionsTable(private val cityScreen: CityScreen) {
private fun getLowerPriorityButton(constructionQueueIndex: Int, name: String, city: CityInfo): Table {
val tab = Table()
tab.add(ImageGetter.getImage("OtherIcons/Down").surroundWithCircle(40f))
tab.add(ImageGetter.getArrowImage(Align.bottom).apply { color = Color.BLACK }.surroundWithCircle(40f))
if (cityScreen.canChangeState && !city.isPuppet) {
tab.touchable = Touchable.enabled
tab.onClick {

View File

@ -209,17 +209,17 @@ open class TileGroup(var tileInfo: TileInfo, val tileSetStrings:TileSetStrings,
if (tileInfo.naturalWonder != null) return listOf(tileSetStrings.orFallback { getTile(tileInfo.naturalWonder!!) })
val shownImprovement = tileInfo.getShownImprovement(viewingCiv)
val shouldShowImprovement = (shownImprovement != null && UncivGame.Current.settings.showPixelImprovements)
val shouldShowImprovement = shownImprovement != null && UncivGame.Current.settings.showPixelImprovements
val shouldShowResource = UncivGame.Current.settings.showPixelImprovements && tileInfo.resource != null &&
(showEntireMap || viewingCiv == null || tileInfo.hasViewableResource(viewingCiv))
val resourceAndImprovementSequence = sequence {
if (shouldShowResource) yield(tileInfo.resource)
if (shouldShowImprovement) yield(shownImprovement)
}.filterNotNull()
if (shouldShowResource) yield(tileInfo.resource!!)
if (shouldShowImprovement) yield(shownImprovement!!)
}
val terrainImages = (sequenceOf(tileInfo.baseTerrain) + tileInfo.terrainFeatures.asSequence()).filterNotNull()
val terrainImages = sequenceOf(tileInfo.baseTerrain) + tileInfo.terrainFeatures.asSequence()
val allTogether = (terrainImages + resourceAndImprovementSequence).joinToString("+")
val allTogetherLocation = tileSetStrings.getTile(allTogether)

View File

@ -3,6 +3,7 @@ package com.unciv.ui.utils
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.Group
import com.badlogic.gdx.utils.Align
class IconCircleGroup(size: Float, val actor: Actor, resizeActor: Boolean = true, color: Color = Color.WHITE): Group(){
val circle = ImageGetter.getCircle().apply {
@ -16,6 +17,7 @@ class IconCircleGroup(size: Float, val actor: Actor, resizeActor: Boolean = true
addActor(circle)
if (resizeActor) actor.setSize(size * 0.75f, size * 0.75f)
actor.center(this)
actor.setOrigin(Align.center)
addActor(actor)
}
}

View File

@ -333,6 +333,15 @@ object ImageGetter {
return redCross
}
fun getArrowImage(align:Int = Align.right): Image {
val image = getImage("OtherIcons/ArrowRight")
image.setOrigin(Align.center)
if (align == Align.left) image.rotation = 180f
if (align == Align.bottom) image.rotation = -90f
if (align == Align.top) image.rotation = 90f
return image
}
fun getResourceImage(resourceName: String, size: Float): IconCircleGroup {
val iconGroup = getImage("ResourceIcons/$resourceName").surroundWithCircle(size)
val resource = ruleset.tileResources[resourceName]