From 0593c1b6390ddf7c92c6a5ddab3e31c5f6e59e7d Mon Sep 17 00:00:00 2001 From: syeyoung <42869671+cyoung06@users.noreply.github.com> Date: Mon, 23 Nov 2020 22:58:36 +0900 Subject: gui elements, better clip --- src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java | 4 ++-- .../java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java index a7bb008e..88b918cf 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java @@ -19,7 +19,7 @@ public class MPanel { protected List childComponents = new ArrayList(); - protected Color backgroundColor; + protected Color backgroundColor = new Color(0,0,0,0); @Getter(AccessLevel.PUBLIC) protected boolean isFocused; @@ -109,7 +109,7 @@ public class MPanel { public void clip(ScaledResolution resolution, int x, int y, int width, int height) { int scale = resolution.getScaleFactor(); - GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width + x) * scale, height * scale); + GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width) * scale, height * scale); } private Rectangle determineClip(Rectangle rect1, Rectangle rect2) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java index 430ca07f..c77cb947 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java @@ -18,9 +18,10 @@ public class MButton extends MPanel { private Color foreground = Color.white; private Color hover = Color.gray; + private Color clicked = Color.lightGray; private Color disabled = Color.darkGray; - private boolean enabled; + private boolean enabled = true; private Runnable onActionPerformed; @@ -34,7 +35,8 @@ public class MButton extends MPanel { } else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) { bg = hover; } - Gui.drawRect(0,0,bounds.width, bounds.height, bg.getRGB()); + if (bg != null) + Gui.drawRect(0,0,bounds.width, bounds.height, bg.getRGB()); FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; int width = renderer.getStringWidth(text); -- cgit