From 406fff6b754539463a97afee1c5d2262b67b76ee Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Thu, 1 Jun 2023 16:57:45 +0100 Subject: [PATCH] Background sprites --- .../java/reborncore/client/gui/GuiBase.java | 2 +- .../reborncore/client/gui/GuiBuilder.java | 22 +++++++++++------- .../reborncore/client/gui/GuiSprites.java | 10 ++++++++ .../elements/AbstractConfigPopupElement.java | 11 ++++++++- .../gui/config/elements/ElementBase.java | 9 ------- .../textures/gui/sprites/background_body.png | Bin 0 -> 70 bytes .../sprites/background_corner_botom_left.png | Bin 0 -> 78 bytes .../sprites/background_corner_bottom_left.png | Bin 0 -> 102 bytes .../background_corner_bottom_right.png | Bin 0 -> 97 bytes .../sprites/background_corner_top_left.png | Bin 0 -> 91 bytes .../sprites/background_corner_top_right.png | Bin 0 -> 100 bytes .../gui/sprites/background_edge_bottom.png | Bin 0 -> 74 bytes .../gui/sprites/background_edge_left.png | Bin 0 -> 78 bytes .../gui/sprites/background_edge_right.png | Bin 0 -> 78 bytes .../gui/sprites/background_edge_top.png | Bin 0 -> 80 bytes 15 files changed, 34 insertions(+), 20 deletions(-) create mode 100644 RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_body.png create mode 100644 RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_botom_left.png create mode 100644 RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_bottom_left.png create mode 100644 RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_bottom_right.png create mode 100644 RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_top_left.png create mode 100644 RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_corner_top_right.png create mode 100644 RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_edge_bottom.png create mode 100644 RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_edge_left.png create mode 100644 RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_edge_right.png create mode 100644 RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/background_edge_top.png 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 0000000000000000000000000000000000000000..cdfff880742ad62a6f905a76e637c44d1316b70f GIT binary patch literal 70 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx1|;Q0k92}1TpU9EpPyhe` literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..5741bed1f829b37c87bfd2c6b6857103cfefde53 GIT binary patch literal 78 zcmeAS@N?(olHy`uVBq!ia0vp^%plCc1|-8Yw(bW~qMj~}AsjQ4QyLonAMcY*c3}G- aSiw+`%@R~ods_vlfWgz%&t;ucLK6UTP!oUv literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..43d6529dfeaa6243271a419fbfeda7606cd0ba0d GIT binary patch literal 102 zcmeAS@N?(olHy`uVBq!ia0vp^EFjFm1|(O0oL2{=bUj@hLpWx-b{`aEP~d3Tu<_2} zsiitqA>#204518ZZS8k+Lw8zurl`ehmlrd0hlqRFe|IPcYGm+q^>bP0l+XkK*=ZZS literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..daa243b0d6313ab17a5a0b6a0a34ee18ad0daaf2 GIT binary patch literal 97 zcmeAS@N?(olHy`uVBq!ia0vp^EFjFm1|(O0oL2{=G(24#LpWx}p4`aGV8C(2;c(x) vPwgtatfxHJ#k|@u=|at~xUCFn%nuknzH+i$-f#FEsE5JR)z4*}Q$iB}y@4Jj literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..9b3bad636a26364bf57e31b2ac016e7719195b8b GIT binary patch literal 91 zcmeAS@N?(olHy`uVBq!ia0vp^EFjFm1|(O0oL2{=lssJ=LpWx}o-pKNFyJ_1aQOfK pnz;-sZ_X)V&6;qehjq((cK>}Ge|Hxb&H$=r@O1TaS?83{1OWdS8-f4; literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..ebca26dae37b024f91ad420f6bc1fded04a7238b GIT binary patch literal 100 zcmeAS@N?(olHy`uVBq!ia0vp^EFjFm1|(O0oL2{=v^`xMLpWyop4!OBV8C(M;BbGX yW&TcPZ&PjuyVXo97Hwk4ojG%Mu5XeMqkP{xu~~b33JwCbF?hQAxvXYDM3#c#}JO0$sD}Af6pIbVExZ1 X$;Hg@JUK`fD9PaI>gTe~DWM4f@L&(c literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..acd6b841c31cc8a4104559b5a76c15b6978577cb GIT binary patch literal 78 zcmeAS@N?(olHy`uVBq!ia0vp^%s|Y@!3HFyABb!LQlg$Njv*W~lT#8Be*FLczn%>Q Z7-au2|J(Rh{S#0DgQu&X%Q~loCIEZ*6lVYc literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..4a4f620aae278557df8c0e0c17c112927ddef1c4 GIT binary patch literal 78 zcmeAS@N?(olHy`uVBq!ia0vp^%s|Y@!3HFyABb!LQlg$Njv*W~lX-Y~|DHc^;J}8e cuUTviQk*P|&z4U$11ezfboFyt=akR{0AsEbApigX literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..4c7a2e58175de07ae22069a4a3b4fa1ee58c66a0 GIT binary patch literal 80 zcmeAS@N?(olHy`uVBq!ia0vp^j6lrH!3HFQ?xr>YDREC1#}JO0$q5MwKhA&o|G%D1 cjSUDGl(|?Ki)DY?0hKU#y85}Sb4q9e0FGc1%m4rY literal 0 HcmV?d00001