y u wont render :(

This commit is contained in:
minjaesong
2021-12-04 17:50:31 +09:00
parent c0b2f4c8df
commit 43ed388615
4 changed files with 40 additions and 33 deletions

View File

@@ -241,10 +241,7 @@ class UIItemTextLineInput(
if (!maxLen.exceeds(textbuf, codepoints)) {
textbuf.addAll(cursorX, codepoints)
cursorX += codepoints.size
cursorDrawX = App.fontGame.getWidth(CodepointSequence(textbuf.subList(0, cursorX)))
tryCursorBack()
moveCursorToEnd(codepoints.size)
}
}
}
@@ -320,10 +317,7 @@ class UIItemTextLineInput(
if (!maxLen.exceeds(textbuf, codepoints)) {
textbuf.addAll(cursorX, codepoints)
cursorX += codepoints.size
cursorDrawX = App.fontGame.getWidth(CodepointSequence(textbuf.subList(0, cursorX)))
tryCursorBack()
moveCursorToEnd(codepoints.size)
}
}
else if (keycodes.containsSome(Input.Keys.ENTER, Input.Keys.NUMPAD_ENTER)) {
@@ -423,10 +417,7 @@ class UIItemTextLineInput(
actuallyInserted.removeAt(0)
textbuf.addAll(cursorX, actuallyInserted)
cursorX += actuallyInserted.size
cursorDrawX = App.fontGame.getWidth(CodepointSequence(textbuf.subList(0, cursorX)))
moveCursorToEnd(actuallyInserted.size)
tryCursorBack()
@@ -441,6 +432,13 @@ class UIItemTextLineInput(
return textbuf.toJavaString()
}
private fun moveCursorToEnd(stride: Int) {
cursorX += stride
cursorDrawX = App.fontGame.getWidth(CodepointSequence(textbuf.subList(0, cursorX)))
tryCursorBack()
}
override fun render(batch: SpriteBatch, camera: Camera) {
val ime = getIME(true)
@@ -609,10 +607,12 @@ class UIItemTextLineInput(
}
fun setText(s: String) {
clearText()
textbuf.addAll(s.toCodePoints())
appendText(s)
}
fun appendText(s: String) {
textbuf.addAll(s.toCodePoints())
val c = s.toCodePoints()
textbuf.addAll(c)
moveCursorToEnd(c.size)
}
override fun dispose() {
fbo.dispose()