mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-27 08:09:21 +07:00
Unit pixel images are now opt-in
This commit is contained in:
@ -19,6 +19,7 @@ class GameSettings {
|
||||
var autoAssignCityProduction: Boolean = true
|
||||
var autoBuildingRoads: Boolean = true
|
||||
var showMinimap: Boolean = true
|
||||
var showPixelUnits: Boolean = false
|
||||
|
||||
var userName:String=""
|
||||
var userId = ""
|
||||
|
@ -43,6 +43,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
|
||||
|
||||
protected var pixelMilitaryUnitImageLocation = ""
|
||||
protected var pixelMilitaryUnitImage: Image? = null
|
||||
protected var pixelCivilianUnitImageLocation = ""
|
||||
protected var pixelCivilianUnitImage: Image? = null
|
||||
|
||||
val miscLayerGroup = Group().apply { isTransform = false; setSize(groupSize, groupSize) }
|
||||
@ -177,8 +178,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
|
||||
}
|
||||
|
||||
fun addPopulationIcon() {
|
||||
this.
|
||||
populationImage = ImageGetter.getStatIcon("Population")
|
||||
this.populationImage = ImageGetter.getStatIcon("Population")
|
||||
populationImage!!.run {
|
||||
color = Color.GREEN.cpy().lerp(Color.BLACK, 0.5f)
|
||||
setSize(20f, 20f)
|
||||
@ -411,16 +411,17 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
|
||||
if (tileInfo.militaryUnit != null && showMilitaryUnit) {
|
||||
val unitType = tileInfo.militaryUnit!!.type
|
||||
val specificUnitIconLocation = tileSetStrings.unitsLocation + tileInfo.militaryUnit!!.name
|
||||
if(ImageGetter.imageExists(specificUnitIconLocation))
|
||||
newImageLocation = specificUnitIconLocation
|
||||
else if(unitType == UnitType.Mounted) newImageLocation = tileSetStrings.unitsLocation+"Horseman"
|
||||
else if(unitType == UnitType.Ranged) newImageLocation = tileSetStrings.unitsLocation+"Archer"
|
||||
else if(unitType == UnitType.Armor) newImageLocation = tileSetStrings.unitsLocation+"Tank"
|
||||
else if(unitType == UnitType.Siege) newImageLocation = tileSetStrings.unitsLocation+"Catapult"
|
||||
else if (unitType.isLandUnit() && ImageGetter.imageExists(tileSetStrings.landUnit))
|
||||
newImageLocation = tileSetStrings.landUnit
|
||||
else if (unitType.isWaterUnit() && ImageGetter.imageExists(tileSetStrings.waterUnit))
|
||||
newImageLocation = tileSetStrings.waterUnit
|
||||
newImageLocation = when {
|
||||
!UnCivGame.Current.settings.showPixelUnits -> ""
|
||||
ImageGetter.imageExists(specificUnitIconLocation) -> specificUnitIconLocation
|
||||
unitType == UnitType.Mounted -> tileSetStrings.unitsLocation + "Horseman"
|
||||
unitType == UnitType.Ranged -> tileSetStrings.unitsLocation + "Archer"
|
||||
unitType == UnitType.Armor -> tileSetStrings.unitsLocation + "Tank"
|
||||
unitType == UnitType.Siege -> tileSetStrings.unitsLocation + "Catapult"
|
||||
unitType.isLandUnit() && ImageGetter.imageExists(tileSetStrings.landUnit) -> tileSetStrings.landUnit
|
||||
unitType.isWaterUnit() && ImageGetter.imageExists(tileSetStrings.waterUnit) -> tileSetStrings.waterUnit
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
if (pixelMilitaryUnitImageLocation != newImageLocation) {
|
||||
@ -435,31 +436,34 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
|
||||
pixelMilitaryUnitImage = pixelUnitImage
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun updatePixelCivilianUnit(tileIsViewable: Boolean) {
|
||||
if (tileInfo.civilianUnit==null || !tileIsViewable) {
|
||||
if (pixelCivilianUnitImage != null) {
|
||||
pixelCivilianUnitImage!!.remove()
|
||||
pixelCivilianUnitImage = null
|
||||
}
|
||||
} else {
|
||||
if (pixelCivilianUnitImage == null) {
|
||||
var imageLocation = ""
|
||||
val specificUnitIconLocation = tileSetStrings.unitsLocation+tileInfo.civilianUnit!!.name
|
||||
if(ImageGetter.imageExists(specificUnitIconLocation))
|
||||
imageLocation = specificUnitIconLocation
|
||||
var newImageLocation = ""
|
||||
|
||||
if (imageLocation != "") {
|
||||
val pixelUnitImage = ImageGetter.getImage(imageLocation)
|
||||
if (tileInfo.civilianUnit != null && tileIsViewable) {
|
||||
val specificUnitIconLocation = tileSetStrings.unitsLocation + tileInfo.civilianUnit!!.name
|
||||
newImageLocation = when {
|
||||
!UnCivGame.Current.settings.showPixelUnits -> ""
|
||||
ImageGetter.imageExists(specificUnitIconLocation) -> specificUnitIconLocation
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
if (pixelCivilianUnitImageLocation != newImageLocation) {
|
||||
pixelCivilianUnitImage?.remove()
|
||||
pixelCivilianUnitImage = null
|
||||
pixelCivilianUnitImageLocation = newImageLocation
|
||||
|
||||
if (newImageLocation != "") {
|
||||
val pixelUnitImage = ImageGetter.getImage(newImageLocation)
|
||||
terrainFeatureLayerGroup.addActor(pixelUnitImage)
|
||||
setHexagonImageSize(pixelUnitImage)// Treat this as A TILE, which gets overlayed on the base tile.
|
||||
pixelCivilianUnitImage = pixelUnitImage
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateImprovementImage(showResourcesAndImprovements: Boolean) {
|
||||
if (improvementImage != null) {
|
||||
|
@ -201,8 +201,9 @@ object ImageGetter {
|
||||
fun getProgressBarVertical(width:Float,height:Float,percentComplete:Float,progressColor:Color,backgroundColor:Color): Table {
|
||||
val advancementGroup = Table()
|
||||
val completionHeight = height * percentComplete
|
||||
advancementGroup.add(getImage(whiteDotLocation).apply { color = backgroundColor }).width(width).height(height-completionHeight).row()
|
||||
advancementGroup.add(getImage(whiteDotLocation).apply { color= progressColor}).width(width).height(completionHeight)
|
||||
advancementGroup.add(getImage(whiteDotLocation).apply { color = backgroundColor })
|
||||
.size(width, height - completionHeight).row()
|
||||
advancementGroup.add(getImage(whiteDotLocation).apply { color = progressColor }).size(width, completionHeight)
|
||||
advancementGroup.pack()
|
||||
return advancementGroup
|
||||
}
|
||||
@ -217,10 +218,10 @@ object ImageGetter {
|
||||
healthPercent > 1 / 3f -> Color.ORANGE
|
||||
else -> Color.RED
|
||||
}
|
||||
healthBar.add(healthPartOfBar).width(healthBarSize * healthPercent).height(5f)
|
||||
healthBar.add(healthPartOfBar).size(healthBarSize * healthPercent, 5f)
|
||||
|
||||
val emptyPartOfBar = getDot(Color.BLACK)
|
||||
healthBar.add(emptyPartOfBar).width(healthBarSize * (1 - healthPercent)).height(5f)
|
||||
healthBar.add(emptyPartOfBar).size(healthBarSize * (1 - healthPercent), 5f)
|
||||
|
||||
healthBar.pad(1f)
|
||||
healthBar.pack()
|
||||
|
@ -92,6 +92,12 @@ class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScr
|
||||
update()
|
||||
}
|
||||
|
||||
innerTable.add("Show pixel units".toLabel())
|
||||
innerTable.addButton(if (settings.showPixelUnits) "Yes".tr() else "No".tr()) {
|
||||
settings.showPixelUnits = !settings.showPixelUnits
|
||||
update()
|
||||
}
|
||||
|
||||
addLanguageSelectBox(innerTable)
|
||||
|
||||
addFontSelectBox(innerTable)
|
||||
|
Reference in New Issue
Block a user