From 4accfb594fb54296fa18ba3f71ad8d2e0daf689c Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 21 Jan 2020 23:27:56 +0200 Subject: [PATCH] Better specialist allocation table placement --- .../src/com/unciv/ui/cityscreen/CityScreen.kt | 9 +--- .../com/unciv/ui/cityscreen/CityStatsTable.kt | 41 +++++++++++-------- .../cityscreen/SpecialistAllocationTable.kt | 2 - 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/core/src/com/unciv/ui/cityscreen/CityScreen.kt b/core/src/com/unciv/ui/cityscreen/CityScreen.kt index 84b0272c41..0a9da6fa2b 100644 --- a/core/src/com/unciv/ui/cityscreen/CityScreen.kt +++ b/core/src/com/unciv/ui/cityscreen/CityScreen.kt @@ -28,6 +28,7 @@ class CityScreen(internal val city: CityInfo): CameraStageBaseScreen() { /** Displays current production, production queue and available productions list - sits on LEFT */ private var constructionsTable = ConstructionsTable(this) + /** Displays stats, buildings, specialists and stats drilldown - sits on TOP RIGHT */ private var cityInfoTable = CityInfoTable(this) @@ -35,10 +36,7 @@ class CityScreen(internal val city: CityInfo): CameraStageBaseScreen() { private var razeCityButtonHolder = Table() /** Displays city stats info */ - private var cityStatsTable = CityStatsTable(this.city) - - /** Displays specialist allocation */ - private var specialistAllocationTable=SpecialistAllocationTable(this) + private var cityStatsTable = CityStatsTable(this) /** Displays tile info, alternate with selectedConstructionTable - sits on BOTTOM RIGHT */ private var tileTable = CityScreenTileTable(city) @@ -60,7 +58,6 @@ class CityScreen(internal val city: CityInfo): CameraStageBaseScreen() { //stage.setDebugTableUnderMouse(true) stage.addActor(cityStatsTable) - stage.addActor(specialistAllocationTable) stage.addActor(constructionsTable) stage.addActor(tileTable) stage.addActor(selectedConstructionTable) @@ -97,8 +94,6 @@ class CityScreen(internal val city: CityInfo): CameraStageBaseScreen() { cityStatsTable.update() cityStatsTable.setPosition( stage.width - 5f, stage.height - 5f, Align.topRight) - specialistAllocationTable.update() - specialistAllocationTable.setPosition(stage.width-5, cityStatsTable.y, Align.topRight) updateAnnexAndRazeCityButton() updateTileGroups() diff --git a/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt b/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt index ee6d4c027e..1a680724ce 100644 --- a/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt +++ b/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt @@ -3,7 +3,6 @@ package com.unciv.ui.cityscreen import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.scenes.scene2d.ui.Table import com.unciv.Constants -import com.unciv.logic.city.CityInfo import com.unciv.models.stats.Stat import com.unciv.models.translations.tr import com.unciv.ui.utils.ImageGetter @@ -13,8 +12,9 @@ import com.unciv.ui.utils.toLabel import kotlin.math.ceil import kotlin.math.round -class CityStatsTable(val cityInfo: CityInfo): Table() { +class CityStatsTable(val cityScreen: CityScreen): Table() { private val innerTable = Table() + private val cityInfo = cityScreen.city init { pad(2f) @@ -30,8 +30,26 @@ class CityStatsTable(val cityInfo: CityInfo): Table() { fun update() { innerTable.clear() - val unassignedPopString = "{Unassigned population}:".tr()+ - " "+cityInfo.population.getFreePopulation().toString() + "/" + cityInfo.population.population + val ministatsTable = Table().pad(5f) + ministatsTable.defaults() + for(stat in cityInfo.cityStats.currentCityStats.toHashMap()) { + if(stat.key == Stat.Happiness) continue + ministatsTable.add(ImageGetter.getStatIcon(stat.key.name)).size(20f).padRight(3f) + ministatsTable.add(round(stat.value).toInt().toString().toLabel()).padRight(13f) + } + innerTable.add(ministatsTable) + + innerTable.addSeparator() + addText() + innerTable.addSeparator() + innerTable.add(SpecialistAllocationTable(cityScreen).apply { update() }) + + pack() + } + + private fun addText() { + val unassignedPopString = "{Unassigned population}:".tr() + + " " + cityInfo.population.getFreePopulation().toString() + "/" + cityInfo.population.population var turnsToExpansionString = if (cityInfo.cityStats.currentCityStats.culture > 0) { @@ -52,25 +70,12 @@ class CityStatsTable(val cityInfo: CityInfo): Table() { cityInfo.cityConstructions.currentConstruction == Constants.settler -> "Food converts to production".tr() else -> "Stopped population growth".tr() } - turnsToPopString += " (" + cityInfo.population.foodStored + "/" + cityInfo.population.getFoodToNextPopulation() + ")" - - val ministatsTable = Table().pad(5f) - ministatsTable.defaults() - - for(stat in cityInfo.cityStats.currentCityStats.toHashMap()) { - if(stat.key == Stat.Happiness) continue - ministatsTable.add(ImageGetter.getStatIcon(stat.key.name)).size(20f).padRight(3f) - ministatsTable.add(round(stat.value).toInt().toString().toLabel()).padRight(13f) - } + turnsToPopString += " (" + cityInfo.population.foodStored + "/" + cityInfo.population.getFoodToNextPopulation() + ")" innerTable.add(unassignedPopString.toLabel()).row() innerTable.add(turnsToExpansionString.toLabel()).row() innerTable.add(turnsToPopString.toLabel()).row() if (cityInfo.isInResistance()) innerTable.add("In resistance for another [${cityInfo.resistanceCounter}] turns".toLabel()).row() - innerTable.addSeparator() - innerTable.add(ministatsTable) - - pack() } } \ No newline at end of file diff --git a/core/src/com/unciv/ui/cityscreen/SpecialistAllocationTable.kt b/core/src/com/unciv/ui/cityscreen/SpecialistAllocationTable.kt index 0a4900ddcd..bb034d6a62 100644 --- a/core/src/com/unciv/ui/cityscreen/SpecialistAllocationTable.kt +++ b/core/src/com/unciv/ui/cityscreen/SpecialistAllocationTable.kt @@ -1,6 +1,5 @@ package com.unciv.ui.cityscreen -import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.scenes.scene2d.Actor import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.TextButton @@ -12,7 +11,6 @@ class SpecialistAllocationTable(val cityScreen: CityScreen): Table(CameraStageBa val cityInfo = cityScreen.city fun update() { - background = ImageGetter.getBackground(Color.BLACK.cpy().apply { a=0.7f }) clear() for (statToMaximumSpecialist in cityInfo.population.getMaxSpecialists().toHashMap()) {