mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 22:19:40 +00:00
Give priority of keybinds with special keys
Stop searching if found match.
This commit is contained in:
1 parent
00eefb0887
commit
3568fb8a86
2 files changed
+33
-2
No files matched your search
@@ -8,7 +8,7 @@ import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class KeyPreset {
|
||||
public class KeyPreset implements Comparable<KeyPreset> {
|
||||
/**
|
||||
* @field SINGLE_PRESS => on releasing before 5 ticks press time
|
||||
* @field PRESS_RELEASE => on pressing and releasing
|
||||
@@ -148,6 +148,26 @@ public class KeyPreset {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(KeyPreset o) {
|
||||
int mySpecialCount = getSpecialKeyCount(this);
|
||||
int otherSpecialCount = getSpecialKeyCount(o);
|
||||
|
||||
return mySpecialCount - otherSpecialCount;
|
||||
}
|
||||
|
||||
private static int getSpecialKeyCount(KeyPreset preset) {
|
||||
int res = 0;
|
||||
if (preset.hasAlt())
|
||||
res += 1;
|
||||
if (preset.hasCtrl())
|
||||
res += 1;
|
||||
if (preset.hasShift())
|
||||
res += 1;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
public static class KeyState {
|
||||
public int keyCode = -1;
|
||||
|
||||
Reference in new issue
Block a user