Small changes to city screen (#4902)

This commit is contained in:
SomeTroglodyte 2021-08-19 08:51:26 +02:00 committed by GitHub
parent ef5483e9d5
commit 0f5f3366ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 6 deletions

View File

@ -75,10 +75,10 @@ class Building : NamedStats(), INonPerpetualConstruction, ICivilopediaText {
override var civilopediaText = listOf<FormattedLine>()
/** Used for AlertType.WonderBuilt, and as sub-text in Nation and Tech descriptions */
fun getShortDescription(ruleset: Ruleset): String { // should fit in one line
val infoList = mutableListOf<String>()
val str = getStats(null).toString()
if (str.isNotEmpty()) infoList += str
getStats(null).toString().also { if (it.isNotEmpty()) infoList += it }
for (stat in getStatPercentageBonuses(null).toHashMap())
if (stat.value != 0f) infoList += "+${stat.value.toInt()}% ${stat.key.name.tr()}"
@ -114,13 +114,18 @@ class Building : NamedStats(), INonPerpetualConstruction, ICivilopediaText {
))
}
private fun getUniquesStringsWithoutDisablers() = getUniquesStrings()
.filterNot { it.startsWith("Hidden ") && it.endsWith(" disabled") || it == "Unbuildable" }
.filterNot {
it.startsWith("Hidden ") && it.endsWith(" disabled") ||
it == "Unbuildable" ||
it == "Will not be displayed in Civilopedia"
}
/** used in CityScreen (CityInfoTable and ConstructionInfoTable) */
fun getDescription(cityInfo: CityInfo?, ruleset: Ruleset): String {
val stats = getStats(cityInfo)
val lines = ArrayList<String>()
if (uniqueTo != null) lines += "Unique to [$uniqueTo], replaces [$replaces]"
if (uniqueTo != null) lines += if (replaces == null) "Unique to [$uniqueTo]"
else "Unique to [$uniqueTo], replaces [$replaces]"
if (isWonder) lines += "Wonder"
if (isNationalWonder) lines += "National Wonder"
for ((resource, amount) in getResourceRequirements()) {

View File

@ -5,6 +5,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.utils.Align
import com.unciv.UncivGame
import com.unciv.logic.city.CityInfo
import com.unciv.models.UncivSound
import com.unciv.models.ruleset.Building
import com.unciv.models.stats.Stat
import com.unciv.models.translations.tr
@ -71,7 +72,7 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
val sellBuildingButton = "Sell for [$sellAmount] gold".toTextButton()
it.add(sellBuildingButton).pad(5f).row()
sellBuildingButton.onClick {
sellBuildingButton.onClick(UncivSound.Coin) {
sellBuildingButton.disable()
cityScreen.closeAllPopups()

View File

@ -90,6 +90,6 @@ class CityStatsTable(val cityScreen: CityScreen): Table() {
innerTable.addSeparator()
val label = cityInfo.religion.getMajorityReligion()
?: "None"
innerTable.add("Majority Religion: [$label]".toLabel())
innerTable.add("Majority Religion: [$label]".toLabel()).padTop(5f)
}
}