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], [undefined],
["\n"], ["\n"],
["\x08"], ["\x08"],
[";","~"], ["¤","~"],
["-","_"], ["-","_"],
["=","+"], ["=","+"],
["[","{"], ["[","{"],
["]","}"], ["]","}"],
["\\","₩"], ["\\","₩"],
["",":"], [";",":"],
["'",'"'], ["'",'"'],
["/","?"], ["/","?"],
[undefined], [undefined],

View File

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

View File

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

View File

@@ -504,7 +504,7 @@ class UIItemTextLineInput(
textbuf.addAll(actuallyInserted) textbuf.addAll(actuallyInserted)
cursorX += codepoints.size 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) moveCursorForward(currentTextLenPx - oldTextLenPx)
oldTextLenPx = currentTextLenPx oldTextLenPx = currentTextLenPx