From ce8a7e9e3e8074b750115f0c724371b56b4a9b52 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 27 Feb 2024 23:37:54 +0200 Subject: [PATCH] Mods with no policy branches don't crash when clicking on culture icon --- .../worldscreen/topbar/WorldScreenTopBarStats.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/com/unciv/ui/screens/worldscreen/topbar/WorldScreenTopBarStats.kt b/core/src/com/unciv/ui/screens/worldscreen/topbar/WorldScreenTopBarStats.kt index c00fb838c5..8a7dfa78bf 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/topbar/WorldScreenTopBarStats.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/topbar/WorldScreenTopBarStats.kt @@ -51,10 +51,11 @@ internal class WorldScreenTopBarStats(topbar: WorldScreenTopBar) : ScalingTableW 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 action = { - worldScreen.game.pushScreen(screenFactory()) + val screen = screenFactory() + if (screen != null) worldScreen.game.pushScreen(screen) } label.onClick(action) image.onClick(action) @@ -79,7 +80,10 @@ internal class WorldScreenTopBarStats(topbar: WorldScreenTopBar) : ScalingTableW happinessContainer.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()) { addStat(faithLabel, "Faith", EmpireOverviewCategories.Religion, isLast = true) } else {