Give priority of keybinds with special keys

Stop searching if found match.
This commit is contained in:
somehussar committed 2025-12-19 23:08:37 +01:00
1 parent 00eefb0887
commit 3568fb8a86
2 files changed
+33 -2

No files matched your search

@@ -13,6 +13,8 @@ public class KeyPresetManager {
public List<KeyPreset> keys = new ArrayList<>();
public String fileName;
private boolean wasSorted = false;
public KeyPresetManager(String fileName) {
this.fileName = fileName;
}
@@ -20,12 +22,21 @@ public class KeyPresetManager {
public KeyPreset add(String name) {
KeyPreset preset = new KeyPreset(name);
keys.add(preset);
wasSorted = false;
return preset;
}
public void tick() {
for (KeyPreset key : keys)
if (!wasSorted) {
keys.sort(KeyPreset::compareTo);
wasSorted = true;
}
for (KeyPreset key : keys) {
key.tick();
if (key.isDown)
return;
}
}