aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-02-04 21:57:08 +0900
committersyeyoung <cyong06@naver.com>2021-02-04 21:57:08 +0900
commit3d20d63e025b827ae9a8e7bd62b436fda7986071 (patch)
tree0477ec0406ce55698fdb0d73f35029c697cf378f /src/main/java
parentc37bda238c5072fa50dfa2d87aa137e1bdf5c4ac (diff)
downloadSkyblock-Dungeons-Guide-3d20d63e025b827ae9a8e7bd62b436fda7986071.tar.gz
Skyblock-Dungeons-Guide-3d20d63e025b827ae9a8e7bd62b436fda7986071.tar.bz2
Skyblock-Dungeons-Guide-3d20d63e025b827ae9a8e7bd62b436fda7986071.zip
tab button inside tab pane
Diffstat (limited to 'src/main/java')
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabButton.java61
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java54
2 files changed, 54 insertions, 61 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabButton.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabButton.java
deleted file mode 100755
index cf6f6fc7..00000000
--- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabButton.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package kr.syeyoung.dungeonsguide.gui.elements;
-
-import kr.syeyoung.dungeonsguide.gui.MPanel;
-import lombok.Getter;
-import lombok.Setter;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.gui.Gui;
-
-import java.awt.*;
-
-@Getter
-@Setter
-public class MTabButton 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 disabled = new Color(0,0,0);
-
- private boolean enabled = true;
-
- private MTabbedPane tabbedPane;
-
- public MTabButton(MTabbedPane tabbedPane, String key) {
- this.tabbedPane = tabbedPane;
- this.text = key;
- }
-
- @Override
- public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) {
- Dimension bounds = getSize();
-
- Color bg = null;
- if (!enabled) {
- bg = disabled;
- } else if (tabbedPane.getSelectedKey().equals(text)) {
- bg = selected;
- } else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) {
- bg = hover;
- }
- if (bg != null)
- Gui.drawRect(0,0,getBounds().width, 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;
-
- renderer.drawString(text, x,y, foreground.getRGB());
- }
-
- @Override
- public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
- if (lastAbsClip.contains(absMouseX, absMouseY)) {
- tabbedPane.setSelectedKey(text);
- }
- }
-}
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 96b2e81d..ddf1c8a9 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java
@@ -3,6 +3,9 @@ package kr.syeyoung.dungeonsguide.gui.elements;
import kr.syeyoung.dungeonsguide.gui.MPanel;
import lombok.Getter;
import lombok.Setter;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.Gui;
import java.awt.*;
import java.util.ArrayList;
@@ -69,4 +72,55 @@ public class MTabbedPane extends MPanel {
this.bounds.width = bounds.width;
this.bounds.height = bounds.height;
}
+
+ @Getter
+ @Setter
+ public static class MTabButton 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 disabled = new Color(0,0,0);
+
+ private boolean enabled = true;
+
+ private MTabbedPane tabbedPane;
+
+ public MTabButton(MTabbedPane tabbedPane, String key) {
+ this.tabbedPane = tabbedPane;
+ this.text = key;
+ }
+
+ @Override
+ public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) {
+ Dimension bounds = getSize();
+
+ Color bg = null;
+ if (!enabled) {
+ bg = disabled;
+ } else if (tabbedPane.getSelectedKey().equals(text)) {
+ bg = selected;
+ } else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) {
+ bg = hover;
+ }
+ if (bg != null)
+ Gui.drawRect(0,0,getBounds().width, 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;
+
+ renderer.drawString(text, x,y, foreground.getRGB());
+ }
+
+ @Override
+ public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
+ if (lastAbsClip.contains(absMouseX, absMouseY)) {
+ tabbedPane.setSelectedKey(text);
+ }
+ }
+ }
}