diff --git a/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt index 9c9cab5f2c..07e0f6e124 100644 --- a/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt @@ -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)) + } + } }