no ui toggle when console is open

This commit is contained in:
minjaesong
2017-05-10 21:01:19 +09:00
parent 31954f3ca7
commit f45dc6fde2
2 changed files with 17 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.gamecontroller
import net.torvald.terrarum.Terrarum
import org.newdawn.slick.GameContainer
import org.newdawn.slick.Input
import java.util.*
@@ -10,12 +11,23 @@ object KeyToggler {
private val isPressed = BitSet(256)
private val isToggled = BitSet(256)
/**
* Keys that won't be updated when console is opened
*/
private val gameKeys = (16..27) + (30..40) + (43..53)
fun isOn(key: Int): Boolean {
return currentState[key]
}
fun update(input: Input) {
(0..255).forEach {
fun update(input: Input, gameMode: Boolean = true) {
for (it in 0..255) {
if (gameMode && it in gameKeys &&
(Terrarum.ingame!!.consoleHandler.isOpening || Terrarum.ingame!!.consoleHandler.isOpened)) {
continue
}
isPressed[it] = input.isKeyDown(it)
if (isPressed[it] && !currentState[it] && !isToggled[it]) {

View File

@@ -72,6 +72,9 @@ class UIHandler(val UI: UICanvas,
setAsClose()
}
}
if (toggleButton != null) {
/* */
}
if (openFired && openCloseCounter > 9) openFired = false