From b45c9417a422827b351c8a797fd158f885b3ce05 Mon Sep 17 00:00:00 2001 From: isXander Date: Sat, 12 Aug 2023 14:37:23 +0100 Subject: Allow unavailable options to be focused but not interacted with. Improves UX on arrow key navigation so you can read the description even if you can't change it. --- .../dev/isxander/yacl3/gui/controllers/ControllerWidget.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'common/src/main/java/dev/isxander/yacl3/gui/controllers') diff --git a/common/src/main/java/dev/isxander/yacl3/gui/controllers/ControllerWidget.java b/common/src/main/java/dev/isxander/yacl3/gui/controllers/ControllerWidget.java index cf7d0dc..19fe2f6 100644 --- a/common/src/main/java/dev/isxander/yacl3/gui/controllers/ControllerWidget.java +++ b/common/src/main/java/dev/isxander/yacl3/gui/controllers/ControllerWidget.java @@ -43,7 +43,7 @@ public abstract class ControllerWidget> extends Abstract Component name = control.option().changed() ? modifiedOptionName : control.option().name(); Component shortenedName = Component.literal(GuiUtils.shortenString(name.getString(), textRenderer, getDimension().width() - getControlWidth() - getXPadding() - 7, "...")).setStyle(name.getStyle()); - drawButtonRect(graphics, getDimension().x(), getDimension().y(), getDimension().xLimit(), getDimension().yLimit(), isHovered(), isAvailable()); + drawButtonRect(graphics, getDimension().x(), getDimension().y(), getDimension().xLimit(), getDimension().yLimit(), hovered || focused, isAvailable()); graphics.drawString(textRenderer, shortenedName, getDimension().x() + getXPadding(), getTextY(), getValueColor(), true); @@ -105,13 +105,6 @@ public abstract class ControllerWidget> extends Abstract return true; } - protected void drawOutline(GuiGraphics graphics, int x1, int y1, int x2, int y2, int width, int color) { - graphics.fill(x1, y1, x2, y1 + width, color); - graphics.fill(x2, y1, x2 - width, y2, color); - graphics.fill(x1, y2, x2, y2 - width, color); - graphics.fill(x1, y1, x1 + width, y2, color); - } - protected int getTextY() { return (int)(getDimension().y() + getDimension().height() / 2f - textRenderer.lineHeight / 2f); } @@ -119,8 +112,6 @@ public abstract class ControllerWidget> extends Abstract @Nullable @Override public ComponentPath nextFocusPath(FocusNavigationEvent focusNavigationEvent) { - if (!this.isAvailable()) - return null; return !this.isFocused() ? ComponentPath.leaf(this) : null; } -- cgit