From b1909c9c820b16f9f3adda64d3332d867d6ef2f7 Mon Sep 17 00:00:00 2001 From: isXander Date: Thu, 25 May 2023 22:07:46 +0100 Subject: Remove references of postRender --- .../java/dev/isxander/yacl/gui/AbstractWidget.java | 4 ---- .../isxander/yacl/gui/ElementListWidgetExt.java | 10 ---------- .../isxander/yacl/gui/OptionDescriptionWidget.java | 20 ++++++++++++++++--- .../dev/isxander/yacl/gui/OptionListWidget.java | 15 +------------- .../dev/isxander/yacl/gui/TooltipButtonWidget.java | 21 +++++++------------- .../java/dev/isxander/yacl/gui/YACLScreen.java | 23 ++++++++-------------- .../yacl/gui/controllers/ControllerWidget.java | 7 ------- .../yacl/gui/controllers/LabelController.java | 6 +++--- .../yacl/gui/controllers/ListEntryWidget.java | 7 ------- .../slider/SliderControllerElement.java | 6 ------ 10 files changed, 36 insertions(+), 83 deletions(-) (limited to 'common/src') diff --git a/common/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java b/common/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java index a34b3fa..06a6e23 100644 --- a/common/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java +++ b/common/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java @@ -24,10 +24,6 @@ public abstract class AbstractWidget implements GuiEventListener, Renderable, Na this.dim = dim; } - public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - - } - public boolean canReset() { return false; } diff --git a/common/src/main/java/dev/isxander/yacl/gui/ElementListWidgetExt.java b/common/src/main/java/dev/isxander/yacl/gui/ElementListWidgetExt.java index ffeffbf..8fdf2ee 100644 --- a/common/src/main/java/dev/isxander/yacl/gui/ElementListWidgetExt.java +++ b/common/src/main/java/dev/isxander/yacl/gui/ElementListWidgetExt.java @@ -85,12 +85,6 @@ public class ElementListWidgetExt> exten this.smoothScrollAmount = getScrollAmount(); } - public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - for (E entry : children()) { - entry.postRender(graphics, mouseX, mouseY, delta); - } - } - @Nullable @Override protected E getEntryAtPosition(double x, double y) { @@ -219,10 +213,6 @@ public class ElementListWidgetExt> exten return false; } - public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - - } - public int getItemHeight() { return 22; } diff --git a/common/src/main/java/dev/isxander/yacl/gui/OptionDescriptionWidget.java b/common/src/main/java/dev/isxander/yacl/gui/OptionDescriptionWidget.java index 4d86048..9f0c642 100644 --- a/common/src/main/java/dev/isxander/yacl/gui/OptionDescriptionWidget.java +++ b/common/src/main/java/dev/isxander/yacl/gui/OptionDescriptionWidget.java @@ -2,12 +2,14 @@ package dev.isxander.yacl.gui; import com.mojang.blaze3d.Blaze3D; import com.mojang.blaze3d.platform.InputConstants; -import dev.isxander.yacl.api.OptionDescription; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ComponentPath; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractWidget; +import net.minecraft.client.gui.narration.NarratedElementType; import net.minecraft.client.gui.narration.NarrationElementOutput; +import net.minecraft.client.gui.navigation.FocusNavigationEvent; import net.minecraft.client.gui.navigation.ScreenRectangle; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Style; @@ -19,8 +21,8 @@ import java.util.List; import java.util.function.Supplier; public class OptionDescriptionWidget extends AbstractWidget { - private static final int AUTO_SCROLL_TIMER = 3000; - private static final float AUTO_SCROLL_SPEED = 1; + private static final int AUTO_SCROLL_TIMER = 1500; + private static final float AUTO_SCROLL_SPEED = 1; // lines per second private @Nullable DescriptionWithName description; private List wrappedText; @@ -184,6 +186,10 @@ public class OptionDescriptionWidget extends AbstractWidget { @Override protected void updateWidgetNarration(NarrationElementOutput builder) { + if (description != null) { + builder.add(NarratedElementType.TITLE, description.name()); + builder.add(NarratedElementType.HINT, description.description().description()); + } } @@ -198,4 +204,12 @@ public class OptionDescriptionWidget extends AbstractWidget { private int currentTimeMS() { return (int)(Blaze3D.getTime() * 1000); } + + @Nullable + @Override + public ComponentPath nextFocusPath(FocusNavigationEvent event) { + // prevents focusing on this widget + return null; + } + } diff --git a/common/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java b/common/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java index fb49578..ca903ef 100644 --- a/common/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java +++ b/common/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java @@ -304,11 +304,6 @@ public class OptionListWidget extends ElementListWidgetExt this.resetListButton.active = !opt.isPendingValueDefault() && opt.available()); this.resetListButton.active = !group.isPendingValueDefault() && group.available(); + this.addListButton = new TooltipButtonWidget(yaclScreen, resetListButton.getX() - 20, -50, 20, 20, Component.literal("+"), Component.translatable("yacl.list.add_top"), btn -> { group.insertNewEntryToTop(); setExpanded(true); @@ -503,15 +499,6 @@ public class OptionListWidget extends ElementListWidgetExt optionList; + private TabListWidget optionList; private final Button saveFinishedButton; private final Button cancelResetButton; private final Button undoButton; @@ -233,13 +226,6 @@ public class YACLScreen extends Screen { public CategoryTab(ConfigCategory category) { this.category = category; - this.optionList = new TabListWidget<>( - () -> new ScreenRectangle(tabArea.position(), tabArea.width() / 3 * 2 + 1, tabArea.height()), - new OptionListWidget(YACLScreen.this, category, minecraft, 0, 0, width / 3 * 2 + 1, height, desc -> { - descriptionWidget.setOptionDescription(desc); - }) - ); - int columnWidth = width / 3; int padding = columnWidth / 20; columnWidth = Math.min(columnWidth, 400); @@ -275,6 +261,13 @@ public class YACLScreen extends Screen { searchQuery -> optionList.getList().updateSearchQuery(searchQuery) ); + this.optionList = new TabListWidget<>( + () -> new ScreenRectangle(tabArea.position(), tabArea.width() / 3 * 2 + 1, tabArea.height()), + new OptionListWidget(YACLScreen.this, category, minecraft, 0, 0, width / 3 * 2 + 1, height, desc -> { + descriptionWidget.setOptionDescription(desc); + }) + ); + descriptionWidget = new OptionDescriptionWidget( () -> new ScreenRectangle( width / 3 * 2 + padding, diff --git a/common/src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java b/common/src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java index 232dddb..a277ad4 100644 --- a/common/src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java +++ b/common/src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java @@ -53,13 +53,6 @@ public abstract class ControllerWidget> extends Abstract } } - @Override - public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - if (hovered || focused) { - YACLScreen.renderMultilineTooltip(graphics, textRenderer, wrappedTooltip, getDimension().centerX(), getDimension().y() - 5, getDimension().yLimit() + 5, screen.width, screen.height); - } - } - protected void drawHoveredControl(GuiGraphics graphics, int mouseX, int mouseY, float delta) { } diff --git a/common/src/main/java/dev/isxander/yacl/gui/controllers/LabelController.java b/common/src/main/java/dev/isxander/yacl/gui/controllers/LabelController.java index a55a255..a3d385c 100644 --- a/common/src/main/java/dev/isxander/yacl/gui/controllers/LabelController.java +++ b/common/src/main/java/dev/isxander/yacl/gui/controllers/LabelController.java @@ -85,10 +85,9 @@ public class LabelController implements Controller { graphics.fill(getDimension().x() - 1, getDimension().yLimit(), getDimension().xLimit() + 1, getDimension().yLimit() + 1, -1); graphics.fill(getDimension().xLimit(), getDimension().y() - 1, getDimension().xLimit() + 1, getDimension().yLimit() + 1, -1); } - } - @Override - public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) { + graphics.pose().pushPose(); + graphics.pose().translate(0, 0, 100); if (isMouseOver(mouseX, mouseY)) { YACLScreen.renderMultilineTooltip(graphics, textRenderer, wrappedTooltip, getDimension().centerX(), getDimension().y() - 5, getDimension().yLimit() + 5, screen.width, screen.height); @@ -115,6 +114,7 @@ public class LabelController implements Controller { } } } + graphics.pose().popPose(); } @Override diff --git a/common/src/main/java/dev/isxander/yacl/gui/controllers/ListEntryWidget.java b/common/src/main/java/dev/isxander/yacl/gui/controllers/ListEntryWidget.java index 2156dcc..af60c08 100644 --- a/common/src/main/java/dev/isxander/yacl/gui/controllers/ListEntryWidget.java +++ b/common/src/main/java/dev/isxander/yacl/gui/controllers/ListEntryWidget.java @@ -80,13 +80,6 @@ public class ListEntryWidget extends AbstractWidget implements ContainerEventHan entryWidget.render(graphics, mouseX, mouseY, delta); } - @Override - public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) { - removeButton.renderHoveredTooltip(graphics); - moveUpButton.renderHoveredTooltip(graphics); - moveDownButton.renderHoveredTooltip(graphics); - } - protected void updateButtonStates() { removeButton.active = listOption.available(); moveUpButton.active = listOption.indexOf(listOptionEntry) > 0 && listOption.available(); diff --git a/common/src/main/java/dev/isxander/yacl/gui/controllers/slider/SliderControllerElement.java b/common/src/main/java/dev/isxander/yacl/gui/controllers/slider/SliderControllerElement.java index b60de07..f1b507d 100644 --- a/common/src/main/java/dev/isxander/yacl/gui/controllers/slider/SliderControllerElement.java +++ b/common/src/main/java/dev/isxander/yacl/gui/controllers/slider/SliderControllerElement.java @@ -155,10 +155,4 @@ public class SliderControllerElement extends ControllerWidget