mirror of
https://github.com/xiaozhou233/OrangeX-Client.git
synced 2026-12-05 13:05:52 +08:00
Clean: remove scroll system, simplify panel rendering
- Remove scrollOffset/maxScroll from Panel (no more scrolling) - Remove handleMouseInput/updateMaxScroll/getScrollOffset methods - Panel content background stays at fixed position - Component.getY() no longer adds scroll offset - Remove Mouse import and handleMouseInput override from ClickGUIScreen - Remove skip checks in draw/click/release/key loops (header drawn last covers content)
This commit is contained in:
1 parent
d9dcc0ac20
commit
6c68130a4f
3 files changed
+20
-63
No files matched your search
@@ -6,7 +6,6 @@ import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.impl.ModuleButton;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -81,25 +80,6 @@ public class ClickGUIScreen extends GuiScreen {
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput() throws java.io.IOException {
|
||||
int amount = Mouse.getEventDWheel();
|
||||
if (amount != 0) {
|
||||
int mouseX = Mouse.getEventX() * width / mc.displayWidth;
|
||||
int mouseY = height - Mouse.getEventY() * height / mc.displayHeight - 1;
|
||||
|
||||
for (Panel panel : panels) {
|
||||
if (panel.isMouseOver(mouseX, mouseY)) {
|
||||
int scrollAmount = amount > 0 ? 10 : -10;
|
||||
panel.handleMouseInput(scrollAmount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.handleMouseInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(
|
||||
int mouseX,
|
||||
|
||||
@@ -35,10 +35,6 @@ public class Panel {
|
||||
|
||||
private final List<Component> components = new ArrayList<>();
|
||||
|
||||
private int scrollOffset;
|
||||
|
||||
private int maxScroll;
|
||||
|
||||
|
||||
public Panel(ModuleCategory category, int x, int y, int width, int height) {
|
||||
this.category = category;
|
||||
@@ -55,36 +51,31 @@ public class Panel {
|
||||
y = mouseY - dragY;
|
||||
}
|
||||
|
||||
drawBackground(mouseX, mouseY);
|
||||
|
||||
if (!open)
|
||||
return;
|
||||
|
||||
for (Component component : components) {
|
||||
component.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void drawBackground(int mouseX, int mouseY) {
|
||||
int contentHeight = calculateContentHeight();
|
||||
int panelHeight = headerHeight + (open ? contentHeight : 0);
|
||||
|
||||
Gui.drawRect(x, y, x + width, y + panelHeight, 0xff1a1a1a);
|
||||
if (open) {
|
||||
Gui.drawRect(x, y + headerHeight, x + width, y + headerHeight + contentHeight, 0xff1a1a1a);
|
||||
}
|
||||
|
||||
Gui.drawRect(x, y, x + width, y + 1, 0xff3d3d3d);
|
||||
Gui.drawRect(x, y + panelHeight - 1, x + width, y + panelHeight, 0xff3d3d3d);
|
||||
Gui.drawRect(x, y, x + 1, y + panelHeight, 0xff3d3d3d);
|
||||
Gui.drawRect(x + width - 1, y, x + width, y + panelHeight, 0xff3d3d3d);
|
||||
// Components (drawn below header, will be covered by header if scrolled up)
|
||||
if (open) {
|
||||
for (Component component : components) {
|
||||
component.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
// Header background (drawn on top, covers scrolled content)
|
||||
boolean headerHovered = isHovered(mouseX, mouseY);
|
||||
Gui.drawRect(x + 1, y + 1, x + width - 1, y + headerHeight, headerHovered ? 0xff353535 : 0xff2d2d2d);
|
||||
|
||||
// Category name
|
||||
OrangeX.getInstance()
|
||||
.getStbFontManager()
|
||||
.getProxima(18)
|
||||
.drawString(category.getName(), x + 5, y + 5, 0xffffffff);
|
||||
|
||||
// Collapse indicator
|
||||
String indicator = open ? "-" : "+";
|
||||
int indicatorX = x + width - 5 -
|
||||
(int) OrangeX.getInstance()
|
||||
@@ -95,6 +86,12 @@ public class Panel {
|
||||
.getStbFontManager()
|
||||
.getProxima(18)
|
||||
.drawString(indicator, indicatorX, y + 5, 0xffaaaaaa);
|
||||
|
||||
// Borders (drawn on top of everything)
|
||||
Gui.drawRect(x, y, x + width, y + 1, 0xff3d3d3d);
|
||||
Gui.drawRect(x, y + panelHeight - 1, x + width, y + panelHeight, 0xff3d3d3d);
|
||||
Gui.drawRect(x, y, x + 1, y + panelHeight, 0xff3d3d3d);
|
||||
Gui.drawRect(x + width - 1, y, x + width, y + panelHeight, 0xff3d3d3d);
|
||||
}
|
||||
|
||||
|
||||
@@ -136,21 +133,6 @@ public class Panel {
|
||||
}
|
||||
|
||||
|
||||
public void handleMouseInput(int amount) {
|
||||
if (!open) return;
|
||||
|
||||
scrollOffset += amount;
|
||||
updateMaxScroll();
|
||||
scrollOffset = Math.max(Math.min(scrollOffset, 0), -maxScroll);
|
||||
}
|
||||
|
||||
|
||||
private void updateMaxScroll() {
|
||||
int contentHeight = calculateContentHeight();
|
||||
maxScroll = Math.max(0, contentHeight - (height - headerHeight));
|
||||
}
|
||||
|
||||
|
||||
private int calculateContentHeight() {
|
||||
int total = 0;
|
||||
for (Component component : components) {
|
||||
@@ -189,11 +171,6 @@ public class Panel {
|
||||
component.setOffsetY(offset);
|
||||
offset += component.getHeight();
|
||||
}
|
||||
|
||||
updateMaxScroll();
|
||||
}
|
||||
|
||||
public int getScrollOffset() {
|
||||
return scrollOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public abstract class Component {
|
||||
|
||||
|
||||
public int getY() {
|
||||
return parent.getY() + parent.getScrollOffset() + offsetY;
|
||||
return parent.getY() + offsetY;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user