fix: title screen UIs can be closed using ESC

This commit is contained in:
minjaesong
2023-09-23 01:14:54 +09:00
parent c1717c7a54
commit d87dc8fffc
23 changed files with 70 additions and 8 deletions

View File

@@ -7,7 +7,9 @@ import net.torvald.terrarum.modulebasegame.ui.UIRemoCon
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
class ModOptionsHost(val remoCon: UIRemoCon) : UICanvas() { class ModOptionsHost(val remoCon: UIRemoCon) : UICanvas() {
init {
handler.allowESCtoClose = false
}
private val moduleAreaHMargin = 48 private val moduleAreaHMargin = 48
private val moduleAreaBorder = 8 private val moduleAreaBorder = 8

View File

@@ -15,7 +15,9 @@ import net.torvald.terrarum.ui.UICanvas
* Created by minjaesong on 2021-09-09. * Created by minjaesong on 2021-09-09.
*/ */
class UIFakeGradOverlay : UICanvas() { class UIFakeGradOverlay : UICanvas() {
init {
handler.allowESCtoClose = false
}
override var width: Int override var width: Int
get() = App.scr.width get() = App.scr.width
set(value) {} set(value) {}
@@ -67,7 +69,9 @@ class UIFakeGradOverlay : UICanvas() {
} }
class UIFakeBlurOverlay(val blurRadius: Float, val nodarken: Boolean) : UICanvas() { class UIFakeBlurOverlay(val blurRadius: Float, val nodarken: Boolean) : UICanvas() {
init {
handler.allowESCtoClose = false
}
override var width: Int override var width: Int
get() = App.scr.width get() = App.scr.width
set(value) {} set(value) {}

View File

@@ -9,6 +9,10 @@ import net.torvald.terrarum.ui.UICanvas
* Created by minjaesong on 2017-03-13. * Created by minjaesong on 2017-03-13.
*/ */
object NullUI : UICanvas() { object NullUI : UICanvas() {
init {
handler.allowESCtoClose = false
}
override var width: Int = 0 override var width: Int = 0
override var height: Int = 0 override var height: Int = 0
override var openCloseTime = 0f override var openCloseTime = 0f

View File

@@ -23,6 +23,8 @@ class UIGraphicsControlPanel(remoCon: UIRemoCon?) : UICanvas() {
override var width = 560 override var width = 560
init { init {
handler.allowESCtoClose = false
ControlPanelCommon.register(this, width, "basegame.graphicscontrolpanel", arrayOf( ControlPanelCommon.register(this, width, "basegame.graphicscontrolpanel", arrayOf(
arrayOf("", { Lang["CREDITS_VFX"] }, "h1"), arrayOf("", { Lang["CREDITS_VFX"] }, "h1"),
arrayOf("fx_dither", { Lang["MENU_OPTIONS_DITHER"] }, "toggle"), arrayOf("fx_dither", { Lang["MENU_OPTIONS_DITHER"] }, "toggle"),

View File

@@ -20,6 +20,10 @@ import net.torvald.terrarum.ui.*
*/ */
class UIIMEConfig(remoCon: UIRemoCon?) : UICanvas() { class UIIMEConfig(remoCon: UIRemoCon?) : UICanvas() {
init {
handler.allowESCtoClose = false
}
override var width = 480 override var width = 480
override var height = 600 override var height = 600

View File

@@ -25,6 +25,9 @@ import java.io.File
* Created by minjaesong on 2023-08-24. * Created by minjaesong on 2023-08-24.
*/ */
class UIImportAvatar(val remoCon: UIRemoCon) : Advanceable() { class UIImportAvatar(val remoCon: UIRemoCon) : Advanceable() {
init {
handler.allowESCtoClose = false
}
override var width = 480 // SAVE_CELL_WIDTH override var width = 480 // SAVE_CELL_WIDTH
override var height = 480 override var height = 480

View File

@@ -330,7 +330,6 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
override fun doClosing(delta: Float) { override fun doClosing(delta: Float) {
super.doClosing(delta) super.doClosing(delta)
screen = 0
} }
override fun endOpening(delta: Float) { override fun endOpening(delta: Float) {

View File

@@ -16,6 +16,9 @@ import net.torvald.terrarum.ui.*
*/ */
class UIKeyboardControlPanel(remoCon: UIRemoCon?) : UICanvas() { class UIKeyboardControlPanel(remoCon: UIRemoCon?) : UICanvas() {
init {
handler.allowESCtoClose = false
}
override var width = 480 override var width = 480
override var height = 600 override var height = 600

View File

@@ -20,6 +20,10 @@ import kotlin.math.roundToInt
*/ */
class UILoadList(val full: UILoadSavegame) : UICanvas() { class UILoadList(val full: UILoadSavegame) : UICanvas() {
init {
handler.allowESCtoClose = false
}
override var width: Int = Toolkit.drawWidth override var width: Int = Toolkit.drawWidth
override var height: Int = App.scr.height override var height: Int = App.scr.height

View File

@@ -34,6 +34,10 @@ import java.util.*
*/ */
class UILoadManage(val full: UILoadSavegame) : UICanvas() { class UILoadManage(val full: UILoadSavegame) : UICanvas() {
init {
handler.allowESCtoClose = false
}
override var width: Int = Toolkit.drawWidth override var width: Int = Toolkit.drawWidth
override var height: Int = App.scr.height override var height: Int = App.scr.height

View File

@@ -11,6 +11,9 @@ import net.torvald.terrarum.ui.UICanvas
* Created by minjaesong on 2023-07-05. * Created by minjaesong on 2023-07-05.
*/ */
class UILoadNewCharacter(val full: UILoadSavegame) : UICanvas() { class UILoadNewCharacter(val full: UILoadSavegame) : UICanvas() {
init {
handler.allowESCtoClose = false
}
override var width: Int = Toolkit.drawWidth override var width: Int = Toolkit.drawWidth
override var height: Int = App.scr.height override var height: Int = App.scr.height

View File

@@ -25,6 +25,8 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
// private val hash = RandomWordsName(3) // private val hash = RandomWordsName(3)
init { init {
handler.allowESCtoClose = false
CommonResourcePool.addToLoadingList("terrarum-defaultsavegamethumb") { CommonResourcePool.addToLoadingList("terrarum-defaultsavegamethumb") {
TextureRegion(Texture(Gdx.files.internal("assets/graphics/gui/savegame_thumb_placeholder.png"))) TextureRegion(Texture(Gdx.files.internal("assets/graphics/gui/savegame_thumb_placeholder.png")))
} }

View File

@@ -27,6 +27,10 @@ import java.io.File
*/ */
class UINewCharacter(val remoCon: UIRemoCon) : UICanvas() { class UINewCharacter(val remoCon: UIRemoCon) : UICanvas() {
init {
handler.allowESCtoClose = false
}
override var width = 480 override var width = 480
override var height = 480 override var height = 480

View File

@@ -33,6 +33,9 @@ import kotlin.math.roundToInt
* Created by minjaesong on 2021-10-25. * Created by minjaesong on 2021-10-25.
*/ */
class UINewWorld(val remoCon: UIRemoCon) : UICanvas() { class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
init {
handler.allowESCtoClose = false
}
private var newPlayerCreationThread = Thread {} private var newPlayerCreationThread = Thread {}
private var existingPlayer: DiskSkimmer? = null private var existingPlayer: DiskSkimmer? = null

View File

@@ -23,6 +23,8 @@ class UIPerformanceControlPanel(remoCon: UIRemoCon?) : UICanvas() {
override var width = 560 override var width = 560
init { init {
handler.allowESCtoClose = false
ControlPanelCommon.register(this, width, "basegame.performancecontrolpanel", arrayOf( ControlPanelCommon.register(this, width, "basegame.performancecontrolpanel", arrayOf(
arrayOf("", { Lang["MENU_OPTIONS_GAMEPLAY"] }, "h1"), arrayOf("", { Lang["MENU_OPTIONS_GAMEPLAY"] }, "h1"),
arrayOf("autosaveinterval", { Lang["MENU_OPTIONS_AUTOSAVE"] + " (${Lang["CONTEXT_TIME_MINUTE_PLURAL"]})" }, "spinnerimul,5,120,5,60000"), arrayOf("autosaveinterval", { Lang["MENU_OPTIONS_AUTOSAVE"] + " (${Lang["CONTEXT_TIME_MINUTE_PLURAL"]})" }, "spinnerimul,5,120,5,60000"),

View File

@@ -24,7 +24,9 @@ import net.torvald.terrarum.ui.UIItemTextButtonList.Companion.DEFAULT_LINE_HEIGH
* Created by minjaesong on 2018-08-29. * Created by minjaesong on 2018-08-29.
*/ */
open class UIRemoCon(val parent: TitleScreen, val treeRoot: QNDTreeNode<String>) : UICanvas() { open class UIRemoCon(val parent: TitleScreen, val treeRoot: QNDTreeNode<String>) : UICanvas() {
init {
handler.allowESCtoClose = false
}
override var openCloseTime = 0f override var openCloseTime = 0f
private var remoConTray: UIRemoConElement // this remocon is dynamically generated private var remoConTray: UIRemoConElement // this remocon is dynamically generated
@@ -196,6 +198,7 @@ open class UIRemoCon(val parent: TitleScreen, val treeRoot: QNDTreeNode<String>)
ui.setPosition(0,0) ui.setPosition(0,0)
parent.uiFakeBlurOverlay.setAsOpen() parent.uiFakeBlurOverlay.setAsOpen()
ui.setAsOpen() ui.setAsOpen()
ui.handler.allowESCtoClose = false
openUI = ui openUI = ui
} }
} }

View File

@@ -14,6 +14,8 @@ class UISoundControlPanel(remoCon: UIRemoCon?) : UICanvas() {
override var width = 560 override var width = 560
init { init {
handler.allowESCtoClose = false
ControlPanelCommon.register(this, width, "basegame.soundcontrolpanel", arrayOf( ControlPanelCommon.register(this, width, "basegame.soundcontrolpanel", arrayOf(
arrayOf("mastervolume", { Lang["MENU_OPTIONS_SOUND_VOLUME"] }, "sliderd,0,1"), arrayOf("mastervolume", { Lang["MENU_OPTIONS_SOUND_VOLUME"] }, "sliderd,0,1"),
arrayOf("", { "" }, "p"), arrayOf("", { "" }, "p"),

View File

@@ -16,6 +16,10 @@ import kotlin.math.max
class UITitleLanguage(remoCon: UIRemoCon?) : UICanvas() { class UITitleLanguage(remoCon: UIRemoCon?) : UICanvas() {
init {
handler.allowESCtoClose = false
}
val menuLabels = arrayOf( val menuLabels = arrayOf(
"MENU_LABEL_RETURN" "MENU_LABEL_RETURN"
) )

View File

@@ -22,6 +22,9 @@ val MODULEINFO_CELL_HEIGHT = 24*3
* Created by minjaesong on 2017-08-01. * Created by minjaesong on 2017-08-01.
*/ */
class UITitleModules(val remoCon: UIRemoCon) : UICanvas() { class UITitleModules(val remoCon: UIRemoCon) : UICanvas() {
init {
handler.allowESCtoClose = false
}
override var width: Int override var width: Int
get() = Toolkit.drawWidth get() = Toolkit.drawWidth

View File

@@ -11,7 +11,9 @@ import net.torvald.terrarum.ui.*
import java.util.TreeMap import java.util.TreeMap
open class UITitleWallOfText(private val text: List<String>) : UICanvas() { open class UITitleWallOfText(private val text: List<String>) : UICanvas() {
init {
handler.allowESCtoClose = false
}
private val textAreaHMargin = 48 private val textAreaHMargin = 48
override var width = 600 override var width = 600

View File

@@ -14,6 +14,10 @@ import kotlin.math.roundToInt
*/ */
class UIAutosaveNotifier : UICanvas() { class UIAutosaveNotifier : UICanvas() {
init {
handler.allowESCtoClose = false
}
companion object { companion object {
const val WIDTH = 180 const val WIDTH = 180
const val HEIGHT = 24 const val HEIGHT = 24

View File

@@ -67,6 +67,7 @@ class UINSMenu(
var invocationArgument: Array<Any> = arrayOf(this) var invocationArgument: Array<Any> = arrayOf(this)
init { init {
handler.allowESCtoClose = false
addSubMenu(tree) addSubMenu(tree)
} }

View File

@@ -113,8 +113,8 @@ internal class UnsafePtr(pointer: Long, allocSize: Long) {
// appear (e.g. getting garbage values when it fucking shouldn't) // appear (e.g. getting garbage values when it fucking shouldn't)
// using ifs instead of assertions: inactive assert statements still slows down the app // using ifs instead of assertions: inactive assert statements still slows down the app
// if (destroyed) { throw DanglingPointerException("The pointer is already destroyed ($this)") } if (destroyed) { throw DanglingPointerException("The pointer is already destroyed ($this)") }
// if (index !in 0 until size) { throw AddressOverflowException("Index: $index; alloc size: $size") } if (index !in 0 until size) { throw AddressOverflowException("Index: $index; alloc size: $size") }
} }
operator fun get(index: Long): Byte { operator fun get(index: Long): Byte {