diff options
author | syeyoung <cyong06@naver.com> | 2021-07-18 23:35:41 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-07-18 23:35:41 +0900 |
commit | 0af44a60844be83fb371c2f0eaeb2feccd1f0207 (patch) | |
tree | 1ac67087eeb7afb1afb7b7afa2d22d3f3c7b3748 /src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java | |
parent | e4ac7cf162d4383424a0798f160073b8d5bc1f1b (diff) | |
download | Skyblock-Dungeons-Guide-0af44a60844be83fb371c2f0eaeb2feccd1f0207.tar.gz Skyblock-Dungeons-Guide-0af44a60844be83fb371c2f0eaeb2feccd1f0207.tar.bz2 Skyblock-Dungeons-Guide-0af44a60844be83fb371c2f0eaeb2feccd1f0207.zip |
Modification to GUI Framework
- Mostly removes Scaled GUI
- Also has done some fixes to gui relocation
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java')
-rw-r--r--[-rwxr-xr-x] | src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java index 911038f2..5f7ff538 100755..100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java @@ -18,15 +18,13 @@ package kr.syeyoung.dungeonsguide.gui; +import kr.syeyoung.dungeonsguide.gui.elements.MTooltip; import lombok.AccessLevel; import lombok.Getter; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import org.lwjgl.opengl.GL11; import java.awt.*; @@ -46,6 +44,9 @@ public class MPanel { @Getter(AccessLevel.PUBLIC) protected boolean isFocused; + @Getter + protected MPanel parent; + public void setBackgroundColor(Color c) { if (c == null) return; this.backgroundColor = c; @@ -83,19 +84,31 @@ public class MPanel { } public void add(MPanel child) { + if (child.parent != null) throw new IllegalArgumentException("What have you done"); this.childComponents.add(child); + child.parent = this; + } + + public void openTooltip(MTooltip mPanel) { + parent.openTooltip(mPanel); + } + public int getTooltipsOpen() { + return parent.getTooltipsOpen(); } public void remove(MPanel panel) { + panel.parent = null; this.childComponents.remove(panel); } + protected Point lastParentPoint; public void render0(ScaledResolution resolution, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { // 0,0 - a a + lastParentPoint = parentPoint; int relMousex = relMousex0 - getBounds().x; int relMousey = relMousey0 - getBounds().y; - GlStateManager.translate(getBounds().x, getBounds().y, 0); + GlStateManager.translate(getBounds().x, getBounds().y, 5); GlStateManager.color(1,1,1,0); @@ -103,6 +116,7 @@ public class MPanel { absBound.setLocation(absBound.x + parentPoint.x, absBound.y + parentPoint.y); Rectangle clip = determineClip(parentClip, absBound); lastAbsClip = clip; + if (clip.getSize().height * clip.getSize().width == 0) return; clip(resolution, clip.x, clip.y, clip.width, clip.height); GlStateManager.pushAttrib(); @@ -115,6 +129,12 @@ public class MPanel { GlStateManager.pushMatrix(); GlStateManager.pushAttrib(); + + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.enableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + render(absMousex, absMousey, relMousex, relMousey, partialTicks, clip); GlStateManager.popAttrib(); GlStateManager.popMatrix(); @@ -137,7 +157,8 @@ public class MPanel { public static void clip(ScaledResolution resolution, int x, int y, int width, int height) { if (width < 0 || height < 0) return; - int scale = resolution.getScaleFactor(); +// int scale = resolution.getScaleFactor(); + int scale = 1; GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width) * scale, height * scale); } |