aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorisXander <xandersmith2008@gmail.com>2022-10-19 20:59:33 +0100
committerisXander <xandersmith2008@gmail.com>2022-10-19 20:59:33 +0100
commitc9e278f8945ff0cd9d144b4f481d9fecae0563b9 (patch)
tree4a0b66466117305e613f41e2d1c4cdc29fa5e2c1 /src
parent732eb451abf40c8b8286627520868687ec7306ff (diff)
downloadYetAnotherConfigLib-c9e278f8945ff0cd9d144b4f481d9fecae0563b9.tar.gz
YetAnotherConfigLib-c9e278f8945ff0cd9d144b4f481d9fecae0563b9.tar.bz2
YetAnotherConfigLib-c9e278f8945ff0cd9d144b4f481d9fecae0563b9.zip
fix label styles appearing at first position before they are rendered
Diffstat (limited to 'src')
-rw-r--r--src/main/java/dev/isxander/yacl/gui/OptionListWidget.java8
-rw-r--r--src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java1
2 files changed, 9 insertions, 0 deletions
diff --git a/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java b/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java
index 6dba77e..ddbb06e 100644
--- a/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java
+++ b/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java
@@ -216,6 +216,14 @@ public class OptionListWidget extends ElementListWidget<OptionListWidget.Entry>
public void recacheViewableChildren() {
this.viewableChildren = ImmutableList.copyOf(super.children().stream().filter(Entry::isViewable).toList());
+
+ // update y positions before they need to be rendered are rendered
+ int i = 0;
+ for (Entry entry : viewableChildren) {
+ if (entry instanceof OptionEntry optionEntry)
+ optionEntry.widget.setDimension(optionEntry.widget.getDimension().setY(getRowTop(i)));
+ i++;
+ }
}
@Override
diff --git a/src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java b/src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java
index 80db142..d1bd2c5 100644
--- a/src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java
+++ b/src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java
@@ -72,6 +72,7 @@ public class ModMenuIntegration implements ModMenuApi {
)
.controller(BooleanController::new)
.flag(OptionFlag.GAME_RESTART)
+ .available(false)
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.of("Custom Boolean Toggle"))