fix: load menu buttons are pushed when they should not listen to the touchdown event

This commit is contained in:
minjaesong
2023-06-28 17:47:04 +09:00
parent 23af64deb4
commit 72c742897e
3 changed files with 48 additions and 15 deletions

View File

@@ -14,7 +14,11 @@ import kotlin.io.path.Path
class SavegameCollection(files0: List<DiskSkimmer>) {
/** Sorted in reverse by the last modified time of the files, index zero being the most recent */
val files = files0.sortedByDescending { it.getLastModifiedTime().shl(2) or it.diskFile.extension.isBlank().toLong(1) or it.diskFile.extension.matches(Regex("^[abc]${'$'}")).toLong() }
val files = files0.sortedByDescending {
it.getLastModifiedTime().shl(2) or
it.diskFile.extension.matches(Regex("^[abc]${'$'}")).toLong(1) or
it.diskFile.extension.isBlank().toLong(0)
}
/** Sorted in reverse by the last modified time of the files, index zero being the most recent */
val autoSaves = files.filter { it.diskFile.extension.matches(Regex("[a-z]")) }
/** Sorted in reverse by the last modified time of the files, index zero being the most recent */

View File

@@ -31,7 +31,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
const val DEFAULT_LOADORDER_FILE = """# Load Order
# Modules are loaded from top to bottom.
# You can disable basegame, but we don't recommend.
# Name of the module corresponds with the name of the directory the module is stored in,
# typically under:
# 1. assets/mods of the installation path (the modules comes with the release of the game)
# 2. %APPDATA%/Modules (the modules installed by the user)
# where %APPDATA% is:
# Windows -- C:\Users\<username>\AppData\Roaming\Terrarum
# macOS -- /Users/<username>/Library/Application Support/Terrarum
# Linux -- /home/<username>/.Terrarum
# Please refrain from removing 'basegame' on the load order -- it may render the game unpalyable.
basegame
"""

View File

@@ -101,7 +101,11 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
private val playerCells = ArrayList<UIItemPlayerCells>()
var mode = 0; private set// 0: show players, 1: show worlds
var mode = 0 // 0: show players, 1: show worlds
private set(value) {
touchLatched = true
field = value
}
private val MODE_SELECT = 0
private val MODE_SELECT_AFTER = 1
@@ -188,6 +192,8 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
}
override fun advanceMode(button: UIItem) {
printdbg(this, "advanceMode ${button.javaClass.canonicalName}")
mode += 1
uiScroll = 0f
scrollFrom = 0
@@ -312,6 +318,8 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
MODE_SAVE_MULTIPLE_CHOICES*/
}
printdbg(this, "mode = $mode")
}
else if (mode == MODE_SAVE_DELETE_CONFIRM) {
// confirm deletion of selected player
@@ -359,6 +367,8 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
playerCells.clear()
}
private var touchLatched = false
private fun getCells() = playerCells
private var loadFired = 0
private var oldMode = -1
@@ -605,29 +615,40 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
}
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
if (mode == MODE_SELECT || mode == MODE_SAVE_DELETE) getCells().forEach { it.touchDown(screenX, screenY, pointer, button) }
if (::loadAutoThumbButton.isInitialized && mode == MODE_SAVE_MULTIPLE_CHOICES) { loadAutoThumbButton.touchDown(screenX, screenY, pointer, button) }
if (::loadManualThumbButton.isInitialized && mode == MODE_SAVE_MULTIPLE_CHOICES) { loadManualThumbButton.touchDown(screenX, screenY, pointer, button) }
if (mode == MODE_SELECT || mode == MODE_SAVE_DELETE) deleteCharacterButton.touchDown(screenX, screenY, pointer, button)
if (mode == MODE_SAVE_DELETE_CONFIRM) {
printdbg(this, "touchDown mode=$mode")
if (mode == MODE_SAVE_MULTIPLE_CHOICES) {
if (::loadAutoThumbButton.isInitialized) loadAutoThumbButton.touchDown(screenX, screenY, pointer, button)
if (::loadManualThumbButton.isInitialized) loadManualThumbButton.touchDown(screenX, screenY, pointer, button)
}
else if (mode == MODE_SELECT || mode == MODE_SAVE_DELETE) {
getCells().forEach { it.touchDown(screenX, screenY, pointer, button) }
deleteCharacterButton.touchDown(screenX, screenY, pointer, button)
}
else if (mode == MODE_SAVE_DELETE_CONFIRM) {
confirmCancelButton.touchDown(screenX, screenY, pointer, button)
confirmDeleteButton.touchDown(screenX, screenY, pointer, button)
}
if (mode == MODE_SAVE_DAMAGED) corruptedBackButton.touchDown(screenX, screenY, pointer, button)
else if (mode == MODE_SAVE_DAMAGED) corruptedBackButton.touchDown(screenX, screenY, pointer, button)
return true
}
override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
if (mode == MODE_SELECT || mode == MODE_SAVE_DELETE) getCells().forEach { it.touchUp(screenX, screenY, pointer, button) }
if (::loadAutoThumbButton.isInitialized && mode == MODE_SAVE_MULTIPLE_CHOICES) { loadAutoThumbButton.touchUp(screenX, screenY, pointer, button) }
if (::loadManualThumbButton.isInitialized && mode == MODE_SAVE_MULTIPLE_CHOICES) { loadManualThumbButton.touchUp(screenX, screenY, pointer, button) }
if (mode == MODE_SELECT || mode == MODE_SAVE_DELETE) deleteCharacterButton.touchUp(screenX, screenY, pointer, button)
if (mode == MODE_SAVE_DELETE_CONFIRM) {
if (mode == MODE_SAVE_MULTIPLE_CHOICES) {
if (::loadAutoThumbButton.isInitialized) loadAutoThumbButton.touchUp(screenX, screenY, pointer, button)
if (::loadManualThumbButton.isInitialized) loadManualThumbButton.touchUp(screenX, screenY, pointer, button)
}
else if (mode == MODE_SELECT || mode == MODE_SAVE_DELETE) {
getCells().forEach { it.touchUp(screenX, screenY, pointer, button) }
deleteCharacterButton.touchUp(screenX, screenY, pointer, button)
}
else if (mode == MODE_SAVE_DELETE_CONFIRM) {
confirmCancelButton.touchUp(screenX, screenY, pointer, button)
confirmDeleteButton.touchUp(screenX, screenY, pointer, button)
}
if (mode == MODE_SAVE_DAMAGED) corruptedBackButton.touchUp(screenX, screenY, pointer, button)
else if (mode == MODE_SAVE_DAMAGED) corruptedBackButton.touchUp(screenX, screenY, pointer, button)
return true
}