From ca040933210315623dd6028b1325feaa94017a47 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 28 Dec 2020 17:37:29 +0200 Subject: [PATCH] Resolved #3470 - popups now make the rest of the screen unclickable to avoid exploits Resolved #3468 the same way --- core/src/com/unciv/ui/utils/Popup.kt | 26 +++--- .../ui/worldscreen/mainmenu/OptionsPopup.kt | 60 ++++++------- .../mainmenu/WorldScreenMenuPopup.kt | 85 ++++++++----------- 3 files changed, 81 insertions(+), 90 deletions(-) diff --git a/core/src/com/unciv/ui/utils/Popup.kt b/core/src/com/unciv/ui/utils/Popup.kt index 16b2920866..79a2ea5e6d 100644 --- a/core/src/com/unciv/ui/utils/Popup.kt +++ b/core/src/com/unciv/ui/utils/Popup.kt @@ -1,6 +1,8 @@ package com.unciv.ui.utils import com.badlogic.gdx.graphics.Color +import com.badlogic.gdx.graphics.Colors +import com.badlogic.gdx.scenes.scene2d.Actor import com.badlogic.gdx.scenes.scene2d.Touchable import com.badlogic.gdx.scenes.scene2d.ui.Cell import com.badlogic.gdx.scenes.scene2d.ui.Label @@ -13,13 +15,18 @@ import com.unciv.Constants * Base class for all Popups, i.e. Tables that get rendered in the middle of a screen and on top of everything else */ open class Popup(val screen: CameraStageBaseScreen): Table(CameraStageBaseScreen.skin) { + val innerTable = Table(CameraStageBaseScreen.skin) init { - background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f)) + background = ImageGetter.getBackground(Color.GRAY.cpy().apply { a=.5f }) + innerTable.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f)) - this.pad(20f) - this.defaults().pad(5f) + innerTable.pad(20f) + innerTable.defaults().pad(5f) + super.add(innerTable) this.isVisible = false + touchable = Touchable.enabled // don't allow clicking behind + setFillParent(true) } /** @@ -32,6 +39,7 @@ open class Popup(val screen: CameraStageBaseScreen): Table(CameraStageBaseScreen } screen.stage.addActor(this) + innerTable.pack() pack() center(screen.stage) } @@ -42,6 +50,11 @@ open class Popup(val screen: CameraStageBaseScreen): Table(CameraStageBaseScreen if (nextPopup != null) nextPopup.isVisible = true } + /** All additions to the popup are to the inner table - we shouldn't care that there's an inner table at all */ + override fun add(actor: T) = innerTable.add(actor) + override fun row() = innerTable.row() + fun addSeparator() = innerTable.addSeparator() + fun addGoodSizedLabel(text: String, size:Int=18): Cell