Better specialist allocation table placement
This commit is contained in:
parent
1633394164
commit
4accfb594f
3 changed files with 25 additions and 27 deletions
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
|
@ -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()) {
|
||||
|
|
Loading…
Reference in a new issue