mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-09 15:29:32 +07:00
Notifications scroll pane position fix (#8900)
* Notifications scroll pane position fix * Removed an unnecessary var
This commit is contained in:
@ -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<Notification>,
|
||||
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)
|
||||
}
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user