diff --git a/src/main/java/com/irtimaled/bbor/client/gui/AbstractSlider.java b/src/main/java/com/irtimaled/bbor/client/gui/AbstractSlider.java index d652ffa3..2076aa52 100644 --- a/src/main/java/com/irtimaled/bbor/client/gui/AbstractSlider.java +++ b/src/main/java/com/irtimaled/bbor/client/gui/AbstractSlider.java @@ -4,8 +4,14 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.sound.SoundManager; +import net.minecraft.util.Identifier; abstract class AbstractSlider extends AbstractControl { + private static final Identifier TEXTURE = Identifier.ofVanilla("widget/slider"); + private static final Identifier HIGHLIGHTED_TEXTURE = Identifier.ofVanilla("widget/slider_highlighted"); + private static final Identifier HANDLE_TEXTURE = Identifier.ofVanilla("widget/slider_handle"); + private static final Identifier HANDLE_HIGHLIGHTED_TEXTURE = Identifier.ofVanilla("widget/slider_handle_highlighted"); + private final int optionCount; private final int total; int position = 0; @@ -16,12 +22,18 @@ abstract class AbstractSlider extends AbstractControl { total = this.width - 8; } + private Identifier getTexture() { + return this.isFocused() ? HIGHLIGHTED_TEXTURE : TEXTURE; + } + + private Identifier getHandleTexture() { + return !this.hovered ? HANDLE_TEXTURE : HANDLE_HIGHLIGHTED_TEXTURE; + } + @Override protected void renderBackground(DrawContext ctx) { -// this.minecraft.getTextureManager().bindTexture(WIDGETS_TEXTURE); - int hoverState = this.isSelected() ? 1 : 0; - // ctx.drawTexture(WIDGETS_TEXTURE, this.getX() + (int) getProgressPercentage(), this.getY(), 0, 46 + hoverState * 20, 4, this.height); FIX - // ctx.drawTexture(WIDGETS_TEXTURE, this.getX() + (int) getProgressPercentage() + 4, this.getY(), 196, 46 + hoverState * 20, 4, 20); + ctx.drawGuiTexture(this.getTexture(), this.getX(), this.getY(), this.getWidth(), this.getHeight()); + ctx.drawGuiTexture(this.getHandleTexture(), this.getX() + (int) getProgressPercentage(), this.getY(), 8, this.getHeight()); } private double getProgressPercentage() { diff --git a/src/main/java/com/irtimaled/bbor/client/gui/ControlList.java b/src/main/java/com/irtimaled/bbor/client/gui/ControlList.java index 9f34761d..8fb13ca3 100644 --- a/src/main/java/com/irtimaled/bbor/client/gui/ControlList.java +++ b/src/main/java/com/irtimaled/bbor/client/gui/ControlList.java @@ -22,6 +22,8 @@ import java.util.List; public class ControlList implements IControlSet { + private static final Identifier OPTIONS_BACKGROUND_TEXTURE = Identifier.tryParse("bbor:textures/gui/options_background.png"); + public static final int CONTROLS_WIDTH = 310; protected static final int PADDING = 8; @@ -179,14 +181,14 @@ public void render(DrawContext ctx, int mouseX, int mouseY) { int listTop = this.top + PADDING - (int) this.amountScrolled; - Screen.renderBackgroundTexture(ctx, Screen.MENU_BACKGROUND_TEXTURE, 0, top, 0.0F, 0.0F, width, height); + Screen.renderBackgroundTexture(ctx, MinecraftClient.getInstance().world != null ? Screen.INWORLD_MENU_BACKGROUND_TEXTURE : Screen.MENU_BACKGROUND_TEXTURE, 0, top, 0.0F, 0.0F, width, height); drawEntries(ctx, mouseX, mouseY, listTop); RenderHelper.enableDepthTest(); RenderHelper.depthFuncAlways(); - this.overlayBackground(ctx, 0, this.top, Screen.HEADER_SEPARATOR_TEXTURE); - this.overlayBackground(ctx, this.bottom, this.height, Screen.FOOTER_SEPARATOR_TEXTURE); + this.overlayBackground(0, this.top); + this.overlayBackground(this.bottom, this.height); RenderHelper.depthFuncLessEqual(); RenderHelper.disableDepthTest(); RenderHelper.enableBlend(); @@ -227,10 +229,29 @@ protected void drawEntry(DrawContext ctx, int mouseX, int mouseY, int top, Contr entry.render(ctx, mouseX, mouseY); } - private void overlayBackground(DrawContext context, int top, int bottom, Identifier texture) { - RenderSystem.enableBlend(); - context.drawTexture(texture, 0, top, 0.0F, 0.0F, 0, bottom, 32, 2); - RenderSystem.disableBlend(); + private void overlayBackground(int top, int bottom) { + Tessellator tessellator = Tessellator.getInstance(); + BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); + RenderSystem.setShader(GameRenderer::getPositionTexColorProgram); + RenderSystem.setShaderTexture(0, OPTIONS_BACKGROUND_TEXTURE); + + bufferBuilder + .vertex(0, bottom, -100.0F) + .texture(0.0F, (float) bottom / 32.0F) + .color(64, 64, 64, 255); + bufferBuilder + .vertex(this.width, bottom, -100.0F) + .texture((float) this.width / 32.0F, (float) bottom / 32.0F) + .color(64, 64, 64, 255); + bufferBuilder + .vertex(this.width, top, -100.0F) + .texture((float) this.width / 32.0F, (float) top / 32.0F) + .color(64, 64, 64, 255); + bufferBuilder + .vertex(0, top, -100.0F) + .texture(0.0f, (float) top / 32.0F) + .color(64, 64, 64, 255); + BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); } private void drawScrollBar(int maxScroll) { diff --git a/src/main/resources/assets/bbor/textures/gui/options_background.png b/src/main/resources/assets/bbor/textures/gui/options_background.png new file mode 100644 index 00000000..617d353e Binary files /dev/null and b/src/main/resources/assets/bbor/textures/gui/options_background.png differ diff --git a/src/main/resources/bbor.accesswidener b/src/main/resources/bbor.accesswidener index b836b81a..ce736850 100644 --- a/src/main/resources/bbor.accesswidener +++ b/src/main/resources/bbor.accesswidener @@ -4,3 +4,4 @@ accessible class net/minecraft/client/world/ClientChunkManager$ClientChunk extendable class net/minecraft/structure/StructureStart extendable class net/minecraft/world/biome/Biome +accessible field net/minecraft/client/gui/screen/Screen INWORLD_MENU_BACKGROUND_TEXTURE Lnet/minecraft/util/Identifier; \ No newline at end of file