diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index 4f7cff079a..b2d458eeac 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -6,6 +6,7 @@ import com.unciv.logic.map.RoadStatus import com.unciv.logic.map.TileInfo import com.unciv.logic.map.TileMap import com.unciv.models.gamebasics.GameBasics +import com.unciv.models.gamebasics.ResourceType import com.unciv.models.gamebasics.TileResource import com.unciv.models.linq.Counter import com.unciv.models.stats.Stats @@ -42,8 +43,11 @@ class CityInfo { for (tileInfo in getTiles().filter { it.resource != null }) { val resource = tileInfo.tileResource - if (resource.improvement == tileInfo.improvement || tileInfo.isCityCenter()) - cityResources.add(resource, 1) + if (resource.improvement == tileInfo.improvement || tileInfo.isCityCenter()){ + if(resource.resourceType == ResourceType.Strategic) cityResources.add(resource, 2) + else cityResources.add(resource, 1) + } + } for (building in cityConstructions.getBuiltBuildings().filter { it.requiredResource != null }) { diff --git a/core/src/com/unciv/ui/tilegroups/TileGroup.kt b/core/src/com/unciv/ui/tilegroups/TileGroup.kt index 99664385a4..37829fbe79 100644 --- a/core/src/com/unciv/ui/tilegroups/TileGroup.kt +++ b/core/src/com/unciv/ui/tilegroups/TileGroup.kt @@ -185,8 +185,8 @@ open class TileGroup(var tileInfo: TileInfo) : Group() { private fun updateResourceImage() { if (tileInfo.hasViewableResource(tileInfo.tileMap.gameInfo.getPlayerCivilization()) && resourceImage == null) { // Need to add the resource image! val fileName = "ResourceIcons/" + tileInfo.resource + "_(Civ5).png" - resourceImage = ImageGetter.getImage(fileName) - resourceImage!!.setSize(20f, 20f) + resourceImage = ImageGetter.getImage(fileName) + resourceImage!!.setSize(20f, 20f) resourceImage!!.setPosition(width / 2 - resourceImage!!.width / 2 - 20f, height / 2 - resourceImage!!.height / 2) // left addActor(resourceImage!!) diff --git a/core/src/com/unciv/ui/worldscreen/CivStatsTable.kt b/core/src/com/unciv/ui/worldscreen/CivStatsTable.kt index 4349177d88..768e537e9e 100644 --- a/core/src/com/unciv/ui/worldscreen/CivStatsTable.kt +++ b/core/src/com/unciv/ui/worldscreen/CivStatsTable.kt @@ -1,55 +1,85 @@ package com.unciv.ui.worldscreen import com.badlogic.gdx.graphics.Color +import com.badlogic.gdx.scenes.scene2d.ui.Image import com.badlogic.gdx.scenes.scene2d.ui.Label import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.TextButton import com.badlogic.gdx.utils.Align +import com.unciv.models.gamebasics.GameBasics +import com.unciv.models.gamebasics.ResourceType import com.unciv.ui.cityscreen.addClickListener import com.unciv.ui.utils.CameraStageBaseScreen import com.unciv.ui.utils.ImageGetter -class CivStatsTable : Table { +class CivStatsTable(val screen: WorldScreen) : Table() { private val turnsLabel = Label("Turns: 0/400", CameraStageBaseScreen.skin) private val goldLabel = Label("Gold:",CameraStageBaseScreen.skin) private val scienceLabel = Label("Science:",CameraStageBaseScreen.skin) private val happinessLabel = Label("Happiness:",CameraStageBaseScreen.skin) private val cultureLabel = Label("Culture:",CameraStageBaseScreen.skin) + private val resourceLabels = HashMap() + private val resourceImages = HashMap() - - internal constructor(screen: WorldScreen){ + init{ val civBackground = ImageGetter.getDrawable("skin/civTableBackground.png") - background = civBackground.tint(Color(0x004085bf)) - addCivilopediaButton(screen) - add(turnsLabel) - add(goldLabel) - scienceLabel.setAlignment(Align.center) - add(scienceLabel) - happinessLabel.setAlignment(Align.center) - add(happinessLabel) - cultureLabel.setAlignment(Align.center) - add(cultureLabel) + background = civBackground.tint(Color(0x004085e0)) + + val resourceTable = Table() + resourceTable.defaults().pad(10f) + val revealedStrategicResources = GameBasics.TileResources.values + .filter { it.resourceType== ResourceType.Strategic} // && civInfo.tech.isResearched(it.revealedBy!!) } + for(resource in revealedStrategicResources){ + val fileName = "ResourceIcons/${resource.name}_(Civ5).png" + val resourceImage = ImageGetter.getImage(fileName) + resourceImages.put(resource.name,resourceImage) + resourceTable.add(resourceImage).size(20f) + val resourceLabel = Label("0",CameraStageBaseScreen.skin) + resourceLabels.put(resource.name, resourceLabel) + resourceTable.add(resourceLabel) + } + add(resourceTable).row() + + + val statsTable = Table() + statsTable.defaults().padRight(20f).padBottom(10f) + statsTable.add(getMenuButton()) + statsTable.add(turnsLabel) + statsTable.add(goldLabel) + statsTable.add(scienceLabel.apply { setAlignment(Align.center) }) + statsTable.add(happinessLabel.apply { setAlignment(Align.center) }) + statsTable.add(cultureLabel.apply { setAlignment(Align.center) }) + add(statsTable) pack() width = screen.stage.width - 20 + statsTable.width = width } - internal fun addCivilopediaButton(screen: WorldScreen){ - row().pad(15f) - val civilopediaButton = TextButton("Menu", CameraStageBaseScreen.skin) - civilopediaButton.addClickListener { + internal fun getMenuButton(): TextButton { + val menuButton = TextButton("Menu", CameraStageBaseScreen.skin) + menuButton.addClickListener { screen.optionsTable.isVisible = !screen.optionsTable.isVisible } - civilopediaButton.label.setFontScale(screen.buttonScale) - add(civilopediaButton) - .size(civilopediaButton.width * screen.buttonScale, civilopediaButton.height * screen.buttonScale) + return menuButton } - internal fun update(screen: WorldScreen) { + internal fun update() { val civInfo = screen.civInfo + val revealedStrategicResources = GameBasics.TileResources.values + .filter { it.resourceType== ResourceType.Strategic} // && } + val civResources = civInfo.getCivResources() + for(resource in revealedStrategicResources){ + val isRevealed = civInfo.tech.isResearched(resource.revealedBy!!) + resourceLabels[resource.name]!!.isVisible = isRevealed + resourceImages[resource.name]!!.isVisible = isRevealed + if(!civResources.containsKey(resource)) resourceLabels[resource.name]!!.setText("0") + else resourceLabels[resource.name]!!.setText(civResources[resource]!!.toString()) + } + turnsLabel.setText("Turns: " + civInfo.gameInfo.turns + "/400") val nextTurnStats = civInfo.getStatsForNextTurn() diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index 0e41c06907..dd481f5baf 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -75,7 +75,7 @@ class WorldScreen : CameraStageBaseScreen() { unitTable.update() // has to come before tilemapholder update because the tilemapholder actions depend on the selected unit! tileMapHolder.updateTiles() - civTable.update(this) + civTable.update() notificationsScroll.update() notificationsScroll.width = stage.width/3 notificationsScroll.setPosition(stage.width - notificationsScroll.width - 5f,