aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-07-21 15:29:43 +0900
committersyeyoung <cyong06@naver.com>2021-07-21 15:29:43 +0900
commitd392b203a93a8897a184f75634338b7c866510f3 (patch)
treea27505fbdc2bc754c674a026915c27065984c00e /src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java
parent4850d1a1f795f625286b9a2058143f688265dc3d (diff)
downloadSkyblock-Dungeons-Guide-d392b203a93a8897a184f75634338b7c866510f3.tar.gz
Skyblock-Dungeons-Guide-d392b203a93a8897a184f75634338b7c866510f3.tar.bz2
Skyblock-Dungeons-Guide-d392b203a93a8897a184f75634338b7c866510f3.zip
custom party finder
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java')
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java
index d30b82c9..da2ff78c 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java
@@ -37,9 +37,10 @@ public class MButton extends MPanel {
private String text;
private Color foreground = Color.white;
- private Color hover = Color.gray;
- private Color clicked = Color.lightGray;
- private Color disabled = Color.darkGray;
+ private int background = RenderUtils.blendAlpha(0xFF141414, 0.08f);
+ private int hover = RenderUtils.blendAlpha(0xFF141414, 0.14f);
+ private int clicked = RenderUtils.blendAlpha(0xFF141414, 0.16f);
+ private int disabled =0xFF141414;
private boolean enabled = true;
@@ -49,14 +50,15 @@ public class MButton extends MPanel {
public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) {
Dimension bounds = getSize();
- Color bg = backgroundColor;
+ int bg = background;
if (!enabled) {
bg = disabled;
+ } else if (isclicked) {
+ bg = clicked;
} else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) {
bg = hover;
}
- if (bg != null)
- Gui.drawRect(0,0,getBounds().width, getBounds().height, bg.getRGB());
+ Gui.drawRect(0,0,getBounds().width, getBounds().height, bg);
FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj;
int width = renderer.getStringWidth(getText());
@@ -69,9 +71,18 @@ public class MButton extends MPanel {
renderer.drawString(getText(), x,y, foreground.getRGB());
}
+ boolean isclicked = false;
@Override
public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
- if (onActionPerformed != null && lastAbsClip.contains(absMouseX, absMouseY))
- onActionPerformed.run();
+ if (lastAbsClip.contains(absMouseX, absMouseY)) {
+ isclicked = true;
+ if (onActionPerformed != null)
+ onActionPerformed.run();
+ }
+ }
+
+ @Override
+ public void mouseReleased(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int state) {
+ isclicked = false;
}
}