diff options
author | bowser0000 <bowser0000@gmail.com> | 2022-08-15 20:40:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-15 20:40:34 -0400 |
commit | 3aa11b859a2a22be30a5035f7273e1a604a4dde4 (patch) | |
tree | 8f428b29a6b56cc9d010b0441bf41b6b78373548 /src/main/java/me/Danker/gui/buttons | |
parent | 33710ac6d9f57fa59e8dfb19a81b053346f1b097 (diff) | |
parent | daceea1e42371c295c36f80b3246601a6ffb2cc5 (diff) | |
download | SkyblockMod-3aa11b859a2a22be30a5035f7273e1a604a4dde4.tar.gz SkyblockMod-3aa11b859a2a22be30a5035f7273e1a604a4dde4.tar.bz2 SkyblockMod-3aa11b859a2a22be30a5035f7273e1a604a4dde4.zip |
1.8.7
Diffstat (limited to 'src/main/java/me/Danker/gui/buttons')
-rw-r--r-- | src/main/java/me/Danker/gui/buttons/FeatureButton.java | 17 | ||||
-rw-r--r-- | src/main/java/me/Danker/gui/buttons/LocationButton.java | 40 |
2 files changed, 38 insertions, 19 deletions
diff --git a/src/main/java/me/Danker/gui/buttons/FeatureButton.java b/src/main/java/me/Danker/gui/buttons/FeatureButton.java new file mode 100644 index 0000000..a997e09 --- /dev/null +++ b/src/main/java/me/Danker/gui/buttons/FeatureButton.java @@ -0,0 +1,17 @@ +package me.Danker.gui.buttons; + +import net.minecraft.client.gui.GuiButton; + +import java.util.Arrays; +import java.util.List; + +public class FeatureButton extends GuiButton { + + public List<String> hoverText; + + public FeatureButton(String displayString, String hoverText) { + super(0, 0, 0, displayString); + this.hoverText = Arrays.asList(hoverText.split("\n")); + } + +} diff --git a/src/main/java/me/Danker/gui/buttons/LocationButton.java b/src/main/java/me/Danker/gui/buttons/LocationButton.java index a8937fd..533bf83 100644 --- a/src/main/java/me/Danker/gui/buttons/LocationButton.java +++ b/src/main/java/me/Danker/gui/buttons/LocationButton.java @@ -13,21 +13,17 @@ public class LocationButton extends GuiButton { private String text; private String text2; private Integer text2Offset; + private int longestText; - public LocationButton(int buttonId, int x, int y, double width, double height, double scale, String text, String text2, Integer text2Offset) { - super(buttonId, x, y, text); + public LocationButton(int x, int y, double scale, String text, String text2, Integer text2Offset) { + super(0, x, y, text); this.x = x; this.y = y; - this.width = (int) width; - this.height = (int) height; this.scale = scale; this.text = text; this.text2 = text2; this.text2Offset = text2Offset; - } - - @Override - public void drawButton(Minecraft mc, int mouseX, int mouseY) { + String[] splitText; if (text2 == null) { splitText = text.split("\n"); @@ -37,24 +33,30 @@ public class LocationButton extends GuiButton { int longestText = -1; for (String s : splitText) { - int stringLength = mc.fontRendererObj.getStringWidth(s); + int stringLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth(s); if (stringLength > longestText) { longestText = stringLength; } } - - if (text2 == null) { - drawRect(x - 2, y - 2, (int) (x + longestText * scale + 3), (int) (y + (splitText.length * 9 + 3) * scale), 0x40D3D3D3); - } else { - drawRect(x - 2, y - 2, (int) (x + (longestText + text2Offset) * scale + 3), (int) (y + (splitText.length * 9 + 3) * scale), 0x40D3D3D3); - new TextRenderer(mc, text2, (int) (x + (text2Offset * scale)), y, scale); - } - new TextRenderer(mc, text, x, y, scale); + + this.longestText = longestText; + int offset = text2Offset == null ? 0 : text2Offset; + this.height = (int) ((splitText.length * 9 + 3) * scale); + this.width = (int) ((this.longestText + offset + 3) * scale); + } + + public LocationButton(int x, int y, double scale, String text) { + this(x, y, scale, text, null, null); } @Override - public void playPressSound(SoundHandler soundHandler) { - + public void drawButton(Minecraft mc, int mouseX, int mouseY) { + drawRect(x - 2, y - 2, x + width, y + height, 0x40D3D3D3); + if (text2 != null) new TextRenderer(mc, text2, (int) (x + (text2Offset * scale)), y, scale); + new TextRenderer(mc, text, x, y, scale); } + @Override + public void playPressSound(SoundHandler soundHandler) {} + } |