aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/gui/buttons
diff options
context:
space:
mode:
authorbowser0000 <bowser0000@gmail.com>2020-10-16 15:20:27 -0400
committerbowser0000 <bowser0000@gmail.com>2020-10-16 15:20:27 -0400
commitff7001b95634e610a56220c58bc9619c063203da (patch)
treefdb0bffb128c4a3cf45584b5392ad5c46527cfc0 /src/main/java/me/Danker/gui/buttons
parent68111a9d9c9d403436dc2041010f337580d48d60 (diff)
downloadSkyblockMod-ff7001b95634e610a56220c58bc9619c063203da.tar.gz
SkyblockMod-ff7001b95634e610a56220c58bc9619c063203da.tar.bz2
SkyblockMod-ff7001b95634e610a56220c58bc9619c063203da.zip
Add ability to drag around displays WIP
WIP, buggy with scaling
Diffstat (limited to 'src/main/java/me/Danker/gui/buttons')
-rw-r--r--src/main/java/me/Danker/gui/buttons/LocationButton.java61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/main/java/me/Danker/gui/buttons/LocationButton.java b/src/main/java/me/Danker/gui/buttons/LocationButton.java
new file mode 100644
index 0000000..061f198
--- /dev/null
+++ b/src/main/java/me/Danker/gui/buttons/LocationButton.java
@@ -0,0 +1,61 @@
+package me.Danker.gui.buttons;
+
+import me.Danker.handlers.TextRenderer;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.SoundHandler;
+import net.minecraft.client.gui.GuiButton;
+
+public class LocationButton extends GuiButton {
+
+ private int x;
+ private int y;
+ private double scale;
+ private String text;
+ private String text2;
+ private Integer text2Offset;
+
+ 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);
+ 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");
+ } else {
+ splitText = text2.split("\n");
+ }
+ int index = 0;
+ int longestText = -1;
+ for (int i = 0; i < splitText.length; i++) {
+ int stringLength = mc.fontRendererObj.getStringWidth(splitText[i]);
+ if (stringLength > longestText) {
+ index = i;
+ 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);
+ }
+
+ @Override
+ public void playPressSound(SoundHandler soundHandler) {
+
+ }
+
+}