Removed double icons

This commit is contained in:
Yair Morgenstern 2023-04-17 08:58:14 +03:00
parent 0bf5cae401
commit 699a6bf12a
9 changed files with 33 additions and 36 deletions

View File

@ -540,7 +540,7 @@ class Civilization : IsPartOfGameInfoSerialization {
fun getLeaderDisplayName(): String { fun getLeaderDisplayName(): String {
val severalHumans = gameInfo.civilizations.count { it.playerType == PlayerType.Human } > 1 val severalHumans = gameInfo.civilizations.count { it.playerType == PlayerType.Human } > 1
val online = gameInfo.gameParameters.isOnlineMultiplayer val online = gameInfo.gameParameters.isOnlineMultiplayer
return nation.getLeaderDisplayName().tr() + return nation.getLeaderDisplayName().tr(hideIcons = true) +
when { when {
!online && !severalHumans -> "" // offline single player will know everybody else is AI !online && !severalHumans -> "" // offline single player will know everybody else is AI
playerType == PlayerType.AI -> " (${"AI".tr()})" playerType == PlayerType.AI -> " (${"AI".tr()})"

View File

@ -113,13 +113,13 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
/** used in CityScreen (CityInfoTable and ConstructionInfoTable) */ /** used in CityScreen (CityInfoTable and ConstructionInfoTable) */
fun getDescription(city: City, showAdditionalInfo: Boolean): String { fun getDescription(city: City, showAdditionalInfo: Boolean): String {
val stats = getStats(city) val stats = getStats(city)
val lines = ArrayList<String>() val translatedLines = ArrayList<String>() // Some translations require special handling
val isFree = name in city.civ.civConstructions.getFreeBuildings(city.id) val isFree = name in city.civ.civConstructions.getFreeBuildings(city.id)
if (uniqueTo != null) lines += if (replaces == null) "Unique to [$uniqueTo]" if (uniqueTo != null) translatedLines += if (replaces == null) "Unique to [$uniqueTo]".tr()
else "Unique to [$uniqueTo], replaces [$replaces]" else "Unique to [$uniqueTo], replaces [$replaces]".tr()
val missingUnique = getMatchingUniques(UniqueType.RequiresBuildingInAllCities).firstOrNull() val missingUnique = getMatchingUniques(UniqueType.RequiresBuildingInAllCities).firstOrNull()
if (isWonder) lines += "Wonder" if (isWonder) translatedLines += "Wonder".tr()
if (isNationalWonder) lines += "National Wonder" if (isNationalWonder) translatedLines += "National Wonder".tr()
if (!isFree) { if (!isFree) {
val availableResources = if (!showAdditionalInfo) emptyMap() val availableResources = if (!showAdditionalInfo) emptyMap()
else city.civ.getCivResourcesByName() else city.civ.getCivResourcesByName()
@ -128,8 +128,8 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
val resource = city.getRuleset().tileResources[resourceName] ?: continue val resource = city.getRuleset().tileResources[resourceName] ?: continue
val consumesString = resourceName.getConsumesAmountString(amount, resource.isStockpiled()) val consumesString = resourceName.getConsumesAmountString(amount, resource.isStockpiled())
lines += if (showAdditionalInfo) "$consumesString ({[$available] available})" translatedLines += if (showAdditionalInfo) "$consumesString ({[$available] available})".tr()
else consumesString else consumesString.tr()
} }
} }
@ -142,39 +142,39 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
} }
else listOf() else listOf()
if (uniques.isNotEmpty()) { if (uniques.isNotEmpty()) {
if (replacementTextForUniques != "") lines += replacementTextForUniques if (replacementTextForUniques != "") translatedLines += replacementTextForUniques.tr()
else lines += getUniquesStringsWithoutDisablers( else translatedLines += getUniquesStringsWithoutDisablers(
filterUniques = if (missingCities.isEmpty()) null filterUniques = if (missingCities.isEmpty()) null
else { unique -> !unique.isOfType(UniqueType.RequiresBuildingInAllCities) } else { unique -> !unique.isOfType(UniqueType.RequiresBuildingInAllCities) }
// Filter out the "Requires a [] in all cities" unique if any cities are still missing the required building, since in that case the list of cities will be appended at the end. // Filter out the "Requires a [] in all cities" unique if any cities are still missing the required building, since in that case the list of cities will be appended at the end.
) ).map { it.tr() }
} }
if (!stats.isEmpty()) if (!stats.isEmpty())
lines += stats.toString() translatedLines += stats.toString()
for ((stat, value) in getStatPercentageBonuses(city)) for ((stat, value) in getStatPercentageBonuses(city))
if (value != 0f) lines += "+${value.toInt()}% {${stat.name}}" if (value != 0f) translatedLines += "+${value.toInt()}% {${stat.name}}".tr()
for ((greatPersonName, value) in greatPersonPoints) for ((greatPersonName, value) in greatPersonPoints)
lines += "+$value " + "[$greatPersonName] points".tr() translatedLines += "+$value " + "[$greatPersonName] points".tr()
for ((specialistName, amount) in newSpecialists()) for ((specialistName, amount) in newSpecialists())
lines += "+$amount " + "[$specialistName] slots".tr() translatedLines += "+$amount " + "[$specialistName] slots".tr()
if (requiredNearbyImprovedResources != null) if (requiredNearbyImprovedResources != null)
lines += "Requires worked [" + requiredNearbyImprovedResources!!.joinToString("/") { it.tr() } + "] near city" translatedLines += "Requires worked [${requiredNearbyImprovedResources!!.joinToString("/") { it.tr() }}] near city".tr()
if (cityStrength != 0) lines += "{City strength} +$cityStrength" if (cityStrength != 0) translatedLines += "{City strength} +$cityStrength".tr()
if (cityHealth != 0) lines += "{City health} +$cityHealth" if (cityHealth != 0) translatedLines += "{City health} +$cityHealth".tr()
if (maintenance != 0 && !isFree) lines += "{Maintenance cost}: $maintenance {Gold}" if (maintenance != 0 && !isFree) translatedLines += "{Maintenance cost}: $maintenance {Gold}".tr()
if (showAdditionalInfo && missingCities.isNotEmpty()) { if (showAdditionalInfo && missingCities.isNotEmpty()) {
// Could be red. But IMO that should be done by enabling GDX's ColorMarkupLanguage globally instead of adding a separate label. // Could be red. But IMO that should be done by enabling GDX's ColorMarkupLanguage globally instead of adding a separate label.
lines += "\n" + translatedLines += "\n" +
"[${city.civ.getEquivalentBuilding(missingUnique!!.params[0])}] required:".tr() + "[${city.civ.getEquivalentBuilding(missingUnique!!.params[0])}] required:".tr() +
" " + missingCities.joinToString(", ") { "{${it.name}}" } " " + missingCities.joinToString(", ") { it.name.tr(hideIcons = true) }
// Can't nest square bracket placeholders inside curlies, and don't see any way to define wildcard placeholders. So run translation explicitly on base text. // Can't nest square bracket placeholders inside curlies, and don't see any way to define wildcard placeholders. So run translation explicitly on base text.
} }
return lines.joinToString("\n") { it.tr() }.trim() return translatedLines.joinToString("\n").trim()
} }
fun getStats(city: City, fun getStats(city: City,

View File

@ -22,11 +22,10 @@ open class IconTextButton(
text: String, text: String,
val icon: Actor? = null, val icon: Actor? = null,
fontSize: Int = Constants.defaultFontSize, fontSize: Int = Constants.defaultFontSize,
fontColor: Color = Color.WHITE, fontColor: Color = Color.WHITE
hideIcons: Boolean = false
): Button(BaseScreen.skin) { ): Button(BaseScreen.skin) {
/** [Label] instance produced by and with content and formatting as specified to [String.toLabel]. */ /** [Label] instance produced by and with content and formatting as specified to [String.toLabel]. */
val label = text.toLabel(fontColor, fontSize, hideIcons = hideIcons) val label = text.toLabel(fontColor, fontSize, hideIcons = true) // Since by definition we already have an icon
/** Table cell containing the [icon] if any, or `null`. */ /** Table cell containing the [icon] if any, or `null`. */
val iconCell: Cell<Actor> = val iconCell: Cell<Actor> =
if (icon != null) { if (icon != null) {

View File

@ -15,7 +15,6 @@ import com.unciv.models.ruleset.Building
import com.unciv.models.ruleset.unique.UniqueType import com.unciv.models.ruleset.unique.UniqueType
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.components.ColorMarkupLabel
import com.unciv.ui.components.ExpanderTab import com.unciv.ui.components.ExpanderTab
import com.unciv.ui.components.Fonts import com.unciv.ui.components.Fonts
import com.unciv.ui.components.extensions.addSeparator import com.unciv.ui.components.extensions.addSeparator
@ -185,7 +184,7 @@ class CityStatsTable(val cityScreen: CityScreen): Table() {
"We Love The King Day for another [${cityInfo.getFlag(CityFlags.WeLoveTheKing)}] turns".toLabel(Color.LIME) "We Love The King Day for another [${cityInfo.getFlag(CityFlags.WeLoveTheKing)}] turns".toLabel(Color.LIME)
cityInfo.demandedResource.isNotEmpty() -> cityInfo.demandedResource.isNotEmpty() ->
ImageGetter.getResourcePortrait(cityInfo.demandedResource, 20f) to ImageGetter.getResourcePortrait(cityInfo.demandedResource, 20f) to
ColorMarkupLabel("Demanding [${cityInfo.demandedResource}]",Color.CORAL) "Demanding [${cityInfo.demandedResource}]".toLabel(Color.CORAL, hideIcons = true)
else -> null to null else -> null to null
} }
if (wltkLabel != null) { if (wltkLabel != null) {
@ -275,7 +274,7 @@ class CityStatsTable(val cityScreen: CityScreen): Table() {
val isFree = building.name in cityScreen.city.civ.civConstructions.getFreeBuildings(cityScreen.city.id) val isFree = building.name in cityScreen.city.civ.civConstructions.getFreeBuildings(cityScreen.city.id)
val displayName = if (isFree) "{${building.name}} ({Free})" else building.name val displayName = if (isFree) "{${building.name}} ({Free})" else building.name
info.add(displayName.toLabel(fontSize = Constants.defaultFontSize)).padBottom(5f).right().row() info.add(displayName.toLabel(fontSize = Constants.defaultFontSize, hideIcons = true)).padBottom(5f).right().row()
val stats = building.getStats(cityInfo).joinToString(separator = " ") { val stats = building.getStats(cityInfo).joinToString(separator = " ") {
"" + it.value.toInt() + it.key.character "" + it.value.toInt() + it.key.character

View File

@ -70,7 +70,7 @@ class ConstructionInfoTable(val cityScreen: CityScreen): Table() {
} }
}).pad(5f) }).pad(5f)
var buildingText = construction.name.tr() var buildingText = construction.name.tr(hideIcons = true)
val specialConstruction = PerpetualConstruction.perpetualConstructionsMap[construction.name] val specialConstruction = PerpetualConstruction.perpetualConstructionsMap[construction.name]
buildingText += specialConstruction?.getProductionTooltip(city) buildingText += specialConstruction?.getProductionTooltip(city)

View File

@ -152,7 +152,7 @@ class DiplomacyScreen(
questIcon.x = floor(civIndicator.width - questIcon.width) questIcon.x = floor(civIndicator.width - questIcon.width)
} }
val civNameLabel = civ.civName.toLabel() val civNameLabel = civ.civName.toLabel(hideIcons = true)
leftSideTable.add(civIndicator).row() leftSideTable.add(civIndicator).row()
leftSideTable.add(civNameLabel).padBottom(20f).row() leftSideTable.add(civNameLabel).padBottom(20f).row()

View File

@ -21,12 +21,12 @@ import com.unciv.logic.trade.TradeType.WarDeclaration
import com.unciv.logic.trade.TradeType.values import com.unciv.logic.trade.TradeType.values
import com.unciv.models.ruleset.tile.ResourceSupplyList import com.unciv.models.ruleset.tile.ResourceSupplyList
import com.unciv.models.translations.tr import com.unciv.models.translations.tr
import com.unciv.ui.images.IconTextButton
import com.unciv.ui.images.ImageGetter
import com.unciv.ui.screens.basescreen.BaseScreen
import com.unciv.ui.components.ExpanderTab import com.unciv.ui.components.ExpanderTab
import com.unciv.ui.components.extensions.disable import com.unciv.ui.components.extensions.disable
import com.unciv.ui.components.extensions.onClick import com.unciv.ui.components.extensions.onClick
import com.unciv.ui.images.IconTextButton
import com.unciv.ui.images.ImageGetter
import com.unciv.ui.screens.basescreen.BaseScreen
import kotlin.math.min import kotlin.math.min
import com.unciv.ui.components.AutoScrollPane as ScrollPane import com.unciv.ui.components.AutoScrollPane as ScrollPane

View File

@ -129,7 +129,7 @@ class GlobalPoliticsOverviewTable (
val civInfoTable = Table(skin) val civInfoTable = Table(skin)
val leaderName = civ.nation.leaderName val leaderName = civ.nation.leaderName
civInfoTable.add(leaderName.toLabel(fontSize = 30)).row() civInfoTable.add(leaderName.toLabel(fontSize = 30)).row()
civInfoTable.add(civ.civName.toLabel()).row() civInfoTable.add(civ.civName.toLabel(hideIcons = true)).row()
civInfoTable.add(civ.tech.era.name.toLabel()).row() civInfoTable.add(civ.tech.era.name.toLabel()).row()
return civInfoTable return civInfoTable
} }

View File

@ -184,8 +184,7 @@ class UnitOverviewTab(
val button = IconTextButton( val button = IconTextButton(
unit.displayName(), unit.displayName(),
UnitGroup(unit, 20f), UnitGroup(unit, 20f),
fontColor = if (unit.due && unit.isIdle()) Color.WHITE else Color.LIGHT_GRAY, fontColor = if (unit.due && unit.isIdle()) Color.WHITE else Color.LIGHT_GRAY
hideIcons = true
) )
button.name = getUnitIdentifier(unit) // Marker to find a unit in select() button.name = getUnitIdentifier(unit) // Marker to find a unit in select()
button.onClick { button.onClick {