Skip to content

Commit bb7a2d3

Browse files
committed
Update the Gui Debug Renderer to log the widget classes under your mouse when you right click
1 parent 9563985 commit bb7a2d3

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

src/main/java/meteordevelopment/meteorclient/gui/WidgetScreen.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ public boolean mouseReleased(Click click) {
144144
mouseX *= s;
145145
mouseY *= s;
146146

147+
if (debug && click.button() == GLFW_MOUSE_BUTTON_RIGHT) DEBUG_RENDERER.mouseReleased(root, new Click(mouseX, mouseY, click.buttonInfo()), 0);
148+
147149
return root.mouseReleased(new Click(mouseX, mouseY, click.buttonInfo()));
148150
}
149151

src/main/java/meteordevelopment/meteorclient/gui/renderer/GuiDebugRenderer.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package meteordevelopment.meteorclient.gui.renderer;
77

8+
import meteordevelopment.meteorclient.MeteorClient;
89
import meteordevelopment.meteorclient.gui.utils.Cell;
910
import meteordevelopment.meteorclient.gui.widgets.WWidget;
1011
import meteordevelopment.meteorclient.gui.widgets.containers.WContainer;
@@ -13,6 +14,7 @@
1314
import meteordevelopment.meteorclient.renderer.MeteorRenderPipelines;
1415
import meteordevelopment.meteorclient.utils.render.color.Color;
1516
import net.minecraft.client.MinecraftClient;
17+
import net.minecraft.client.gui.Click;
1618

1719
public class GuiDebugRenderer {
1820
private static final Color CELL_COLOR = new Color(25, 225, 25);
@@ -34,11 +36,25 @@ public void render(WWidget widget) {
3436
.end();
3537
}
3638

39+
public void mouseReleased(WWidget widget, Click click, int i) {
40+
if (widget == null) return;
41+
42+
MeteorClient.LOG.info("{} {}", widget.getClass(), i);
43+
44+
if (widget instanceof WContainer container) {
45+
for (Cell<?> cell : container.cells) {
46+
if (cell.widget().isOver(click.x(), click.y())) {
47+
mouseReleased(cell.widget(), click, i + 1);
48+
}
49+
}
50+
}
51+
}
52+
3753
private void renderWidget(WWidget widget) {
3854
lineBox(widget.x, widget.y, widget.width, widget.height, WIDGET_COLOR);
3955

40-
if (widget instanceof WContainer) {
41-
for (Cell<?> cell : ((WContainer) widget).cells) {
56+
if (widget instanceof WContainer container) {
57+
for (Cell<?> cell : container.cells) {
4258
lineBox(cell.x, cell.y, cell.width, cell.height, CELL_COLOR);
4359
renderWidget(cell.widget());
4460
}

0 commit comments

Comments
 (0)