mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-16 08:36:07 +09:00
no ui toggle when console is open
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package net.torvald.terrarum.gamecontroller
|
package net.torvald.terrarum.gamecontroller
|
||||||
|
|
||||||
|
import net.torvald.terrarum.Terrarum
|
||||||
import org.newdawn.slick.GameContainer
|
import org.newdawn.slick.GameContainer
|
||||||
import org.newdawn.slick.Input
|
import org.newdawn.slick.Input
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -10,12 +11,23 @@ object KeyToggler {
|
|||||||
private val isPressed = BitSet(256)
|
private val isPressed = BitSet(256)
|
||||||
private val isToggled = 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 {
|
fun isOn(key: Int): Boolean {
|
||||||
return currentState[key]
|
return currentState[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
fun update(input: Input) {
|
fun update(input: Input, gameMode: Boolean = true) {
|
||||||
(0..255).forEach {
|
for (it in 0..255) {
|
||||||
|
if (gameMode && it in gameKeys &&
|
||||||
|
(Terrarum.ingame!!.consoleHandler.isOpening || Terrarum.ingame!!.consoleHandler.isOpened)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
isPressed[it] = input.isKeyDown(it)
|
isPressed[it] = input.isKeyDown(it)
|
||||||
|
|
||||||
if (isPressed[it] && !currentState[it] && !isToggled[it]) {
|
if (isPressed[it] && !currentState[it] && !isToggled[it]) {
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ class UIHandler(val UI: UICanvas,
|
|||||||
setAsClose()
|
setAsClose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (toggleButton != null) {
|
||||||
|
/* */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (openFired && openCloseCounter > 9) openFired = false
|
if (openFired && openCloseCounter > 9) openFired = false
|
||||||
|
|||||||
Reference in New Issue
Block a user