1
0
Fork 0

add bind categories

This commit is contained in:
Sen 2025-09-05 13:27:03 +02:00
parent cb71a528f9
commit bfee96d5b5
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
5 changed files with 95 additions and 44 deletions

View file

@ -436,7 +436,8 @@ public class Client implements IThreadListener {
private final List<Message> hotbar = Lists.newArrayList(); private final List<Message> hotbar = Lists.newArrayList();
private final File config = new File(System.getProperty("config.file", "client.cfg")); private final File config = new File(System.getProperty("config.file", "client.cfg"));
private final Bind[] keyBindsHotbar = new Bind[] { private final Bind[] keyBindsHotbar = new Bind[] {
Bind.SELECT1, Bind.SELECT2, Bind.SELECT3, Bind.SELECT4, Bind.SELECT5, Bind.SELECT6, Bind.SELECT7, Bind.SELECT8, Bind.SELECT9, Bind.SELECT10, Bind.SELECT11, Bind.SELECT12 Bind.SELECT1, Bind.SELECT2, Bind.SELECT3, Bind.SELECT4, Bind.SELECT5, Bind.SELECT6, Bind.SELECT7, Bind.SELECT8,
Bind.SELECT9, Bind.SELECT10, Bind.SELECT11, Bind.SELECT12, Bind.SELECT13, Bind.SELECT14, Bind.SELECT15, Bind.SELECT16
}; };
private final int[] tickTimes = new int[240]; private final int[] tickTimes = new int[240];
private final long[] frames = new long[240]; private final long[] frames = new long[240];

View file

@ -5,23 +5,44 @@ import client.gui.element.ActButton;
import client.gui.element.ButtonCallback; import client.gui.element.ButtonCallback;
import client.gui.element.Label; import client.gui.element.Label;
import client.gui.element.PressType; import client.gui.element.PressType;
import client.gui.element.SelectableButton;
import client.window.Bind; import client.window.Bind;
import client.window.BindCategory;
import common.util.Color; import common.util.Color;
public class GuiBinds extends GuiOptions { public class GuiBinds extends GuiOptions {
private BindCategory page = BindCategory.GENERAL;
protected GuiBinds() { protected GuiBinds() {
} }
public void init(int width, int height) { public void init(int width, int height) {
int y = 0;
int x = -1; int x = -1;
for(Bind bind : Bind.values()) { int y = 0;
for(final BindCategory cat : BindCategory.values()) {
if(++x == 4) { if(++x == 4) {
x = 0; x = 0;
y += LABEL_SHIFT; y += LABEL_SHIFT;
} }
this.add(new Label(x * ((BASE_WIDTH - BASE_GAP) / 2 + BASE_GAP), y, (BASE_WIDTH - BASE_GAP) / 2, bind.getDisplay())); this.add(new SelectableButton(x * ((BASE_WIDTH - BASE_GAP) / 2 + BASE_GAP), y, (BASE_WIDTH - BASE_GAP) / 2, 0, new ButtonCallback() {
this.add(new ActButton(x * ((BASE_WIDTH - BASE_GAP) / 2 + BASE_GAP), y, (BASE_WIDTH - BASE_GAP) / 2, 0, new ButtonCallback() { public void use(ActButton elem, PressType action) {
GuiBinds.this.page = cat;
GuiBinds.this.gm.show(GuiBinds.this);
}
}, cat.toString(), cat == this.page));
}
x = -1;
y += LABEL_SHIFT + SEPARATOR_SHIFT - BASE_SHIFT;
int ny = 0;
for(Bind bind : Bind.values()) {
if(bind.getBindCategory() != this.page)
continue;
if(++x == 4) {
x = 0;
ny += LABEL_SHIFT;
}
this.add(new Label(x * ((BASE_WIDTH - BASE_GAP) / 2 + BASE_GAP), y + ny, (BASE_WIDTH - BASE_GAP) / 2, bind.getDisplay()));
this.add(new ActButton(x * ((BASE_WIDTH - BASE_GAP) / 2 + BASE_GAP), y + ny, (BASE_WIDTH - BASE_GAP) / 2, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) { public void use(ActButton elem, PressType action) {
if(action == PressType.SECONDARY) { if(action == PressType.SECONDARY) {
if(!bind.isDefault()) { if(!bind.isDefault()) {
@ -50,6 +71,7 @@ public class GuiBinds extends GuiOptions {
} }
})); }));
} }
y += LABEL_SHIFT * 3;
this.add(new ActButton(0, y += SEPARATOR_SHIFT, 0, 0, new ButtonCallback() { this.add(new ActButton(0, y += SEPARATOR_SHIFT, 0, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) { public void use(ActButton elem, PressType action) {

View file

@ -9,43 +9,47 @@ import common.util.Color;
import common.util.Util; import common.util.Util;
public enum Bind implements Identifyable, CVar { public enum Bind implements Identifyable, CVar {
FORWARD("forward", "Vorwärts", Keysym.W), FORWARD(BindCategory.MOVEMENT, "forward", "Vorwärts", Keysym.W),
LEFT("left", "Nach links", Keysym.A), LEFT(BindCategory.MOVEMENT, "left", "Nach links", Keysym.A),
BACKWARD("backward", "Rückwärts", Keysym.S), BACKWARD(BindCategory.MOVEMENT, "backward", "Rückwärts", Keysym.S),
RIGHT("right", "Nach rechts", Keysym.D), RIGHT(BindCategory.MOVEMENT, "right", "Nach rechts", Keysym.D),
UP("up", "Aufwärts, Sprung", Keysym.SPACE), UP(BindCategory.MOVEMENT, "up", "Aufwärts, Sprung", Keysym.SPACE),
DOWN("down", "Abwärts, Langsam", Keysym.LEFT_CONTROL), DOWN(BindCategory.MOVEMENT, "down", "Abwärts, Langsam", Keysym.LEFT_CONTROL),
FAST("fast", "Schneller", Keysym.LEFT_SHIFT), FAST(BindCategory.MOVEMENT, "fast", "Schneller", Keysym.LEFT_SHIFT),
INVENTORY("inventory", "Inventar", Keysym.E), INVENTORY(BindCategory.INTERACTION, "inventory", "Inventar", Keysym.E),
PRIMARY("primary", "Primäre Aktion", Button.MOUSE_LEFT), PRIMARY(BindCategory.INTERACTION, "primary", "Primäre Aktion", Button.MOUSE_LEFT),
SECONDARY("secondary", "Sekundäre Aktion", Button.MOUSE_RIGHT), SECONDARY(BindCategory.INTERACTION, "secondary", "Sekundäre Aktion", Button.MOUSE_RIGHT),
TERTIARY("tertiary", "Tertiäre Aktion", Button.MOUSE_MIDDLE), TERTIARY(BindCategory.INTERACTION, "tertiary", "Tertiäre Aktion", Button.MOUSE_MIDDLE),
QUARTERNARY("quarternary", "Quartäre Aktion", Keysym.R), QUARTERNARY(BindCategory.INTERACTION, "quarternary", "Quartäre Aktion", Keysym.R),
THROW("throw", "Weg werfen", Keysym.Q), THROW(BindCategory.INTERACTION, "throw", "Weg werfen", Keysym.Q),
SELECT1("select1", "Auswahl #1", Keysym.N1), SELECT1(BindCategory.SELECTORS, "select1", "Auswahl #1", Keysym.N1),
SELECT2("select2", "Auswahl #2", Keysym.N2), SELECT2(BindCategory.SELECTORS, "select2", "Auswahl #2", Keysym.N2),
SELECT3("select3", "Auswahl #3", Keysym.N3), SELECT3(BindCategory.SELECTORS, "select3", "Auswahl #3", Keysym.N3),
SELECT4("select4", "Auswahl #4", Keysym.N4), SELECT4(BindCategory.SELECTORS, "select4", "Auswahl #4", Keysym.N4),
SELECT5("select5", "Auswahl #5", Keysym.N5), SELECT5(BindCategory.SELECTORS, "select5", "Auswahl #5", Keysym.N5),
SELECT6("select6", "Auswahl #6", Keysym.N6), SELECT6(BindCategory.SELECTORS, "select6", "Auswahl #6", Keysym.N6),
SELECT7("select7", "Auswahl #7", Keysym.N7), SELECT7(BindCategory.SELECTORS, "select7", "Auswahl #7", Keysym.N7),
SELECT8("select8", "Auswahl #8", Keysym.N8), SELECT8(BindCategory.SELECTORS, "select8", "Auswahl #8", Keysym.N8),
SELECT9("select9", "Auswahl #9", Keysym.N9), SELECT9(BindCategory.SELECTORS, "select9", "Auswahl #9", Keysym.N9),
SELECT10("select10", "Auswahl #10", Keysym.N0), SELECT10(BindCategory.SELECTORS, "select10", "Auswahl #10", Keysym.N0),
SELECT11("select11", "Auswahl #11", Keysym.SHARP_S), SELECT11(BindCategory.SELECTORS, "select11", "Auswahl #11", Keysym.SHARP_S),
SELECT12("select12", "Auswahl #12", Keysym.ACUTE), SELECT12(BindCategory.SELECTORS, "select12", "Auswahl #12", Keysym.ACUTE),
CRAFT("craft", "Herstellen", Keysym.M), SELECT13(BindCategory.SELECTORS, "select13", "Auswahl #13", Keysym.O),
RENAME("rename", "Umbenennen", Keysym.N), SELECT14(BindCategory.SELECTORS, "select14", "Auswahl #14", Keysym.P),
CONSOLE("console", "Konsole", Keysym.F1), SELECT15(BindCategory.SELECTORS, "select15", "Auswahl #15", Keysym.UE),
COMMAND("command", "Befehl / Chat", Keysym.C), SELECT16(BindCategory.SELECTORS, "select16", "Auswahl #16", Keysym.PLUS),
INFO("info", "Infos einblenden", Keysym.TAB), CRAFT(BindCategory.INTERACTION, "craft", "Herstellen", Keysym.M),
PERSPECTIVE("perspective", "Perspektive", Keysym.F5), RENAME(BindCategory.INTERACTION, "rename", "Umbenennen", Keysym.N),
ZOOM("zoom", "Kamera zoomen", Keysym.Y), CONSOLE(BindCategory.GENERAL, "console", "Konsole", Keysym.F1),
MENU("menu", "Menü", Keysym.ESCAPE), COMMAND(BindCategory.GENERAL, "command", "Befehl / Chat", Keysym.C),
SCREENSHOT("screenshot", "Bildschirmfoto", Keysym.F10), INFO(BindCategory.GENERAL, "info", "Infos einblenden", Keysym.TAB),
SHOW("overlay", "Perf.-Anzeige", Keysym.F2), PERSPECTIVE(BindCategory.GENERAL, "perspective", "Perspektive", Keysym.F4),
FULLSCREEN("fullscreen", "Vollbild", Keysym.F12), ZOOM(BindCategory.GENERAL, "zoom", "Kamera zoomen", Keysym.Y),
CHEAT("cheat", "Schummeln / Debug", Keysym.F3); MENU(BindCategory.GENERAL, "menu", "Menü", Keysym.ESCAPE),
SCREENSHOT(BindCategory.GENERAL, "screenshot", "Bildschirmfoto", Keysym.F10),
SHOW(BindCategory.GENERAL, "overlay", "Perf.-Anzeige", Keysym.F2),
FULLSCREEN(BindCategory.GENERAL, "fullscreen", "Vollbild", Keysym.F12),
CHEAT(BindCategory.GENERAL, "cheat", "Schummeln / Debug", Keysym.F3);
private static boolean windowActive; private static boolean windowActive;
private static boolean inputEnabled; private static boolean inputEnabled;
@ -56,6 +60,7 @@ public enum Bind implements Identifyable, CVar {
private final String id; private final String id;
private final String name; private final String name;
private final Input defInput; private final Input defInput;
private final BindCategory category;
private Input input; private Input input;
private boolean pressed; private boolean pressed;
@ -140,10 +145,11 @@ public enum Bind implements Identifyable, CVar {
} }
} }
private Bind(String id, String name, Input input) { private Bind(BindCategory category, String id, String name, Input input) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.input = this.defInput = input; this.input = this.defInput = input;
this.category = category;
} }
private void update() { private void update() {
@ -190,6 +196,10 @@ public enum Bind implements Identifyable, CVar {
return CVarCategory.INPUT; return CVarCategory.INPUT;
} }
public BindCategory getBindCategory() {
return this.category;
}
public boolean parse(String str) { public boolean parse(String str) {
if("none".equalsIgnoreCase(str)) { if("none".equalsIgnoreCase(str)) {
this.input = null; this.input = null;

View file

@ -0,0 +1,18 @@
package client.window;
public enum BindCategory {
GENERAL("Allgemein"),
MOVEMENT("Bewegung"),
INTERACTION("Interaktion"),
SELECTORS("Schnellauswahl");
private final String name;
private BindCategory(String name) {
this.name = name;
}
public String toString() {
return this.name;
}
}

View file

@ -294,7 +294,7 @@ public abstract class Container
} }
} }
} }
else if (mode == 2 && clickedButton >= 0 && clickedButton < 12) else if (mode == 2 && clickedButton >= 0 && clickedButton < 16)
{ {
Slot slot5 = (Slot)this.inventorySlots.get(slotId); Slot slot5 = (Slot)this.inventorySlots.get(slotId);