mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-11 11:28:03 +07:00
Promotion picker keeps vertical scroll pos on promote or resize (#4247)
* Promotion picker keeps vertical scroll pos on promote or resize * Promotion picker keeps vertical scroll - without parameter
This commit is contained in:
parent
af0cd0c9df
commit
06b2e7da2f
@ -21,7 +21,7 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
||||
|
||||
unit.promotions.addPromotion(promotion.name)
|
||||
if (unit.promotions.canBePromoted())
|
||||
game.setScreen(PromotionPickerScreen(unit))
|
||||
game.setScreen(PromotionPickerScreen(unit).setScrollY(scrollPane.scrollY))
|
||||
else
|
||||
game.setWorldScreen()
|
||||
dispose()
|
||||
@ -32,7 +32,6 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
||||
onBackButtonClicked { UncivGame.Current.setWorldScreen() }
|
||||
setDefaultCloseAction()
|
||||
|
||||
|
||||
rightSideButton.setText("Pick promotion".tr())
|
||||
rightSideButton.onClick(UncivSound.Promote) {
|
||||
acceptPromotion(selectedPromotion)
|
||||
@ -99,4 +98,17 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
||||
|
||||
displayTutorial(Tutorial.Experience)
|
||||
}
|
||||
|
||||
fun setScrollY(scrollY: Float): PromotionPickerScreen {
|
||||
splitPane.pack() // otherwise scrollPane.maxY == 0
|
||||
scrollPane.scrollY = scrollY
|
||||
scrollPane.updateVisualScroll()
|
||||
return this
|
||||
}
|
||||
|
||||
override fun resize(width: Int, height: Int) {
|
||||
if (stage.viewport.screenWidth != width || stage.viewport.screenHeight != height) {
|
||||
game.setScreen(PromotionPickerScreen(unit).setScrollY(scrollPane.scrollY))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user