aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java
diff options
context:
space:
mode:
authorsyeyoung <42869671+cyoung06@users.noreply.github.com>2020-11-25 23:17:13 +0900
committersyeyoung <42869671+cyoung06@users.noreply.github.com>2020-11-25 23:17:13 +0900
commit49b083afffdf24f0bcd637909d15b88d9ed272b8 (patch)
tree4f02d7950d3cc00ac9d17f70a406b1bb543472dc /src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java
parent3a3b70806358e5e44232e793c84879514b1857b4 (diff)
downloadSkyblock-Dungeons-Guide-49b083afffdf24f0bcd637909d15b88d9ed272b8.tar.gz
Skyblock-Dungeons-Guide-49b083afffdf24f0bcd637909d15b88d9ed272b8.tar.bz2
Skyblock-Dungeons-Guide-49b083afffdf24f0bcd637909d15b88d9ed272b8.zip
LAST COMMIT OF TODAY
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java
index ba62e8ef..298a88e0 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MLabelAndElement.java
@@ -1,6 +1,9 @@
package kr.syeyoung.dungeonsguide.roomedit.elements;
import kr.syeyoung.dungeonsguide.roomedit.MPanel;
+import lombok.Getter;
+import lombok.Setter;
+import net.minecraft.client.gui.Gui;
import java.awt.*;
@@ -8,6 +11,11 @@ public class MLabelAndElement extends MPanel {
private MLabel label;
private MPanel element;
+ @Getter @Setter
+ private Color hover;
+ @Getter @Setter
+ private Runnable onClick;
+
public MLabelAndElement(String label, MPanel element) {
this.add(this.label = new MLabel());
this.label.setText(label);
@@ -16,6 +24,20 @@ public class MLabelAndElement extends MPanel {
}
@Override
+ public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
+ if (hover != null && new Rectangle(new Point(0,0),bounds.getSize()).contains(relMousex0, relMousey0)) {
+ Gui.drawRect(0,0,bounds.width, bounds.height, hover.getRGB());
+ }
+ }
+
+ @Override
+ protected void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
+ if (onClick!= null && new Rectangle(new Point(0,0),bounds.getSize()).contains(relMouseX, relMouseY)) {
+ onClick.run();
+ }
+ }
+
+ @Override
public void resize(int parentWidth, int parentHeight) {
this.setSize(new Dimension(parentWidth, bounds.height));
label.setBounds(new Rectangle(0,0,parentHeight / 3, bounds.height));