Fix ScrollPanel render calls and usage (#8012)

This commit is contained in:
iTitus authored and GitHub committed 2021-08-31 16:57:08 +02:00
1 parent b375da6962
commit a96d078a7a
2 files changed
+32 -18

No files matched your search

@@ -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();
}
@@ -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);