Use empty hotkey button when key is unbound across all versions

This happened to already be the case in 1.16.3 (because of another bug), this
commit makes it intentional and consistent across all versions.
Using the empty label over NONE or another label because it doesn't change the
width of the button and therefore fits nicer with all the other buttons.
This commit is contained in:
Jonas Herzig
2020-11-05 15:41:40 +01:00
parent e86a583558
commit f51f6032ca
2 changed files with 9 additions and 1 deletions

View File

@@ -185,6 +185,14 @@ public class KeyBindingRegistry extends EventRegistrations {
return MCVer.getBoundKey(keyBinding);
}
public boolean isBound() {
//#if MC>=11400
return !keyBinding.isUnbound();
//#else
//$$ return keyBinding.getKeyCode() != 0;
//#endif
}
public void trigger() {
KeyBindingAccessor acc = (KeyBindingAccessor) keyBinding;
acc.setPressTime(acc.getPressTime() + 1);

View File

@@ -73,7 +73,7 @@ public class HotkeyButtons extends EventRegistrations implements Extra {
@Override
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
// There doesn't seem to be an KeyBindingUpdate event, so we'll just update it every time
setLabel(keyBinding.getBoundKey());
setLabel(keyBinding.isBound() ? keyBinding.getBoundKey() : "");
super.draw(renderer, size, renderInfo);
}
}.onClick(keyBinding::trigger);