From 64cd5e6d0a571c95c2435bfc232522d7ca8d5d87 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Thu, 5 Aug 2021 12:55:29 +0900 Subject: Bigger Tooltips for GUI Relocate --- .../config/guiconfig/location/PanelDelegate.java | 1 + .../dungeonsguide/features/GuiFeature.java | 4 +-- .../gui/elements/MPassiveLabelAndElement.java | 2 +- .../dungeonsguide/gui/elements/MPopupMenu.java | 32 ++++++++++++++++++++-- 4 files changed, 34 insertions(+), 5 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/PanelDelegate.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/PanelDelegate.java index 4e776eef..d34eb6c1 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/PanelDelegate.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/location/PanelDelegate.java @@ -316,6 +316,7 @@ public class PanelDelegate extends MPanel { } else if (getTooltipsOpen() == 0){ if (mTooltip != null) mTooltip.close(); mTooltip = new MPopupMenu(absMouseX, absMouseY, guiFeature.getTooltipForEditor(guiGuiLocationConfig)); + mTooltip.setScale(2.0f); mTooltip.open(this); } throw new IllegalArgumentException("bruh, a hack to stop event progress"); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java index 52278f6b..b4fc8688 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/GuiFeature.java @@ -126,7 +126,7 @@ public abstract class GuiFeature extends AbstractFeature implements ScreenRender @Override public Dimension getPreferredSize() { - return new Dimension(Minecraft.getMinecraft().fontRendererObj.getStringWidth(getName()), 30); + return new Dimension(Minecraft.getMinecraft().fontRendererObj.getStringWidth(getName()), 20); } }); mPanels.add(new MButton() { @@ -146,7 +146,7 @@ public abstract class GuiFeature extends AbstractFeature implements ScreenRender @Override public Dimension getPreferredSize() { - return new Dimension(150,30); + return new Dimension(100,20); } }); mPanels.add(new MPassiveLabelAndElement("Enabled", new MToggleButton() {{ diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPassiveLabelAndElement.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPassiveLabelAndElement.java index a90e40e5..4a56d411 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPassiveLabelAndElement.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPassiveLabelAndElement.java @@ -46,7 +46,7 @@ public class MPassiveLabelAndElement extends MPanel { @Override public Dimension getPreferredSize() { - return new Dimension(200, 30); + return new Dimension(100, 20); } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPopupMenu.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPopupMenu.java index 242d5a03..4bec72ed 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPopupMenu.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MPopupMenu.java @@ -33,7 +33,9 @@ import java.awt.*; import java.util.List; public class MPopupMenu extends MTooltip { + private int x, y; public MPopupMenu(int x, int y, List popupMenuElementList) { + this.x = x; this.y = y; int maxWidth = 150; for (MPanel mPanel : popupMenuElementList) { Dimension dimension = mPanel.getPreferredSize(); @@ -54,15 +56,41 @@ public class MPopupMenu extends MTooltip { setBounds(new Rectangle(x,y,maxWidth+2, h1)); } + @Override + public void setScale(double scale) { + super.setScale(scale); + + int maxWidth = 150; + for (MPanel mPanel : getChildComponents()) { + Dimension dimension = mPanel.getPreferredSize(); + if (dimension.width > maxWidth) maxWidth = dimension.width; + } + int h1 = 7; + for (MPanel mPanel : getChildComponents()) { + Dimension dimension = mPanel.getPreferredSize(); + mPanel.setBounds(new Rectangle(7,h1, maxWidth-13, dimension.height)); + h1 += dimension.height + 7; + } + maxWidth += 2; + maxWidth *= scale; h1 *= scale; + + if (y + h1 > Minecraft.getMinecraft().displayHeight) + y = Minecraft.getMinecraft().displayHeight - h1; + if (x + maxWidth > Minecraft.getMinecraft().displayWidth) + x = Minecraft.getMinecraft().displayWidth - maxWidth; + setBounds(new Rectangle(x,y,maxWidth, h1)); + } + @Override public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { super.render(absMousex, absMousey, relMousex0, relMousey0, partialTicks, scissor); int radius = 7; double deltaDegree = Math.PI/6; - RenderUtils.drawRoundedRectangle(0,0,getBounds().width,getBounds().height,radius,deltaDegree, RenderUtils.blendAlpha(0x121212, 0.0f)); + Dimension effectiveDim = getEffectiveDimension(); + RenderUtils.drawRoundedRectangle(0,0,effectiveDim.width,effectiveDim.height,radius,deltaDegree, RenderUtils.blendAlpha(0x121212, 0.0f)); for (int i = 1; i < getChildComponents().size(); i++) { MPanel childComponent = getChildComponents().get(i); - Gui.drawRect(7,childComponent.getBounds().y - 4, getBounds().width-7, childComponent.getBounds().y - 3, RenderUtils.blendAlpha(0x121212, 0.10f)); + Gui.drawRect(7,childComponent.getBounds().y - 4, effectiveDim.width-7, childComponent.getBounds().y - 3, RenderUtils.blendAlpha(0x121212, 0.10f)); } } -- cgit