City screen stats double separators (#4821)

This commit is contained in:
SomeTroglodyte
2021-08-09 14:32:30 +02:00
committed by GitHub
parent e59db3ada3
commit 3c4bb1a558
2 changed files with 16 additions and 12 deletions

View File

@ -989,7 +989,8 @@ Found Religion =
Found Pantheon =
Follow [belief] =
Religions and Beliefs =
Majority Religion: [name] =
# Religion overview screen
Religion Name: =
Founding Civ: =

View File

@ -2,6 +2,7 @@ package com.unciv.ui.cityscreen
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.unciv.logic.civilization.ReligionState
import com.unciv.models.stats.Stat
import com.unciv.models.translations.tr
import com.unciv.ui.utils.ImageGetter
@ -29,24 +30,24 @@ class CityStatsTable(val cityScreen: CityScreen): Table() {
fun update() {
innerTable.clear()
val ministatsTable = Table()
val miniStatsTable = Table()
for ((stat, amount) in cityInfo.cityStats.currentCityStats.toHashMap()) {
if (stat == Stat.Faith && !cityInfo.civInfo.gameInfo.hasReligionEnabled()) continue
ministatsTable.add(ImageGetter.getStatIcon(stat.name)).size(20f).padRight(5f)
miniStatsTable.add(ImageGetter.getStatIcon(stat.name)).size(20f).padRight(5f)
val valueToDisplay = if (stat == Stat.Happiness) cityInfo.cityStats.happinessList.values.sum() else amount
ministatsTable.add(round(valueToDisplay).toInt().toString().toLabel()).padRight(10f)
miniStatsTable.add(round(valueToDisplay).toInt().toLabel()).padRight(10f)
}
innerTable.add(ministatsTable)
innerTable.add(miniStatsTable)
innerTable.addSeparator()
addText()
innerTable.addSeparator()
innerTable.add(SpecialistAllocationTable(cityScreen).apply { update() })
if (cityInfo.civInfo.gameInfo.hasReligionEnabled()) {
if (!cityInfo.population.getMaxSpecialists().isEmpty()) {
innerTable.addSeparator()
addReligionInfo()
innerTable.add(SpecialistAllocationTable(cityScreen).apply { update() })
}
addReligionInfo()
pack()
}
@ -85,8 +86,10 @@ class CityStatsTable(val cityScreen: CityScreen): Table() {
private fun addReligionInfo() {
// This will later become large enough to be its own class, but for now it is small enough to fit inside a single function
val majorityReligion = cityInfo.religion.getMajorityReligion()
val label = majorityReligion ?: "None"
innerTable.add("Majority Religion: $label".toLabel())
if(cityInfo.civInfo.religionManager.religionState == ReligionState.None) return
innerTable.addSeparator()
val label = cityInfo.religion.getMajorityReligion()
?: "None"
innerTable.add("Majority Religion: [$label]".toLabel())
}
}