From bfee96d5b506112455f4840bd07b543181ac1ef4 Mon Sep 17 00:00:00 2001 From: Sen Date: Fri, 5 Sep 2025 13:27:03 +0200 Subject: [PATCH] add bind categories --- client/src/main/java/client/Client.java | 3 +- .../java/client/gui/options/GuiBinds.java | 30 ++++++- client/src/main/java/client/window/Bind.java | 86 +++++++++++-------- .../main/java/client/window/BindCategory.java | 18 ++++ .../main/java/common/inventory/Container.java | 2 +- 5 files changed, 95 insertions(+), 44 deletions(-) create mode 100644 client/src/main/java/client/window/BindCategory.java diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index f6200e01..6690b07d 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -436,7 +436,8 @@ public class Client implements IThreadListener { private final List hotbar = Lists.newArrayList(); private final File config = new File(System.getProperty("config.file", "client.cfg")); 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 long[] frames = new long[240]; diff --git a/client/src/main/java/client/gui/options/GuiBinds.java b/client/src/main/java/client/gui/options/GuiBinds.java index b8910ee4..5d3b82d3 100644 --- a/client/src/main/java/client/gui/options/GuiBinds.java +++ b/client/src/main/java/client/gui/options/GuiBinds.java @@ -5,23 +5,44 @@ import client.gui.element.ActButton; import client.gui.element.ButtonCallback; import client.gui.element.Label; import client.gui.element.PressType; +import client.gui.element.SelectableButton; import client.window.Bind; +import client.window.BindCategory; import common.util.Color; public class GuiBinds extends GuiOptions { + private BindCategory page = BindCategory.GENERAL; + protected GuiBinds() { } public void init(int width, int height) { - int y = 0; int x = -1; - for(Bind bind : Bind.values()) { + int y = 0; + for(final BindCategory cat : BindCategory.values()) { if(++x == 4) { x = 0; 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 ActButton(x * ((BASE_WIDTH - BASE_GAP) / 2 + BASE_GAP), y, (BASE_WIDTH - BASE_GAP) / 2, 0, new ButtonCallback() { + this.add(new SelectableButton(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) { if(action == PressType.SECONDARY) { 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() { public void use(ActButton elem, PressType action) { diff --git a/client/src/main/java/client/window/Bind.java b/client/src/main/java/client/window/Bind.java index 96e67f07..eaedb1c9 100644 --- a/client/src/main/java/client/window/Bind.java +++ b/client/src/main/java/client/window/Bind.java @@ -9,43 +9,47 @@ import common.util.Color; import common.util.Util; public enum Bind implements Identifyable, CVar { - FORWARD("forward", "Vorwärts", Keysym.W), - LEFT("left", "Nach links", Keysym.A), - BACKWARD("backward", "Rückwärts", Keysym.S), - RIGHT("right", "Nach rechts", Keysym.D), - UP("up", "Aufwärts, Sprung", Keysym.SPACE), - DOWN("down", "Abwärts, Langsam", Keysym.LEFT_CONTROL), - FAST("fast", "Schneller", Keysym.LEFT_SHIFT), - INVENTORY("inventory", "Inventar", Keysym.E), - PRIMARY("primary", "Primäre Aktion", Button.MOUSE_LEFT), - SECONDARY("secondary", "Sekundäre Aktion", Button.MOUSE_RIGHT), - TERTIARY("tertiary", "Tertiäre Aktion", Button.MOUSE_MIDDLE), - QUARTERNARY("quarternary", "Quartäre Aktion", Keysym.R), - THROW("throw", "Weg werfen", Keysym.Q), - SELECT1("select1", "Auswahl #1", Keysym.N1), - SELECT2("select2", "Auswahl #2", Keysym.N2), - SELECT3("select3", "Auswahl #3", Keysym.N3), - SELECT4("select4", "Auswahl #4", Keysym.N4), - SELECT5("select5", "Auswahl #5", Keysym.N5), - SELECT6("select6", "Auswahl #6", Keysym.N6), - SELECT7("select7", "Auswahl #7", Keysym.N7), - SELECT8("select8", "Auswahl #8", Keysym.N8), - SELECT9("select9", "Auswahl #9", Keysym.N9), - SELECT10("select10", "Auswahl #10", Keysym.N0), - SELECT11("select11", "Auswahl #11", Keysym.SHARP_S), - SELECT12("select12", "Auswahl #12", Keysym.ACUTE), - CRAFT("craft", "Herstellen", Keysym.M), - RENAME("rename", "Umbenennen", Keysym.N), - CONSOLE("console", "Konsole", Keysym.F1), - COMMAND("command", "Befehl / Chat", Keysym.C), - INFO("info", "Infos einblenden", Keysym.TAB), - PERSPECTIVE("perspective", "Perspektive", Keysym.F5), - ZOOM("zoom", "Kamera zoomen", Keysym.Y), - MENU("menu", "Menü", Keysym.ESCAPE), - SCREENSHOT("screenshot", "Bildschirmfoto", Keysym.F10), - SHOW("overlay", "Perf.-Anzeige", Keysym.F2), - FULLSCREEN("fullscreen", "Vollbild", Keysym.F12), - CHEAT("cheat", "Schummeln / Debug", Keysym.F3); + FORWARD(BindCategory.MOVEMENT, "forward", "Vorwärts", Keysym.W), + LEFT(BindCategory.MOVEMENT, "left", "Nach links", Keysym.A), + BACKWARD(BindCategory.MOVEMENT, "backward", "Rückwärts", Keysym.S), + RIGHT(BindCategory.MOVEMENT, "right", "Nach rechts", Keysym.D), + UP(BindCategory.MOVEMENT, "up", "Aufwärts, Sprung", Keysym.SPACE), + DOWN(BindCategory.MOVEMENT, "down", "Abwärts, Langsam", Keysym.LEFT_CONTROL), + FAST(BindCategory.MOVEMENT, "fast", "Schneller", Keysym.LEFT_SHIFT), + INVENTORY(BindCategory.INTERACTION, "inventory", "Inventar", Keysym.E), + PRIMARY(BindCategory.INTERACTION, "primary", "Primäre Aktion", Button.MOUSE_LEFT), + SECONDARY(BindCategory.INTERACTION, "secondary", "Sekundäre Aktion", Button.MOUSE_RIGHT), + TERTIARY(BindCategory.INTERACTION, "tertiary", "Tertiäre Aktion", Button.MOUSE_MIDDLE), + QUARTERNARY(BindCategory.INTERACTION, "quarternary", "Quartäre Aktion", Keysym.R), + THROW(BindCategory.INTERACTION, "throw", "Weg werfen", Keysym.Q), + SELECT1(BindCategory.SELECTORS, "select1", "Auswahl #1", Keysym.N1), + SELECT2(BindCategory.SELECTORS, "select2", "Auswahl #2", Keysym.N2), + SELECT3(BindCategory.SELECTORS, "select3", "Auswahl #3", Keysym.N3), + SELECT4(BindCategory.SELECTORS, "select4", "Auswahl #4", Keysym.N4), + SELECT5(BindCategory.SELECTORS, "select5", "Auswahl #5", Keysym.N5), + SELECT6(BindCategory.SELECTORS, "select6", "Auswahl #6", Keysym.N6), + SELECT7(BindCategory.SELECTORS, "select7", "Auswahl #7", Keysym.N7), + SELECT8(BindCategory.SELECTORS, "select8", "Auswahl #8", Keysym.N8), + SELECT9(BindCategory.SELECTORS, "select9", "Auswahl #9", Keysym.N9), + SELECT10(BindCategory.SELECTORS, "select10", "Auswahl #10", Keysym.N0), + SELECT11(BindCategory.SELECTORS, "select11", "Auswahl #11", Keysym.SHARP_S), + SELECT12(BindCategory.SELECTORS, "select12", "Auswahl #12", Keysym.ACUTE), + SELECT13(BindCategory.SELECTORS, "select13", "Auswahl #13", Keysym.O), + SELECT14(BindCategory.SELECTORS, "select14", "Auswahl #14", Keysym.P), + SELECT15(BindCategory.SELECTORS, "select15", "Auswahl #15", Keysym.UE), + SELECT16(BindCategory.SELECTORS, "select16", "Auswahl #16", Keysym.PLUS), + CRAFT(BindCategory.INTERACTION, "craft", "Herstellen", Keysym.M), + RENAME(BindCategory.INTERACTION, "rename", "Umbenennen", Keysym.N), + CONSOLE(BindCategory.GENERAL, "console", "Konsole", Keysym.F1), + COMMAND(BindCategory.GENERAL, "command", "Befehl / Chat", Keysym.C), + INFO(BindCategory.GENERAL, "info", "Infos einblenden", Keysym.TAB), + PERSPECTIVE(BindCategory.GENERAL, "perspective", "Perspektive", Keysym.F4), + ZOOM(BindCategory.GENERAL, "zoom", "Kamera zoomen", Keysym.Y), + 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 inputEnabled; @@ -56,6 +60,7 @@ public enum Bind implements Identifyable, CVar { private final String id; private final String name; private final Input defInput; + private final BindCategory category; private Input input; 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.name = name; this.input = this.defInput = input; + this.category = category; } private void update() { @@ -190,6 +196,10 @@ public enum Bind implements Identifyable, CVar { return CVarCategory.INPUT; } + public BindCategory getBindCategory() { + return this.category; + } + public boolean parse(String str) { if("none".equalsIgnoreCase(str)) { this.input = null; diff --git a/client/src/main/java/client/window/BindCategory.java b/client/src/main/java/client/window/BindCategory.java new file mode 100644 index 00000000..9f4e433c --- /dev/null +++ b/client/src/main/java/client/window/BindCategory.java @@ -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; + } +} diff --git a/common/src/main/java/common/inventory/Container.java b/common/src/main/java/common/inventory/Container.java index 256fd0ab..097709f5 100755 --- a/common/src/main/java/common/inventory/Container.java +++ b/common/src/main/java/common/inventory/Container.java @@ -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);