aboutsummaryrefslogtreecommitdiff
path: root/common/src/main/java/dev/isxander/yacl3/gui/TextScaledButtonWidget.java
diff options
context:
space:
mode:
authorisXander <xandersmith2008@gmail.com>2023-06-03 23:10:03 +0100
committerisXander <xandersmith2008@gmail.com>2023-06-04 16:25:09 +0100
commit3e36feeef60e56ef8cb7f737ac8eeab9fbcd6abb (patch)
treef9c3395b4da2235681b87a35ac5056a0724a181b /common/src/main/java/dev/isxander/yacl3/gui/TextScaledButtonWidget.java
parentd00a486d3bdf6105f8ca8af1034c384058b8c832 (diff)
downloadYetAnotherConfigLib-3e36feeef60e56ef8cb7f737ac8eeab9fbcd6abb.tar.gz
YetAnotherConfigLib-3e36feeef60e56ef8cb7f737ac8eeab9fbcd6abb.tar.bz2
YetAnotherConfigLib-3e36feeef60e56ef8cb7f737ac8eeab9fbcd6abb.zip
Change package and modid to yacl3 and yet_another_config_lib_3 respectively
Diffstat (limited to 'common/src/main/java/dev/isxander/yacl3/gui/TextScaledButtonWidget.java')
-rw-r--r--common/src/main/java/dev/isxander/yacl3/gui/TextScaledButtonWidget.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/common/src/main/java/dev/isxander/yacl3/gui/TextScaledButtonWidget.java b/common/src/main/java/dev/isxander/yacl3/gui/TextScaledButtonWidget.java
new file mode 100644
index 0000000..6ad0d1c
--- /dev/null
+++ b/common/src/main/java/dev/isxander/yacl3/gui/TextScaledButtonWidget.java
@@ -0,0 +1,34 @@
+package dev.isxander.yacl3.gui;
+
+import com.mojang.blaze3d.vertex.PoseStack;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.Font;
+import net.minecraft.client.gui.GuiGraphics;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.network.chat.Component;
+import net.minecraft.util.Mth;
+
+public class TextScaledButtonWidget extends TooltipButtonWidget {
+ public float textScale;
+
+ public TextScaledButtonWidget(Screen screen, int x, int y, int width, int height, float textScale, Component message, Component tooltip, OnPress onPress) {
+ super(screen, x, y, width, height, message, tooltip, onPress);
+ this.textScale = textScale;
+ }
+
+ public TextScaledButtonWidget(Screen screen, int x, int y, int width, int height, float textScale, Component message, OnPress onPress) {
+ this(screen, x, y, width, height, textScale, message, null, onPress);
+ }
+
+ @Override
+ public void renderString(GuiGraphics graphics, Font textRenderer, int color) {
+ Font font = Minecraft.getInstance().font;
+ PoseStack pose = graphics.pose();
+
+ pose.pushPose();
+ pose.translate(((this.getX() + this.width / 2f) - font.width(getMessage()) * textScale / 2), (float)this.getY() + (this.height - 8 * textScale) / 2f / textScale, 0);
+ pose.scale(textScale, textScale, 1);
+ graphics.drawString(font, getMessage(), 0, 0, color | Mth.ceil(this.alpha * 255.0F) << 24, true);
+ pose.popPose();
+ }
+}