30 lines
1.1 KiB
Kotlin
30 lines
1.1 KiB
Kotlin
package fr.username404.snowygui.misc
|
|
|
|
import com.mojang.blaze3d.platform.InputConstants
|
|
import fr.username404.snowygui.ClickGui
|
|
import fr.username404.snowygui.config.SnowyConfigScreen
|
|
import fr.username404.snowygui.config.configScreenParent
|
|
import net.minecraft.client.KeyMapping
|
|
import net.minecraft.client.Minecraft
|
|
import org.lwjgl.glfw.GLFW.GLFW_KEY_U
|
|
import org.lwjgl.glfw.GLFW.GLFW_KEY_Y
|
|
|
|
private typealias privateLambda = (() -> Unit)?
|
|
object AddKeyMaps {
|
|
private const val prefix = "snowy"
|
|
@JvmOverloads
|
|
internal fun mkMap(
|
|
translationSuffix: String,
|
|
key: Int, category: String = "keycategory",
|
|
lambda: privateLambda = null
|
|
): Pair<KeyMapping, privateLambda> = KeyMapping(
|
|
"key.$prefix.$translationSuffix", InputConstants.Type.KEYSYM,
|
|
key, "category.$prefix.$category"
|
|
) to lambda
|
|
val list: MutableMap<KeyMapping, privateLambda> = with(Minecraft.getInstance()) {
|
|
mutableMapOf(
|
|
mkMap("opengui", GLFW_KEY_Y) { setScreen(ClickGui) },
|
|
mkMap("configkey", GLFW_KEY_U) { setScreen(run { configScreenParent = null; SnowyConfigScreen }) }
|
|
)
|
|
}
|
|
} |