NONE key selection when backspace
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package org.saturnclient.modules.mods;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.saturnclient.modules.HudMod;
|
||||
import org.saturnclient.modules.ModDimensions;
|
||||
import org.saturnclient.modules.Module;
|
||||
@@ -15,7 +14,6 @@ import net.minecraft.item.Items;
|
||||
|
||||
public class ArmorDisplay extends Module implements HudMod {
|
||||
private static Property<Boolean> enabled = Property.bool(true);
|
||||
private static Property<Integer> test = Property.keybinding(GLFW.GLFW_KEY_Y);
|
||||
private static ModDimensions dimensions = new ModDimensions(40, 60);
|
||||
|
||||
public ArmorDisplay() {
|
||||
@@ -24,17 +22,9 @@ public class ArmorDisplay extends Module implements HudMod {
|
||||
.version("v0.1.0")
|
||||
.tags("Utility"),
|
||||
enabled.named("Enabled"),
|
||||
test.named("Test key"),
|
||||
dimensions.prop());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (test.isKeyPressed()) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void renderArmor(RenderScope scope, ItemStack helmet, ItemStack chestplate, ItemStack leggings, ItemStack boots) {
|
||||
int row = 0;
|
||||
|
||||
|
||||
@@ -196,6 +196,6 @@ public class Property<T> {
|
||||
}
|
||||
|
||||
public boolean isKeyPressed() {
|
||||
return GLFW.glfwGetKey(SaturnClient.client.getWindow().getHandle(), (Integer) (Object) value) == GLFW.GLFW_PRESS;
|
||||
return (Integer) value == -1 ? false : GLFW.glfwGetKey(SaturnClient.client.getWindow().getHandle(), (Integer) (Object) value) == GLFW.GLFW_PRESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,15 +22,19 @@ public class KeybindingSelector extends Element {
|
||||
@Override
|
||||
public void render(RenderScope renderScope, ElementContext ctx) {
|
||||
int textColor = focused ? 0xFFFFFF : 0xAAAAAA;
|
||||
int scanCode = GLFW.glfwGetKeyScancode(prop.value);
|
||||
|
||||
renderScope.drawRoundedRectangle(0, 0, width, height, 10, 0xFF000000);
|
||||
renderScope.drawText(0.6f, GLFW.glfwGetKeyName(prop.value, scanCode).toUpperCase(), 4, 4, font.value, textColor);
|
||||
renderScope.drawText(0.6f, prop.value == -1 ? "<NONE>" :
|
||||
GLFW.glfwGetKeyName(prop.value, GLFW.glfwGetKeyScancode(prop.value)).toUpperCase(),
|
||||
4, 4, font.value, textColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||
if (keyCode == GLFW.GLFW_KEY_BACKSPACE) {
|
||||
prop.value = -1;
|
||||
} else {
|
||||
prop.value = keyCode;
|
||||
}
|
||||
focused = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user