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