Resolved #3428 - added a toggle for displaying yield icons

This commit is contained in:
Yair Morgenstern
2020-12-19 21:26:18 +02:00
parent 78513b87c1
commit eda8b84c2d

View File

@ -96,11 +96,11 @@ class Minimap(val mapHolder: WorldMapHolder) : Table(){
} }
} }
class MinimapHolder(mapHolder: WorldMapHolder): Table(){ class MinimapHolder(mapHolder: WorldMapHolder): Table() {
val minimap = Minimap(mapHolder) val minimap = Minimap(mapHolder)
val worldScreen = mapHolder.worldScreen val worldScreen = mapHolder.worldScreen
init{ init {
add(getToggleIcons()).align(Align.bottom) add(getToggleIcons()).align(Align.bottom)
add(getWrappedMinimap()) add(getWrappedMinimap())
pack() pack()
@ -108,57 +108,59 @@ class MinimapHolder(mapHolder: WorldMapHolder): Table(){
private fun getWrappedMinimap(): Table { private fun getWrappedMinimap(): Table {
val internalMinimapWrapper = Table() val internalMinimapWrapper = Table()
// // Temporarily disabled until we can make them work nicely together internalMinimapWrapper.add(minimap)
// val sizePercent = worldScreen.game.settings.minimapSize
// val sizeWinX = worldScreen.stage.width * sizePercent / 100
// val sizeWinY = worldScreen.stage.height * sizePercent / 100
// val isSquare = worldScreen.game.settings.minimapSquare
// val sizeX = if (isSquare) sqrt(sizeWinX * sizeWinY) else sizeWinX
// val sizeY = if (isSquare) sizeX else sizeWinY
internalMinimapWrapper.add(minimap) //.size(sizeX,sizeY)
minimap
internalMinimapWrapper.background=ImageGetter.getBackground(Color.GRAY) internalMinimapWrapper.background = ImageGetter.getBackground(Color.GRAY)
internalMinimapWrapper.pack() internalMinimapWrapper.pack()
val externalMinimapWrapper = Table() val externalMinimapWrapper = Table()
externalMinimapWrapper.add(internalMinimapWrapper).pad(5f) externalMinimapWrapper.add(internalMinimapWrapper).pad(5f)
externalMinimapWrapper.background=ImageGetter.getBackground(Color.WHITE) externalMinimapWrapper.background = ImageGetter.getBackground(Color.WHITE)
externalMinimapWrapper.pack() externalMinimapWrapper.pack()
return externalMinimapWrapper return externalMinimapWrapper
} }
private fun getToggleIcons():Table{ private fun getToggleIcons(): Table {
val toggleIconTable=Table() val toggleIconTable = Table()
val settings = UncivGame.Current.settings val settings = UncivGame.Current.settings
val yieldImage = ImageGetter.getStatIcon("Food").surroundWithCircle(40f)
yieldImage.circle.color = Color.BLACK
yieldImage.actor.color.a = if (settings.showTileYields) 1f else 0.5f
yieldImage.onClick {
settings.showTileYields = !settings.showTileYields
yieldImage.actor.color.a = if (settings.showTileYields) 1f else 0.5f
worldScreen.shouldUpdate = true
}
toggleIconTable.add(yieldImage).row()
val populationImage = ImageGetter.getStatIcon("Population").surroundWithCircle(40f) val populationImage = ImageGetter.getStatIcon("Population").surroundWithCircle(40f)
populationImage.circle.color = Color.BLACK populationImage.circle.color = Color.BLACK
populationImage.actor.color.a = if(settings.showWorkedTiles) 1f else 0.5f populationImage.actor.color.a = if (settings.showWorkedTiles) 1f else 0.5f
populationImage.onClick { populationImage.onClick {
settings.showWorkedTiles = !settings.showWorkedTiles settings.showWorkedTiles = !settings.showWorkedTiles
populationImage.actor.color.a = if(settings.showWorkedTiles) 1f else 0.5f populationImage.actor.color.a = if (settings.showWorkedTiles) 1f else 0.5f
worldScreen.shouldUpdate=true worldScreen.shouldUpdate = true
} }
toggleIconTable.add(populationImage).row() toggleIconTable.add(populationImage).row()
val resourceImage = ImageGetter.getImage("ResourceIcons/Cattle") val resourceImage = ImageGetter.getImage("ResourceIcons/Cattle")
.surroundWithCircle(30f).apply { circle.color = Color.GREEN } .surroundWithCircle(30f).apply { circle.color = Color.GREEN }
.surroundWithCircle(40f,false).apply { circle.color = Color.BLACK } .surroundWithCircle(40f, false).apply { circle.color = Color.BLACK }
resourceImage.actor.color.a = if(settings.showResourcesAndImprovements) 1f else 0.5f resourceImage.actor.color.a = if (settings.showResourcesAndImprovements) 1f else 0.5f
resourceImage.onClick { resourceImage.onClick {
settings.showResourcesAndImprovements = !settings.showResourcesAndImprovements settings.showResourcesAndImprovements = !settings.showResourcesAndImprovements
resourceImage.actor.color.a = if(settings.showResourcesAndImprovements) 1f else 0.5f resourceImage.actor.color.a = if (settings.showResourcesAndImprovements) 1f else 0.5f
worldScreen.shouldUpdate=true worldScreen.shouldUpdate = true
} }
toggleIconTable.add(resourceImage) toggleIconTable.add(resourceImage)
toggleIconTable.pack() toggleIconTable.pack()
return toggleIconTable return toggleIconTable
} }
fun update(civInfo:CivilizationInfo){ fun update(civInfo: CivilizationInfo) {
isVisible = UncivGame.Current.settings.showMinimap isVisible = UncivGame.Current.settings.showMinimap
minimap.update(civInfo) minimap.update(civInfo)
} }