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 worldScreen = mapHolder.worldScreen
init{
init {
add(getToggleIcons()).align(Align.bottom)
add(getWrappedMinimap())
pack()
@ -108,57 +108,59 @@ class MinimapHolder(mapHolder: WorldMapHolder): Table(){
private fun getWrappedMinimap(): Table {
val internalMinimapWrapper = Table()
// // Temporarily disabled until we can make them work nicely together
// 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.add(minimap)
internalMinimapWrapper.background=ImageGetter.getBackground(Color.GRAY)
internalMinimapWrapper.background = ImageGetter.getBackground(Color.GRAY)
internalMinimapWrapper.pack()
val externalMinimapWrapper = Table()
externalMinimapWrapper.add(internalMinimapWrapper).pad(5f)
externalMinimapWrapper.background=ImageGetter.getBackground(Color.WHITE)
externalMinimapWrapper.background = ImageGetter.getBackground(Color.WHITE)
externalMinimapWrapper.pack()
return externalMinimapWrapper
}
private fun getToggleIcons():Table{
val toggleIconTable=Table()
private fun getToggleIcons(): Table {
val toggleIconTable = Table()
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)
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 {
settings.showWorkedTiles = !settings.showWorkedTiles
populationImage.actor.color.a = if(settings.showWorkedTiles) 1f else 0.5f
worldScreen.shouldUpdate=true
populationImage.actor.color.a = if (settings.showWorkedTiles) 1f else 0.5f
worldScreen.shouldUpdate = true
}
toggleIconTable.add(populationImage).row()
val resourceImage = ImageGetter.getImage("ResourceIcons/Cattle")
.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 {
settings.showResourcesAndImprovements = !settings.showResourcesAndImprovements
resourceImage.actor.color.a = if(settings.showResourcesAndImprovements) 1f else 0.5f
worldScreen.shouldUpdate=true
resourceImage.actor.color.a = if (settings.showResourcesAndImprovements) 1f else 0.5f
worldScreen.shouldUpdate = true
}
toggleIconTable.add(resourceImage)
toggleIconTable.pack()
return toggleIconTable
}
fun update(civInfo:CivilizationInfo){
fun update(civInfo: CivilizationInfo) {
isVisible = UncivGame.Current.settings.showMinimap
minimap.update(civInfo)
}
@ -168,4 +170,4 @@ class MinimapHolder(mapHolder: WorldMapHolder): Table(){
override fun draw(batch: Batch?, parentAlpha: Float) {
super.draw(batch, parentAlpha)
}
}
}