Fixed crash when viewing the name of a religion (#5092)

This commit is contained in:
Xander Lenstra 2021-09-05 11:05:54 +02:00 committed by GitHub
parent 54583844fc
commit 980f0f4611
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 8 deletions

View File

@ -973,7 +973,7 @@ class MapUnit {
fun getReligionDisplayName(): String? {
if (religion == null) return null
return civInfo.gameInfo.religions[religion]!!.displayName ?: religion
return civInfo.gameInfo.religions[religion]!!.getReligionDisplayName()
}
fun religiousActionsUnitCanDo(): Sequence<String> {

View File

@ -21,7 +21,6 @@ class Religion() : INamed {
constructor(name: String, gameInfo: GameInfo, foundingCivName: String) : this() {
this.name = name
this.displayName = name
this.foundingCivName = foundingCivName
this.gameInfo = gameInfo
}
@ -42,6 +41,10 @@ class Religion() : INamed {
if (isPantheon()) "Pantheon"
else name
fun getReligionDisplayName() =
if (displayName != null) displayName!!
else name
private fun mapToExistingBeliefs(beliefs: HashSet<String>): List<Belief> {
val rulesetBeliefs = gameInfo.ruleSet.beliefs
return beliefs.mapNotNull {

View File

@ -83,7 +83,7 @@ class CityStatsTable(val cityScreen: CityScreen): Table() {
}
private fun addReligionInfo() {
val label = cityInfo.religion.getMajorityReligion()?.displayName
val label = cityInfo.religion.getMajorityReligion()?.getReligionDisplayName()
?: "None"
val icon =
if (label == "None") "Religion"
@ -107,7 +107,7 @@ class CityStatsTable(val cityScreen: CityScreen): Table() {
// I want this to be centered, but `.center()` doesn't seem to do anything,
// regardless of where I place it :(
it.add(
"Holy city of: [${cityInfo.civInfo.gameInfo.religions[cityInfo.religion.religionThisIsTheHolyCityOf!!]!!.displayName}]".toLabel()
"Holy city of: [${cityInfo.civInfo.gameInfo.religions[cityInfo.religion.religionThisIsTheHolyCityOf!!]!!.getReligionDisplayName()}]".toLabel()
).center().colspan(2).pad(5f).row()
}
it.add(getReligionsTable()).colspan(2).pad(5f)

View File

@ -66,13 +66,13 @@ class ReligionOverviewTable(
private fun loadReligion(religion: Religion) {
statsTable.clear()
beliefsTable.clear()
topButtonLabel.setText(religion.displayName!!.tr())
topButtonLabel.setText(religion.getReligionDisplayName().tr())
for (belief in religion.getAllBeliefsOrdered()) {
beliefsTable.add(createBeliefDescription(belief)).pad(10f).row()
}
statsTable.add("Religion Name:".toLabel())
statsTable.add(religion.displayName!!.toLabel()).pad(5f).row()
statsTable.add(religion.getReligionDisplayName().toLabel()).pad(5f).row()
statsTable.add("Founding Civ:".toLabel())
val foundingCivName =
if (viewingPlayer.knows(religion.foundingCivName) || viewingPlayer.civName == religion.foundingCivName)

View File

@ -50,7 +50,7 @@ class ReligiousBeliefsPickerScreen (
topTable.add(middlePanes)
if (pickIconAndName) rightSideButton.label = "Choose a religion".toLabel()
else rightSideButton.label = "Enhance [${choosingCiv.religionManager.religion!!.displayName}]".toLabel()
else rightSideButton.label = "Enhance [${choosingCiv.religionManager.religion!!.getReligionDisplayName()}]".toLabel()
rightSideButton.onClick(UncivSound.Choir) {
choosingCiv.religionManager.chooseBeliefs(displayName, religionName, beliefsContainer.chosenBeliefs.map { it!! })
UncivGame.Current.setWorldScreen()

View File

@ -503,7 +503,7 @@ object UnitActions {
if (!unit.hasUnique("May enhance a religion")) return
if (!unit.civInfo.religionManager.mayEnhanceReligionAtAll(unit)) return
actionList += UnitAction(UnitActionType.EnhanceReligion,
title = "Enhance [${unit.civInfo.religionManager.religion!!.displayName}]",
title = "Enhance [${unit.civInfo.religionManager.religion!!.getReligionDisplayName()}]",
action = getEnhanceReligionAction(unit).takeIf { unit.civInfo.religionManager.mayEnhanceReligionNow(unit) }
)
}