diff options
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt | 17 |
1 files changed, 17 insertions, 0 deletions
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 + } + } |