mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 03:24:06 +09:00
Working line-of-text and single key input
Former-commit-id: 339650979ff2cb5ec18b52a9f3f38b281c7862c9 Former-commit-id: d5ebd860afc8d569ba9ab741b6ca7872380af949
This commit is contained in:
@@ -19,7 +19,7 @@ import org.newdawn.slick.state.StateBasedGame
|
||||
*/
|
||||
class StateVTTest : BasicGameState() {
|
||||
|
||||
val vt = SimpleTextTerminal(SimpleTextTerminal.WHITE, 80, 25, colour = true)
|
||||
val vt = SimpleTextTerminal(SimpleTextTerminal.IBM_GREEN, 80, 25, colour = false)
|
||||
val computerInside = BaseTerrarumComputer(vt)
|
||||
|
||||
val vtUI = Image(vt.displayW, vt.displayH)
|
||||
@@ -29,7 +29,7 @@ class StateVTTest : BasicGameState() {
|
||||
}
|
||||
|
||||
override fun init(container: GameContainer, game: StateBasedGame) {
|
||||
vt.openInput()
|
||||
//vt.openInput()
|
||||
}
|
||||
|
||||
override fun update(container: GameContainer, game: StateBasedGame, delta: Int) {
|
||||
@@ -57,15 +57,13 @@ class StateVTTest : BasicGameState() {
|
||||
super.keyPressed(key, c)
|
||||
vt.keyPressed(key, c)
|
||||
|
||||
if (key == Key.RETURN) {
|
||||
val input = vt.closeInput()
|
||||
|
||||
computerInside.runCommand(input, "=prompt")
|
||||
|
||||
vt.openInput()
|
||||
|
||||
if (!computerInside.isHalted)
|
||||
computerInside.runCommand("io.write(_COMPUTER.prompt)", "=prompt")
|
||||
if (!computerInside.isHalted) {
|
||||
if (key == Key.RETURN && computerInside.luaJ_globals["__scanMode__"].checkjstring() == "line") {
|
||||
vt.closeInputString() // cut input by pressing Key.RETURN
|
||||
}
|
||||
else if (computerInside.luaJ_globals["__scanMode__"].checkjstring() == "a_key") {
|
||||
vt.closeInputKey(key) // cut input by pressing any key
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user