Pretty formatting

This commit is contained in:
zeroeightsix 2018-10-10 17:35:47 +02:00
parent 3e7d3cd414
commit 2d711bb10a
2 changed files with 9 additions and 4 deletions

View File

@ -33,13 +33,13 @@ public class BindButton extends EnumButton {
if (isShift(key)) {
shift = true;
modes = new String[]{(ctrl ? "Ctrl + " : "") + (alt ? "Alt + " : "") + "Shift + "};
modes = new String[]{(ctrl ? "Ctrl+" : "") + (alt ? "Alt+" : "") + "Shift+"};
} else if (isCtrl(key)) {
ctrl = true;
modes = new String[]{"Ctrl + " + (alt ? "Alt + " : "") + (shift ? "Shift + " : "")};
modes = new String[]{"Ctrl+" + (alt ? "Alt+" : "") + (shift ? "Shift+" : "")};
} else if (isAlt(key)) {
alt = true;
modes = new String[]{(ctrl ? "Ctrl + " : "") + "Alt + " + (shift ? "Shift + " : "")};
modes = new String[]{(ctrl ? "Ctrl+" : "") + "Alt+" + (shift ? "Shift+" : "")};
} else if (key == Keyboard.KEY_BACK) {
m.getBind().setCtrl(false);
m.getBind().setShift(false);

View File

@ -57,7 +57,7 @@ public class Bind {
@Override
public String toString() {
return isEmpty() ? "None" : (isCtrl() ? "Ctrl + " : "") + (isAlt() ? "Alt + " : "") + (isShift() ? "Shift + " : "") + (key < 0 ? "None" : Keyboard.getKeyName(key));
return isEmpty() ? "None" : (isCtrl() ? "Ctrl+" : "") + (isAlt() ? "Alt+" : "") + (isShift() ? "Shift+" : "") + (key < 0 ? "None" : capitalise(Keyboard.getKeyName(key)));
}
public boolean isDown() {
@ -75,6 +75,11 @@ public class Bind {
return Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU);
}
public String capitalise(String str) {
if (str.isEmpty()) return "";
return Character.toUpperCase(str.charAt(0)) + (str.length() != 1 ? str.substring(1).toLowerCase() : "");
}
public static Bind none() {
return new Bind(false, false, false, -1);
}