diff options
author | isXander <xandersmith2008@gmail.com> | 2022-11-13 19:04:45 +0000 |
---|---|---|
committer | isXander <xandersmith2008@gmail.com> | 2022-11-13 19:04:55 +0000 |
commit | 6f3dc40a6bc554b6decb685cb6d1eb6370b1eea6 (patch) | |
tree | 3245fcd0782ff44c9f7c62f26844ab4c7510bbeb /src/main/java/dev/isxander/yacl/gui/controllers/LabelController.java | |
parent | b9052c99778b5ad6e54e720f6f10756e8ef8cdc0 (diff) | |
download | YetAnotherConfigLib-6f3dc40a6bc554b6decb685cb6d1eb6370b1eea6.tar.gz YetAnotherConfigLib-6f3dc40a6bc554b6decb685cb6d1eb6370b1eea6.tar.bz2 YetAnotherConfigLib-6f3dc40a6bc554b6decb685cb6d1eb6370b1eea6.zip |
lots of QOL and minor improvements
smooth category scrolling
individual reset buttons for all controllers
separate Dimension into Dimension and MutableDimension to prevent mods from modifying controller dimensions without invoking the hooks
made the dimension field private in AbstractWidget so people can't modify it without the method setDimension
new Option API method to check if pending value is equal to default value
add documentation to ConfigInstance
fix bug where Option#requestSetDefault and Option#forgetPendingValue implementations weren't notifying listeners
Diffstat (limited to 'src/main/java/dev/isxander/yacl/gui/controllers/LabelController.java')
-rw-r--r-- | src/main/java/dev/isxander/yacl/gui/controllers/LabelController.java | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/main/java/dev/isxander/yacl/gui/controllers/LabelController.java b/src/main/java/dev/isxander/yacl/gui/controllers/LabelController.java index 98f69e1..8369680 100644 --- a/src/main/java/dev/isxander/yacl/gui/controllers/LabelController.java +++ b/src/main/java/dev/isxander/yacl/gui/controllers/LabelController.java @@ -62,9 +62,9 @@ public class LabelController implements Controller<Text> { public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { updateText(); - float y = dim.y(); + float y = getDimension().y(); for (OrderedText text : wrappedText) { - textRenderer.drawWithShadow(matrices, text, dim.x(), y + getYPadding(), option().available() ? -1 : 0xFFA0A0A0); + textRenderer.drawWithShadow(matrices, text, getDimension().x(), y + getYPadding(), option().available() ? -1 : 0xFFA0A0A0); y += textRenderer.fontHeight; } } @@ -72,7 +72,7 @@ public class LabelController implements Controller<Text> { @Override public void postRender(MatrixStack matrices, int mouseX, int mouseY, float delta) { if (isMouseOver(mouseX, mouseY)) { - YACLScreen.renderMultilineTooltip(matrices, textRenderer, wrappedTooltip, dim.centerX(), dim.y() - 5, dim.yLimit() + 5, screen.width, screen.height); + YACLScreen.renderMultilineTooltip(matrices, textRenderer, wrappedTooltip, getDimension().centerX(), getDimension().y() - 5, getDimension().yLimit() + 5, screen.width, screen.height); Style style = getStyle(mouseX, mouseY); if (style != null && style.getHoverEvent() != null) { @@ -90,8 +90,8 @@ public class LabelController implements Controller<Text> { } else { Text text = hoverEvent.getValue(HoverEvent.Action.SHOW_TEXT); if (text != null) { - MultilineText multilineText = MultilineText.create(textRenderer, text, dim.width()); - YACLScreen.renderMultilineTooltip(matrices, textRenderer, multilineText, dim.centerX(), dim.y(), dim.yLimit(), screen.width, screen.height); + MultilineText multilineText = MultilineText.create(textRenderer, text, getDimension().width()); + YACLScreen.renderMultilineTooltip(matrices, textRenderer, multilineText, getDimension().centerX(), getDimension().y(), getDimension().yLimit(), screen.width, screen.height); } } } @@ -109,15 +109,15 @@ public class LabelController implements Controller<Text> { } protected Style getStyle(int mouseX, int mouseY) { - if (!dim.isPointInside(mouseX, mouseY)) + if (!getDimension().isPointInside(mouseX, mouseY)) return null; - int x = mouseX - dim.x(); - int y = mouseY - dim.y() - getYPadding(); + int x = mouseX - getDimension().x(); + int y = mouseY - getDimension().y() - getYPadding(); int line = y / textRenderer.fontHeight; - if (x < 0 || x > dim.xLimit()) return null; - if (y < 0 || y > dim.yLimit()) return null; + if (x < 0 || x > getDimension().xLimit()) return null; + if (y < 0 || y > getDimension().yLimit()) return null; if (line < 0 || line >= wrappedText.size()) return null; return textRenderer.getTextHandler().getStyleAt(wrappedText.get(line), x); @@ -128,8 +128,8 @@ public class LabelController implements Controller<Text> { } private void updateText() { - wrappedText = textRenderer.wrapLines(formatValue(), dim.width()); - dim.setHeight(wrappedText.size() * textRenderer.fontHeight + getYPadding() * 2); + wrappedText = textRenderer.wrapLines(formatValue(), getDimension().width()); + setDimension(getDimension().withHeight(wrappedText.size() * textRenderer.fontHeight + getYPadding() * 2)); } private void updateTooltip() { |