mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-08 14:57:58 +07:00
Notificiations tab scroll fix in empire overview (#7536)
* Update NotificationsOverviewTable.kt * Update EmpireOverviewCategories.kt * Update NotificationsOverviewTable.kt
This commit is contained in:
@ -61,9 +61,11 @@ enum class EmpireOverviewCategories(
|
|||||||
= WonderOverviewTab(viewingPlayer, overviewScreen),
|
= WonderOverviewTab(viewingPlayer, overviewScreen),
|
||||||
fun (viewingPlayer: CivilizationInfo) = (viewingPlayer.naturalWonders.isEmpty() && viewingPlayer.cities.isEmpty()).toState()),
|
fun (viewingPlayer: CivilizationInfo) = (viewingPlayer.naturalWonders.isEmpty() && viewingPlayer.cities.isEmpty()).toState()),
|
||||||
Notifications("OtherIcons/Notifications", 'N', Align.top,
|
Notifications("OtherIcons/Notifications", 'N', Align.top,
|
||||||
fun (viewingPlayer: CivilizationInfo, overviewScreen: EmpireOverviewScreen, _: EmpireOverviewTabPersistableData?)
|
fun (viewingPlayer: CivilizationInfo, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?)
|
||||||
= NotificationsOverviewTable(worldScreen = UncivGame.Current.worldScreen!!, viewingPlayer, overviewScreen),
|
= NotificationsOverviewTable(worldScreen = UncivGame.Current.worldScreen!!, viewingPlayer, overviewScreen, persistedData),
|
||||||
fun (_: CivilizationInfo) = EmpireOverviewTabState.Normal);
|
fun (_: CivilizationInfo) = EmpireOverviewTabState.Normal)
|
||||||
|
|
||||||
|
; //must be here
|
||||||
|
|
||||||
constructor(iconName: String, shortcutChar: Char, scrollAlign: Int, factory: FactoryType, stateTester: StateTesterType = { _ -> EmpireOverviewTabState.Normal })
|
constructor(iconName: String, shortcutChar: Char, scrollAlign: Int, factory: FactoryType, stateTester: StateTesterType = { _ -> EmpireOverviewTabState.Normal })
|
||||||
: this(iconName, KeyCharAndCode(shortcutChar), scrollAlign, factory, stateTester)
|
: this(iconName, KeyCharAndCode(shortcutChar), scrollAlign, factory, stateTester)
|
||||||
|
@ -9,6 +9,7 @@ import com.unciv.logic.civilization.Notification
|
|||||||
import com.unciv.ui.images.ImageGetter
|
import com.unciv.ui.images.ImageGetter
|
||||||
import com.unciv.ui.utils.BaseScreen
|
import com.unciv.ui.utils.BaseScreen
|
||||||
import com.unciv.ui.utils.WrappableLabel
|
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.onClick
|
||||||
import com.unciv.ui.utils.extensions.toLabel
|
import com.unciv.ui.utils.extensions.toLabel
|
||||||
import com.unciv.ui.worldscreen.WorldScreen
|
import com.unciv.ui.worldscreen.WorldScreen
|
||||||
@ -16,8 +17,23 @@ import com.unciv.ui.worldscreen.WorldScreen
|
|||||||
class NotificationsOverviewTable(
|
class NotificationsOverviewTable(
|
||||||
val worldScreen: WorldScreen,
|
val worldScreen: WorldScreen,
|
||||||
viewingPlayer: CivilizationInfo,
|
viewingPlayer: CivilizationInfo,
|
||||||
overviewScreen: EmpireOverviewScreen
|
overviewScreen: EmpireOverviewScreen,
|
||||||
|
persistedData: EmpireOverviewTabPersistableData? = null
|
||||||
) : EmpireOverviewTab(viewingPlayer, overviewScreen) {
|
) : 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
|
val notificationLog = viewingPlayer.notificationsLog
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user