mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-25 21:03:15 -04:00
Mods with no policy branches don't crash when clicking on culture icon
This commit is contained in:
parent
9054d84626
commit
ce8a7e9e3e
@ -51,10 +51,11 @@ internal class WorldScreenTopBarStats(topbar: WorldScreenTopBar) : ScalingTableW
|
|||||||
isTransform = false
|
isTransform = false
|
||||||
|
|
||||||
|
|
||||||
fun addStat(label: Label, icon: String, isLast: Boolean = false, screenFactory: ()-> BaseScreen) {
|
fun addStat(label: Label, icon: String, isLast: Boolean = false, screenFactory: ()-> BaseScreen?) {
|
||||||
val image = ImageGetter.getStatIcon(icon)
|
val image = ImageGetter.getStatIcon(icon)
|
||||||
val action = {
|
val action = {
|
||||||
worldScreen.game.pushScreen(screenFactory())
|
val screen = screenFactory()
|
||||||
|
if (screen != null) worldScreen.game.pushScreen(screen)
|
||||||
}
|
}
|
||||||
label.onClick(action)
|
label.onClick(action)
|
||||||
image.onClick(action)
|
image.onClick(action)
|
||||||
@ -79,7 +80,10 @@ internal class WorldScreenTopBarStats(topbar: WorldScreenTopBar) : ScalingTableW
|
|||||||
happinessContainer.onClick(invokeResourcesPage)
|
happinessContainer.onClick(invokeResourcesPage)
|
||||||
happinessLabel.onClick(invokeResourcesPage)
|
happinessLabel.onClick(invokeResourcesPage)
|
||||||
|
|
||||||
addStat(cultureLabel, "Culture") { PolicyPickerScreen(worldScreen.selectedCiv, worldScreen.canChangeState) }
|
addStat(cultureLabel, "Culture") {
|
||||||
|
if (worldScreen.gameInfo.ruleset.policyBranches.isEmpty()) null
|
||||||
|
else PolicyPickerScreen(worldScreen.selectedCiv, worldScreen.canChangeState)
|
||||||
|
}
|
||||||
if (worldScreen.gameInfo.isReligionEnabled()) {
|
if (worldScreen.gameInfo.isReligionEnabled()) {
|
||||||
addStat(faithLabel, "Faith", EmpireOverviewCategories.Religion, isLast = true)
|
addStat(faithLabel, "Faith", EmpireOverviewCategories.Religion, isLast = true)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user