Use a Map instead of a list in AddKeyMaps.kt.
This commit is contained in:
parent
51662011b8
commit
42b48f7065
|
@ -14,13 +14,11 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
|
||||
@Mixin(Options.class)
|
||||
class KeyMappings {
|
||||
private static final List<KeyMapping> keysToAdd = AddKeyMaps.INSTANCE.getList();
|
||||
private static final Collection<KeyMapping> keysToAdd = AddKeyMaps.INSTANCE.getList().keySet();
|
||||
|
||||
@Mutable @Shadow @Final public KeyMapping[] keyMappings;
|
||||
|
||||
|
|
|
@ -5,18 +5,17 @@ import net.minecraft.client.KeyMapping
|
|||
import org.lwjgl.glfw.GLFW.GLFW_KEY_U
|
||||
import org.lwjgl.glfw.GLFW.GLFW_KEY_Y
|
||||
|
||||
private typealias privLambda = (() -> Unit)?
|
||||
object AddKeyMaps {
|
||||
private const val prefix = "snowy"
|
||||
private fun mkMap(translationSuffix: String, key: Int, category: String = "keycategory"): KeyMapping {
|
||||
private fun mkMap(translationSuffix: String, key: Int, category: String = "keycategory", lambda: privLambda = null): Pair<KeyMapping, privLambda> {
|
||||
return KeyMapping(
|
||||
"key.$prefix.$translationSuffix", InputConstants.Type.KEYSYM,
|
||||
key, "category.$prefix.$category"
|
||||
)
|
||||
}
|
||||
fun getList(): List<KeyMapping> {
|
||||
return listOf(
|
||||
mkMap("opengui", GLFW_KEY_Y),
|
||||
mkMap("configkey", GLFW_KEY_U)
|
||||
)
|
||||
) to lambda
|
||||
}
|
||||
val list: Map<KeyMapping, (() -> Unit)?> = mutableMapOf(
|
||||
mkMap("opengui", GLFW_KEY_Y),
|
||||
mkMap("configkey", GLFW_KEY_U)
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue