code input wip

This commit is contained in:
minjaesong
2025-01-27 23:23:27 +09:00
parent 6b4b7917d9
commit 879cc79bbf
5 changed files with 130 additions and 9 deletions

View File

@@ -8,6 +8,7 @@ import net.torvald.terrarum.App
import net.torvald.terrarum.ControlPresets
import net.torvald.terrarum.INGAME
import net.torvald.terrarum.RunningEnvironment
import net.torvald.terrarum.gamecontroller.TerrarumKeyboardEvent
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.ui.*
import net.torvald.unicode.getKeycapPC
@@ -54,6 +55,27 @@ class UIRedeemCodeMachine : UICanvas(
private val thisOffsetX = UIInventoryFull.INVENTORY_CELLS_OFFSET_X() + UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap - halfSlotOffset
private val yEnd = -UIInventoryFull.YPOS_CORRECTION + (App.scr.height + UIInventoryFull.internalHeight).div(2).toFloat()
private val alphnums = (('0'..'9') + ('a'..'z') + ('A'..'Z')).map { "$it" }.toHashSet()
override fun inputStrobed(e: TerrarumKeyboardEvent) {
super.inputStrobed(e)
if (alphnums.contains(e.character)) {
inputPanel.acceptChar(e.character[0].uppercaseChar())
}
else if (e.keycodes[0] == Input.Keys.BACKSPACE && e.keycodes[1] == 0) {
inputPanel.backspace()
}
else if (e.keycodes[0] == Input.Keys.FORWARD_DEL && e.keycodes[1] == 0) {
inputPanel.reverseBackspace()
}
else if (e.keycodes[0] == Input.Keys.LEFT && e.keycodes[1] == 0) {
inputPanel.__moveCursorBackward(1)
}
else if (e.keycodes[0] == Input.Keys.RIGHT && e.keycodes[1] == 0) {
inputPanel.__moveCursorForward(1)
}
}
override fun renderImpl(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera) {
UIInventoryFull.drawBackground(batch, 1f)