mirror of
https://github.com/xiaozhou233/OrangeX-Client.git
synced 2026-12-05 13:05:52 +08:00
[Refactor] Remove clickgui and update ModuleCategory
This commit is contained in:
1 parent
b617c374f3
commit
cc242c402e
6 files changed
+6
-287
No files matched your search
@@ -1,5 +1,9 @@
|
||||
package cn.xiaozhou233.orangex.module;
|
||||
|
||||
public enum ModuleCategory {
|
||||
RENDER, MISC
|
||||
RENDER,
|
||||
COMBAT,
|
||||
MISC,
|
||||
MOVEMENT,
|
||||
PLAYER
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
package cn.xiaozhou233.orangex.module.impl.render;
|
||||
|
||||
import cn.xiaozhou233.orangex.event.impl.EventKey;
|
||||
import cn.xiaozhou233.orangex.module.Module;
|
||||
import cn.xiaozhou233.orangex.module.ModuleCategory;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.ClickGuiScreen;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
public class ClickGUI extends Module {
|
||||
@@ -17,7 +15,7 @@ public class ClickGUI extends Module {
|
||||
protected void onEnable() {
|
||||
super.onEnable();
|
||||
|
||||
mc.displayGuiScreen(new ClickGuiScreen());
|
||||
// mc.displayGuiScreen(new ClickGuiScreen());
|
||||
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.ui.clickgui;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.module.Module;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.ModuleButton;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.PanelUI;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ClickGuiScreen extends GuiScreen {
|
||||
|
||||
private PanelUI panel;
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
panel = new PanelUI(10, 10, 120, 180, "Combat");
|
||||
|
||||
for (Module module : OrangeX.getInstance().getModuleManager().getAllModules()) {
|
||||
panel.addComponent(new ModuleButton(module, 120));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
// Background
|
||||
Gui.drawRect(
|
||||
0,
|
||||
0,
|
||||
width,
|
||||
height,
|
||||
new Color(50, 50, 50, 100).getRGB()
|
||||
);
|
||||
|
||||
if (panel != null) {
|
||||
panel.draw(mouseX, mouseY);
|
||||
}
|
||||
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
if (panel != null) {
|
||||
panel.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseReleased(int mouseX, int mouseY, int state) {
|
||||
if (panel != null) {
|
||||
panel.mouseReleased(state);
|
||||
}
|
||||
super.mouseReleased(mouseX, mouseY, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.ui.clickgui.component;
|
||||
|
||||
public abstract class Component {
|
||||
|
||||
protected int x, y, width, height;
|
||||
|
||||
public abstract void draw(int mouseX, int mouseY);
|
||||
|
||||
public void mouseClicked(int mouseX, int mouseY, int button) {}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
protected boolean isHovering(int mouseX, int mouseY) {
|
||||
return mouseX >= x && mouseX <= x + width
|
||||
&& mouseY >= y && mouseY <= y + height;
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.ui.clickgui.component;
|
||||
|
||||
import cn.xiaozhou233.orangex.module.Module;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class ModuleButton extends Component {
|
||||
|
||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
private final Module module;
|
||||
private boolean expanded;
|
||||
|
||||
private static final int BUTTON_HEIGHT = 14;
|
||||
private static final int EXPANDED_HEIGHT = 20; // placeholder
|
||||
|
||||
public ModuleButton(Module module, int width) {
|
||||
this.module = module;
|
||||
this.width = width;
|
||||
this.height = BUTTON_HEIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int mouseX, int mouseY) {
|
||||
boolean hover = isHovering(mouseX, mouseY);
|
||||
|
||||
int bgColor;
|
||||
if (module.isEnabled()) {
|
||||
bgColor = hover
|
||||
? new Color(70, 130, 180, 220).getRGB()
|
||||
: new Color(60, 120, 170, 200).getRGB();
|
||||
} else {
|
||||
bgColor = hover
|
||||
? new Color(80, 80, 80, 200).getRGB()
|
||||
: new Color(60, 60, 60, 180).getRGB();
|
||||
}
|
||||
|
||||
// Button background
|
||||
Gui.drawRect(x, y, x + width, y + BUTTON_HEIGHT, bgColor);
|
||||
|
||||
// Module name
|
||||
mc.fontRendererObj.drawString(
|
||||
module.getName(),
|
||||
x + 4,
|
||||
y + 3,
|
||||
0xFFFFFFFF
|
||||
);
|
||||
|
||||
// Expanded area (future settings)
|
||||
if (expanded) {
|
||||
Gui.drawRect(
|
||||
x,
|
||||
y + BUTTON_HEIGHT,
|
||||
x + width,
|
||||
y + height,
|
||||
new Color(45, 45, 45, 200).getRGB()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int button) {
|
||||
if (!isHovering(mouseX, mouseY)) return;
|
||||
|
||||
// Left click: toggle
|
||||
if (button == 0) {
|
||||
module.toggle();
|
||||
}
|
||||
|
||||
// Right click: expand
|
||||
if (button == 1) {
|
||||
expanded = !expanded;
|
||||
height = expanded
|
||||
? BUTTON_HEIGHT + EXPANDED_HEIGHT
|
||||
: BUTTON_HEIGHT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.ui.clickgui.component;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PanelUI {
|
||||
|
||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
private int x, y, width, height;
|
||||
private final String title;
|
||||
|
||||
/* ================= Drag ================= */
|
||||
|
||||
private boolean dragging;
|
||||
private int dragOffsetX, dragOffsetY;
|
||||
|
||||
/* ================= Layout ================= */
|
||||
|
||||
private static final int TITLE_HEIGHT = 15;
|
||||
private final List<Component> components = new ArrayList<>();
|
||||
|
||||
public PanelUI(int x, int y, int width, int height, String title) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/* ================= Render ================= */
|
||||
|
||||
public void draw(int mouseX, int mouseY) {
|
||||
// Handle dragging
|
||||
if (dragging) {
|
||||
x = mouseX - dragOffsetX;
|
||||
y = mouseY - dragOffsetY;
|
||||
}
|
||||
|
||||
// Title bar
|
||||
Gui.drawRect(
|
||||
x,
|
||||
y,
|
||||
x + width,
|
||||
y + TITLE_HEIGHT,
|
||||
new Color(32, 32, 32, 200).getRGB()
|
||||
);
|
||||
|
||||
mc.fontRendererObj.drawString(
|
||||
title,
|
||||
x + 4,
|
||||
y + 4,
|
||||
0xFFFFFFFF
|
||||
);
|
||||
|
||||
// Auto layout components
|
||||
int offsetY = y + TITLE_HEIGHT;
|
||||
|
||||
for (Component component : components) {
|
||||
component.x = x;
|
||||
component.y = offsetY;
|
||||
component.width = width;
|
||||
|
||||
component.draw(mouseX, mouseY);
|
||||
|
||||
offsetY += component.getHeight();
|
||||
}
|
||||
|
||||
// Panel background (based on content height)
|
||||
height = offsetY - y;
|
||||
|
||||
Gui.drawRect(
|
||||
x,
|
||||
y + TITLE_HEIGHT,
|
||||
x + width,
|
||||
y + height,
|
||||
new Color(60, 60, 60, 180).getRGB()
|
||||
);
|
||||
}
|
||||
|
||||
/* ================= Mouse ================= */
|
||||
|
||||
public void mouseClicked(int mouseX, int mouseY, int button) {
|
||||
// Drag panel
|
||||
if (button == 0 && isHoveringTitle(mouseX, mouseY)) {
|
||||
dragging = true;
|
||||
dragOffsetX = mouseX - x;
|
||||
dragOffsetY = mouseY - y;
|
||||
return;
|
||||
}
|
||||
|
||||
// Forward to components
|
||||
for (Component component : components) {
|
||||
component.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseReleased(int mouseButton) {
|
||||
if (mouseButton == 0) {
|
||||
dragging = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* ================= Utils ================= */
|
||||
|
||||
public void addComponent(Component component) {
|
||||
components.add(component);
|
||||
}
|
||||
|
||||
private boolean isHoveringTitle(int mouseX, int mouseY) {
|
||||
return mouseX >= x
|
||||
&& mouseX <= x + width
|
||||
&& mouseY >= y
|
||||
&& mouseY <= y + TITLE_HEIGHT;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user