diff --git a/core/src/com/unciv/ui/screens/worldscreen/NotificationsScroll.kt b/core/src/com/unciv/ui/screens/worldscreen/NotificationsScroll.kt index ae5a41991b..3ddc8a148d 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/NotificationsScroll.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/NotificationsScroll.kt @@ -32,7 +32,6 @@ class NotificationsScroll( private var notificationsHash: Int = 0 private var notificationsTable = Table() - private var endOfTableSpacerCell: Cell<*>? = null private val maxEntryWidth = worldScreen.stage.width * maxWidthOfStage * inverseScaleFactor @@ -50,13 +49,12 @@ class NotificationsScroll( */ internal fun update( notifications: MutableList, - maxNotificationsHeight: Float, - tileInfoTableHeight: Float + maxNotificationsHeight: Float ) { val previousScrollY = scrollY updateContent(notifications) - updateLayout(maxNotificationsHeight, tileInfoTableHeight) + updateLayout(maxNotificationsHeight) scrollY = previousScrollY updateVisualScroll() @@ -69,7 +67,6 @@ class NotificationsScroll( notificationsHash = newHash notificationsTable.clearChildren() - endOfTableSpacerCell = null val reversedNotifications = notifications.asReversed().toList() // toList to avoid concurrency problems for (category in NotificationCategory.values()){ @@ -120,29 +117,14 @@ class NotificationsScroll( notificationsTable.pack() // needed to get height - prefHeight is set and close but not quite the same value } - private fun updateLayout(maxNotificationsHeight: Float, tileInfoTableHeight: Float) { + private fun updateLayout(maxNotificationsHeight: Float) { val newHeight = min(notificationsTable.height, maxNotificationsHeight * inverseScaleFactor) - sizeScrollingSpacer(tileInfoTableHeight) - pack() height = newHeight // after this, maxY is still incorrect until layout() layout() } - /** Add some empty space that can be scrolled under the TileInfoTable which is covering our lower part */ - private fun sizeScrollingSpacer(tileInfoTableHeight: Float) { - if (endOfTableSpacerCell == null) { - endOfTableSpacerCell = notificationsTable.add().pad(5f) - notificationsTable.row() - } - val scaledHeight = tileInfoTableHeight * inverseScaleFactor - endOfTableSpacerCell!!.height(scaledHeight) - notificationsTable.invalidate() // looks redundant but isn't - // (the flags it sets are already on when inspected in debugger, but when omitting it the - // ScrollPane will not properly scroll down to the new maxY when TileInfoTable changes to a smaller height) - } - fun setTopRight (right: Float, top: Float) { setPosition(right - width * scaleFactor, top - height * scaleFactor) } diff --git a/core/src/com/unciv/ui/screens/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/screens/worldscreen/WorldScreen.kt index 066f25aa01..6535fec604 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/WorldScreen.kt @@ -454,8 +454,8 @@ class WorldScreen( updateGameplayButtons() val maxNotificationsHeight = statusButtons.y - - (if (game.settings.showMinimap) minimapWrapper.height else 0f) - 5f - notificationsScroll.update(viewingCiv.notifications, maxNotificationsHeight, bottomTileInfoTable.height) + (if (game.settings.showMinimap) minimapWrapper.height else 0f) - bottomTileInfoTable.height - 5f + notificationsScroll.update(viewingCiv.notifications, maxNotificationsHeight) notificationsScroll.setTopRight(stage.width - 10f, statusButtons.y - 5f) val posZoomFromRight = if (game.settings.showMinimap) minimapWrapper.width