Resolved #3520 - picker screens go back on Back button / Esc

This commit is contained in:
Yair Morgenstern 2021-01-12 16:34:13 +02:00
parent af326100fc
commit 09d44bfcd2
2 changed files with 8 additions and 2 deletions

View File

@ -128,6 +128,10 @@ class MainMenuScreen: CameraStageBaseScreen() {
stage.addActor(scroll) stage.addActor(scroll)
onBackButtonClicked { onBackButtonClicked {
if(hasOpenPopups()) {
closeAllPopups()
return@onBackButtonClicked
}
val promptWindow = Popup(this) val promptWindow = Popup(this)
promptWindow.addGoodSizedLabel("Do you want to exit the game?".tr()) promptWindow.addGoodSizedLabel("Do you want to exit the game?".tr())
promptWindow.row() promptWindow.row()

View File

@ -46,11 +46,13 @@ open class PickerScreen : CameraStageBaseScreen() {
} }
fun setDefaultCloseAction(previousScreen: CameraStageBaseScreen?=null) { fun setDefaultCloseAction(previousScreen: CameraStageBaseScreen?=null) {
closeButton.onClick { val closeAction = {
if (previousScreen != null) game.setScreen(previousScreen) if (previousScreen != null) game.setScreen(previousScreen)
else game.setWorldScreen() else game.setWorldScreen()
dispose() dispose()
} }
closeButton.onClick(closeAction)
onBackButtonClicked(closeAction)
} }
fun setRightSideButtonEnabled(bool: Boolean) { fun setRightSideButtonEnabled(bool: Boolean) {
@ -59,7 +61,7 @@ open class PickerScreen : CameraStageBaseScreen() {
} }
protected fun pick(rightButtonText: String) { protected fun pick(rightButtonText: String) {
if(UncivGame.Current.worldScreen.isPlayersTurn) rightSideButton.enable() if (UncivGame.Current.worldScreen.isPlayersTurn) rightSideButton.enable()
rightSideButton.setText(rightButtonText) rightSideButton.setText(rightButtonText)
} }