mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-14 17:59:11 +07:00
Better specialist allocation table placement
This commit is contained in:
@ -28,6 +28,7 @@ class CityScreen(internal val city: CityInfo): CameraStageBaseScreen() {
|
|||||||
|
|
||||||
/** Displays current production, production queue and available productions list - sits on LEFT */
|
/** Displays current production, production queue and available productions list - sits on LEFT */
|
||||||
private var constructionsTable = ConstructionsTable(this)
|
private var constructionsTable = ConstructionsTable(this)
|
||||||
|
|
||||||
/** Displays stats, buildings, specialists and stats drilldown - sits on TOP RIGHT */
|
/** Displays stats, buildings, specialists and stats drilldown - sits on TOP RIGHT */
|
||||||
private var cityInfoTable = CityInfoTable(this)
|
private var cityInfoTable = CityInfoTable(this)
|
||||||
|
|
||||||
@ -35,10 +36,7 @@ class CityScreen(internal val city: CityInfo): CameraStageBaseScreen() {
|
|||||||
private var razeCityButtonHolder = Table()
|
private var razeCityButtonHolder = Table()
|
||||||
|
|
||||||
/** Displays city stats info */
|
/** Displays city stats info */
|
||||||
private var cityStatsTable = CityStatsTable(this.city)
|
private var cityStatsTable = CityStatsTable(this)
|
||||||
|
|
||||||
/** Displays specialist allocation */
|
|
||||||
private var specialistAllocationTable=SpecialistAllocationTable(this)
|
|
||||||
|
|
||||||
/** Displays tile info, alternate with selectedConstructionTable - sits on BOTTOM RIGHT */
|
/** Displays tile info, alternate with selectedConstructionTable - sits on BOTTOM RIGHT */
|
||||||
private var tileTable = CityScreenTileTable(city)
|
private var tileTable = CityScreenTileTable(city)
|
||||||
@ -60,7 +58,6 @@ class CityScreen(internal val city: CityInfo): CameraStageBaseScreen() {
|
|||||||
|
|
||||||
//stage.setDebugTableUnderMouse(true)
|
//stage.setDebugTableUnderMouse(true)
|
||||||
stage.addActor(cityStatsTable)
|
stage.addActor(cityStatsTable)
|
||||||
stage.addActor(specialistAllocationTable)
|
|
||||||
stage.addActor(constructionsTable)
|
stage.addActor(constructionsTable)
|
||||||
stage.addActor(tileTable)
|
stage.addActor(tileTable)
|
||||||
stage.addActor(selectedConstructionTable)
|
stage.addActor(selectedConstructionTable)
|
||||||
@ -97,8 +94,6 @@ class CityScreen(internal val city: CityInfo): CameraStageBaseScreen() {
|
|||||||
|
|
||||||
cityStatsTable.update()
|
cityStatsTable.update()
|
||||||
cityStatsTable.setPosition( stage.width - 5f, stage.height - 5f, Align.topRight)
|
cityStatsTable.setPosition( stage.width - 5f, stage.height - 5f, Align.topRight)
|
||||||
specialistAllocationTable.update()
|
|
||||||
specialistAllocationTable.setPosition(stage.width-5, cityStatsTable.y, Align.topRight)
|
|
||||||
|
|
||||||
updateAnnexAndRazeCityButton()
|
updateAnnexAndRazeCityButton()
|
||||||
updateTileGroups()
|
updateTileGroups()
|
||||||
|
@ -3,7 +3,6 @@ package com.unciv.ui.cityscreen
|
|||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
import com.unciv.logic.city.CityInfo
|
|
||||||
import com.unciv.models.stats.Stat
|
import com.unciv.models.stats.Stat
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.utils.ImageGetter
|
import com.unciv.ui.utils.ImageGetter
|
||||||
@ -13,8 +12,9 @@ import com.unciv.ui.utils.toLabel
|
|||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
import kotlin.math.round
|
import kotlin.math.round
|
||||||
|
|
||||||
class CityStatsTable(val cityInfo: CityInfo): Table() {
|
class CityStatsTable(val cityScreen: CityScreen): Table() {
|
||||||
private val innerTable = Table()
|
private val innerTable = Table()
|
||||||
|
private val cityInfo = cityScreen.city
|
||||||
|
|
||||||
init {
|
init {
|
||||||
pad(2f)
|
pad(2f)
|
||||||
@ -30,8 +30,26 @@ class CityStatsTable(val cityInfo: CityInfo): Table() {
|
|||||||
fun update() {
|
fun update() {
|
||||||
innerTable.clear()
|
innerTable.clear()
|
||||||
|
|
||||||
val unassignedPopString = "{Unassigned population}:".tr()+
|
val ministatsTable = Table().pad(5f)
|
||||||
" "+cityInfo.population.getFreePopulation().toString() + "/" + cityInfo.population.population
|
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 =
|
var turnsToExpansionString =
|
||||||
if (cityInfo.cityStats.currentCityStats.culture > 0) {
|
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()
|
cityInfo.cityConstructions.currentConstruction == Constants.settler -> "Food converts to production".tr()
|
||||||
else -> "Stopped population growth".tr()
|
else -> "Stopped population growth".tr()
|
||||||
}
|
}
|
||||||
turnsToPopString += " (" + cityInfo.population.foodStored + "/" + cityInfo.population.getFoodToNextPopulation() + ")"
|
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
innerTable.add(unassignedPopString.toLabel()).row()
|
innerTable.add(unassignedPopString.toLabel()).row()
|
||||||
innerTable.add(turnsToExpansionString.toLabel()).row()
|
innerTable.add(turnsToExpansionString.toLabel()).row()
|
||||||
innerTable.add(turnsToPopString.toLabel()).row()
|
innerTable.add(turnsToPopString.toLabel()).row()
|
||||||
if (cityInfo.isInResistance())
|
if (cityInfo.isInResistance())
|
||||||
innerTable.add("In resistance for another [${cityInfo.resistanceCounter}] turns".toLabel()).row()
|
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
|
package com.unciv.ui.cityscreen
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||||
@ -12,7 +11,6 @@ class SpecialistAllocationTable(val cityScreen: CityScreen): Table(CameraStageBa
|
|||||||
val cityInfo = cityScreen.city
|
val cityInfo = cityScreen.city
|
||||||
|
|
||||||
fun update() {
|
fun update() {
|
||||||
background = ImageGetter.getBackground(Color.BLACK.cpy().apply { a=0.7f })
|
|
||||||
clear()
|
clear()
|
||||||
|
|
||||||
for (statToMaximumSpecialist in cityInfo.population.getMaxSpecialists().toHashMap()) {
|
for (statToMaximumSpecialist in cityInfo.population.getMaxSpecialists().toHashMap()) {
|
||||||
|
Reference in New Issue
Block a user