mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-30 23:41:03 -04: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)
|
unit.promotions.addPromotion(promotion.name)
|
||||||
if (unit.promotions.canBePromoted())
|
if (unit.promotions.canBePromoted())
|
||||||
game.setScreen(PromotionPickerScreen(unit))
|
game.setScreen(PromotionPickerScreen(unit).setScrollY(scrollPane.scrollY))
|
||||||
else
|
else
|
||||||
game.setWorldScreen()
|
game.setWorldScreen()
|
||||||
dispose()
|
dispose()
|
||||||
@ -32,7 +32,6 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
|||||||
onBackButtonClicked { UncivGame.Current.setWorldScreen() }
|
onBackButtonClicked { UncivGame.Current.setWorldScreen() }
|
||||||
setDefaultCloseAction()
|
setDefaultCloseAction()
|
||||||
|
|
||||||
|
|
||||||
rightSideButton.setText("Pick promotion".tr())
|
rightSideButton.setText("Pick promotion".tr())
|
||||||
rightSideButton.onClick(UncivSound.Promote) {
|
rightSideButton.onClick(UncivSound.Promote) {
|
||||||
acceptPromotion(selectedPromotion)
|
acceptPromotion(selectedPromotion)
|
||||||
@ -99,4 +98,17 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
|||||||
|
|
||||||
displayTutorial(Tutorial.Experience)
|
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…
x
Reference in New Issue
Block a user