Use a receiver for the list in AddKeyMaps.kt

This commit is contained in:
Username404 2021-06-05 16:24:27 +02:00
parent 439a6e6574
commit 3c37ffcb81
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 8 additions and 6 deletions

View File

@ -9,18 +9,20 @@ import net.minecraft.client.Minecraft
import org.lwjgl.glfw.GLFW.GLFW_KEY_U
import org.lwjgl.glfw.GLFW.GLFW_KEY_Y
private typealias privLambda = (() -> Unit)?
private typealias privateLambda = (() -> Unit)?
object AddKeyMaps {
private const val prefix = "snowy"
@JvmOverloads
internal fun mkMap(translationSuffix: String, key: Int, category: String = "keycategory", lambda: privLambda = null): Pair<KeyMapping, privLambda> {
internal fun mkMap(translationSuffix: String, key: Int, category: String = "keycategory", lambda: privateLambda = null): Pair<KeyMapping, privateLambda> {
return KeyMapping(
"key.$prefix.$translationSuffix", InputConstants.Type.KEYSYM,
key, "category.$prefix.$category"
) to lambda
}
val list: MutableMap<KeyMapping, (() -> Unit)?> = mutableMapOf(
mkMap("opengui", GLFW_KEY_Y) { Minecraft.getInstance().setScreen(ClickGui) },
mkMap("configkey", GLFW_KEY_U) { Minecraft.getInstance().setScreen(run { configScreenParent = null; SnowyConfigScreen }) }
)
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 }) }
)
}
}