mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-14 15:46:06 +09:00
code input wip
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user