Add a setting to forbid closing popups by clicking behind them (#10539)

* Add a setting to forbit closing popups by clicking behind them

* Change default checkbox state to false

* Update template and Russian translation
This commit is contained in:
Sergey
2023-11-23 02:59:07 +05:00
committed by GitHub
parent 8bd2363361
commit 30c4b323ec
5 changed files with 6 additions and 1 deletions

View File

@ -746,6 +746,7 @@ Reset = Сбросить
Show zoom buttons in world screen = Показывать кнопки масштабирования на экране мира
Experimental Demographics scoreboard = Экспериментальная таблица рейтинга
Never close popups by clicking outside = Не закрывать всплывающие окна нажатием на их фон
Size of Unitset art in Civilopedia = Размер изображений палитры юнитов в Цивилопедии

View File

@ -746,6 +746,7 @@ Reset =
Show zoom buttons in world screen =
Experimental Demographics scoreboard =
Never close popups by clicking outside =
Size of Unitset art in Civilopedia =

View File

@ -81,6 +81,7 @@ class GameSettings {
var visualMods = HashSet<String>()
var useDemographics: Boolean = false
var showZoomButtons: Boolean = false
var forbidPopupClickBehindToClose: Boolean = false
var notificationsLogMaxTurns = 5

View File

@ -18,6 +18,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener
import com.badlogic.gdx.utils.Align
import com.unciv.Constants
import com.unciv.GUI
import com.unciv.logic.event.EventBus
import com.unciv.ui.components.widgets.AutoScrollPane
import com.unciv.ui.components.extensions.addSeparator
@ -227,7 +228,7 @@ open class Popup(
/** Allow closing a popup by clicking 'outside', Android-style, but only if a Close button exists */
private fun getBehindClickListener() = object : ClickListener() {
override fun clicked(event: InputEvent?, x: Float, y: Float) {
if (!clickBehindToClose) return
if (!clickBehindToClose || GUI.getSettings().forbidPopupClickBehindToClose) return
// Since Gdx doesn't limit events to the actually `hit` actors...
if (event?.target != this@Popup) return
close()

View File

@ -71,6 +71,7 @@ fun displayTab(
addResetTutorials(this, settings)
optionsPopup.addCheckbox(this, "Show zoom buttons in world screen", settings.showZoomButtons, true) { settings.showZoomButtons = it }
optionsPopup.addCheckbox(this, "Experimental Demographics scoreboard", settings.useDemographics, true) { settings.useDemographics = it }
optionsPopup.addCheckbox(this, "Never close popups by clicking outside", settings.forbidPopupClickBehindToClose, false) { settings.forbidPopupClickBehindToClose = it }
addPediaUnitArtSizeSlider(this, settings, optionsPopup.selectBoxMinWidth)
addSeparator()