Resolved #593 - Show/Hide resources and improvements button wasn't working

This commit is contained in:
Yair Morgenstern 2019-03-22 10:57:18 +02:00
parent a3542597ae
commit a751ed6e31
2 changed files with 14 additions and 12 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 939 KiB

After

Width:  |  Height:  |  Size: 939 KiB

View File

@ -392,23 +392,25 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
}
private fun updateResourceImage(showResourcesAndImprovements: Boolean) {
val shouldDisplayResource =
if(showEntireMap) tileInfo.resource!=null
else showResourcesAndImprovements
&& tileInfo.hasViewableResource(tileInfo.tileMap.gameInfo.getCurrentPlayerCivilization())
if(resource!=tileInfo.resource){
resource=tileInfo.resource
if (resourceImage != null) resourceImage!!.remove()
resourceImage=null
if (resource==null) resourceImage=null
else {
resourceImage = ImageGetter.getResourceImage(tileInfo.resource!!, 20f)
resourceImage!!.center(this)
resourceImage!!.x = resourceImage!!.x - 22 // left
resourceImage!!.y = resourceImage!!.y + 10 // top
miscLayerGroup.addActor(resourceImage!!)
}
}
if (resourceImage == null && shouldDisplayResource) { // This could happen on any turn, since resources need certain techs to reveal them
resourceImage = ImageGetter.getResourceImage(tileInfo.resource!!, 20f)
resourceImage!!.center(this)
resourceImage!!.x = resourceImage!!.x - 22 // left
resourceImage!!.y = resourceImage!!.y + 10 // top
miscLayerGroup.addActor(resourceImage!!)
if (resourceImage != null) { // This could happen on any turn, since resources need certain techs to reveal them
val shouldDisplayResource =
if(showEntireMap) tileInfo.resource!=null
else showResourcesAndImprovements
&& tileInfo.hasViewableResource(tileInfo.tileMap.gameInfo.getCurrentPlayerCivilization())
resourceImage!!.isVisible = shouldDisplayResource
}
}