mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 21:35:14 -04:00
Fixed crash when viewing the name of a religion (#5092)
This commit is contained in:
parent
54583844fc
commit
980f0f4611
@ -973,7 +973,7 @@ class MapUnit {
|
|||||||
|
|
||||||
fun getReligionDisplayName(): String? {
|
fun getReligionDisplayName(): String? {
|
||||||
if (religion == null) return null
|
if (religion == null) return null
|
||||||
return civInfo.gameInfo.religions[religion]!!.displayName ?: religion
|
return civInfo.gameInfo.religions[religion]!!.getReligionDisplayName()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun religiousActionsUnitCanDo(): Sequence<String> {
|
fun religiousActionsUnitCanDo(): Sequence<String> {
|
||||||
|
@ -21,7 +21,6 @@ class Religion() : INamed {
|
|||||||
|
|
||||||
constructor(name: String, gameInfo: GameInfo, foundingCivName: String) : this() {
|
constructor(name: String, gameInfo: GameInfo, foundingCivName: String) : this() {
|
||||||
this.name = name
|
this.name = name
|
||||||
this.displayName = name
|
|
||||||
this.foundingCivName = foundingCivName
|
this.foundingCivName = foundingCivName
|
||||||
this.gameInfo = gameInfo
|
this.gameInfo = gameInfo
|
||||||
}
|
}
|
||||||
@ -42,6 +41,10 @@ class Religion() : INamed {
|
|||||||
if (isPantheon()) "Pantheon"
|
if (isPantheon()) "Pantheon"
|
||||||
else name
|
else name
|
||||||
|
|
||||||
|
fun getReligionDisplayName() =
|
||||||
|
if (displayName != null) displayName!!
|
||||||
|
else name
|
||||||
|
|
||||||
private fun mapToExistingBeliefs(beliefs: HashSet<String>): List<Belief> {
|
private fun mapToExistingBeliefs(beliefs: HashSet<String>): List<Belief> {
|
||||||
val rulesetBeliefs = gameInfo.ruleSet.beliefs
|
val rulesetBeliefs = gameInfo.ruleSet.beliefs
|
||||||
return beliefs.mapNotNull {
|
return beliefs.mapNotNull {
|
||||||
|
@ -83,7 +83,7 @@ class CityStatsTable(val cityScreen: CityScreen): Table() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun addReligionInfo() {
|
private fun addReligionInfo() {
|
||||||
val label = cityInfo.religion.getMajorityReligion()?.displayName
|
val label = cityInfo.religion.getMajorityReligion()?.getReligionDisplayName()
|
||||||
?: "None"
|
?: "None"
|
||||||
val icon =
|
val icon =
|
||||||
if (label == "None") "Religion"
|
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,
|
// I want this to be centered, but `.center()` doesn't seem to do anything,
|
||||||
// regardless of where I place it :(
|
// regardless of where I place it :(
|
||||||
it.add(
|
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()
|
).center().colspan(2).pad(5f).row()
|
||||||
}
|
}
|
||||||
it.add(getReligionsTable()).colspan(2).pad(5f)
|
it.add(getReligionsTable()).colspan(2).pad(5f)
|
||||||
|
@ -66,13 +66,13 @@ class ReligionOverviewTable(
|
|||||||
private fun loadReligion(religion: Religion) {
|
private fun loadReligion(religion: Religion) {
|
||||||
statsTable.clear()
|
statsTable.clear()
|
||||||
beliefsTable.clear()
|
beliefsTable.clear()
|
||||||
topButtonLabel.setText(religion.displayName!!.tr())
|
topButtonLabel.setText(religion.getReligionDisplayName().tr())
|
||||||
for (belief in religion.getAllBeliefsOrdered()) {
|
for (belief in religion.getAllBeliefsOrdered()) {
|
||||||
beliefsTable.add(createBeliefDescription(belief)).pad(10f).row()
|
beliefsTable.add(createBeliefDescription(belief)).pad(10f).row()
|
||||||
}
|
}
|
||||||
|
|
||||||
statsTable.add("Religion Name:".toLabel())
|
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())
|
statsTable.add("Founding Civ:".toLabel())
|
||||||
val foundingCivName =
|
val foundingCivName =
|
||||||
if (viewingPlayer.knows(religion.foundingCivName) || viewingPlayer.civName == religion.foundingCivName)
|
if (viewingPlayer.knows(religion.foundingCivName) || viewingPlayer.civName == religion.foundingCivName)
|
||||||
|
@ -50,7 +50,7 @@ class ReligiousBeliefsPickerScreen (
|
|||||||
topTable.add(middlePanes)
|
topTable.add(middlePanes)
|
||||||
|
|
||||||
if (pickIconAndName) rightSideButton.label = "Choose a religion".toLabel()
|
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) {
|
rightSideButton.onClick(UncivSound.Choir) {
|
||||||
choosingCiv.religionManager.chooseBeliefs(displayName, religionName, beliefsContainer.chosenBeliefs.map { it!! })
|
choosingCiv.religionManager.chooseBeliefs(displayName, religionName, beliefsContainer.chosenBeliefs.map { it!! })
|
||||||
UncivGame.Current.setWorldScreen()
|
UncivGame.Current.setWorldScreen()
|
||||||
|
@ -503,7 +503,7 @@ object UnitActions {
|
|||||||
if (!unit.hasUnique("May enhance a religion")) return
|
if (!unit.hasUnique("May enhance a religion")) return
|
||||||
if (!unit.civInfo.religionManager.mayEnhanceReligionAtAll(unit)) return
|
if (!unit.civInfo.religionManager.mayEnhanceReligionAtAll(unit)) return
|
||||||
actionList += UnitAction(UnitActionType.EnhanceReligion,
|
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) }
|
action = getEnhanceReligionAction(unit).takeIf { unit.civInfo.religionManager.mayEnhanceReligionNow(unit) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user