diff options
author | isXander <xandersmith2008@gmail.com> | 2023-05-16 17:04:51 +0100 |
---|---|---|
committer | isXander <xandersmith2008@gmail.com> | 2023-05-16 17:04:51 +0100 |
commit | 4f1bba3f51de1f544b239e7eac740eab5832dc5b (patch) | |
tree | 72357adf401c2f0c2962eba59d2a793ba238a182 /common/src/main/java/dev/isxander/yacl/gui/controllers | |
parent | 5b368af9efcc1c587c608d014e9dc79bcc3c691c (diff) | |
download | YetAnotherConfigLib-4f1bba3f51de1f544b239e7eac740eab5832dc5b.tar.gz YetAnotherConfigLib-4f1bba3f51de1f544b239e7eac740eab5832dc5b.tar.bz2 YetAnotherConfigLib-4f1bba3f51de1f544b239e7eac740eab5832dc5b.zip |
1.20
Diffstat (limited to 'common/src/main/java/dev/isxander/yacl/gui/controllers')
8 files changed, 81 insertions, 90 deletions
diff --git a/common/src/main/java/dev/isxander/yacl/gui/controllers/BooleanController.java b/common/src/main/java/dev/isxander/yacl/gui/controllers/BooleanController.java index d7d17d5..1c395d6 100644 --- a/common/src/main/java/dev/isxander/yacl/gui/controllers/BooleanController.java +++ b/common/src/main/java/dev/isxander/yacl/gui/controllers/BooleanController.java @@ -1,13 +1,13 @@ package dev.isxander.yacl.gui.controllers; import com.mojang.blaze3d.platform.InputConstants; -import com.mojang.blaze3d.vertex.PoseStack; import dev.isxander.yacl.api.Controller; import dev.isxander.yacl.api.Option; import dev.isxander.yacl.api.utils.Dimension; import dev.isxander.yacl.gui.AbstractWidget; import dev.isxander.yacl.gui.YACLScreen; import net.minecraft.ChatFormatting; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; @@ -108,7 +108,7 @@ public class BooleanController implements Controller<Boolean> { } @Override - protected void drawHoveredControl(PoseStack matrices, int mouseX, int mouseY, float delta) { + protected void drawHoveredControl(GuiGraphics graphics, int mouseX, int mouseY, float delta) { } diff --git a/common/src/main/java/dev/isxander/yacl/gui/controllers/ColorController.java b/common/src/main/java/dev/isxander/yacl/gui/controllers/ColorController.java index 3cbce40..4f71248 100644 --- a/common/src/main/java/dev/isxander/yacl/gui/controllers/ColorController.java +++ b/common/src/main/java/dev/isxander/yacl/gui/controllers/ColorController.java @@ -1,7 +1,6 @@ package dev.isxander.yacl.gui.controllers; import com.google.common.collect.ImmutableList; -import com.mojang.blaze3d.vertex.PoseStack; import dev.isxander.yacl.api.Option; import dev.isxander.yacl.api.utils.Dimension; import dev.isxander.yacl.api.utils.MutableDimension; @@ -10,7 +9,7 @@ import dev.isxander.yacl.gui.YACLScreen; import dev.isxander.yacl.gui.controllers.string.IStringController; import dev.isxander.yacl.gui.controllers.string.StringControllerElement; import net.minecraft.ChatFormatting; -import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; @@ -114,14 +113,14 @@ public class ColorController implements IStringController<Color> { } @Override - protected void drawValueText(PoseStack matrices, int mouseX, int mouseY, float delta) { + protected void drawValueText(GuiGraphics graphics, int mouseX, int mouseY, float delta) { if (isHovered()) { colorPreviewDim.move(-inputFieldBounds.width() - 5, 0); - super.drawValueText(matrices, mouseX, mouseY, delta); + super.drawValueText(graphics, mouseX, mouseY, delta); } - GuiComponent.fill(matrices, colorPreviewDim.x(), colorPreviewDim.y(), colorPreviewDim.xLimit(), colorPreviewDim.yLimit(), colorController.option().pendingValue().getRGB()); - drawOutline(matrices, colorPreviewDim.x(), colorPreviewDim.y(), colorPreviewDim.xLimit(), colorPreviewDim.yLimit(), 1, 0xFF000000); + graphics.fill(colorPreviewDim.x(), colorPreviewDim.y(), colorPreviewDim.xLimit(), colorPreviewDim.yLimit(), colorController.option().pendingValue().getRGB()); + drawOutline(graphics, colorPreviewDim.x(), colorPreviewDim.y(), colorPreviewDim.xLimit(), colorPreviewDim.yLimit(), 1, 0xFF000000); } @Override 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 22c469d..232dddb 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 @@ -1,6 +1,5 @@ package dev.isxander.yacl.gui.controllers; -import com.mojang.blaze3d.vertex.PoseStack; import dev.isxander.yacl.api.Controller; import dev.isxander.yacl.api.utils.Dimension; import dev.isxander.yacl.gui.AbstractWidget; @@ -8,7 +7,7 @@ import dev.isxander.yacl.gui.YACLScreen; import dev.isxander.yacl.gui.utils.GuiUtils; import net.minecraft.ChatFormatting; import net.minecraft.client.gui.ComponentPath; -import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.MultiLineLabel; import net.minecraft.client.gui.narration.NarratedElementType; import net.minecraft.client.gui.narration.NarrationElementOutput; @@ -38,41 +37,36 @@ public abstract class ControllerWidget<T extends Controller<?>> extends Abstract } @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { hovered = isMouseOver(mouseX, mouseY); 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(matrices, getDimension().x(), getDimension().y(), getDimension().xLimit(), getDimension().yLimit(), isHovered(), isAvailable()); - matrices.pushPose(); - matrices.translate(getDimension().x() + getXPadding(), getTextY(), 0); - textRenderer.drawShadow(matrices, shortenedName, 0, 0, getValueColor()); - matrices.popPose(); + drawButtonRect(graphics, getDimension().x(), getDimension().y(), getDimension().xLimit(), getDimension().yLimit(), isHovered(), isAvailable()); + graphics.drawString(textRenderer, shortenedName, getDimension().x() + getXPadding(), getTextY(), getValueColor(), true); - drawValueText(matrices, mouseX, mouseY, delta); + + drawValueText(graphics, mouseX, mouseY, delta); if (isHovered()) { - drawHoveredControl(matrices, mouseX, mouseY, delta); + drawHoveredControl(graphics, mouseX, mouseY, delta); } } @Override - public void postRender(PoseStack matrices, int mouseX, int mouseY, float delta) { + public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) { if (hovered || focused) { - YACLScreen.renderMultilineTooltip(matrices, textRenderer, wrappedTooltip, getDimension().centerX(), getDimension().y() - 5, getDimension().yLimit() + 5, screen.width, screen.height); + YACLScreen.renderMultilineTooltip(graphics, textRenderer, wrappedTooltip, getDimension().centerX(), getDimension().y() - 5, getDimension().yLimit() + 5, screen.width, screen.height); } } - protected void drawHoveredControl(PoseStack matrices, int mouseX, int mouseY, float delta) { + protected void drawHoveredControl(GuiGraphics graphics, int mouseX, int mouseY, float delta) { } - protected void drawValueText(PoseStack matrices, int mouseX, int mouseY, float delta) { + protected void drawValueText(GuiGraphics graphics, int mouseX, int mouseY, float delta) { Component valueText = getValueText(); - matrices.pushPose(); - matrices.translate(getDimension().xLimit() - textRenderer.width(valueText) - getXPadding(), getTextY(), 0); - textRenderer.drawShadow(matrices, valueText, 0, 0, getValueColor()); - matrices.popPose(); + graphics.drawString(textRenderer, valueText, getDimension().xLimit() - textRenderer.width(valueText) - getXPadding(), getTextY(), getValueColor(), true); } private void updateTooltip() { @@ -118,15 +112,15 @@ public abstract class ControllerWidget<T extends Controller<?>> extends Abstract return true; } - protected void drawOutline(PoseStack matrices, int x1, int y1, int x2, int y2, int width, int color) { - GuiComponent.fill(matrices, x1, y1, x2, y1 + width, color); - GuiComponent.fill(matrices, x2, y1, x2 - width, y2, color); - GuiComponent.fill(matrices, x1, y2, x2, y2 - width, color); - GuiComponent.fill(matrices, x1, y1, x1 + width, y2, color); + 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 float getTextY() { - return getDimension().y() + getDimension().height() / 2f - textRenderer.lineHeight / 2f; + protected int getTextY() { + return (int)(getDimension().y() + getDimension().height() / 2f - textRenderer.lineHeight / 2f); } @Nullable 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 1dfae0b..a55a255 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 @@ -7,11 +7,12 @@ import dev.isxander.yacl.api.utils.Dimension; import dev.isxander.yacl.gui.AbstractWidget; import dev.isxander.yacl.gui.YACLScreen; import net.minecraft.client.gui.ComponentPath; -import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.MultiLineLabel; 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.screens.Screen; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.HoverEvent; import net.minecraft.network.chat.Style; @@ -69,27 +70,27 @@ public class LabelController implements Controller<Component> { } @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { updateText(); - float y = getDimension().y(); + int y = getDimension().y(); for (FormattedCharSequence text : wrappedText) { - textRenderer.drawShadow(matrices, text, getDimension().x() + getXPadding(), y + getYPadding(), option().available() ? -1 : 0xFFA0A0A0); + graphics.drawString(textRenderer, text, getDimension().x() + getXPadding(), y + getYPadding(), option().available() ? -1 : 0xFFA0A0A0, true); y += textRenderer.lineHeight; } if (isFocused()) { - GuiComponent.fill(matrices, getDimension().x() - 1, getDimension().y() - 1, getDimension().xLimit() + 1, getDimension().y(), -1); - GuiComponent.fill(matrices, getDimension().x() - 1, getDimension().y() - 1, getDimension().x(), getDimension().yLimit() + 1, -1); - GuiComponent.fill(matrices, getDimension().x() - 1, getDimension().yLimit(), getDimension().xLimit() + 1, getDimension().yLimit() + 1, -1); - GuiComponent.fill(matrices, getDimension().xLimit(), getDimension().y() - 1, getDimension().xLimit() + 1, getDimension().yLimit() + 1, -1); + graphics.fill(getDimension().x() - 1, getDimension().y() - 1, getDimension().xLimit() + 1, getDimension().y(), -1); + graphics.fill(getDimension().x() - 1, getDimension().y() - 1, getDimension().x(), getDimension().yLimit() + 1, -1); + 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(PoseStack matrices, int mouseX, int mouseY, float delta) { + public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) { if (isMouseOver(mouseX, mouseY)) { - YACLScreen.renderMultilineTooltip(matrices, textRenderer, wrappedTooltip, getDimension().centerX(), getDimension().y() - 5, getDimension().yLimit() + 5, screen.width, screen.height); + YACLScreen.renderMultilineTooltip(graphics, textRenderer, wrappedTooltip, getDimension().centerX(), getDimension().y() - 5, getDimension().yLimit() + 5, screen.width, screen.height); Style style = getStyle(mouseX, mouseY); if (style != null && style.getHoverEvent() != null) { @@ -97,18 +98,18 @@ public class LabelController implements Controller<Component> { HoverEvent.ItemStackInfo itemStackContent = hoverEvent.getValue(HoverEvent.Action.SHOW_ITEM); if (itemStackContent != null) { ItemStack stack = itemStackContent.getItemStack(); - screen.renderTooltip(matrices, screen.getTooltipFromItem(stack), stack.getTooltipImage(), mouseX, mouseY); + graphics.renderTooltip(textRenderer, Screen.getTooltipFromItem(client, stack), stack.getTooltipImage(), mouseX, mouseY); } else { HoverEvent.EntityTooltipInfo entityContent = hoverEvent.getValue(HoverEvent.Action.SHOW_ENTITY); if (entityContent != null) { if (this.client.options.advancedItemTooltips) { - screen.renderComponentTooltip(matrices, entityContent.getTooltipLines(), mouseX, mouseY); + graphics.renderComponentTooltip(textRenderer, entityContent.getTooltipLines(), mouseX, mouseY); } } else { Component text = hoverEvent.getValue(HoverEvent.Action.SHOW_TEXT); if (text != null) { MultiLineLabel multilineText = MultiLineLabel.create(textRenderer, text, getDimension().width()); - YACLScreen.renderMultilineTooltip(matrices, textRenderer, multilineText, getDimension().centerX(), getDimension().y(), getDimension().yLimit(), screen.width, screen.height); + YACLScreen.renderMultilineTooltip(graphics, textRenderer, multilineText, getDimension().centerX(), getDimension().y(), getDimension().yLimit(), screen.width, screen.height); } } } 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 c3f674d..2156dcc 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 @@ -8,6 +8,7 @@ import dev.isxander.yacl.api.utils.Dimension; import dev.isxander.yacl.gui.AbstractWidget; import dev.isxander.yacl.gui.TooltipButtonWidget; import dev.isxander.yacl.gui.YACLScreen; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.events.ContainerEventHandler; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarrationElementOutput; @@ -65,7 +66,7 @@ public class ListEntryWidget extends AbstractWidget implements ContainerEventHan } @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { updateButtonStates(); // update every render in case option becomes available/unavailable removeButton.setY(getDimension().y()); @@ -73,17 +74,17 @@ public class ListEntryWidget extends AbstractWidget implements ContainerEventHan moveDownButton.setY(getDimension().y()); entryWidget.setDimension(entryWidget.getDimension().withY(getDimension().y())); - removeButton.render(matrices, mouseX, mouseY, delta); - moveUpButton.render(matrices, mouseX, mouseY, delta); - moveDownButton.render(matrices, mouseX, mouseY, delta); - entryWidget.render(matrices, mouseX, mouseY, delta); + removeButton.render(graphics, mouseX, mouseY, delta); + moveUpButton.render(graphics, mouseX, mouseY, delta); + moveDownButton.render(graphics, mouseX, mouseY, delta); + entryWidget.render(graphics, mouseX, mouseY, delta); } @Override - public void postRender(PoseStack matrices, int mouseX, int mouseY, float delta) { - removeButton.renderHoveredTooltip(matrices); - moveUpButton.renderHoveredTooltip(matrices); - moveDownButton.renderHoveredTooltip(matrices); + public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) { + removeButton.renderHoveredTooltip(graphics); + moveUpButton.renderHoveredTooltip(graphics); + moveDownButton.renderHoveredTooltip(graphics); } protected void updateButtonStates() { diff --git a/common/src/main/java/dev/isxander/yacl/gui/controllers/TickBoxController.java b/common/src/main/java/dev/isxander/yacl/gui/controllers/TickBoxController.java index 3f615db..31200b6 100644 --- a/common/src/main/java/dev/isxander/yacl/gui/controllers/TickBoxController.java +++ b/common/src/main/java/dev/isxander/yacl/gui/controllers/TickBoxController.java @@ -7,7 +7,7 @@ import dev.isxander.yacl.api.Option; import dev.isxander.yacl.api.utils.Dimension; import dev.isxander.yacl.gui.AbstractWidget; import dev.isxander.yacl.gui.YACLScreen; -import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; /** @@ -55,7 +55,7 @@ public class TickBoxController implements Controller<Boolean> { } @Override - protected void drawHoveredControl(PoseStack matrices, int mouseX, int mouseY, float delta) { + protected void drawHoveredControl(GuiGraphics graphics, int mouseX, int mouseY, float delta) { int outlineSize = 10; int outlineX1 = getDimension().xLimit() - getXPadding() - outlineSize; int outlineY1 = getDimension().centerY() - outlineSize / 2; @@ -65,18 +65,18 @@ public class TickBoxController implements Controller<Boolean> { int color = getValueColor(); int shadowColor = multiplyColor(color, 0.25f); - drawOutline(matrices, outlineX1 + 1, outlineY1 + 1, outlineX2 + 1, outlineY2 + 1, 1, shadowColor); - drawOutline(matrices, outlineX1, outlineY1, outlineX2, outlineY2, 1, color); + drawOutline(graphics, outlineX1 + 1, outlineY1 + 1, outlineX2 + 1, outlineY2 + 1, 1, shadowColor); + drawOutline(graphics, outlineX1, outlineY1, outlineX2, outlineY2, 1, color); if (control.option().pendingValue()) { - GuiComponent.fill(matrices, outlineX1 + 3, outlineY1 + 3, outlineX2 - 1, outlineY2 - 1, shadowColor); - GuiComponent.fill(matrices, outlineX1 + 2, outlineY1 + 2, outlineX2 - 2, outlineY2 - 2, color); + graphics.fill(outlineX1 + 3, outlineY1 + 3, outlineX2 - 1, outlineY2 - 1, shadowColor); + graphics.fill(outlineX1 + 2, outlineY1 + 2, outlineX2 - 2, outlineY2 - 2, color); } } @Override - protected void drawValueText(PoseStack matrices, int mouseX, int mouseY, float delta) { + protected void drawValueText(GuiGraphics graphics, int mouseX, int mouseY, float delta) { if (!isHovered()) - drawHoveredControl(matrices, mouseX, mouseY, delta); + drawHoveredControl(graphics, mouseX, mouseY, delta); } @Override 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 d00f3d7..b60de07 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 @@ -5,7 +5,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import dev.isxander.yacl.api.utils.Dimension; import dev.isxander.yacl.gui.YACLScreen; import dev.isxander.yacl.gui.controllers.ControllerWidget; -import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.util.Mth; @@ -27,32 +27,32 @@ public class SliderControllerElement extends ControllerWidget<ISliderController< } @Override - public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { - super.render(matrices, mouseX, mouseY, delta); + public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { + super.render(graphics, mouseX, mouseY, delta); calculateInterpolation(); } @Override - protected void drawHoveredControl(PoseStack matrices, int mouseX, int mouseY, float delta) { + protected void drawHoveredControl(GuiGraphics graphics, int mouseX, int mouseY, float delta) { // track - GuiComponent.fill(matrices, sliderBounds.x(), sliderBounds.centerY() - 1, sliderBounds.xLimit(), sliderBounds.centerY(), -1); + graphics.fill(sliderBounds.x(), sliderBounds.centerY() - 1, sliderBounds.xLimit(), sliderBounds.centerY(), -1); // track shadow - GuiComponent.fill(matrices, sliderBounds.x() + 1, sliderBounds.centerY(), sliderBounds.xLimit() + 1, sliderBounds.centerY() + 1, 0xFF404040); + graphics.fill(sliderBounds.x() + 1, sliderBounds.centerY(), sliderBounds.xLimit() + 1, sliderBounds.centerY() + 1, 0xFF404040); // thumb shadow - GuiComponent.fill(matrices, getThumbX() - getThumbWidth() / 2 + 1, sliderBounds.y() + 1, getThumbX() + getThumbWidth() / 2 + 1, sliderBounds.yLimit() + 1, 0xFF404040); + graphics.fill(getThumbX() - getThumbWidth() / 2 + 1, sliderBounds.y() + 1, getThumbX() + getThumbWidth() / 2 + 1, sliderBounds.yLimit() + 1, 0xFF404040); // thumb - GuiComponent.fill(matrices, getThumbX() - getThumbWidth() / 2, sliderBounds.y(), getThumbX() + getThumbWidth() / 2, sliderBounds.yLimit(), -1); + graphics.fill(getThumbX() - getThumbWidth() / 2, sliderBounds.y(), getThumbX() + getThumbWidth() / 2, sliderBounds.yLimit(), -1); } @Override - protected void drawValueText(PoseStack matrices, int mouseX, int mouseY, float delta) { - matrices.pushPose(); + protected void drawValueText(GuiGraphics graphics, int mouseX, int mouseY, float delta) { + graphics.pose().pushPose(); if (isHovered()) - matrices.translate(-(sliderBounds.width() + 6 + getThumbWidth() / 2f), 0, 0); - super.drawValueText(matrices, mouseX, mouseY, delta); - matrices.popPose(); + graphics.pose().translate(-(sliderBounds.width() + 6 + getThumbWidth() / 2f), 0, 0); + super.drawValueText(graphics, mouseX, mouseY, delta); + graphics.pose().popPose(); } @Override @@ -157,8 +157,8 @@ public class SliderControllerElement extends ControllerWidget<ISliderController< } @Override - public void postRender(PoseStack matrices, int mouseX, int mouseY, float delta) { + public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) { if (super.isMouseOver(mouseX, mouseY) || focused) - super.postRender(matrices, mouseX, mouseY, delta); + super.postRender(graphics, mouseX, mouseY, delta); } } diff --git a/common/src/main/java/dev/isxander/yacl/gui/controllers/string/StringControllerElement.java b/common/src/main/java/dev/isxander/yacl/gui/controllers/string/StringControllerElement.java index cb2ad4e..08c3275 100644 --- a/common/src/main/java/dev/isxander/yacl/gui/controllers/string/StringControllerElement.java +++ b/common/src/main/java/dev/isxander/yacl/gui/controllers/string/StringControllerElement.java @@ -2,13 +2,12 @@ package dev.isxander.yacl.gui.controllers.string; import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; import dev.isxander.yacl.api.utils.Dimension; import dev.isxander.yacl.gui.YACLScreen; import dev.isxander.yacl.gui.controllers.ControllerWidget; import dev.isxander.yacl.gui.utils.GuiUtils; import net.minecraft.ChatFormatting; -import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; @@ -42,29 +41,26 @@ public class StringControllerElement extends ControllerWidget<IStringController< } @Override - protected void drawHoveredControl(PoseStack matrices, int mouseX, int mouseY, float delta) { + protected void drawHoveredControl(GuiGraphics graphics, int mouseX, int mouseY, float delta) { } @Override - protected void drawValueText(PoseStack matrices, int mouseX, int mouseY, float delta) { + protected void drawValueText(GuiGraphics graphics, int mouseX, int mouseY, float delta) { Component valueText = getValueText(); if (!isHovered()) valueText = Component.literal(GuiUtils.shortenString(valueText.getString(), textRenderer, getMaxUnwrapLength(), "...")).setStyle(valueText.getStyle()); - matrices.pushPose(); int textX = getDimension().xLimit() - textRenderer.width(valueText) + renderOffset - getXPadding(); - matrices.translate(textX, getTextY(), 0); GuiUtils.enableScissor(inputFieldBounds.x(), inputFieldBounds.y() - 2, inputFieldBounds.width() + 1, inputFieldBounds.height() + 4); - textRenderer.drawShadow(matrices, valueText, 0, 0, getValueColor()); - matrices.popPose(); + graphics.drawString(textRenderer, valueText, textX, getTextY(), getValueColor(), true); if (isHovered()) { ticks += delta; String text = getValueText().getString(); - GuiComponent.fill(matrices, inputFieldBounds.x(), inputFieldBounds.yLimit(), inputFieldBounds.xLimit(), inputFieldBounds.yLimit() + 1, -1); - GuiComponent.fill(matrices, inputFieldBounds.x() + 1, inputFieldBounds.yLimit() + 1, inputFieldBounds.xLimit() + 1, inputFieldBounds.yLimit() + 2, 0xFF404040); + graphics.fill(inputFieldBounds.x(), inputFieldBounds.yLimit(), inputFieldBounds.xLimit(), inputFieldBounds.yLimit() + 1, -1); + graphics.fill(inputFieldBounds.x() + 1, inputFieldBounds.yLimit() + 1, inputFieldBounds.xLimit() + 1, inputFieldBounds.yLimit() + 2, 0xFF404040); if (inputFieldFocused || focused) { if (caretPos > text.length()) @@ -75,12 +71,12 @@ public class StringControllerElement extends ControllerWidget<IStringController< caretX = inputFieldBounds.x() + inputFieldBounds.width() / 2; if (ticks % 20 <= 10) { - GuiComponent.fill(matrices, caretX, inputFieldBounds.y(), caretX + 1, inputFieldBounds.yLimit(), -1); + graphics.fill(caretX, inputFieldBounds.y(), caretX + 1, inputFieldBounds.yLimit(), -1); } if (selectionLength != 0) { int selectionX = textX + textRenderer.width(text.substring(0, caretPos + selectionLength)); - GuiComponent.fill(matrices, caretX, inputFieldBounds.y() - 1, selectionX, inputFieldBounds.yLimit(), 0x803030FF); + graphics.fill(caretX, inputFieldBounds.y() - 1, selectionX, inputFieldBounds.yLimit(), 0x803030FF); } } } |