From a96d078a7a34cf2128a314bcf8026092b899a19a Mon Sep 17 00:00:00 2001 From: iTitus Date: Tue, 31 Aug 2021 16:57:08 +0200 Subject: [PATCH] Fix ScrollPanel render calls and usage (#8012) --- .../client/gui/ScrollPanel.java | 35 ++++++++++--------- .../fmlclient/gui/screen/ModListScreen.java | 15 +++++++- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/main/java/net/minecraftforge/client/gui/ScrollPanel.java b/src/main/java/net/minecraftforge/client/gui/ScrollPanel.java index 731b162201..2f34fcc7b1 100644 --- a/src/main/java/net/minecraftforge/client/gui/ScrollPanel.java +++ b/src/main/java/net/minecraftforge/client/gui/ScrollPanel.java @@ -23,6 +23,7 @@ import java.util.Collections; import java.util.List; import com.mojang.blaze3d.vertex.*; +import net.minecraft.client.gui.narration.NarratableEntry; import net.minecraft.client.renderer.GameRenderer; import org.lwjgl.opengl.GL11; @@ -35,7 +36,7 @@ import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.components.Widget; import net.minecraftforge.fmlclient.gui.GuiUtils; -public abstract class ScrollPanel extends AbstractContainerEventHandler implements Widget +public abstract class ScrollPanel extends AbstractContainerEventHandler implements Widget, NarratableEntry { private final Minecraft client; protected final int width; @@ -227,25 +228,25 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen barTop = this.top; } - RenderSystem.setShader(GameRenderer::getPositionTexColorShader); + RenderSystem.setShader(GameRenderer::getPositionColorShader); RenderSystem.disableTexture(); - worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); - worldr.vertex(barLeft, this.bottom, 0.0D).uv(0.0F, 1.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex(); - worldr.vertex(barLeft + barWidth, this.bottom, 0.0D).uv(1.0F, 1.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex(); - worldr.vertex(barLeft + barWidth, this.top, 0.0D).uv(1.0F, 0.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex(); - worldr.vertex(barLeft, this.top, 0.0D).uv(0.0F, 0.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex(); + worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + worldr.vertex(barLeft, this.bottom, 0.0D).color(0x00, 0x00, 0x00, 0xFF).endVertex(); + worldr.vertex(barLeft + barWidth, this.bottom, 0.0D).color(0x00, 0x00, 0x00, 0xFF).endVertex(); + worldr.vertex(barLeft + barWidth, this.top, 0.0D).color(0x00, 0x00, 0x00, 0xFF).endVertex(); + worldr.vertex(barLeft, this.top, 0.0D).color(0x00, 0x00, 0x00, 0xFF).endVertex(); tess.end(); - worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); - worldr.vertex(barLeft, barTop + barHeight, 0.0D).uv(0.0F, 1.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex(); - worldr.vertex(barLeft + barWidth, barTop + barHeight, 0.0D).uv(1.0F, 1.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex(); - worldr.vertex(barLeft + barWidth, barTop, 0.0D).uv(1.0F, 0.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex(); - worldr.vertex(barLeft, barTop, 0.0D).uv(0.0F, 0.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex(); + worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + worldr.vertex(barLeft, barTop + barHeight, 0.0D).color(0x80, 0x80, 0x80, 0xFF).endVertex(); + worldr.vertex(barLeft + barWidth, barTop + barHeight, 0.0D).color(0x80, 0x80, 0x80, 0xFF).endVertex(); + worldr.vertex(barLeft + barWidth, barTop, 0.0D).color(0x80, 0x80, 0x80, 0xFF).endVertex(); + worldr.vertex(barLeft, barTop, 0.0D).color(0x80, 0x80, 0x80, 0xFF).endVertex(); tess.end(); - worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); - worldr.vertex(barLeft, barTop + barHeight - 1, 0.0D).uv(0.0F, 1.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex(); - worldr.vertex(barLeft + barWidth - 1, barTop + barHeight - 1, 0.0D).uv(1.0F, 1.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex(); - worldr.vertex(barLeft + barWidth - 1, barTop, 0.0D).uv(1.0F, 0.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex(); - worldr.vertex(barLeft, barTop, 0.0D).uv(0.0F, 0.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex(); + worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + worldr.vertex(barLeft, barTop + barHeight - 1, 0.0D).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex(); + worldr.vertex(barLeft + barWidth - 1, barTop + barHeight - 1, 0.0D).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex(); + worldr.vertex(barLeft + barWidth - 1, barTop, 0.0D).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex(); + worldr.vertex(barLeft, barTop, 0.0D).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex(); tess.end(); } diff --git a/src/main/java/net/minecraftforge/fmlclient/gui/screen/ModListScreen.java b/src/main/java/net/minecraftforge/fmlclient/gui/screen/ModListScreen.java index c9c63d5a0b..64366420d6 100644 --- a/src/main/java/net/minecraftforge/fmlclient/gui/screen/ModListScreen.java +++ b/src/main/java/net/minecraftforge/fmlclient/gui/screen/ModListScreen.java @@ -31,6 +31,7 @@ import java.util.function.Function; import java.util.stream.Collectors; import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.client.renderer.GameRenderer; import net.minecraftforge.fmlclient.gui.GuiUtils; import net.minecraftforge.fmlclient.gui.widget.ModListWidget; @@ -223,6 +224,9 @@ public class ModListScreen extends Screen } private Style findTextLine(final int mouseX, final int mouseY) { + if (!isMouseOver(mouseX, mouseY)) + return null; + double offset = (mouseY - top) + border + scrollDistance + 1; if (logoPath != null) { offset -= 50; @@ -255,6 +259,15 @@ public class ModListScreen extends Screen @Override protected void drawBackground() { } + + @Override + public NarrationPriority narrationPriority() { + return NarrationPriority.NONE; + } + + @Override + public void updateNarration(NarrationElementOutput p_169152_) { + } } @Override @@ -285,7 +298,7 @@ public class ModListScreen extends Screen this.modInfo = new InfoPanel(this.minecraft, modInfoWidth, this.height - PADDING - fullButtonHeight, PADDING); this.addRenderableWidget(modList); - this.addRenderableOnly(modInfo); + this.addRenderableWidget(modInfo); this.addRenderableWidget(search); this.addRenderableWidget(doneButton); this.addRenderableWidget(configButton);