From 699a6bf12a4f29ffda8ef6cc0e3929c6680bd295 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 17 Apr 2023 08:58:14 +0300 Subject: [PATCH] Removed double icons --- .../unciv/logic/civilization/Civilization.kt | 2 +- core/src/com/unciv/models/ruleset/Building.kt | 42 +++++++++---------- .../src/com/unciv/ui/images/IconTextButton.kt | 5 +-- .../ui/screens/cityscreen/CityStatsTable.kt | 5 +-- .../cityscreen/ConstructionInfoTable.kt | 2 +- .../diplomacyscreen/DiplomacyScreen.kt | 2 +- .../diplomacyscreen/OffersListScroll.kt | 6 +-- .../GlobalPoliticsOverviewTable.kt | 2 +- .../overviewscreen/UnitOverviewTable.kt | 3 +- 9 files changed, 33 insertions(+), 36 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/Civilization.kt b/core/src/com/unciv/logic/civilization/Civilization.kt index f3440767ff..37b067fb2a 100644 --- a/core/src/com/unciv/logic/civilization/Civilization.kt +++ b/core/src/com/unciv/logic/civilization/Civilization.kt @@ -540,7 +540,7 @@ class Civilization : IsPartOfGameInfoSerialization { fun getLeaderDisplayName(): String { val severalHumans = gameInfo.civilizations.count { it.playerType == PlayerType.Human } > 1 val online = gameInfo.gameParameters.isOnlineMultiplayer - return nation.getLeaderDisplayName().tr() + + return nation.getLeaderDisplayName().tr(hideIcons = true) + when { !online && !severalHumans -> "" // offline single player will know everybody else is AI playerType == PlayerType.AI -> " (${"AI".tr()})" diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index b1ae21203e..50283f58e3 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -113,13 +113,13 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction { /** used in CityScreen (CityInfoTable and ConstructionInfoTable) */ fun getDescription(city: City, showAdditionalInfo: Boolean): String { val stats = getStats(city) - val lines = ArrayList() + val translatedLines = ArrayList() // Some translations require special handling val isFree = name in city.civ.civConstructions.getFreeBuildings(city.id) - if (uniqueTo != null) lines += if (replaces == null) "Unique to [$uniqueTo]" - else "Unique to [$uniqueTo], replaces [$replaces]" + if (uniqueTo != null) translatedLines += if (replaces == null) "Unique to [$uniqueTo]".tr() + else "Unique to [$uniqueTo], replaces [$replaces]".tr() val missingUnique = getMatchingUniques(UniqueType.RequiresBuildingInAllCities).firstOrNull() - if (isWonder) lines += "Wonder" - if (isNationalWonder) lines += "National Wonder" + if (isWonder) translatedLines += "Wonder".tr() + if (isNationalWonder) translatedLines += "National Wonder".tr() if (!isFree) { val availableResources = if (!showAdditionalInfo) emptyMap() else city.civ.getCivResourcesByName() @@ -128,8 +128,8 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction { val resource = city.getRuleset().tileResources[resourceName] ?: continue val consumesString = resourceName.getConsumesAmountString(amount, resource.isStockpiled()) - lines += if (showAdditionalInfo) "$consumesString ({[$available] available})" - else consumesString + translatedLines += if (showAdditionalInfo) "$consumesString ({[$available] available})".tr() + else consumesString.tr() } } @@ -142,39 +142,39 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction { } else listOf() if (uniques.isNotEmpty()) { - if (replacementTextForUniques != "") lines += replacementTextForUniques - else lines += getUniquesStringsWithoutDisablers( + if (replacementTextForUniques != "") translatedLines += replacementTextForUniques.tr() + else translatedLines += getUniquesStringsWithoutDisablers( filterUniques = if (missingCities.isEmpty()) null 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. - ) + ).map { it.tr() } } if (!stats.isEmpty()) - lines += stats.toString() + translatedLines += stats.toString() 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) - lines += "+$value " + "[$greatPersonName] points".tr() + translatedLines += "+$value " + "[$greatPersonName] points".tr() for ((specialistName, amount) in newSpecialists()) - lines += "+$amount " + "[$specialistName] slots".tr() + translatedLines += "+$amount " + "[$specialistName] slots".tr() 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 (cityHealth != 0) lines += "{City health} +$cityHealth" - if (maintenance != 0 && !isFree) lines += "{Maintenance cost}: $maintenance {Gold}" + if (cityStrength != 0) translatedLines += "{City strength} +$cityStrength".tr() + if (cityHealth != 0) translatedLines += "{City health} +$cityHealth".tr() + if (maintenance != 0 && !isFree) translatedLines += "{Maintenance cost}: $maintenance {Gold}".tr() 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. - lines += "\n" + + translatedLines += "\n" + "[${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. } - return lines.joinToString("\n") { it.tr() }.trim() + return translatedLines.joinToString("\n").trim() } fun getStats(city: City, diff --git a/core/src/com/unciv/ui/images/IconTextButton.kt b/core/src/com/unciv/ui/images/IconTextButton.kt index 3444e3d029..394cd77880 100644 --- a/core/src/com/unciv/ui/images/IconTextButton.kt +++ b/core/src/com/unciv/ui/images/IconTextButton.kt @@ -22,11 +22,10 @@ open class IconTextButton( text: String, val icon: Actor? = null, fontSize: Int = Constants.defaultFontSize, - fontColor: Color = Color.WHITE, - hideIcons: Boolean = false + fontColor: Color = Color.WHITE ): Button(BaseScreen.skin) { /** [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`. */ val iconCell: Cell = if (icon != null) { diff --git a/core/src/com/unciv/ui/screens/cityscreen/CityStatsTable.kt b/core/src/com/unciv/ui/screens/cityscreen/CityStatsTable.kt index bd8defc3b4..a9b0f52d09 100644 --- a/core/src/com/unciv/ui/screens/cityscreen/CityStatsTable.kt +++ b/core/src/com/unciv/ui/screens/cityscreen/CityStatsTable.kt @@ -15,7 +15,6 @@ import com.unciv.models.ruleset.Building import com.unciv.models.ruleset.unique.UniqueType import com.unciv.models.stats.Stat import com.unciv.models.translations.tr -import com.unciv.ui.components.ColorMarkupLabel import com.unciv.ui.components.ExpanderTab import com.unciv.ui.components.Fonts 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) cityInfo.demandedResource.isNotEmpty() -> ImageGetter.getResourcePortrait(cityInfo.demandedResource, 20f) to - ColorMarkupLabel("Demanding [${cityInfo.demandedResource}]",Color.CORAL) + "Demanding [${cityInfo.demandedResource}]".toLabel(Color.CORAL, hideIcons = true) else -> null to 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 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 = " ") { "" + it.value.toInt() + it.key.character diff --git a/core/src/com/unciv/ui/screens/cityscreen/ConstructionInfoTable.kt b/core/src/com/unciv/ui/screens/cityscreen/ConstructionInfoTable.kt index 659e57d953..cd4d314c74 100644 --- a/core/src/com/unciv/ui/screens/cityscreen/ConstructionInfoTable.kt +++ b/core/src/com/unciv/ui/screens/cityscreen/ConstructionInfoTable.kt @@ -70,7 +70,7 @@ class ConstructionInfoTable(val cityScreen: CityScreen): Table() { } }).pad(5f) - var buildingText = construction.name.tr() + var buildingText = construction.name.tr(hideIcons = true) val specialConstruction = PerpetualConstruction.perpetualConstructionsMap[construction.name] buildingText += specialConstruction?.getProductionTooltip(city) diff --git a/core/src/com/unciv/ui/screens/diplomacyscreen/DiplomacyScreen.kt b/core/src/com/unciv/ui/screens/diplomacyscreen/DiplomacyScreen.kt index bb4b25ea2c..7d5d9fb490 100644 --- a/core/src/com/unciv/ui/screens/diplomacyscreen/DiplomacyScreen.kt +++ b/core/src/com/unciv/ui/screens/diplomacyscreen/DiplomacyScreen.kt @@ -152,7 +152,7 @@ class DiplomacyScreen( 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(civNameLabel).padBottom(20f).row() diff --git a/core/src/com/unciv/ui/screens/diplomacyscreen/OffersListScroll.kt b/core/src/com/unciv/ui/screens/diplomacyscreen/OffersListScroll.kt index b488998e49..1aa430c713 100644 --- a/core/src/com/unciv/ui/screens/diplomacyscreen/OffersListScroll.kt +++ b/core/src/com/unciv/ui/screens/diplomacyscreen/OffersListScroll.kt @@ -21,12 +21,12 @@ import com.unciv.logic.trade.TradeType.WarDeclaration import com.unciv.logic.trade.TradeType.values import com.unciv.models.ruleset.tile.ResourceSupplyList 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.extensions.disable 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 com.unciv.ui.components.AutoScrollPane as ScrollPane diff --git a/core/src/com/unciv/ui/screens/overviewscreen/GlobalPoliticsOverviewTable.kt b/core/src/com/unciv/ui/screens/overviewscreen/GlobalPoliticsOverviewTable.kt index b64677200c..e7c1cebbbb 100644 --- a/core/src/com/unciv/ui/screens/overviewscreen/GlobalPoliticsOverviewTable.kt +++ b/core/src/com/unciv/ui/screens/overviewscreen/GlobalPoliticsOverviewTable.kt @@ -129,7 +129,7 @@ class GlobalPoliticsOverviewTable ( val civInfoTable = Table(skin) val leaderName = civ.nation.leaderName 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() return civInfoTable } diff --git a/core/src/com/unciv/ui/screens/overviewscreen/UnitOverviewTable.kt b/core/src/com/unciv/ui/screens/overviewscreen/UnitOverviewTable.kt index 72181c1690..da42788369 100644 --- a/core/src/com/unciv/ui/screens/overviewscreen/UnitOverviewTable.kt +++ b/core/src/com/unciv/ui/screens/overviewscreen/UnitOverviewTable.kt @@ -184,8 +184,7 @@ class UnitOverviewTab( val button = IconTextButton( unit.displayName(), UnitGroup(unit, 20f), - fontColor = if (unit.due && unit.isIdle()) Color.WHITE else Color.LIGHT_GRAY, - hideIcons = true + fontColor = if (unit.due && unit.isIdle()) Color.WHITE else Color.LIGHT_GRAY ) button.name = getUnitIdentifier(unit) // Marker to find a unit in select() button.onClick {