diff --git a/core/src/com/unciv/ui/overviewscreen/EmpireOverviewCategories.kt b/core/src/com/unciv/ui/overviewscreen/EmpireOverviewCategories.kt index 8b0d4b8fa7..055c853b8f 100644 --- a/core/src/com/unciv/ui/overviewscreen/EmpireOverviewCategories.kt +++ b/core/src/com/unciv/ui/overviewscreen/EmpireOverviewCategories.kt @@ -61,9 +61,11 @@ enum class EmpireOverviewCategories( = WonderOverviewTab(viewingPlayer, overviewScreen), fun (viewingPlayer: CivilizationInfo) = (viewingPlayer.naturalWonders.isEmpty() && viewingPlayer.cities.isEmpty()).toState()), Notifications("OtherIcons/Notifications", 'N', Align.top, - fun (viewingPlayer: CivilizationInfo, overviewScreen: EmpireOverviewScreen, _: EmpireOverviewTabPersistableData?) - = NotificationsOverviewTable(worldScreen = UncivGame.Current.worldScreen!!, viewingPlayer, overviewScreen), - fun (_: CivilizationInfo) = EmpireOverviewTabState.Normal); + fun (viewingPlayer: CivilizationInfo, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?) + = NotificationsOverviewTable(worldScreen = UncivGame.Current.worldScreen!!, viewingPlayer, overviewScreen, persistedData), + fun (_: CivilizationInfo) = EmpireOverviewTabState.Normal) + + ; //must be here constructor(iconName: String, shortcutChar: Char, scrollAlign: Int, factory: FactoryType, stateTester: StateTesterType = { _ -> EmpireOverviewTabState.Normal }) : this(iconName, KeyCharAndCode(shortcutChar), scrollAlign, factory, stateTester) diff --git a/core/src/com/unciv/ui/overviewscreen/NotificationsOverviewTable.kt b/core/src/com/unciv/ui/overviewscreen/NotificationsOverviewTable.kt index c910afabcc..2e5522c60f 100644 --- a/core/src/com/unciv/ui/overviewscreen/NotificationsOverviewTable.kt +++ b/core/src/com/unciv/ui/overviewscreen/NotificationsOverviewTable.kt @@ -9,6 +9,7 @@ import com.unciv.logic.civilization.Notification import com.unciv.ui.images.ImageGetter import com.unciv.ui.utils.BaseScreen import com.unciv.ui.utils.WrappableLabel +import com.unciv.ui.utils.TabbedPager import com.unciv.ui.utils.extensions.onClick import com.unciv.ui.utils.extensions.toLabel import com.unciv.ui.worldscreen.WorldScreen @@ -16,8 +17,23 @@ import com.unciv.ui.worldscreen.WorldScreen class NotificationsOverviewTable( val worldScreen: WorldScreen, viewingPlayer: CivilizationInfo, - overviewScreen: EmpireOverviewScreen + overviewScreen: EmpireOverviewScreen, + persistedData: EmpireOverviewTabPersistableData? = null ) : EmpireOverviewTab(viewingPlayer, overviewScreen) { + class NotificationsTabPersistableData( + var scrollY: Float? = null + ) : EmpireOverviewTabPersistableData() { + override fun isEmpty() = scrollY == null + } + override val persistableData = (persistedData as? NotificationsTabPersistableData) ?: NotificationsTabPersistableData() + override fun activated(index: Int, caption: String, pager: TabbedPager) { + if (persistableData.scrollY != null) + pager.setPageScrollY(index, persistableData.scrollY!!) + super.activated(index, caption, pager) + } + override fun deactivated(index: Int, caption: String, pager: TabbedPager) { + persistableData.scrollY = pager.getPageScrollY(index) + } val notificationLog = viewingPlayer.notificationsLog