mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-30 07:21:34 -04:00
Start preference Avoid shown with red X (#5253)
This commit is contained in:
parent
f02675c5b0
commit
8cff3fda49
@ -230,7 +230,8 @@ class Nation : INamed, ICivilopediaText, IHasUniques {
|
|||||||
textList += FormattedLine(
|
textList += FormattedLine(
|
||||||
(if (it.index == 0) "[Start bias:] " else "") + it.value.tr(), // extra tr because tr cannot nest {[]}
|
(if (it.index == 0) "[Start bias:] " else "") + it.value.tr(), // extra tr because tr cannot nest {[]}
|
||||||
link = "Terrain/$link",
|
link = "Terrain/$link",
|
||||||
indent = if (it.index == 0) 0 else 1)
|
indent = if (it.index == 0) 0 else 1,
|
||||||
|
iconCrossed = it.value.startsWith("Avoid "))
|
||||||
}
|
}
|
||||||
textList += FormattedLine()
|
textList += FormattedLine()
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.unciv.ui.civilopedia
|
|||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Group
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
@ -64,7 +65,9 @@ class FormattedLine (
|
|||||||
/** Decorates text with a star icon - if set, it receives the [color] instead of the text. */
|
/** Decorates text with a star icon - if set, it receives the [color] instead of the text. */
|
||||||
val starred: Boolean = false,
|
val starred: Boolean = false,
|
||||||
/** Centers the line (and turns off wrap) */
|
/** Centers the line (and turns off wrap) */
|
||||||
val centered: Boolean = false
|
val centered: Boolean = false,
|
||||||
|
/** Paint a red X over the [icon] or [link] image */
|
||||||
|
val iconCrossed: Boolean = false
|
||||||
) {
|
) {
|
||||||
// Note: This gets directly deserialized by Json - please keep all attributes meant to be read
|
// Note: This gets directly deserialized by Json - please keep all attributes meant to be read
|
||||||
// from json in the primary constructor parameters above. Everything else should be a fun(),
|
// from json in the primary constructor parameters above. Everything else should be a fun(),
|
||||||
@ -305,7 +308,20 @@ class FormattedLine (
|
|||||||
val category = CivilopediaCategories.fromLink(parts[0]) ?: return 0
|
val category = CivilopediaCategories.fromLink(parts[0]) ?: return 0
|
||||||
val image = category.getImage?.invoke(parts[1], iconSize) ?: return 0
|
val image = category.getImage?.invoke(parts[1], iconSize) ?: return 0
|
||||||
|
|
||||||
table.add(image).size(iconSize).padRight(iconPad)
|
if (iconCrossed) {
|
||||||
|
val cross = ImageGetter.getRedCross(iconSize * 0.7f, 0.7f)
|
||||||
|
val group = Group().apply {
|
||||||
|
isTransform = false
|
||||||
|
setSize(iconSize, iconSize)
|
||||||
|
image.center(this)
|
||||||
|
addActor(image)
|
||||||
|
cross.center(this)
|
||||||
|
addActor(cross)
|
||||||
|
}
|
||||||
|
table.add(group).size(iconSize).padRight(iconPad)
|
||||||
|
} else {
|
||||||
|
table.add(image).size(iconSize).padRight(iconPad)
|
||||||
|
}
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||||
import com.badlogic.gdx.scenes.scene2d.Group
|
import com.badlogic.gdx.scenes.scene2d.Group
|
||||||
import com.badlogic.gdx.scenes.scene2d.Touchable
|
import com.badlogic.gdx.scenes.scene2d.Touchable
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Slider
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
@ -12,7 +11,6 @@ import com.unciv.logic.civilization.CivilizationInfo
|
|||||||
import com.unciv.logic.map.MapUnit
|
import com.unciv.logic.map.MapUnit
|
||||||
import com.unciv.logic.map.RoadStatus
|
import com.unciv.logic.map.RoadStatus
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.logic.map.TileMap
|
|
||||||
import com.unciv.models.metadata.Player
|
import com.unciv.models.metadata.Player
|
||||||
import com.unciv.models.ruleset.Nation
|
import com.unciv.models.ruleset.Nation
|
||||||
import com.unciv.models.ruleset.tile.TerrainType
|
import com.unciv.models.ruleset.tile.TerrainType
|
||||||
@ -82,7 +80,7 @@ class MapEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(CameraS
|
|||||||
val baseTerrainTable = Table().apply { defaults().pad(20f) }
|
val baseTerrainTable = Table().apply { defaults().pad(20f) }
|
||||||
val terrainFeaturesTable = Table().apply { defaults().pad(20f) }
|
val terrainFeaturesTable = Table().apply { defaults().pad(20f) }
|
||||||
|
|
||||||
terrainFeaturesTable.add(getHex(getRedCross(50f, 0.6f)).apply {
|
terrainFeaturesTable.add(getHex(ImageGetter.getRedCross(50f, 0.6f)).apply {
|
||||||
onClick {
|
onClick {
|
||||||
tileAction = {
|
tileAction = {
|
||||||
it.terrainFeatures.clear()
|
it.terrainFeatures.clear()
|
||||||
@ -91,7 +89,7 @@ class MapEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(CameraS
|
|||||||
it.hasBottomLeftRiver = false
|
it.hasBottomLeftRiver = false
|
||||||
it.hasBottomRightRiver = false
|
it.hasBottomRightRiver = false
|
||||||
}
|
}
|
||||||
setCurrentHex(getHex(getRedCross(40f, 0.6f)), "Clear terrain features")
|
setCurrentHex(getHex(ImageGetter.getRedCross(40f, 0.6f)), "Clear terrain features")
|
||||||
}
|
}
|
||||||
}).row()
|
}).row()
|
||||||
|
|
||||||
@ -125,10 +123,10 @@ class MapEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(CameraS
|
|||||||
editorPickTable.clear()
|
editorPickTable.clear()
|
||||||
|
|
||||||
val improvementsTable = Table()
|
val improvementsTable = Table()
|
||||||
improvementsTable.add(getHex(getRedCross(40f, 0.6f)).apply {
|
improvementsTable.add(getHex(ImageGetter.getRedCross(40f, 0.6f)).apply {
|
||||||
onClick {
|
onClick {
|
||||||
tileAction = { it.improvement = null; it.roadStatus = RoadStatus.None }
|
tileAction = { it.improvement = null; it.roadStatus = RoadStatus.None }
|
||||||
setCurrentHex(getHex(getRedCross(40f, 0.6f)), "Clear improvements")
|
setCurrentHex(getHex(ImageGetter.getRedCross(40f, 0.6f)), "Clear improvements")
|
||||||
}
|
}
|
||||||
}).row()
|
}).row()
|
||||||
|
|
||||||
@ -269,20 +267,13 @@ class MapEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(CameraS
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getCrossedIcon(): Actor {
|
private fun getCrossedIcon(): Actor {
|
||||||
return getRedCross(20f, 0.6f)
|
return ImageGetter.getRedCross(20f, 0.6f)
|
||||||
.surroundWithCircle(40f, false)
|
.surroundWithCircle(40f, false)
|
||||||
.apply { circle.color = Color.WHITE }
|
.apply { circle.color = Color.WHITE }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getRedCross(size: Float, alpha: Float): Actor {
|
|
||||||
val redCross = ImageGetter.getImage("OtherIcons/Close")
|
|
||||||
redCross.setSize(size, size)
|
|
||||||
redCross.color = Color.RED.cpy().apply { a = alpha }
|
|
||||||
return redCross
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getCrossedResource(): Actor {
|
private fun getCrossedResource(): Actor {
|
||||||
val redCross = getRedCross(45f, 0.5f)
|
val redCross = ImageGetter.getRedCross(45f, 0.5f)
|
||||||
val group = IconCircleGroup(40f, redCross, false)
|
val group = IconCircleGroup(40f, redCross, false)
|
||||||
group.circle.color = ImageGetter.foodCircleColor
|
group.circle.color = ImageGetter.foodCircleColor
|
||||||
return group
|
return group
|
||||||
|
@ -151,9 +151,7 @@ class ImprovementPickerScreen(val tileInfo: TileInfo, unit: MapUnit, val onAccep
|
|||||||
// icon for removing the resource by replacing improvement
|
// icon for removing the resource by replacing improvement
|
||||||
if (removeImprovement && tileInfo.hasViewableResource(currentPlayerCiv) && tileInfo.getTileResource().improvement == tileInfo.improvement) {
|
if (removeImprovement && tileInfo.hasViewableResource(currentPlayerCiv) && tileInfo.getTileResource().improvement == tileInfo.improvement) {
|
||||||
val crossedResource = Group()
|
val crossedResource = Group()
|
||||||
val cross = ImageGetter.getImage("OtherIcons/Close")
|
val cross = ImageGetter.getRedCross(30f, 0.8f)
|
||||||
cross.setSize(30f, 30f)
|
|
||||||
cross.color = Color.RED
|
|
||||||
val resourceIcon = ImageGetter.getResourceImage(tileInfo.resource.toString(), 30f)
|
val resourceIcon = ImageGetter.getResourceImage(tileInfo.resource.toString(), 30f)
|
||||||
crossedResource.addActor(resourceIcon)
|
crossedResource.addActor(resourceIcon)
|
||||||
crossedResource.addActor(cross)
|
crossedResource.addActor(cross)
|
||||||
|
@ -59,9 +59,7 @@ class TechButton(techName:String, private val techManager: TechManager, isWorldS
|
|||||||
|
|
||||||
for (building in tech.getObsoletedBuildings(techManager.civInfo))
|
for (building in tech.getObsoletedBuildings(techManager.civInfo))
|
||||||
techEnabledIcons.add(ImageGetter.getConstructionImage(building.name).surroundWithCircle(techIconSize).apply {
|
techEnabledIcons.add(ImageGetter.getConstructionImage(building.name).surroundWithCircle(techIconSize).apply {
|
||||||
val closeImage = ImageGetter.getImage("OtherIcons/Close")
|
val closeImage = ImageGetter.getRedCross(techIconSize / 2, 1f)
|
||||||
closeImage.setSize(techIconSize / 2, techIconSize / 2)
|
|
||||||
closeImage.color = Color.RED
|
|
||||||
closeImage.center(this)
|
closeImage.center(this)
|
||||||
addActor(closeImage)
|
addActor(closeImage)
|
||||||
})
|
})
|
||||||
|
@ -5,12 +5,16 @@ import com.badlogic.gdx.scenes.scene2d.Actor
|
|||||||
import com.badlogic.gdx.scenes.scene2d.Group
|
import com.badlogic.gdx.scenes.scene2d.Group
|
||||||
|
|
||||||
class IconCircleGroup(size: Float, val actor: Actor, resizeActor: Boolean = true, color: Color = Color.WHITE): Group(){
|
class IconCircleGroup(size: Float, val actor: Actor, resizeActor: Boolean = true, color: Color = Color.WHITE): Group(){
|
||||||
val circle = ImageGetter.getCircle().apply { setSize(size, size); setColor(color) }
|
val circle = ImageGetter.getCircle().apply {
|
||||||
|
setSize(size, size)
|
||||||
|
setColor(color)
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
isTransform=false // performance helper - nothing here is rotated or scaled
|
isTransform = false // performance helper - nothing here is rotated or scaled
|
||||||
setSize(size, size)
|
setSize(size, size)
|
||||||
addActor(circle)
|
addActor(circle)
|
||||||
if(resizeActor) actor.setSize(size * 0.75f, size * 0.75f)
|
if (resizeActor) actor.setSize(size * 0.75f, size * 0.75f)
|
||||||
actor.center(this)
|
actor.center(this)
|
||||||
addActor(actor)
|
addActor(actor)
|
||||||
}
|
}
|
||||||
|
@ -322,6 +322,12 @@ object ImageGetter {
|
|||||||
return drawable.tint(color)
|
return drawable.tint(color)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getRedCross(size: Float, alpha: Float): Actor {
|
||||||
|
val redCross = getImage("OtherIcons/Close")
|
||||||
|
redCross.setSize(size, size)
|
||||||
|
redCross.color = Color.RED.cpy().apply { a = alpha }
|
||||||
|
return redCross
|
||||||
|
}
|
||||||
|
|
||||||
fun getResourceImage(resourceName: String, size: Float): Actor {
|
fun getResourceImage(resourceName: String, size: Float): Actor {
|
||||||
val iconGroup = getImage("ResourceIcons/$resourceName").surroundWithCircle(size)
|
val iconGroup = getImage("ResourceIcons/$resourceName").surroundWithCircle(size)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user