diff --git a/src/main/java/com/lothrazar/storagenetwork/block/expand/ScreenNetworkInventoryExpanded.java b/src/main/java/com/lothrazar/storagenetwork/block/expand/ScreenNetworkInventoryExpanded.java index a9e4880a..aae49b6d 100644 --- a/src/main/java/com/lothrazar/storagenetwork/block/expand/ScreenNetworkInventoryExpanded.java +++ b/src/main/java/com/lothrazar/storagenetwork/block/expand/ScreenNetworkInventoryExpanded.java @@ -5,6 +5,9 @@ import com.lothrazar.storagenetwork.block.AbstractNetworkScreen; import com.lothrazar.storagenetwork.gui.NetworkScreenSize; import com.lothrazar.storagenetwork.gui.NetworkWidget; +import com.lothrazar.storagenetwork.gui.TileableTexture; +import com.lothrazar.storagenetwork.util.SsnConsts; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; @@ -12,14 +15,18 @@ import net.minecraft.world.entity.player.Inventory; import net.minecraftforge.fml.ModList; -public class ScreenNetworkInventoryExpanded extends AbstractNetworkScreen {//AbstractContainerScreen implements IGuiNetwork { +public class ScreenNetworkInventoryExpanded extends AbstractNetworkScreen { protected int HEIGHT = 256; public int WIDTH = 176; + //i know they could all be in the same png file and i pull out sprites from it, but split images is easier to work with + private TileableTexture head = new TileableTexture(new ResourceLocation(StorageNetworkMod.MODID, "textures/gui/expandable_head.png"), WIDTH, 10); + private TileableTexture row = new TileableTexture(new ResourceLocation(StorageNetworkMod.MODID, "textures/gui/expandable_row.png"), WIDTH, SsnConsts.SQ); + private TileableTexture crafting = new TileableTexture(new ResourceLocation(StorageNetworkMod.MODID, "textures/gui/expandable_crafting.png"), WIDTH, 58); + private TileableTexture player = new TileableTexture(new ResourceLocation(StorageNetworkMod.MODID, "textures/gui/expandable_player.png"), WIDTH, 104); + protected final NetworkWidget network; private TileInventoryExpanded tile; - private ResourceLocation top = new ResourceLocation(StorageNetworkMod.MODID, "textures/gui/inventory_expanded_top.png"); - private ResourceLocation bot = new ResourceLocation(StorageNetworkMod.MODID, "textures/gui/inventory_expanded_bottom.png"); public ScreenNetworkInventoryExpanded(ContainerNetworkInventoryExpanded container, Inventory inv, Component name) { super(container, inv, name); @@ -46,13 +53,33 @@ public void init() { @Override public void renderBg(GuiGraphics ms, float partialTicks, int mouseX, int mouseY) { + //get center points from screen size int xCenter = (width - imageWidth) / 2; int yCenter = (height - imageHeight) / 2; - ms.blit(top, xCenter, yCenter - imageHeight / 2, 0, 0, imageWidth, imageHeight); - ms.blit(bot, xCenter, yCenter + imageHeight / 2, 0, imageHeight, imageWidth, imageHeight); + //render the top + int ypos = yCenter - imageHeight / 2; + ms.blit(head.texture(), xCenter, ypos, 0, 0, imageWidth, head.height()); + //render the rows + // -1 for the top header row, and pixel to math ratio of 2x + final int textureLines = (network.getLines() - 1)*2; + for(int line = 0; line < textureLines; line++) { + + ypos += head.height(); + ms.blit(row.texture(), xCenter, ypos, 0, 0, imageWidth, row.height()); + } + //render player inventory + ypos = ypos - 12; //border buffers of 8+4 overlap + ms.blit(player.texture(), xCenter, ypos, 0, imageHeight, imageWidth, imageHeight); + //update network network.applySearchTextToSlots(); network.renderItemSlots(ms, mouseX, mouseY, font); } + + @Override + public void resize(Minecraft mc, int w, int h) { + super.resize(mc,w,h); + network.resize(mc,w,h); + } // all the IGUINETWORK implementations @Override diff --git a/src/main/java/com/lothrazar/storagenetwork/block/inventory/ScreenNetworkInventory.java b/src/main/java/com/lothrazar/storagenetwork/block/inventory/ScreenNetworkInventory.java index 4226fa31..800ea417 100644 --- a/src/main/java/com/lothrazar/storagenetwork/block/inventory/ScreenNetworkInventory.java +++ b/src/main/java/com/lothrazar/storagenetwork/block/inventory/ScreenNetworkInventory.java @@ -5,6 +5,7 @@ import com.lothrazar.storagenetwork.block.AbstractNetworkScreen; import com.lothrazar.storagenetwork.gui.NetworkScreenSize; import com.lothrazar.storagenetwork.gui.NetworkWidget; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; @@ -12,7 +13,7 @@ import net.minecraft.world.entity.player.Inventory; import net.minecraftforge.fml.ModList; -public class ScreenNetworkInventory extends AbstractNetworkScreen {//AbstractContainerScreen implements IGuiNetwork { +public class ScreenNetworkInventory extends AbstractNetworkScreen { protected int HEIGHT = 256; public int WIDTH = 176; @@ -51,6 +52,13 @@ public void renderBg(GuiGraphics ms, float partialTicks, int mouseX, int mouseY) network.applySearchTextToSlots(); network.renderItemSlots(ms, mouseX, mouseY, font); } + + + @Override + public void resize(Minecraft mc, int w, int h) { + super.resize(mc,w,h); + network.resize(mc,w,h); + } // all the IGUINETWORK implementations @Override diff --git a/src/main/java/com/lothrazar/storagenetwork/block/request/ScreenNetworkTable.java b/src/main/java/com/lothrazar/storagenetwork/block/request/ScreenNetworkTable.java index ca9c9c74..aa42c020 100644 --- a/src/main/java/com/lothrazar/storagenetwork/block/request/ScreenNetworkTable.java +++ b/src/main/java/com/lothrazar/storagenetwork/block/request/ScreenNetworkTable.java @@ -5,6 +5,7 @@ import com.lothrazar.storagenetwork.block.AbstractNetworkScreen; import com.lothrazar.storagenetwork.gui.NetworkScreenSize; import com.lothrazar.storagenetwork.gui.NetworkWidget; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; @@ -12,9 +13,7 @@ import net.minecraft.world.entity.player.Inventory; import net.minecraftforge.fml.ModList; -public class ScreenNetworkTable extends - AbstractNetworkScreen { - //AbstractContainerScreen implements IGuiNetwork { +public class ScreenNetworkTable extends AbstractNetworkScreen { private static final int HEIGHT = 256; public static final int WIDTH = 176; @@ -54,6 +53,13 @@ public void renderBg(GuiGraphics ms, float partialTicks, int mouseX, int mouseY) network.applySearchTextToSlots(); network.renderItemSlots(ms, mouseX, mouseY, font); } + + + @Override + public void resize(Minecraft mc, int w, int h) { + super.resize(mc,w,h); + network.resize(mc,w,h); + } // all the IGUINETWORK implementations @Override diff --git a/src/main/java/com/lothrazar/storagenetwork/gui/NetworkWidget.java b/src/main/java/com/lothrazar/storagenetwork/gui/NetworkWidget.java index 00c2f1b4..f72b2759 100644 --- a/src/main/java/com/lothrazar/storagenetwork/gui/NetworkWidget.java +++ b/src/main/java/com/lothrazar/storagenetwork/gui/NetworkWidget.java @@ -156,7 +156,7 @@ public boolean canClick() { return System.currentTimeMillis() > lastClick + 100L; } - int getLines() { + public int getLines() { return lines; } @@ -452,4 +452,11 @@ public void render() { jeiBtn.setTextureId(gui.isJeiSearchSynced() ? TextureEnum.JEI_GREEN : TextureEnum.JEI_RED); } } + + public void resize(Minecraft mc, int width, int height) { + + //todo: how many rows? dynamically change size on screen resize from client + //System.out.println("resized width="+width); + // System.out.println("resized height="+height); + } } diff --git a/src/main/java/com/lothrazar/storagenetwork/gui/TileableTexture.java b/src/main/java/com/lothrazar/storagenetwork/gui/TileableTexture.java new file mode 100644 index 00000000..bf2393e2 --- /dev/null +++ b/src/main/java/com/lothrazar/storagenetwork/gui/TileableTexture.java @@ -0,0 +1,7 @@ +package com.lothrazar.storagenetwork.gui; + +import net.minecraft.resources.ResourceLocation; + +public record TileableTexture(ResourceLocation texture, int width, int height) { + +} diff --git a/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkCraftingRemote.java b/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkCraftingRemote.java index 5368032e..32fe4a25 100644 --- a/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkCraftingRemote.java +++ b/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkCraftingRemote.java @@ -5,6 +5,7 @@ import com.lothrazar.storagenetwork.block.AbstractNetworkScreen; import com.lothrazar.storagenetwork.gui.NetworkScreenSize; import com.lothrazar.storagenetwork.gui.NetworkWidget; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -53,6 +54,12 @@ protected void renderBg(GuiGraphics ms, float partialTicks, int mouseX, int mous network.renderItemSlots(ms, mouseX, mouseY, font); } + @Override + public void resize(Minecraft mc, int w, int h) { + super.resize(mc,w,h); + network.resize(mc,w,h); + } + @Override public boolean getDownwards() { return ItemStorageCraftingRemote.getDownwards(remote); diff --git a/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkRemote.java b/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkRemote.java index 021ca8f6..9a096288 100644 --- a/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkRemote.java +++ b/src/main/java/com/lothrazar/storagenetwork/item/remote/ScreenNetworkRemote.java @@ -5,6 +5,7 @@ import com.lothrazar.storagenetwork.block.AbstractNetworkScreen; import com.lothrazar.storagenetwork.gui.NetworkScreenSize; import com.lothrazar.storagenetwork.gui.NetworkWidget; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -54,6 +55,12 @@ protected void renderBg(GuiGraphics ms, float partialTicks, int mouseX, int mous network.renderItemSlots(ms, mouseX, mouseY, font); } + @Override + public void resize(Minecraft mc, int w, int h) { + super.resize(mc,w,h); + network.resize(mc,w,h); + } + @Override public boolean getDownwards() { return ItemStorageCraftingRemote.getDownwards(remote); diff --git a/src/main/resources/assets/storagenetwork/textures/gui/inventory_expanded_bottom.png b/src/main/resources/assets/storagenetwork/textures/gui/inventory_expanded_bottom.png deleted file mode 100644 index 8ee440c3..00000000 Binary files a/src/main/resources/assets/storagenetwork/textures/gui/inventory_expanded_bottom.png and /dev/null differ diff --git a/src/main/resources/assets/storagenetwork/textures/gui/inventory_expanded_top.png b/src/main/resources/assets/storagenetwork/textures/gui/inventory_expanded_top.png deleted file mode 100644 index c3c801d7..00000000 Binary files a/src/main/resources/assets/storagenetwork/textures/gui/inventory_expanded_top.png and /dev/null differ