Fixed click bugs

This commit is contained in:
2026-02-22 03:20:16 +01:00
parent 85d4a1de38
commit 377031c0a9
3 changed files with 32 additions and 20 deletions
@@ -17,6 +17,10 @@ public class SaturnModule extends Element {
private final Module mod; private final Module mod;
static int p = 10; // padding
static int s = 14; // settings icon size
static int expand = 5; // settings icon click area
public SaturnModule(Module mod) { public SaturnModule(Module mod) {
this.mod = mod; this.mod = mod;
this.width = 160; this.width = 160;
@@ -25,18 +29,17 @@ public class SaturnModule extends Element {
@Override @Override
public void render(RenderScope renderScope, ElementContext ctx) { public void render(RenderScope renderScope, ElementContext ctx) {
int p = 10; // padding
int s = 14; // settings icon size
boolean hovered = ctx.isHovering(); boolean hovered = ctx.isHovering();
boolean enabled = mod.isEnabled(); boolean enabled = mod.isEnabled();
boolean settingsHover = Utils.isHovering( int iconX = width - s - p;
ctx.mouseX - (width - s - p - 5), int iconY = height - s - p;
ctx.mouseY - (height - s - p - 5),
s + 10, boolean settingsHover = ctx.isHovering(
s + 10, getSettingsX(),
1.0f); getSettingsY(),
getSettingsHitBox(),
getSettingsHitBox());
renderScope.setRenderLayer(RenderLayer::getGuiTextured); renderScope.setRenderLayer(RenderLayer::getGuiTextured);
@@ -125,8 +128,8 @@ public class SaturnModule extends Element {
// Settings icon // Settings icon
renderScope.drawTexture( renderScope.drawTexture(
Textures.SETTINGS, Textures.SETTINGS,
width - s - p, iconX,
height - s - p, iconY,
0, 0, 0, 0,
s, s, s, s,
settingsColor); settingsColor);
@@ -134,14 +137,11 @@ public class SaturnModule extends Element {
@Override @Override
public void click(int mouseX, int mouseY) { public void click(int mouseX, int mouseY) {
int p = 10;
int s = 14;
boolean settingsHover = Utils.isHovering( boolean settingsHover = Utils.isHovering(
mouseX - (width - s - p - 5), mouseX - getSettingsX(),
mouseY - (height - s - p - 5), mouseY - getSettingsY(),
s + 10, getSettingsHitBox(),
s + 10, getSettingsHitBox(),
1.0f); 1.0f);
if (settingsHover) { if (settingsHover) {
@@ -150,4 +150,16 @@ public class SaturnModule extends Element {
mod.setEnabled(!mod.isEnabled()); mod.setEnabled(!mod.isEnabled());
} }
} }
private int getSettingsX() {
return width - s - p - expand;
}
private int getSettingsY() {
return height - s - p - expand;
}
private int getSettingsHitBox() {
return s + expand * 2;
}
} }
@@ -18,7 +18,7 @@ public class Toggle extends Element {
@Override @Override
public void render(RenderScope renderScope, ElementContext ctx) { public void render(RenderScope renderScope, ElementContext ctx) {
renderScope.drawRoundedRectangle(0, 0, width, height, height, renderScope.drawRoundedRectangle(0, 0, width, height, height,
prop.value ? Theme.ACCENT.value : Theme.PRIMARY.value); Theme.withAlpha(0.5f, prop.value ? Theme.ACCENT.value : Theme.PRIMARY.value));
renderScope.drawRoundedRectangle(prop.value ? 30 : 0, 0, 30, 30, 30, renderScope.drawRoundedRectangle(prop.value ? 30 : 0, 0, 30, 30, 30,
prop.value ? Theme.ACCENT.value : Theme.PRIMARY.value); prop.value ? Theme.ACCENT.value : Theme.PRIMARY.value);
} }
@@ -115,7 +115,7 @@ public class Scroll extends Element {
@Override @Override
public void mouseClicked(double mouseX, double mouseY, int button) { public void mouseClicked(double mouseX, double mouseY, int button) {
ElementRenderer.mouseClicked(children, mouseX, mouseY, button); ElementRenderer.mouseClicked(children, mouseX - padding, mouseY - padding + scroll, button);
} }
@Override @Override