mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 19:39:07 +00:00
Fixed KeyPreset not fully respecting SHIFT/ALT/CTRL modifiers + removed redundant code
This commit is contained in:
1 parent
1ac7c0e797
commit
950a749be6
2 files changed
+3
-37
No files matched your search
@@ -8,7 +8,7 @@ import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class KeyPreset implements Comparable<KeyPreset> {
|
||||
public class KeyPreset {
|
||||
/**
|
||||
* @field SINGLE_PRESS => on releasing before 5 ticks press time
|
||||
* @field PRESS_RELEASE => on pressing and releasing
|
||||
@@ -58,8 +58,7 @@ public class KeyPreset implements Comparable<KeyPreset> {
|
||||
return;
|
||||
|
||||
boolean isDown = isMouseKey() ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode);
|
||||
isDown = isDown && (hasCtrl() ? isCtrlKeyDown() : true) && (hasAlt() ? isAltKeyDown() : true) && (hasShift() ? isShiftKeyDown() : true);
|
||||
|
||||
isDown = isDown && (isCtrlKeyDown() == hasCtrl()) && (isAltKeyDown() == hasAlt()) && (isShiftKeyDown() == hasShift());
|
||||
setDown(isDown);
|
||||
}
|
||||
|
||||
@@ -148,27 +147,6 @@ public class KeyPreset implements Comparable<KeyPreset> {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(KeyPreset o) {
|
||||
int mySpecialCount = getSpecialKeyCount(this);
|
||||
int otherSpecialCount = getSpecialKeyCount(o);
|
||||
|
||||
return otherSpecialCount - mySpecialCount;
|
||||
}
|
||||
|
||||
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;
|
||||
public boolean hasCtrl, hasAlt, hasShift;
|
||||
|
||||
Reference in new issue
Block a user