aboutsummaryrefslogtreecommitdiff
path: root/common/src/main
diff options
context:
space:
mode:
authorisXander <xandersmith2008@gmail.com>2023-08-12 14:37:23 +0100
committerisXander <xandersmith2008@gmail.com>2023-08-12 14:39:00 +0100
commitb45c9417a422827b351c8a797fd158f885b3ce05 (patch)
tree5b4bc5e18b399f19a964a00c5b84f39f74779fd7 /common/src/main
parentff6b36987d1c149a9f1b7e1b23748cb581b8fa6f (diff)
downloadYetAnotherConfigLib-b45c9417a422827b351c8a797fd158f885b3ce05.tar.gz
YetAnotherConfigLib-b45c9417a422827b351c8a797fd158f885b3ce05.tar.bz2
YetAnotherConfigLib-b45c9417a422827b351c8a797fd158f885b3ce05.zip
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.
Diffstat (limited to 'common/src/main')
-rw-r--r--common/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java11
-rw-r--r--common/src/main/java/dev/isxander/yacl3/gui/ImageRenderer.java4
-rw-r--r--common/src/main/java/dev/isxander/yacl3/gui/controllers/ControllerWidget.java11
3 files changed, 13 insertions, 13 deletions
diff --git a/common/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java b/common/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java
index 8b9779c..a34329a 100644
--- a/common/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java
+++ b/common/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java
@@ -77,6 +77,17 @@ public abstract class AbstractWidget implements GuiEventListener, Renderable, Na
int i = !enabled ? 0 : hovered ? 2 : 1;
graphics.blit(net.minecraft.client.gui.components.AbstractWidget.WIDGETS_LOCATION, x1, y1, 0, 0, 46 + i * 20, width / 2, height, 256, 256);
graphics.blit(net.minecraft.client.gui.components.AbstractWidget.WIDGETS_LOCATION, x1 + width / 2, y1, 0, 200 - width / 2f, 46 + i * 20, width / 2, height, 256, 256);
+
+ if (hovered && !enabled) {
+ drawOutline(graphics, x1, y1, x2, y2, 1, 0xFFD0D0D0);
+ }
+ }
+
+ 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 multiplyColor(int hex, float amount) {
diff --git a/common/src/main/java/dev/isxander/yacl3/gui/ImageRenderer.java b/common/src/main/java/dev/isxander/yacl3/gui/ImageRenderer.java
index 7e9b9ab..717adaa 100644
--- a/common/src/main/java/dev/isxander/yacl3/gui/ImageRenderer.java
+++ b/common/src/main/java/dev/isxander/yacl3/gui/ImageRenderer.java
@@ -192,8 +192,6 @@ public interface ImageRenderer {
ImageReader reader = ImageIO.getImageReadersBySuffix("gif").next();
reader.setInput(ImageIO.createImageInputStream(is));
-
-
AnimFrameProvider animFrameFunction = i -> {
IIOMetadata metadata = reader.getImageMetadata(i);
String metaFormatName = metadata.getNativeMetadataFormatName();
@@ -281,7 +279,7 @@ public interface ImageRenderer {
int cols = (int)Math.ceil(Math.sqrt(frameCount) / Math.sqrt(ratio));
int rows = (int)Math.ceil(frameCount / (double)cols);
- NativeImage image = new NativeImage(frameWidth * cols, frameHeight * rows, true);
+ NativeImage image = new NativeImage(NativeImage.Format.RGBA, frameWidth * cols, frameHeight * rows, true);
// // Fill whole atlas with black, as each frame may have different dimensions
// // that would cause borders of transparent pixels to appear around the frames
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<T extends Controller<?>> 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<T extends Controller<?>> 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<T extends Controller<?>> extends Abstract
@Nullable
@Override
public ComponentPath nextFocusPath(FocusNavigationEvent focusNavigationEvent) {
- if (!this.isAvailable())
- return null;
return !this.isFocused() ? ComponentPath.leaf(this) : null;
}