fix: game crashes on pasting text

This commit is contained in:
minjaesong
2024-02-17 15:26:18 +09:00
parent a7ba39a43c
commit 6da155d4f3
4 changed files with 9 additions and 7 deletions

View File

@@ -65,13 +65,13 @@ let states = {"keylayouts":[[""],[undefined],
[undefined],
["\n"],
["\x08"],
[";","~"],
["¤","~"],
["-","_"],
["=","+"],
["[","{"],
["]","}"],
["\\","₩"],
["",":"],
[";",":"],
["'",'"'],
["/","?"],
[undefined],

View File

@@ -73,8 +73,8 @@ basegame
// Commit counts up to the Release 0.3.3: 3020
// val VERSION_SNAPSHOT = Snapshot(0) // for normal dev
// val VERSION_SNAPSHOT = ForcedSnapshot("24w04a") // for snapshot release
val VERSION_SNAPSHOT = null // for the release
val VERSION_SNAPSHOT = ForcedSnapshot("24w07b") // for snapshot release
// val VERSION_SNAPSHOT = null // for the release
const val VERSION_TAG: String = ""

View File

@@ -119,6 +119,8 @@ object ControlPanelCommon {
}
}
else if (args.startsWith("typeinres")) {
val oldwidth = App.scr.width
val oldheight = App.scr.height
val keyWidth = optionNames[0]
val keyHeight = optionNames[1]
UIItemTextLineInput(parent, x, y, CONFIG_SPINNER_WIDTH,
@@ -178,8 +180,8 @@ object ControlPanelCommon {
}
else {
it.markAsInvalid()
App.setConfig(keyWidth, TerrarumScreenSize.defaultW)
App.setConfig(keyHeight, TerrarumScreenSize.defaultH)
App.setConfig(keyWidth, oldwidth)
App.setConfig(keyHeight, oldheight)
}
}
}

View File

@@ -504,7 +504,7 @@ class UIItemTextLineInput(
textbuf.addAll(actuallyInserted)
cursorX += codepoints.size
currentTextLenPx = App.fontGame.getWidth(CodepointSequence(textbuf.subList(0, cursorX)))
currentTextLenPx = App.fontGame.getWidth(CodepointSequence(textbuf.subList(0, minOf(cursorX, textbuf.size))))
moveCursorForward(currentTextLenPx - oldTextLenPx)
oldTextLenPx = currentTextLenPx