mirror of
https://github.com/xiaozhou233/OrangeX-Client.git
synced 2026-12-05 13:05:52 +08:00
Fix: ClickGUI critical bugs + scroll + position persistence
- Fix ModuleButton.drawString() empty override (module names were invisible) - Fix mouseReleased/keyTyped event forwarding (slider drag, text input work) - Fix Panel.drawBackground() empty (now renders dark theme background) - Fix ClickGUI onEnable() keeping module disabled - Add scroll support with hover-panel-only mouse wheel dispatch - Add panel position persistence (saved to profile.json clickgui section) - Add keybind display on module button right side - Add click-outside-to-exit for StringComponent editing - Filter empty category panels, use getModulesByCategory() - Clean up dead code in ModuleButton
This commit is contained in:
1 parent
5bf074444e
commit
d9dcc0ac20
8 files changed
+233
-154
No files matched your search
+1
-2
@@ -41,5 +41,4 @@ bin/
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
|
||||
Minecraft-1.8.8-runtime/*
|
||||
AGENTS.md
|
||||
Minecraft-1.8.8-runtime/*
|
||||
@@ -32,6 +32,35 @@ public class ModuleConfig {
|
||||
modulesArray.add(moduleObj);
|
||||
}
|
||||
config.add("modules", modulesArray);
|
||||
writeConfig(config);
|
||||
}
|
||||
|
||||
public void saveClickGui(JsonObject clickGuiData) {
|
||||
JsonObject config = loadRaw();
|
||||
config.add("clickgui", clickGuiData);
|
||||
writeConfig(config);
|
||||
}
|
||||
|
||||
public JsonObject loadClickGui() {
|
||||
JsonObject config = loadRaw();
|
||||
if (config == null || !config.has("clickgui")) {
|
||||
return new JsonObject();
|
||||
}
|
||||
return config.getAsJsonObject("clickgui");
|
||||
}
|
||||
|
||||
private JsonObject loadRaw() {
|
||||
if (!configFile.exists()) return new JsonObject();
|
||||
try (Reader reader = new InputStreamReader(Files.newInputStream(configFile.toPath()), StandardCharsets.UTF_8)) {
|
||||
JsonObject config = gson.fromJson(reader, JsonObject.class);
|
||||
return config != null ? config : new JsonObject();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return new JsonObject();
|
||||
}
|
||||
}
|
||||
|
||||
private void writeConfig(JsonObject config) {
|
||||
configFile.getParentFile().mkdirs();
|
||||
try (Writer writer = new OutputStreamWriter(Files.newOutputStream(configFile.toPath()), StandardCharsets.UTF_8)) {
|
||||
gson.toJson(config, writer);
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
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.greenrobot.eventbus.Subscribe;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
public class ClickGUI extends Module {
|
||||
@@ -19,9 +17,4 @@ public class ClickGUI extends Module {
|
||||
mc.displayGuiScreen(new ClickGUIScreen());
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onKey(EventKey eventKey) {
|
||||
// unused, but necessary for eventbus
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,9 @@ import cn.xiaozhou233.orangex.module.Module;
|
||||
import cn.xiaozhou233.orangex.module.ModuleCategory;
|
||||
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;
|
||||
@@ -13,17 +15,19 @@ public class ClickGUIScreen extends GuiScreen {
|
||||
|
||||
private final List<Panel> panels = new ArrayList<>();
|
||||
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
|
||||
panels.clear();
|
||||
|
||||
|
||||
int x = 20;
|
||||
|
||||
for (ModuleCategory category : ModuleCategory.values()) {
|
||||
List<Module> categoryModules = OrangeX.getInstance()
|
||||
.getModuleManager()
|
||||
.getModulesByCategory(category);
|
||||
|
||||
for(ModuleCategory category : ModuleCategory.values()) {
|
||||
if (categoryModules.isEmpty())
|
||||
continue;
|
||||
|
||||
Panel panel = new Panel(
|
||||
category,
|
||||
@@ -33,20 +37,9 @@ public class ClickGUIScreen extends GuiScreen {
|
||||
20
|
||||
);
|
||||
|
||||
|
||||
int y = 20;
|
||||
|
||||
|
||||
for(Module module :
|
||||
OrangeX.getInstance()
|
||||
.getModuleManager()
|
||||
.getModules()) {
|
||||
|
||||
|
||||
if(module.getCategory() != category)
|
||||
continue;
|
||||
|
||||
|
||||
for (Module module : categoryModules) {
|
||||
panel.addComponent(
|
||||
new ModuleButton(
|
||||
panel,
|
||||
@@ -56,17 +49,16 @@ public class ClickGUIScreen extends GuiScreen {
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
y += 20;
|
||||
}
|
||||
|
||||
|
||||
panels.add(panel);
|
||||
|
||||
x += 140;
|
||||
}
|
||||
}
|
||||
|
||||
loadPanelPositions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(
|
||||
@@ -74,10 +66,7 @@ public class ClickGUIScreen extends GuiScreen {
|
||||
int mouseY,
|
||||
float partialTicks
|
||||
) {
|
||||
|
||||
|
||||
for(Panel panel : panels) {
|
||||
|
||||
for (Panel panel : panels) {
|
||||
panel.drawScreen(
|
||||
mouseX,
|
||||
mouseY,
|
||||
@@ -85,7 +74,6 @@ public class ClickGUIScreen extends GuiScreen {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
super.drawScreen(
|
||||
mouseX,
|
||||
mouseY,
|
||||
@@ -93,6 +81,24 @@ 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(
|
||||
@@ -100,10 +106,7 @@ public class ClickGUIScreen extends GuiScreen {
|
||||
int mouseY,
|
||||
int mouseButton
|
||||
) throws java.io.IOException {
|
||||
|
||||
|
||||
for(Panel panel : panels) {
|
||||
|
||||
for (Panel panel : panels) {
|
||||
panel.mouseClicked(
|
||||
mouseX,
|
||||
mouseY,
|
||||
@@ -111,7 +114,6 @@ public class ClickGUIScreen extends GuiScreen {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
super.mouseClicked(
|
||||
mouseX,
|
||||
mouseY,
|
||||
@@ -119,17 +121,13 @@ public class ClickGUIScreen extends GuiScreen {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void mouseReleased(
|
||||
int mouseX,
|
||||
int mouseY,
|
||||
int mouseButton
|
||||
) {
|
||||
|
||||
|
||||
for(Panel panel : panels) {
|
||||
|
||||
for (Panel panel : panels) {
|
||||
panel.mouseReleased(
|
||||
mouseX,
|
||||
mouseY,
|
||||
@@ -137,7 +135,6 @@ public class ClickGUIScreen extends GuiScreen {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
super.mouseReleased(
|
||||
mouseX,
|
||||
mouseY,
|
||||
@@ -145,37 +142,71 @@ public class ClickGUIScreen extends GuiScreen {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void keyTyped(
|
||||
char typedChar,
|
||||
int keyCode
|
||||
) throws java.io.IOException {
|
||||
|
||||
|
||||
for(Panel panel : panels) {
|
||||
|
||||
for (Panel panel : panels) {
|
||||
panel.keyTyped(
|
||||
typedChar,
|
||||
keyCode
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if(keyCode == 1) {
|
||||
if (keyCode == 1) {
|
||||
mc.displayGuiScreen(null);
|
||||
}
|
||||
|
||||
|
||||
super.keyTyped(
|
||||
typedChar,
|
||||
keyCode
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
savePanelPositions();
|
||||
}
|
||||
|
||||
private void savePanelPositions() {
|
||||
JsonObject data = new JsonObject();
|
||||
|
||||
for (Panel panel : panels) {
|
||||
JsonObject panelObj = new JsonObject();
|
||||
panelObj.addProperty("x", panel.getX());
|
||||
panelObj.addProperty("y", panel.getY());
|
||||
panelObj.addProperty("open", panel.isOpen());
|
||||
data.add(panel.getCategory().getName(), panelObj);
|
||||
}
|
||||
|
||||
OrangeX.getInstance()
|
||||
.getModuleManager()
|
||||
.getConfig()
|
||||
.saveClickGui(data);
|
||||
}
|
||||
|
||||
private void loadPanelPositions() {
|
||||
JsonObject data = OrangeX.getInstance()
|
||||
.getModuleManager()
|
||||
.getConfig()
|
||||
.loadClickGui();
|
||||
|
||||
for (Panel panel : panels) {
|
||||
String categoryName = panel.getCategory().getName();
|
||||
if (data.has(categoryName)) {
|
||||
JsonObject panelObj = data.getAsJsonObject(categoryName);
|
||||
panel.setX(panelObj.get("x").getAsInt());
|
||||
panel.setY(panelObj.get("y").getAsInt());
|
||||
if (panelObj.has("open")) {
|
||||
panel.setOpen(panelObj.get("open").getAsBoolean());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package cn.xiaozhou233.orangex.ui.clickgui;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.module.ModuleCategory;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.Component;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -12,7 +15,9 @@ public class Panel {
|
||||
|
||||
private final ModuleCategory category;
|
||||
|
||||
@Setter
|
||||
private int x;
|
||||
@Setter
|
||||
private int y;
|
||||
|
||||
private final int width;
|
||||
@@ -20,6 +25,7 @@ public class Panel {
|
||||
|
||||
private final int headerHeight = 20;
|
||||
|
||||
@Setter
|
||||
private boolean open = true;
|
||||
|
||||
private boolean dragging;
|
||||
@@ -29,8 +35,12 @@ public class Panel {
|
||||
|
||||
private final List<Component> components = new ArrayList<>();
|
||||
|
||||
private int scrollOffset;
|
||||
|
||||
public Panel(ModuleCategory category,int x,int y,int width,int height) {
|
||||
private int maxScroll;
|
||||
|
||||
|
||||
public Panel(ModuleCategory category, int x, int y, int width, int height) {
|
||||
this.category = category;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -39,105 +49,151 @@ public class Panel {
|
||||
}
|
||||
|
||||
|
||||
public void drawScreen(int mouseX,int mouseY,float partialTicks) {
|
||||
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
if (dragging) {
|
||||
x = mouseX - dragX;
|
||||
y = mouseY - dragY;
|
||||
}
|
||||
|
||||
|
||||
drawBackground();
|
||||
|
||||
drawBackground(mouseX, mouseY);
|
||||
|
||||
if (!open)
|
||||
return;
|
||||
|
||||
|
||||
for (Component component : components) {
|
||||
component.drawScreen(mouseX,mouseY,partialTicks);
|
||||
component.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void drawBackground() {
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
boolean headerHovered = isHovered(mouseX, mouseY);
|
||||
Gui.drawRect(x + 1, y + 1, x + width - 1, y + headerHeight, headerHovered ? 0xff353535 : 0xff2d2d2d);
|
||||
|
||||
OrangeX.getInstance()
|
||||
.getStbFontManager()
|
||||
.getProxima(18)
|
||||
.drawString(category.getName(), x + 5, y + 5, 0xffffffff);
|
||||
|
||||
String indicator = open ? "-" : "+";
|
||||
int indicatorX = x + width - 5 -
|
||||
(int) OrangeX.getInstance()
|
||||
.getStbFontManager()
|
||||
.getProxima(18)
|
||||
.getStringWidth(indicator);
|
||||
OrangeX.getInstance()
|
||||
.getStbFontManager()
|
||||
.getProxima(18)
|
||||
.drawString(indicator, indicatorX, y + 5, 0xffaaaaaa);
|
||||
}
|
||||
|
||||
|
||||
public void mouseClicked(int mouseX,int mouseY,int mouseButton) {
|
||||
|
||||
if (isHovered(mouseX,mouseY)) {
|
||||
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
if (isHovered(mouseX, mouseY)) {
|
||||
if (mouseButton == 0) {
|
||||
|
||||
dragging = true;
|
||||
|
||||
dragX = mouseX - x;
|
||||
dragY = mouseY - y;
|
||||
}
|
||||
|
||||
if (mouseButton == 1) {
|
||||
open = !open;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!open)
|
||||
return;
|
||||
|
||||
|
||||
for (Component component : components) {
|
||||
component.mouseClicked(mouseX,mouseY,mouseButton);
|
||||
component.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void mouseReleased(int mouseX,int mouseY,int mouseButton) {
|
||||
|
||||
public void mouseReleased(int mouseX, int mouseY, int mouseButton) {
|
||||
if (mouseButton == 0)
|
||||
dragging = false;
|
||||
|
||||
|
||||
for (Component component : components) {
|
||||
component.mouseReleased(mouseX,mouseY,mouseButton);
|
||||
component.mouseReleased(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void keyTyped(char typedChar,int keyCode) {
|
||||
|
||||
public void keyTyped(char typedChar, int keyCode) {
|
||||
for (Component component : components) {
|
||||
component.keyTyped(typedChar,keyCode);
|
||||
component.keyTyped(typedChar, keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isHovered(int mouseX,int mouseY) {
|
||||
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) {
|
||||
total += component.getHeight();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
private boolean isHovered(int mouseX, int mouseY) {
|
||||
return mouseX >= x &&
|
||||
mouseX <= x + width &&
|
||||
mouseY >= y &&
|
||||
mouseY <= y + headerHeight;
|
||||
}
|
||||
|
||||
public boolean isMouseOver(int mouseX, int mouseY) {
|
||||
int contentHeight = calculateContentHeight();
|
||||
int panelHeight = headerHeight + (open ? contentHeight : 0);
|
||||
return mouseX >= x &&
|
||||
mouseX <= x + width &&
|
||||
mouseY >= y &&
|
||||
mouseY <= y + panelHeight;
|
||||
}
|
||||
|
||||
|
||||
public void addComponent(Component component) {
|
||||
components.add(component);
|
||||
|
||||
updateLayout();
|
||||
}
|
||||
|
||||
public void updateLayout() {
|
||||
|
||||
int offset = headerHeight;
|
||||
|
||||
|
||||
for(Component component : components) {
|
||||
|
||||
for (Component component : components) {
|
||||
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() + offsetY;
|
||||
return parent.getY() + parent.getScrollOffset() + offsetY;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+32
-64
@@ -1,5 +1,6 @@
|
||||
package cn.xiaozhou233.orangex.ui.clickgui.component.impl;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.module.Module;
|
||||
import cn.xiaozhou233.orangex.module.option.Option;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.Panel;
|
||||
@@ -7,6 +8,7 @@ import cn.xiaozhou233.orangex.ui.clickgui.component.Component;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.option.OptionComponent;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.option.OptionComponentFactory;
|
||||
import lombok.Getter;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -20,15 +22,14 @@ public class ModuleButton extends Component {
|
||||
@Getter
|
||||
private final List<OptionComponent> options = new ArrayList<>();
|
||||
|
||||
public ModuleButton(Panel parent,Module module,int offsetX,int offsetY) {
|
||||
super(parent,offsetX,offsetY,120,20);
|
||||
public ModuleButton(Panel parent, Module module, int offsetX, int offsetY) {
|
||||
super(parent, offsetX, offsetY, 120, 20);
|
||||
|
||||
this.module = module;
|
||||
|
||||
int optionY = 20;
|
||||
|
||||
for (Option<?> option : module.getOptions()) {
|
||||
|
||||
OptionComponent component =
|
||||
OptionComponentFactory.create(
|
||||
parent,
|
||||
@@ -37,17 +38,15 @@ public class ModuleButton extends Component {
|
||||
offsetY + optionY
|
||||
);
|
||||
|
||||
if(component != null)
|
||||
if (component != null)
|
||||
options.add(component);
|
||||
|
||||
optionY += 18;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX,int mouseY,float partialTicks) {
|
||||
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
int color = module.isEnabled()
|
||||
? 0xff55ffff
|
||||
: 0xffffffff;
|
||||
@@ -59,96 +58,65 @@ public class ModuleButton extends Component {
|
||||
color
|
||||
);
|
||||
|
||||
if (module.getKey() != Keyboard.KEY_NONE) {
|
||||
String keyName = Keyboard.getKeyName(module.getKey());
|
||||
int keyX = getX() + width - 5 -
|
||||
(int) OrangeX.getInstance()
|
||||
.getStbFontManager()
|
||||
.getProxima(18)
|
||||
.getStringWidth(keyName);
|
||||
drawString(keyName, keyX, getY() + 5, 0xff555555);
|
||||
}
|
||||
|
||||
if(expanded) {
|
||||
for(OptionComponent option : options) {
|
||||
option.drawScreen(mouseX,mouseY,partialTicks);
|
||||
if (expanded) {
|
||||
for (OptionComponent option : options) {
|
||||
option.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void drawOptions(int mouseX,int mouseY,float partialTicks) {
|
||||
|
||||
for(OptionComponent option : options) {
|
||||
option.drawScreen(mouseX,mouseY,partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX,int mouseY,int mouseButton) {
|
||||
|
||||
if(isHovered(mouseX,mouseY)) {
|
||||
|
||||
if(mouseButton == 0)
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
if (isHovered(mouseX, mouseY)) {
|
||||
if (mouseButton == 0)
|
||||
module.toggle();
|
||||
|
||||
if(mouseButton == 1) {
|
||||
|
||||
if (mouseButton == 1) {
|
||||
expanded = !expanded;
|
||||
|
||||
parent.updateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(expanded) {
|
||||
for(OptionComponent option : options) {
|
||||
option.mouseClicked(mouseX,mouseY,mouseButton);
|
||||
if (expanded) {
|
||||
for (OptionComponent option : options) {
|
||||
option.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void mouseClickedOptions(int mouseX,int mouseY,int mouseButton) {
|
||||
|
||||
for(OptionComponent option : options) {
|
||||
option.mouseClicked(mouseX,mouseY,mouseButton);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY, int mouseButton) {
|
||||
|
||||
if (expanded) {
|
||||
mouseReleasedOptions(mouseX,mouseY,mouseButton);
|
||||
for (OptionComponent option : options) {
|
||||
option.mouseReleased(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void mouseReleasedOptions(int mouseX,int mouseY,int mouseButton) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void keyTyped(char typedChar, int keyCode) {
|
||||
|
||||
if (expanded) {
|
||||
keyTypedOptions(typedChar,keyCode);
|
||||
for (OptionComponent option : options) {
|
||||
option.keyTyped(typedChar, keyCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void keyTypedOptions(char typedChar,int keyCode) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void drawString(String text,int x,int y,int color) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
|
||||
if(!expanded)
|
||||
if (!expanded)
|
||||
return 20;
|
||||
|
||||
|
||||
return 20 + options.size() * 18;
|
||||
}
|
||||
|
||||
}
|
||||
+5
-2
@@ -55,10 +55,13 @@ public class StringComponent extends OptionComponent {
|
||||
int mouseY,
|
||||
int mouseButton
|
||||
) {
|
||||
|
||||
if(!isHovered(mouseX,mouseY))
|
||||
if (typing && !isHovered(mouseX, mouseY)) {
|
||||
typing = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isHovered(mouseX,mouseY))
|
||||
return;
|
||||
|
||||
if(mouseButton == 0) {
|
||||
typing = true;
|
||||
|
||||
Reference in new issue
Block a user