fix(config-ui-tiny): prevent incorrect gradients when in world
This commit is contained in:
parent
70647e1710
commit
69b8ef894e
|
@ -1,6 +1,5 @@
|
|||
package io.gitlab.jfronny.libjf.config.impl.ui.tiny.entry;
|
||||
|
||||
import io.gitlab.jfronny.libjf.LibJf;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
@ -8,21 +7,27 @@ import net.minecraft.client.font.TextRenderer;
|
|||
import net.minecraft.client.gui.*;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.*;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.text.*;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class EntryListWidget extends ElementListWidget<EntryListWidget.ConfigEntry> {
|
||||
TextRenderer textRenderer;
|
||||
private final TextRenderer textRenderer;
|
||||
private final boolean background;
|
||||
|
||||
public EntryListWidget(MinecraftClient client, TextRenderer tr, int width, int height, int top, int bottom) {
|
||||
super(client, width, height, top, bottom, 25);
|
||||
this.centerListVertically = false;
|
||||
textRenderer = tr;
|
||||
setRenderBackground(client.world == null);
|
||||
background = client.world == null;
|
||||
setRenderBackground(background);
|
||||
setRenderHorizontalShadows(background);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,6 +78,22 @@ public class EntryListWidget extends ElementListWidget<EntryListWidget.ConfigEnt
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderDecorations(DrawContext context, int mouseX, int mouseY) {
|
||||
super.renderDecorations(context, mouseX, mouseY);
|
||||
if (background) return;
|
||||
|
||||
// Background texture at the top of the screen
|
||||
context.setShaderColor(0.25f, 0.25f, 0.25f, 1.0f);
|
||||
context.drawTexture(Screen.OPTIONS_BACKGROUND_TEXTURE, left, 0, 0.0f, 0.0f, width, top, 32, 32);
|
||||
context.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
// Gradient at the top of the screen
|
||||
context.fillGradient(RenderLayer.getGuiOverlay(), left, top, right, top + 4, 0xff000000, 0x00000000, 0);
|
||||
// Gradient at the bottom of the screen
|
||||
if (getScrollAmount() < getMaxScroll()) context.fillGradient(RenderLayer.getGuiOverlay(), left, bottom - 4, right, bottom, 0x00000000, 0xff000000, 0);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public abstract static class ConfigEntry extends Entry<ConfigEntry> implements Reflowable {
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue