mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-10 23:37:31 +07:00
Notificiations tab scroll fix in empire overview (#7536)
* Update NotificationsOverviewTable.kt * Update EmpireOverviewCategories.kt * Update NotificationsOverviewTable.kt
This commit is contained in:
parent
9967642573
commit
89979748a1
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user