From dc3adecc1b34758ccd62b5086d0052ef70555282 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Fri, 5 Jul 2024 22:52:06 +0200 Subject: Improve keybinding support --- .../moe/nea/firmament/keybindings/SavedKeyBinding.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt') diff --git a/src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt b/src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt index 56865cc..f07cd29 100644 --- a/src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt +++ b/src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt @@ -10,6 +10,7 @@ import org.lwjgl.glfw.GLFW import kotlinx.serialization.Serializable import net.minecraft.client.MinecraftClient import net.minecraft.client.util.InputUtil +import net.minecraft.text.Text import moe.nea.firmament.util.MC @Serializable @@ -87,4 +88,20 @@ data class SavedKeyBinding( return keyCode == this.keyCode && getMods(modifiers) == Triple(shift, ctrl, alt) } + fun format(): Text { + val stroke = Text.literal("") + if (ctrl) { + stroke.append("CTRL + ") + } + if (alt) { + stroke.append("ALT + ") + } + if (shift) { + stroke.append("SHIFT + ") // TODO: translations? + } + + stroke.append(InputUtil.Type.KEYSYM.createFromCode(keyCode).localizedText) + return stroke + } + } -- cgit