diff options
author | syeyoung <cyong06@naver.com> | 2021-02-05 17:29:09 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-02-05 17:29:09 +0900 |
commit | 6b4e2499ece7f4328381a88380baea85fe24246d (patch) | |
tree | 07a1da8b9d2b6f543d5905a29adc2a5a1c46736d /src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java | |
parent | 3d20d63e025b827ae9a8e7bd62b436fda7986071 (diff) | |
download | Skyblock-Dungeons-Guide-6b4e2499ece7f4328381a88380baea85fe24246d.tar.gz Skyblock-Dungeons-Guide-6b4e2499ece7f4328381a88380baea85fe24246d.tar.bz2 Skyblock-Dungeons-Guide-6b4e2499ece7f4328381a88380baea85fe24246d.zip |
Gui Overhaul part 1
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java')
-rwxr-xr-x | src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java index ddf1c8a9..dc14264b 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java @@ -1,6 +1,7 @@ package kr.syeyoung.dungeonsguide.gui.elements; import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Getter; import lombok.Setter; import net.minecraft.client.Minecraft; @@ -35,16 +36,24 @@ public class MTabbedPane extends MPanel { } } + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { + Gui.drawRect(0, 15, getBounds().width, getBounds().height, 0xFF444444); + } + public void addTab(String tab, MPanel panel) { MPanel panel2 = new MPanel() ; panel2.add(panel); panel2.setBackgroundColor(background2); tabs.put(tab, panel2); - panel2.setBounds(new Rectangle(0,15,getBounds().width, getBounds().height-15)); + panel2.setBounds(new Rectangle(1,16,getBounds().width-2, getBounds().height-17)); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; MTabButton button = new MTabButton(this, tab); - button.setBackgroundColor(background2.brighter()); - button.setBounds(new Rectangle(buttons.size()* 50, 0, 50, 15)); + int totalX = 0; + for (MTabButton button1:buttons.values()) + totalX += button1.getBounds().width; + button.setBounds(new Rectangle(totalX, 0, Math.max(25, fr.getStringWidth(tab) + 6), 15)); buttons.put(tab, button); if (tabs.size() == 1) selectedKey = tab; @@ -61,7 +70,7 @@ public class MTabbedPane extends MPanel { public void resize(int parentWidth, int parentHeight) { this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); for (MPanel ma:tabs.values()) - ma.setBounds(new Rectangle(0,15,parentWidth, parentHeight-15)); + ma.setBounds(new Rectangle(1,16,getBounds().width-2, getBounds().height-17)); } @Override @@ -79,9 +88,9 @@ public class MTabbedPane extends MPanel { private String text; private Color foreground = Color.white; - private Color hover = new Color(236, 236, 236, 64); - private Color clicked = new Color(30,30,30,0); - private Color selected = new Color(0,0,0,255); + private Color hover = new Color(154, 154, 154, 255); + private Color clicked = new Color(88, 88, 88,255); + private Color selected = new Color(111, 111, 111,255); private Color disabled = new Color(0,0,0); private boolean enabled = true; @@ -105,13 +114,14 @@ public class MTabbedPane extends MPanel { } else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) { bg = hover; } + Gui.drawRect(0, tabbedPane.getSelectedKey().equals(text) ? 0 : 2, getBounds().width, getBounds().height, 0xFF444444); if (bg != null) - Gui.drawRect(0,0,getBounds().width, getBounds().height, bg.getRGB()); + Gui.drawRect(1,tabbedPane.getSelectedKey().equals(text) ? 1 : 3,getBounds().width - 1, getBounds().height, bg.getRGB()); FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj; int width = renderer.getStringWidth(text); int x = (getBounds().width - width) / 2; - int y = (getBounds().height - renderer.FONT_HEIGHT) / 2; + int y = (getBounds().height - 3 - renderer.FONT_HEIGHT) / 2 + 3; renderer.drawString(text, x,y, foreground.getRGB()); } |