Fix translated sorting (#9563)

* Fix translated sorting

* Minor linting, missing pedia icon, missing tooltip template

* Wiki on icons for Beliefs
This commit is contained in:
SomeTroglodyte
2023-06-11 11:37:25 +02:00
committed by GitHub
parent c506331dcc
commit 7fb8bae251
15 changed files with 33 additions and 23 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -81,6 +81,13 @@ ReligionIcons/Religion
orig: 100, 100
offset: 0, 0
index: -1
ReligionIcons/Religions
rotate: false
xy: 1084, 4
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
ReligionIcons/Shinto
rotate: false
xy: 1192, 4

View File

@ -1384,6 +1384,7 @@ Allied with [civName] =
Civilization Info =
Relations =
Trade request =
Garrisoned by unit =
# Victory

View File

@ -28,7 +28,7 @@ class DiplomacyFunctions(val civInfo: Civilization){
}
.sortedWith(
compareByDescending<Civilization> { it.isMajorCiv() }
.thenBy (UncivGame.Current.settings.getCollatorFromLocale()) { it.civName.tr() }
.thenBy (UncivGame.Current.settings.getCollatorFromLocale()) { it.civName.tr(hideIcons = true) }
)

View File

@ -71,7 +71,7 @@ class Belief() : RulesetObject() {
name = "Religions"
val lines = ArrayList<FormattedLine>()
lines += FormattedLine(separator = true)
ruleset.religions.sortedWith(compareBy(UncivGame.Current.settings.getCollatorFromLocale()) { it.tr() }).forEach {
ruleset.religions.sortedWith(compareBy(UncivGame.Current.settings.getCollatorFromLocale()) { it.tr(hideIcons = true) }).forEach {
lines += FormattedLine(it, icon = "Belief/$it")
}
civilopediaText = lines

View File

@ -274,13 +274,11 @@ object ImageGetter {
fun getReligionIcon(iconName: String): Image { return getImage("ReligionIcons/$iconName") }
fun getReligionPortrait(iconName: String, size: Float): Portrait {
if (religionIconExists(iconName)) {
if (religionIconExists(iconName))
return PortraitReligion(iconName, size)
} else {
val typeName = ruleset.beliefs[iconName]?.type?.name
if (typeName != null && religionIconExists(typeName))
return PortraitReligion(typeName, size)
}
val typeName = ruleset.beliefs[iconName]?.type?.name
if (typeName != null && religionIconExists(typeName))
return PortraitReligion(typeName, size)
return PortraitReligion(iconName, size)
}

View File

@ -58,7 +58,6 @@ import com.unciv.ui.components.AutoScrollPane as ScrollPane
* When [selectCiv] and [selectTrade] are supplied, that Trade for that Civilization is selected, used for the counter-offer option from `TradePopup`.
* Note calling this with [selectCiv] a City State and [selectTrade] supplied is **not allowed**.
*/
@Suppress("KDocUnresolvedReference") // Mentioning non-field parameters is flagged, but they work anyway
class DiplomacyScreen(
private val viewingCiv: Civilization,
private val selectCiv: Civilization? = null,

View File

@ -304,7 +304,7 @@ class MapEditorEditStartsTab(
private fun allowedNations() = ruleset.nations.values.asSequence()
.filter { it.name !in disallowNations && !it.hasUnique(UniqueType.CityStateDeprecated) }
private fun getNations() = allowedNations()
.sortedWith(compareBy<Nation>{ it.isCityState }.thenBy(collator) { it.name.tr() })
.sortedWith(compareBy<Nation>{ it.isCityState }.thenBy(collator) { it.name.tr(hideIcons = true) })
.map { FormattedLine("[${it.name}] starting location", it.name, "Nation/${it.name}", size = 24) }
.asIterable()

View File

@ -106,7 +106,7 @@ class MapEditorViewTab(
naturalWonders.clear()
tileMap.values.asSequence()
.mapNotNull { it.naturalWonder }
.sortedWith(compareBy(collator) { it.tr() })
.sortedWith(compareBy(collator) { it.tr(hideIcons = true) })
.forEach {
naturalWonders.add(it, 1)
}
@ -260,11 +260,11 @@ class MapEditorViewTab(
startingLocationsByNation.asSequence()
.filter { tile == null || tile in it.value }
.mapNotNull { ruleset!!.nations[it.key] }
.sortedWith(compareBy<Nation>{ it.isCityState }.thenBy(collator) { it.name.tr() })
.sortedWith(compareBy<Nation>{ it.isCityState }.thenBy(collator) { it.name.tr(hideIcons = true) })
private fun TileMap.getStartingLocationSummary() =
startingLocationsByNation.asSequence()
.mapNotNull { if (it.key in ruleset!!.nations) ruleset!!.nations[it.key]!! to it.value.size else null }
.sortedWith(compareBy<Pair<Nation,Int>>{ it.first.isCityState }.thenBy(collator) { it.first.name.tr() })
.sortedWith(compareBy<Pair<Nation,Int>>{ it.first.isCityState }.thenBy(collator) { it.first.name.tr(hideIcons = true) })
.map { it.first.name to it.second }
}

View File

@ -516,7 +516,7 @@ private class RandomNationPickerPopup(
init {
val sortedNations = previousScreen.ruleset.nations.values
.filter { it.isMajorCiv }
.sortedWith(compareBy(UncivGame.Current.settings.getCollatorFromLocale()) { it.name.tr() })
.sortedWith(compareBy(UncivGame.Current.settings.getCollatorFromLocale()) { it.name.tr(hideIcons = true) })
allNationTables = ArrayList(
sortedNations.map { NationTable(it, civBlocksWidth, 0f) } // no need for min height
)

View File

@ -119,15 +119,15 @@ class CityOverviewTab(
private fun getComparator() = Comparator { city2: City, city1: City ->
when(persistableData.sortedBy) {
CITY -> collator.compare(city2.name.tr(), city1.name.tr())
CITY -> collator.compare(city2.name.tr(hideIcons = true), city1.name.tr(hideIcons = true))
CONSTRUCTION -> collator.compare(
city2.cityConstructions.currentConstructionFromQueue.tr(),
city1.cityConstructions.currentConstructionFromQueue.tr())
city2.cityConstructions.currentConstructionFromQueue.tr(hideIcons = true),
city1.cityConstructions.currentConstructionFromQueue.tr(hideIcons = true))
"Population" -> city2.population.population - city1.population.population
WLTK -> city2.isWeLoveTheKingDayActive().compareTo(city1.isWeLoveTheKingDayActive())
GARRISON -> collator.compare(
city2.getGarrison()?.name?.tr() ?: "",
city1.getGarrison()?.name?.tr() ?: "",
city2.getGarrison()?.name?.tr(hideIcons = true) ?: "",
city1.getGarrison()?.name?.tr(hideIcons = true) ?: "",
)
else -> {
val stat = Stat.safeValueOf(persistableData.sortedBy)!!

View File

@ -128,9 +128,9 @@ class EspionageOverviewScreen(val civInfo: Civilization) : PickerScreen(true) {
}.thenBy {
it.civ.isCityState()
}.thenBy(collator) {
it.civ.civName.tr()
it.civ.civName.tr(hideIcons = true)
}.thenBy(collator) {
it.name.tr()
it.name.tr(hideIcons = true)
}
)
for (city in sortedCities) {

View File

@ -66,7 +66,7 @@ class ResourcesOverviewTab(
.distinct()
.sortedWith(
compareBy<TileResource> { it.resourceType }
.thenBy(UncivGame.Current.settings.getCollatorFromLocale()) { it.name.tr() }
.thenBy(UncivGame.Current.settings.getCollatorFromLocale()) { it.name.tr(hideIcons = true) }
)
.toList()
private val origins: List<String> = resourceDrilldown.asSequence()

View File

@ -184,7 +184,7 @@ class WonderInfo {
ruleSet.buildings.values.asSequence()
.filter { it.isWonder }
// 100 is so wonders with no era get displayed after all eras, not before
.sortedWith(compareBy<Building> { wonderEraMap[it.name]?.eraNumber ?: 100 }.thenBy(collator) { it.name.tr() })
.sortedWith(compareBy<Building> { wonderEraMap[it.name]?.eraNumber ?: 100 }.thenBy(collator) { it.name.tr(hideIcons = true) })
.withIndex()
.associate { it.index to it.value.name }
val wonderCount = allWonderMap.size

View File

@ -62,6 +62,11 @@ For example, [here](https://github.com/vegeta1k95/Civ-5-Icons) is mod showing ho
The Unit Types as defined in [UnitTypes.json](../Other/Unit-related-JSON-files#unittypesjson) have no icons in the base game, but Civilopedia can decorate their entries if you supply images named 'Images/UnitTypeIcons/<UnitType>.png'.
(while you're at it, you may override the default icon for the Unit Type _category header_ - it's 'UnitTypes.png' in the same folder, or the icons used for the movement domains - 'DomainLand', 'DomainWater', 'DomainAir')
### Adding icons for Beliefs
The individual Beliefs - as opposed to Belief types, as defined in [Beliefs.json](../Other/Civilization-related-JSON-files#beliefsjson) have no icons in the base game, but Civilopedia can decorate their entries if you supply images named 'Images/ReligionIcons/<Belief>.png'.
Civilopedia falls back to the icon for the Belief type - as you can see in the base game, but individual icons have precedence if they exist.
## Sounds
Standard values are below. The sounds themselves can be found [here](/sounds).