aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java
diff options
context:
space:
mode:
authorisXander <isxander@users.noreply.github.com>2022-09-18 19:14:58 +0100
committerisXander <isxander@users.noreply.github.com>2022-09-18 19:15:09 +0100
commit33e98c7edc1404e099f9c9bcc586fd5c55cb8bdd (patch)
treea964082d62c3b13f5628c036fe49f9ea19d32315 /src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java
parent564a028eed25cfce0e0486f1a1a21affb499a311 (diff)
downloadYetAnotherConfigLib-33e98c7edc1404e099f9c9bcc586fd5c55cb8bdd.tar.gz
YetAnotherConfigLib-33e98c7edc1404e099f9c9bcc586fd5c55cb8bdd.tar.bz2
YetAnotherConfigLib-33e98c7edc1404e099f9c9bcc586fd5c55cb8bdd.zip
1.3.0
option tooltips now consume the pending value PlaceholderCategory: a category that when selected, just opens a screen
Diffstat (limited to 'src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java')
-rw-r--r--src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java b/src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java
index 1c986e4..cd70872 100644
--- a/src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java
+++ b/src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java
@@ -16,7 +16,7 @@ import java.util.List;
public abstract class ControllerWidget<T extends Controller<?>> extends AbstractWidget {
protected final T control;
- protected final MultilineText wrappedTooltip;
+ protected MultilineText wrappedTooltip;
protected final YACLScreen screen;
protected boolean focused = false;
@@ -29,7 +29,8 @@ public abstract class ControllerWidget<T extends Controller<?>> extends Abstract
super(dim);
this.control = control;
this.screen = screen;
- this.wrappedTooltip = MultilineText.create(textRenderer, control.option().tooltip(), screen.width / 2);
+ control.option().addListener((opt, pending) -> updateTooltip());
+ updateTooltip();
}
@Override
@@ -71,7 +72,7 @@ public abstract class ControllerWidget<T extends Controller<?>> extends Abstract
@Override
public void postRender(MatrixStack matrices, int mouseX, int mouseY, float delta) {
- if (hoveredTicks > YACLConstants.HOVER_TICKS) {
+ if (hoveredTicks >= YACLConstants.HOVER_TICKS) {
YACLScreen.renderMultilineTooltip(matrices, textRenderer, wrappedTooltip, mouseX, mouseY, screen.width, screen.height);
}
}
@@ -94,6 +95,10 @@ public abstract class ControllerWidget<T extends Controller<?>> extends Abstract
return this.dim.isPointInside((int) mouseX, (int) mouseY);
}
+ private void updateTooltip() {
+ this.wrappedTooltip = MultilineText.create(textRenderer, control.option().tooltip(), screen.width / 2);
+ }
+
protected int getControlWidth() {
return isHovered() ? getHoveredControlWidth() : getUnhoveredControlWidth();
}