mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 20:14:05 +09:00
fix: 'q' would close the ui when you're typing in something
This commit is contained in:
25
src/net/torvald/terrarum/TerrarumGlobalState.kt
Normal file
25
src/net/torvald/terrarum/TerrarumGlobalState.kt
Normal file
@@ -0,0 +1,25 @@
|
||||
package net.torvald.terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2023-09-05.
|
||||
*/
|
||||
object TerrarumGlobalState {
|
||||
|
||||
var HAS_KEYBOARD_INPUT_FOCUS = CountedBool()
|
||||
|
||||
}
|
||||
|
||||
class CountedBool {
|
||||
private var counter = 0L
|
||||
|
||||
fun set() {
|
||||
counter += 1
|
||||
}
|
||||
fun unset() {
|
||||
if (counter >= 1) counter -= 1
|
||||
}
|
||||
val value: Boolean
|
||||
get() = counter > 0
|
||||
fun isOn() = value
|
||||
fun isOff() = !value
|
||||
}
|
||||
Reference in New Issue
Block a user