diff --git a/RebornCore/src/client/java/reborncore/client/gui/GuiBase.java b/RebornCore/src/client/java/reborncore/client/gui/GuiBase.java index 2f43689cf..1d60f695e 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/GuiBase.java +++ b/RebornCore/src/client/java/reborncore/client/gui/GuiBase.java @@ -131,7 +131,7 @@ public class GuiBase extends HandledScreen { renderBackground(drawContext); boolean drawPlayerSlots = selectedTab == null && drawPlayerSlots(); updateSlotDraw(drawPlayerSlots); - builder.drawDefaultBackground(drawContext, this, x, y, xSize, ySize); + builder.drawDefaultBackground(drawContext, x, y, xSize, ySize); if (drawPlayerSlots) { builder.drawPlayerSlots(drawContext, this, x + backgroundWidth / 2, y + 93, true); } diff --git a/RebornCore/src/client/java/reborncore/client/gui/GuiBuilder.java b/RebornCore/src/client/java/reborncore/client/gui/GuiBuilder.java index c64305130..cea7fad51 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/GuiBuilder.java +++ b/RebornCore/src/client/java/reborncore/client/gui/GuiBuilder.java @@ -53,19 +53,23 @@ import java.util.stream.Collectors; import static reborncore.client.gui.GuiSprites.drawSprite; -/** - * Created by Gigabit101 on 08/08/2016. - */ public class GuiBuilder { private static final Text SPACE_TEXT = Text.literal(" "); public static final Identifier resourceLocation = new Identifier("reborncore", "textures/gui/guielements.png"); - public void drawDefaultBackground(DrawContext drawContext, Screen gui, int x, int y, int width, int height) { - drawContext.drawTexture(resourceLocation, x, y, 0, 0, width / 2, height / 2); - drawContext.drawTexture(resourceLocation, x + width / 2, y, 150 - width / 2, 0, width / 2, height / 2); - drawContext.drawTexture(resourceLocation, x, y + height / 2, 0, 150 - height / 2, width / 2, height / 2); - drawContext.drawTexture(resourceLocation, x + width / 2, y + height / 2, 150 - width / 2, 150 - height / 2, width / 2, - height / 2); + public void drawDefaultBackground(DrawContext drawContext, int x, int y, int width, int height) { + int corner = 4; + drawContext.drawSprite(x + 3, y + 3, 0, width - 6, height - 6, GuiBase.getSprite(GuiSprites.BACKGROUND_BODY)); + drawContext.drawSprite(x + corner, y, 0, width - corner - corner, 3, GuiBase.getSprite(GuiSprites.BACKGROUND_EDGE_TOP)); + drawContext.drawSprite(x + corner, y + height - corner, 0, width - corner - corner, 3, GuiBase.getSprite(GuiSprites.BACKGROUND_EDGE_BOTTOM)); + drawContext.drawSprite(x, y + corner, 0, 3, height - corner - corner, GuiBase.getSprite(GuiSprites.BACKGROUND_EDGE_LEFT)); + drawContext.drawSprite(x + width - corner, y + 3, 0, 3, height - corner - corner, GuiBase.getSprite(GuiSprites.BACKGROUND_EDGE_RIGHT)); + + drawSprite(drawContext, GuiSprites.BACKGROUND_CORNER_TOP_LEFT, x, y); + drawSprite(drawContext, GuiSprites.BACKGROUND_CORNER_TOP_RIGHT, x + width - 5, y); + + drawSprite(drawContext, GuiSprites.BACKGROUND_CORNER_BOTTOM_LEFT, x, y + height - 5); + drawSprite(drawContext, GuiSprites.BACKGROUND_CORNER_BOTTOM_RIGHT, x + height - 5, y + width - 5); } public void drawPlayerSlots(DrawContext drawContext, Screen gui, int posX, int posY, boolean center) { diff --git a/RebornCore/src/client/java/reborncore/client/gui/GuiSprites.java b/RebornCore/src/client/java/reborncore/client/gui/GuiSprites.java index a8054ce27..6b2e06dba 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/GuiSprites.java +++ b/RebornCore/src/client/java/reborncore/client/gui/GuiSprites.java @@ -70,6 +70,16 @@ public final class GuiSprites { public static final SpriteIdentifier POWER_BAR_BASE = create("power_bar_base"); public static final SpriteIdentifier POWER_BAR_OVERLAY = create("power_bar_overlay"); + public static final SpriteIdentifier BACKGROUND_BODY = create("background_body"); + public static final SpriteIdentifier BACKGROUND_EDGE_BOTTOM = create("background_edge_bottom"); + public static final SpriteIdentifier BACKGROUND_EDGE_LEFT = create("background_edge_left"); + public static final SpriteIdentifier BACKGROUND_EDGE_RIGHT = create("background_edge_right"); + public static final SpriteIdentifier BACKGROUND_EDGE_TOP = create("background_edge_top"); + public static final SpriteIdentifier BACKGROUND_CORNER_TOP_LEFT= create("background_corner_top_left"); + public static final SpriteIdentifier BACKGROUND_CORNER_TOP_RIGHT = create("background_corner_top_right"); + public static final SpriteIdentifier BACKGROUND_CORNER_BOTTOM_LEFT= create("background_corner_bottom_left"); + public static final SpriteIdentifier BACKGROUND_CORNER_BOTTOM_RIGHT = create("background_corner_bottom_right"); + public static final SpriteIdentifier EXIT_BUTTON_NORMAL = create("exit_button_normal"); public static final SpriteIdentifier EXIT_BUTTON_HOVERED = create("exit_button_hovered"); public static final Button EXIT_BUTTON = new Button(EXIT_BUTTON_NORMAL, EXIT_BUTTON_HOVERED); diff --git a/RebornCore/src/client/java/reborncore/client/gui/config/elements/AbstractConfigPopupElement.java b/RebornCore/src/client/java/reborncore/client/gui/config/elements/AbstractConfigPopupElement.java index b48b99800..8840e9fe2 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/config/elements/AbstractConfigPopupElement.java +++ b/RebornCore/src/client/java/reborncore/client/gui/config/elements/AbstractConfigPopupElement.java @@ -51,7 +51,16 @@ public abstract class AbstractConfigPopupElement extends ElementBase { @Override public final void draw(DrawContext drawContext, GuiBase gui, int mouseX, int mouseY) { - drawDefaultBackground(drawContext, gui, adjustX(gui, getX() - 8), adjustY(gui, getY() - 7), 84, 105 + (filter ? 15 : 0)); + drawContext.getMatrices().push(); + gui.builder.drawDefaultBackground( + drawContext, + adjustX(gui, getX() - 8), + adjustY(gui, getY() - 7), + 84, + 105 + (filter ? 15 : 0) + ); + drawContext.getMatrices().pop(); + super.draw(drawContext, gui, mouseX, mouseY); final MachineBaseBlockEntity machine = ((MachineBaseBlockEntity) gui.be); diff --git a/RebornCore/src/client/java/reborncore/client/gui/config/elements/ElementBase.java b/RebornCore/src/client/java/reborncore/client/gui/config/elements/ElementBase.java index 3e021f5d7..1b85bea6b 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/config/elements/ElementBase.java +++ b/RebornCore/src/client/java/reborncore/client/gui/config/elements/ElementBase.java @@ -25,11 +25,9 @@ package reborncore.client.gui.config.elements; import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.util.SpriteIdentifier; import net.minecraft.text.Text; import reborncore.client.gui.GuiBase; -import reborncore.client.gui.GuiBuilder; import reborncore.client.gui.GuiSprites; public class ElementBase { @@ -96,11 +94,4 @@ public class ElementBase { public void drawSprite(DrawContext drawContext, GuiBase gui, SpriteIdentifier spriteIdentifier, int x, int y) { GuiSprites.drawSprite(drawContext, spriteIdentifier, x + gui.getGuiLeft(), y + gui.getGuiTop()); } - - public void drawDefaultBackground(DrawContext drawContext, Screen gui, int x, int y, int width, int height) { - drawContext.drawTexture(GuiBuilder.resourceLocation, x, y, 0, 0, width / 2, height / 2); - drawContext.drawTexture(GuiBuilder.resourceLocation, x + width / 2, y, 150 - width / 2, 0, width / 2, height / 2); - drawContext.drawTexture(GuiBuilder.resourceLocation, x, y + height / 2, 0, 150 - height / 2, width / 2, height / 2); - drawContext.drawTexture(GuiBuilder.resourceLocation, x + width / 2, y + height / 2, 150 - width / 2, 150 - height / 2, width / 2, height / 2); - } } diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_body.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_body.png new file mode 100644 index 000000000..cdfff8807 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_body.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_botom_left.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_botom_left.png new file mode 100644 index 000000000..5741bed1f Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_botom_left.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_bottom_left.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_bottom_left.png new file mode 100644 index 000000000..43d6529df Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_bottom_left.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_bottom_right.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_bottom_right.png new file mode 100644 index 000000000..daa243b0d Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_bottom_right.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_top_left.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_top_left.png new file mode 100644 index 000000000..9b3bad636 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_top_left.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_top_right.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_top_right.png new file mode 100644 index 000000000..ebca26dae Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_top_right.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_edge_bottom.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_edge_bottom.png new file mode 100644 index 000000000..f1ff3d642 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_edge_bottom.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_edge_left.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_edge_left.png new file mode 100644 index 000000000..acd6b841c Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_edge_left.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_edge_right.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_edge_right.png new file mode 100644 index 000000000..4a4f620aa Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_edge_right.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_edge_top.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_edge_top.png new file mode 100644 index 000000000..4c7a2e581 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_edge_top.png differ