From 795a8b1a6c7d7137b626efceb78d6dbbd476957c Mon Sep 17 00:00:00 2001 From: tanishisherewithhh <120117618+tanishisherewithhh@users.noreply.github.com> Date: Sun, 14 Apr 2024 15:38:06 +0530 Subject: [PATCH] Polishing changes --- .../dynamichud/config/GlobalConfig.java | 7 +++-- .../utils/contextmenu/ContextMenu.java | 12 ++++--- .../dynamichud/utils/contextmenu/Option.java | 1 - .../contextmenu/options/ColorOption.java | 11 ++++--- .../contextmenu/options/DoubleOption.java | 8 +++-- .../utils/contextmenu/options/ListOption.java | 2 +- .../contextmenu/options/RunnableOption.java | 7 +++-- .../contextmenu/options/SubMenuOption.java | 8 +++-- .../options/coloroption/AlphaSlider.java | 2 +- .../coloroption/ColorGradientPicker.java | 31 +++++++++++++------ .../options/coloroption/GradientBox.java | 2 +- .../dynamichud/widget/Widget.java | 13 ++++---- .../dynamichud/widget/WidgetRenderer.java | 2 +- .../dynamichud/widgets/TextWidget.java | 28 +++++++++++------ 14 files changed, 85 insertions(+), 49 deletions(-) diff --git a/src/main/java/com/tanishisherewith/dynamichud/config/GlobalConfig.java b/src/main/java/com/tanishisherewith/dynamichud/config/GlobalConfig.java index 0fd6e0a..7c34869 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/config/GlobalConfig.java +++ b/src/main/java/com/tanishisherewith/dynamichud/config/GlobalConfig.java @@ -23,13 +23,13 @@ public class GlobalConfig { * Common scale for all widgets. Set by the user using YACL. */ @SerialEntry - public float scale = 1.0f; + private float scale = 1.0f; public static GlobalConfig get() { return INSTANCE; } - public Screen createYACLGUI() { + public final Screen createYACLGUI() { return YetAnotherConfigLib.createBuilder() .title(Text.literal("DynamicHUD config screen.")) .category(ConfigCategory.createBuilder() @@ -49,4 +49,7 @@ public Screen createYACLGUI() { .build() .generateScreen(null); } + public float getScale(){ + return scale; + } } diff --git a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/ContextMenu.java b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/ContextMenu.java index 7ce748c..dfef1f5 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/ContextMenu.java +++ b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/ContextMenu.java @@ -12,7 +12,9 @@ public class ContextMenu { public int x, y; public int width = 0, finalWidth = 0; public int height = 0; - public Color backgroundColor = new Color(107, 112, 126, 124);// Semi-transparent light greyish - blue color + public Color backgroundColor = new Color(107, 112, 126, 124); + private Color darkerBorderColor = backgroundColor.darker().darker().darker().darker().darker().darker(); + //Todo: Add padding around the rectangle instead of just one side. public int padding = 5; // The amount of padding around the rectangle public int heightOffset = 4; // Height offset from the widget public boolean shouldDisplay = false; @@ -39,7 +41,7 @@ public void render(DrawContext drawContext, int x, int y, int height, int mouseX // Draw the background DrawHelper.drawRoundedRectangle(drawContext.getMatrices().peek().getPositionMatrix(), this.x - 1, this.y, this.width, this.height, 2,backgroundColor.getRGB()); if(drawBorder){ - DrawHelper.drawOutlineRoundedBox(drawContext.getMatrices().peek().getPositionMatrix(), this.x - 1,this.y,width + 1,this.height,2,0.7f,backgroundColor.darker().darker().darker().darker().darker().getRGB()); + DrawHelper.drawOutlineRoundedBox(drawContext.getMatrices().peek().getPositionMatrix(), this.x - 1,this.y,width + 1,this.height,2,0.7f,darkerBorderColor.getRGB()); } int yOffset = this.y + 3; @@ -47,13 +49,13 @@ public void render(DrawContext drawContext, int x, int y, int height, int mouseX for (Option option : options) { if (!option.shouldRender()) continue; if(isMouseOver(mouseX,mouseY, this.x +1,yOffset-1,this.finalWidth - 2,option.height)){ - DrawHelper.drawRoundedRectangle(drawContext.getMatrices().peek().getPositionMatrix(), this.x,yOffset - 1.24f,this.finalWidth - 2,option.height + 0.48f,2,backgroundColor.darker().darker().getRGB()); + DrawHelper.drawRoundedRectangle(drawContext.getMatrices().peek().getPositionMatrix(), this.x,yOffset - 1.24f,this.finalWidth - 2,option.height + 0.48f,2,backgroundColor.darker().darker().getRGB()); } option.render(drawContext, x + 2, yOffset,mouseX,mouseY); - this.width = Math.max(this.width, option.width + padding); + this.width = Math.max(this.width, option.width); yOffset += option.height + 1; } - this.width = this.width + 3; + this.width = this.width + padding; this.finalWidth = this.width; this.height = (yOffset - this.y); diff --git a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/Option.java b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/Option.java index 7f24f05..dfea08c 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/Option.java +++ b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/Option.java @@ -18,7 +18,6 @@ public abstract class Option { protected Consumer setter; protected T defaultValue = null; protected MinecraftClient mc = MinecraftClient.getInstance(); - private Widget selectedWidget; // The widget that this context menu is associated with public Option(Supplier getter, Consumer setter) { this.getter = getter; diff --git a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/ColorOption.java b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/ColorOption.java index ab92642..b30f8a6 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/ColorOption.java +++ b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/ColorOption.java @@ -21,7 +21,8 @@ public ColorOption(String name, ContextMenu parentMenu, Supplier getter, super(getter, setter); this.name = name; this.parentMenu = parentMenu; - colorPicker = new ColorGradientPicker(x + this.parentMenu.width + 10, y - 10, value, this::set, 50, 100); + System.out.println(get()); + colorPicker = new ColorGradientPicker(x + this.parentMenu.finalWidth, y - 10, get(), this::set, 50, 100); } @Override @@ -30,13 +31,13 @@ public void render(DrawContext drawContext, int x, int y) { int color = isVisible ? Color.GREEN.getRGB() : Color.RED.getRGB(); this.height = mc.textRenderer.fontHeight; - this.width = mc.textRenderer.getWidth(name) + 12; + this.width = mc.textRenderer.getWidth(name) + 8; drawContext.drawText(mc.textRenderer, Text.of(name), x, y, color, false); int shadowOpacity = Math.min(value.getAlpha(),90); DrawHelper.drawRoundedRectangleWithShadowBadWay(drawContext.getMatrices().peek().getPositionMatrix(), - x + width - 8, - y, + x + width - 4, + y - 1, 8, 8, 2, @@ -45,7 +46,7 @@ public void render(DrawContext drawContext, int x, int y) { 1, 1); - colorPicker.render(drawContext, this.x + width / 3 + parentMenu.width + 10, y - 10); + colorPicker.render(drawContext, this.x + parentMenu.finalWidth + 7, y - 10); } @Override diff --git a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/DoubleOption.java b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/DoubleOption.java index 399a10c..90123ee 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/DoubleOption.java +++ b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/DoubleOption.java @@ -1,6 +1,7 @@ package com.tanishisherewith.dynamichud.utils.contextmenu.options; import com.tanishisherewith.dynamichud.helpers.DrawHelper; +import com.tanishisherewith.dynamichud.utils.contextmenu.ContextMenu; import com.tanishisherewith.dynamichud.utils.contextmenu.Option; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; @@ -15,8 +16,9 @@ public class DoubleOption extends Option { float step = 0.1f; private boolean isDragging = false; private double minValue = 0.0, maxValue = 0.0; + ContextMenu parentMenu; - public DoubleOption(String name, double minValue, double maxValue, float step, Supplier getter, Consumer setter) { + public DoubleOption(String name, double minValue, double maxValue, float step, Supplier getter, Consumer setter, ContextMenu parentMenu) { super(getter, setter); this.name = name; this.value = get(); @@ -25,6 +27,7 @@ public DoubleOption(String name, double minValue, double maxValue, float step, S this.width = 30; this.height = 16; this.step = step; + this.parentMenu = parentMenu; Validate.isTrue(this.step > 0.0f, "Step cannot be less than or equal to 0 (zero)"); } @@ -33,8 +36,9 @@ public void render(DrawContext drawContext, int x, int y) { super.render(drawContext, x, y); value = get(); - this.width = 30; + this.width = 35; this.height = 16; + // Draw the label TextRenderer textRenderer = mc.textRenderer; DrawHelper.scaleAndPosition(drawContext.getMatrices(), x, y, 0.7f); diff --git a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/ListOption.java b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/ListOption.java index e7d63bb..a7aef94 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/ListOption.java +++ b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/ListOption.java @@ -32,7 +32,7 @@ public void render(DrawContext drawContext, int x, int y) { super.render(drawContext, x, y); value = get(); - this.height = mc.textRenderer.fontHeight; + this.height = mc.textRenderer.fontHeight + 1; this.width = mc.textRenderer.getWidth(name + ": " + value.toString()) + 1; drawContext.drawText(mc.textRenderer, Text.of(name + ": "), x, y, Color.WHITE.getRGB(), false); diff --git a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/RunnableOption.java b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/RunnableOption.java index 6b8c4f5..a1b3497 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/RunnableOption.java +++ b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/RunnableOption.java @@ -25,6 +25,9 @@ public RunnableOption(String name, Supplier getter, Consumer s this.name = "Run: " + name; // prepend the "run" symbol to the name this.task = task; } + Color DARK_RED = new Color(116, 0, 0); + Color DARK_GREEN = new Color(24, 132, 0, 226); + @Override public void render(DrawContext drawContext, int x, int y) { @@ -32,8 +35,8 @@ public void render(DrawContext drawContext, int x, int y) { value = get(); this.height = mc.textRenderer.fontHeight; - this.width = mc.textRenderer.getWidth("Run: " + name) + 1; - int color = value ? Color.BLUE.getRGB() : Color.GRAY.getRGB(); + this.width = mc.textRenderer.getWidth("Run: " + name); + int color = value ? DARK_GREEN.getRGB() : DARK_RED.getRGB(); drawContext.drawText(mc.textRenderer, Text.of(name), x, y, color, false); } diff --git a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/SubMenuOption.java b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/SubMenuOption.java index 6823ad0..c917ee8 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/SubMenuOption.java +++ b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/SubMenuOption.java @@ -29,7 +29,7 @@ public SubMenuOption(String name, @NotNull ContextMenu parentMenu, Supplier= y && mouseY <= y + height) { alphaHandleY = (int) mouseY - y; alpha = 1.0f - (alphaHandleY / (float) height); if (alpha < 0.0f) { diff --git a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/coloroption/ColorGradientPicker.java b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/coloroption/ColorGradientPicker.java index a11d61d..8d70df3 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/coloroption/ColorGradientPicker.java +++ b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/coloroption/ColorGradientPicker.java @@ -20,22 +20,26 @@ public class ColorGradientPicker { private final int boxSize; private int x, y; private boolean display = false; + private final Color initialColor; public ColorGradientPicker(int x, int y, Color initialColor, Consumer onColorSelected, int boxSize, int colors) { this.x = x; this.y = y; + this.initialColor = initialColor; this.onColorSelected = onColorSelected; - float[] hsv = Color.RGBtoHSB(initialColor.getRed(), initialColor.getGreen(), initialColor.getBlue(), null); - this.boxSize = boxSize; this.gradientSlider = new GradientSlider(x, y, colors, 10); - this.gradientSlider.setHue(hsv[0]); - this.gradientBox = new GradientBox(x, y + 20, boxSize); + this.alphaSlider = new AlphaSlider(x, y, 10, boxSize, initialColor); + + float[] hsv = new float[3]; + Color.RGBtoHSB(initialColor.getRed(), initialColor.getGreen(), initialColor.getBlue(), hsv); + + this.boxSize = boxSize; + this.gradientSlider.setHue(hsv[0]); this.gradientBox.setHue(hsv[0]); this.gradientBox.setSaturation(hsv[1]); this.gradientBox.setValue(hsv[2]); - this.alphaSlider = new AlphaSlider(x, y, 10, boxSize, initialColor); this.colorPickerButton = new ColorPickerButton(x + boxSize + 8, y + 20, 30, 18); } @@ -57,10 +61,10 @@ public void render(DrawContext drawContext, int x1, int y1) { if (!display) { return; } - gradientSlider.render(drawContext, x + 30, y + client.textRenderer.fontHeight + 4); - gradientBox.render(drawContext, x + 30, y + client.textRenderer.fontHeight + gradientSlider.getHeight() + 10); - colorPickerButton.render(drawContext, x + 54 + boxSize, y + client.textRenderer.fontHeight + gradientSlider.getHeight() + 8); - alphaSlider.render(drawContext, x + 40 + boxSize, y + client.textRenderer.fontHeight + gradientSlider.getHeight() + 10); + gradientSlider.render(drawContext, x, y + client.textRenderer.fontHeight + 4); + gradientBox.render(drawContext, x, y + client.textRenderer.fontHeight + gradientSlider.getHeight() + 10); + colorPickerButton.render(drawContext, x + 24 + boxSize, y + client.textRenderer.fontHeight + gradientSlider.getHeight() + 8); + alphaSlider.render(drawContext, x + 10 + boxSize, y + client.textRenderer.fontHeight + gradientSlider.getHeight() + 10); if (colorPickerButton.isPicking()) { // Draw the preview box near cursor @@ -92,6 +96,15 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { if (!display) { return false; } + + float[] hsv1 = new float[3]; + Color.RGBtoHSB(initialColor.getRed(), initialColor.getGreen(), initialColor.getBlue(), hsv1); + + this.gradientSlider.setHue(hsv1[0]); + this.gradientBox.setHue(hsv1[0]); + this.gradientBox.setSaturation(hsv1[1]); + this.gradientBox.setValue(hsv1[2]); + if (colorPickerButton.onClick(mouseX, mouseY, button)) { return true; } else if (gradientSlider.isMouseOver(mouseX, mouseY)) { diff --git a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/coloroption/GradientBox.java b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/coloroption/GradientBox.java index f30b184..49d7699 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/coloroption/GradientBox.java +++ b/src/main/java/com/tanishisherewith/dynamichud/utils/contextmenu/options/coloroption/GradientBox.java @@ -28,7 +28,7 @@ public void render(DrawContext drawContext, int x, int y) { DrawHelper.drawOutlinedBox(drawContext, x - 2, y - 2, x + size + 2, y + size + 2, -1); // Draw the gradient - com.tanishisherewith.dynamichud.helpers.DrawHelper.drawRoundedGradientRectangle(drawContext.getMatrices().peek().getPositionMatrix(), Color.BLACK, Color.BLACK, Color.getHSBColor(hue, 1.0f, 1.0f), Color.WHITE, x, y, size, size, 2); + DrawHelper.drawRoundedGradientRectangle(drawContext.getMatrices().peek().getPositionMatrix(), Color.BLACK, Color.BLACK, Color.getHSBColor(hue, 1.0f, 1.0f), Color.WHITE, x, y, size, size, 2); // Draw the handle float handleSize = 3; diff --git a/src/main/java/com/tanishisherewith/dynamichud/widget/Widget.java b/src/main/java/com/tanishisherewith/dynamichud/widget/Widget.java index bda7cbf..31bb9e6 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/widget/Widget.java +++ b/src/main/java/com/tanishisherewith/dynamichud/widget/Widget.java @@ -53,7 +53,7 @@ public abstract class Widget { /** * Scale of the current widget. * - * @see GlobalConfig#scale + * @see GlobalConfig#getScale() */ protected float scale = 1.0f; //Dimensions of the widget @@ -68,7 +68,7 @@ public Widget(WidgetData DATA, String modId) { } /** - * This method is called at the end of the {@link Widget#Widget(WidgetData)} constructor. + * This method is called at the end of the {@link Widget#Widget(WidgetData, String)} constructor. */ public void init() { @@ -127,11 +127,11 @@ public boolean isOverlapping(Widget other) { /** * Renders the widget on the screen. */ - public void render(DrawContext drawContext, int mouseX, int mouseY) { + public final void render(DrawContext drawContext, int mouseX, int mouseY) { if (!shouldDisplay()) return; if (shouldScale) { - DrawHelper.scaleAndPosition(drawContext.getMatrices(), getX(), getY(), GlobalConfig.get().scale); + DrawHelper.scaleAndPosition(drawContext.getMatrices(), getX(), getY(), GlobalConfig.get().getScale()); } renderWidget(drawContext, mouseX, mouseY); @@ -144,11 +144,11 @@ public void render(DrawContext drawContext, int mouseX, int mouseY) { /** * Renders the widget on the editor screen. */ - public void renderInEditor(DrawContext drawContext, int mouseX, int mouseY) { + public final void renderInEditor(DrawContext drawContext, int mouseX, int mouseY) { displayBg(drawContext); if (shouldScale) { - DrawHelper.scaleAndPosition(drawContext.getMatrices(), getX(), getY(), GlobalConfig.get().scale); + DrawHelper.scaleAndPosition(drawContext.getMatrices(), getX(), getY(), GlobalConfig.get().getScale()); } renderWidgetInEditor(drawContext, mouseX, mouseY); @@ -183,6 +183,7 @@ private void renderWidgetInEditor(DrawContext context, int mouseX, int mouseY) { renderWidget(context, mouseX, mouseY); } + /* Input related methods. Override with super call to add your own input-based code like contextMenu */ public boolean mouseClicked(double mouseX, double mouseY, int button) { diff --git a/src/main/java/com/tanishisherewith/dynamichud/widget/WidgetRenderer.java b/src/main/java/com/tanishisherewith/dynamichud/widget/WidgetRenderer.java index b850815..db0c9c5 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/widget/WidgetRenderer.java +++ b/src/main/java/com/tanishisherewith/dynamichud/widget/WidgetRenderer.java @@ -42,7 +42,7 @@ public void shouldRenderInGameHud(boolean renderInGameHud) { } public void renderWidgets(DrawContext context, int mouseX, int mouseY) { - if (WidgetManager.getWidgets().isEmpty()) return; + if (WidgetManager.getWidgets().isEmpty() || DynamicHUD.MC.getDebugHud().shouldShowDebugHud()) return; Screen currentScreen = DynamicHUD.MC.currentScreen; diff --git a/src/main/java/com/tanishisherewith/dynamichud/widgets/TextWidget.java b/src/main/java/com/tanishisherewith/dynamichud/widgets/TextWidget.java index 64556b3..67924b4 100644 --- a/src/main/java/com/tanishisherewith/dynamichud/widgets/TextWidget.java +++ b/src/main/java/com/tanishisherewith/dynamichud/widgets/TextWidget.java @@ -4,11 +4,7 @@ import com.tanishisherewith.dynamichud.helpers.ColorHelper; import com.tanishisherewith.dynamichud.utils.DynamicValueRegistry; import com.tanishisherewith.dynamichud.utils.contextmenu.ContextMenu; -import com.tanishisherewith.dynamichud.utils.contextmenu.options.BooleanOption; -import com.tanishisherewith.dynamichud.utils.contextmenu.options.DoubleOption; -import com.tanishisherewith.dynamichud.utils.contextmenu.options.EnumOption; -import com.tanishisherewith.dynamichud.utils.contextmenu.options.ListOption; -import com.tanishisherewith.dynamichud.utils.contextmenu.options.ColorOption; +import com.tanishisherewith.dynamichud.utils.contextmenu.options.*; import com.tanishisherewith.dynamichud.widget.Widget; import com.tanishisherewith.dynamichud.widget.WidgetData; import net.minecraft.client.gui.DrawContext; @@ -18,6 +14,7 @@ import java.awt.*; import java.util.Arrays; import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Supplier; @@ -76,16 +73,26 @@ public void createMenu() { menu = new ContextMenu(getX(), getY()); menu.addOption(new BooleanOption("Shadow", () -> this.shadow, value -> this.shadow = value)); menu.addOption(new BooleanOption("Rainbow", () -> this.rainbow, value -> this.rainbow = value)); - menu.addOption(new ColorOption("TextColor", menu, () -> textColor, value -> textColor = value)); - menu.addOption(new DoubleOption("RainbowSpeed", 1, 4, 1.0f, () -> (double) this.rainbowSpeed, value -> this.rainbowSpeed = value.intValue())); + menu.addOption(new ColorOption("TextColor", menu, () -> this.textColor, value -> this.textColor = value)); + menu.addOption(new DoubleOption("RainbowSpeed", 1, 4, 1.0f, () -> (double) this.rainbowSpeed, value -> this.rainbowSpeed = value.intValue(),menu)); /* TEST */ AtomicReference enums = new AtomicReference<>(Enum.Enum1); AtomicReference option = new AtomicReference<>("Enum1"); - menu.addOption(new EnumOption<>("Enum", enums::get, enums::set, Enum.values())); - List options = Arrays.asList("List1", "List2", "List3"); + AtomicBoolean running = new AtomicBoolean(false); + AtomicBoolean subMenu = new AtomicBoolean(false); + menu.addOption(new EnumOption<>("Enum", enums::get, enums::set, Enum.values())); menu.addOption(new ListOption<>("List", option::get, option::set, options)); + menu.addOption(new RunnableOption("Runnable Test",running::get,running::set, this::printStuff)); + SubMenuOption subMenuOption = new SubMenuOption("SubMenu",menu,subMenu::get,subMenu::set); + subMenuOption.getSubMenu().addOption(new BooleanOption("Shadows2", () -> this.shadow, value -> this.shadow = value)); + subMenuOption.getSubMenu().addOption(new BooleanOption("Shadows3", () -> this.shadow, value -> this.shadow = value)); + subMenuOption.getSubMenu().addOption(new BooleanOption("Shadows4", () -> this.shadow, value -> this.shadow = value)); + menu.addOption(subMenuOption); + } + public void printStuff(){ + System.out.println("Runnable works"); } @Override @@ -94,7 +101,7 @@ public void renderWidget(DrawContext drawContext, int mouseX, int mouseY) { if (textSupplier != null) { String text = textSupplier.get(); drawContext.drawText(mc.textRenderer, text, getX() + 2, getY() + 2, color, shadow); - widgetBox.setSizeAndPosition(getX(), getY(), mc.textRenderer.getWidth(text) + 3, mc.textRenderer.fontHeight + 2, this.shouldScale, GlobalConfig.get().scale); + widgetBox.setSizeAndPosition(getX(), getY(), mc.textRenderer.getWidth(text) + 3, mc.textRenderer.fontHeight + 2, this.shouldScale, GlobalConfig.get().getScale()); } menu.render(drawContext, getX(), getY(), (int) Math.ceil(getHeight()),mouseX,mouseY); } @@ -161,6 +168,7 @@ public void readFromTag(NbtCompound tag) { dynamicValueRegistry = dvr; return; } + createMenu(); } public enum Enum {