diff --git a/src/main/java/baubles/client/gui/GuiBaublesButton.java b/src/main/java/baubles/client/gui/GuiBaublesButton.java index d27aa51..1a54211 100644 --- a/src/main/java/baubles/client/gui/GuiBaublesButton.java +++ b/src/main/java/baubles/client/gui/GuiBaublesButton.java @@ -7,6 +7,8 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.renderer.OpenGlHelper; +import static baubles.common.BaublesConfig.useOldGuiButton; + public class GuiBaublesButton extends GuiButton { public GuiBaublesButton(int buttonId, int xIn, int yIn, int widthIn, int heightIn, String resource) { @@ -17,7 +19,11 @@ public class GuiBaublesButton extends GuiButton { if (this.visible) { FontRenderer fontrenderer = mc.fontRenderer; - mc.getTextureManager().bindTexture(GuiPlayerExpanded.gui_background); + if (useOldGuiButton) { + mc.getTextureManager().bindTexture(GuiPlayerExpanded.background); + } else { + mc.getTextureManager().bindTexture(GuiPlayerExpanded.gui_background); + } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.field_146123_n = xx >= this.xPosition && yy >= this.yPosition && xx < this.xPosition + this.width && yy < this.yPosition + this.height; int hover = this.getHoverState(this.field_146123_n); @@ -27,41 +33,48 @@ public class GuiBaublesButton extends GuiButton { if (hover == 1) { - this.drawTexturedModalRect(this.xPosition, this.yPosition, 50, 0, 14, 14); - } else { - this.drawTexturedModalRect(this.xPosition, this.yPosition, 50, 14, 14, 14); - - int k = 0; - int w = fontrenderer.getStringWidth(this.displayString); - - if (w > k) { - k = w; + if (useOldGuiButton) { + this.drawTexturedModalRect(this.xPosition, this.yPosition, 200, 48, 10, 10); + } else { + this.drawTexturedModalRect(this.xPosition, this.yPosition, 50, 0, 14, 14); } + } else { + if (useOldGuiButton) { + this.drawTexturedModalRect(this.xPosition, this.yPosition, 210, 48, 10, 10); + this.drawCenteredString(fontrenderer, this.displayString, + this.xPosition + 5, this.yPosition + this.height, 0xffffff); + } else { + this.drawTexturedModalRect(this.xPosition, this.yPosition, 50, 14, 14, 14); - int j2 = this.xPosition + 20; - int k2 = this.yPosition - this.height; - int i1 = 8; + int k = 0; + int w = fontrenderer.getStringWidth(this.displayString); - int j1 = -267386864; - this.drawGradientRect(j2 - 3, k2 - 4, j2 + k + 3, k2 - 3, j1, j1); - this.drawGradientRect(j2 - 3, k2 + i1 + 3, j2 + k + 3, k2 + i1 + 4, j1, j1); - this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 + i1 + 3, j1, j1); - this.drawGradientRect(j2 - 4, k2 - 3, j2 - 3, k2 + i1 + 3, j1, j1); - this.drawGradientRect(j2 + k + 3, k2 - 3, j2 + k + 4, k2 + i1 + 3, j1, j1); - int k1 = 1347420415; - int l1 = (k1 & 16711422) >> 1 | k1 & -16777216; - this.drawGradientRect(j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + i1 + 3 - 1, k1, l1); - this.drawGradientRect(j2 + k + 2, k2 - 3 + 1, j2 + k + 3, k2 + i1 + 3 - 1, k1, l1); - this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 - 3 + 1, k1, k1); - this.drawGradientRect(j2 - 3, k2 + i1 + 2, j2 + k + 3, k2 + i1 + 3, l1, l1); + if (w > k) { + k = w; + } - this.drawString(fontrenderer, this.displayString, this.xPosition + 20, - this.yPosition - this.height, 0xffffff); + int j2 = this.xPosition + 20; + int k2 = this.yPosition - this.height; + int i1 = 8; + + int j1 = -267386864; + this.drawGradientRect(j2 - 3, k2 - 4, j2 + k + 3, k2 - 3, j1, j1); + this.drawGradientRect(j2 - 3, k2 + i1 + 3, j2 + k + 3, k2 + i1 + 4, j1, j1); + this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 + i1 + 3, j1, j1); + this.drawGradientRect(j2 - 4, k2 - 3, j2 - 3, k2 + i1 + 3, j1, j1); + this.drawGradientRect(j2 + k + 3, k2 - 3, j2 + k + 4, k2 + i1 + 3, j1, j1); + int k1 = 1347420415; + int l1 = (k1 & 16711422) >> 1 | k1 & -16777216; + this.drawGradientRect(j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + i1 + 3 - 1, k1, l1); + this.drawGradientRect(j2 + k + 2, k2 - 3 + 1, j2 + k + 3, k2 + i1 + 3 - 1, k1, l1); + this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 - 3 + 1, k1, k1); + this.drawGradientRect(j2 - 3, k2 + i1 + 2, j2 + k + 3, k2 + i1 + 3, l1, l1); + + this.drawString(fontrenderer, this.displayString, this.xPosition + 20, + this.yPosition - this.height, 0xffffff); + } + this.mouseDragged(mc, xx, yy); } - - this.mouseDragged(mc, xx, yy); - } } - } diff --git a/src/main/java/baubles/client/gui/GuiEvents.java b/src/main/java/baubles/client/gui/GuiEvents.java index 4d0f63e..3e4adf7 100644 --- a/src/main/java/baubles/client/gui/GuiEvents.java +++ b/src/main/java/baubles/client/gui/GuiEvents.java @@ -12,6 +12,8 @@ import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.client.resources.I18n; import net.minecraftforge.client.event.GuiScreenEvent; +import static baubles.common.BaublesConfig.useOldGuiButton; + public class GuiEvents { @SideOnly(value = Side.CLIENT) @@ -30,8 +32,13 @@ public class GuiEvents { guiLeft = 160 + (event.gui.width - xSize - 200) / 2; } - event.buttonList.add(new GuiBaublesButton(55, guiLeft + 26, guiTop + 9, 10, 10, - I18n.format((event.gui instanceof GuiInventory)?"button.baubles":"button.normal", new Object[0]))); + if (useOldGuiButton) { + event.buttonList.add(new GuiBaublesButton(55, guiLeft + 66, guiTop + 9, 10, 10, + I18n.format((event.gui instanceof GuiInventory)?"button.baubles":"button.normal", new Object[0]))); + } else { + event.buttonList.add(new GuiBaublesButton(55, guiLeft + 26, guiTop + 9, 10, 10, + I18n.format((event.gui instanceof GuiInventory) ? "button.baubles" : "button.normal", new Object[0]))); + } } } diff --git a/src/main/java/baubles/client/gui/GuiPlayerExpanded.java b/src/main/java/baubles/client/gui/GuiPlayerExpanded.java index 938598c..0a8306b 100644 --- a/src/main/java/baubles/client/gui/GuiPlayerExpanded.java +++ b/src/main/java/baubles/client/gui/GuiPlayerExpanded.java @@ -34,13 +34,14 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import static baubles.common.BaublesConfig.useOldGuiRendering; import static net.minecraft.client.gui.inventory.GuiInventory.func_147046_a; @Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems") public class GuiPlayerExpanded extends GuiContainer implements INEIGuiHandler { + public static final ResourceLocation background = new ResourceLocation("baubles","textures/gui/bauble_inventory.png"); public static final ResourceLocation gui_background = new ResourceLocation("baubles","textures/gui/bauble_background.png"); - private static final ResourceLocation creative_inventory_tabs = new ResourceLocation("textures/gui/container/creative_inventory/tabs.png"); /** @@ -54,7 +55,7 @@ public class GuiPlayerExpanded extends GuiContainer implements INEIGuiHandler { public boolean showActivePotionEffects; - /** Amount scrolled in Creative mode inventory (0 = top, 1 = bottom) */ + /** Amount scrolled in inventory (0 = top, 1 = bottom) */ private float currentScroll; /** True if the scrollbar is being dragged */ private boolean isScrolling; @@ -84,7 +85,7 @@ public class GuiPlayerExpanded extends GuiContainer implements INEIGuiHandler { buttonList.clear(); super.initGui(); - if (!this.mc.thePlayer.getActivePotionEffects().isEmpty()) { + if (!this.mc.thePlayer.getActivePotionEffects().isEmpty() && !useOldGuiRendering) { this.showActivePotionEffects = true; } } @@ -103,13 +104,20 @@ public class GuiPlayerExpanded extends GuiContainer implements INEIGuiHandler { @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - this.fontRendererObj.drawString(I18n.format("container.crafting"), 86, 16, 4210752); + if (!useOldGuiRendering) { + this.fontRendererObj.drawString(I18n.format("container.crafting"), 86, 16, 4210752); + } } @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.getTextureManager().bindTexture(GuiInventory.field_147001_a); + if (useOldGuiRendering) { + mc.getTextureManager().bindTexture(background); + } else { + mc.getTextureManager().bindTexture(GuiInventory.field_147001_a); + } + this.drawBaubleSlots(); if (showActivePotionEffects) { drawPotionEffects(); @@ -122,34 +130,36 @@ public class GuiPlayerExpanded extends GuiContainer implements INEIGuiHandler { private void drawBaubleSlots() { drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); int upperHeight = 7 + BaubleExpandedSlots.slotsCurrentlyUsed() * 18; - this.mc.getTextureManager().bindTexture(gui_background); + if (!useOldGuiRendering) { + this.mc.getTextureManager().bindTexture(gui_background); + } final int slotOffset = 18; - final int slotStartX = guiLeft - 26; - final int slotStartY = 12; + int slotStartX = guiLeft - 26; + int slotStartY = 12; - if (BaubleExpandedSlots.slotsCurrentlyUsed() <= 8) { - this.drawTexturedModalRect(this.guiLeft - 26, this.guiTop + 4, 0, 0, 27, upperHeight); - this.drawTexturedModalRect(this.guiLeft - 26, this.guiTop + 4 + upperHeight, 0, 151, 27, 7); + if (useOldGuiRendering) { + slotStartX = guiLeft + 79; + slotStartY = guiTop +7; } else { - this.drawTexturedModalRect(this.guiLeft - 26, this.guiTop + 4, 0, 0, 27, 158); - this.drawTexturedModalRect(this.guiLeft - 42, this.guiTop + 4, 27, 0, 23, 158); - this.mc.getTextureManager().bindTexture(creative_inventory_tabs); - this.drawTexturedModalRect(this.guiLeft - 34, this.guiTop + 12 + (int) (127f * this.currentScroll), 232, 0, 12, 15); + if (BaubleExpandedSlots.slotsCurrentlyUsed() <= 8) { + this.drawTexturedModalRect(this.guiLeft - 26, this.guiTop + 4, 0, 0, 27, upperHeight); + this.drawTexturedModalRect(this.guiLeft - 26, this.guiTop + 4 + upperHeight, 0, 151, 27, 7); + } else { + this.drawTexturedModalRect(this.guiLeft - 26, this.guiTop + 4, 0, 0, 27, 158); + this.drawTexturedModalRect(this.guiLeft - 42, this.guiTop + 4, 27, 0, 23, 158); + this.mc.getTextureManager().bindTexture(creative_inventory_tabs); + this.drawTexturedModalRect(this.guiLeft - 34, this.guiTop + 12 + (int) (127f * this.currentScroll), 232, 0, 12, 15); + } } //bauble slot backgrounds for (int slotIndex = 0; slotIndex < BaubleExpandedSlots.slotLimit; slotIndex++) { String slotType = BaubleExpandedSlots.getSlotType(slotIndex); - int slotPage = 1; if (BaublesConfig.showUnusedSlots || !slotType.equals(BaubleExpandedSlots.unknownType)) { - //Slot slot = (Slot)inventorySlots.inventorySlots.get(slotIndex + 4); - - - if (BaubleExpandedSlots.slotsCurrentlyUsed() <= 8 && slotPage == 1) { - drawTexturedModalRect(slotStartX + (slotOffset * (slotIndex / 4)), slotStartY + (slotOffset * slotIndex), 200, 0, 18, 18); - } - if (BaubleExpandedSlots.slotsCurrentlyUsed() >= 9 && BaubleExpandedSlots.slotsCurrentlyUsed() >= 16 && slotPage == 2) { + if (useOldGuiRendering) { + drawTexturedModalRect(slotStartX + (slotOffset * (slotIndex / 4)), slotStartY + (slotOffset * (slotIndex % 4)), 200, 0, 18, 18); + } else { drawTexturedModalRect(slotStartX + (slotOffset * (slotIndex / 4)), slotStartY + (slotOffset * slotIndex), 200, 0, 18, 18); } } @@ -296,7 +306,7 @@ public class GuiPlayerExpanded extends GuiContainer implements INEIGuiHandler { @Optional.Method(modid = "NotEnoughItems") public boolean hideItemPanelSlot(GuiContainer gui, int slotX, int slotY, int slotW, int slotH) { int upperHeight = 7 + BaubleExpandedSlots.slotsCurrentlyUsed() * 18; - if (gui instanceof GuiPlayerExpanded) { + if (gui instanceof GuiPlayerExpanded && !useOldGuiRendering) { int slotIndent = 26; int slotWidth = 18; diff --git a/src/main/java/baubles/common/BaublesConfig.java b/src/main/java/baubles/common/BaublesConfig.java index 9a56363..ba66f74 100644 --- a/src/main/java/baubles/common/BaublesConfig.java +++ b/src/main/java/baubles/common/BaublesConfig.java @@ -10,6 +10,9 @@ public class BaublesConfig { public static boolean hideDebugItem = true; public static int[] soulBoundEnchantments = new int[] {}; + + public static boolean useOldGuiButton = false; + public static boolean useOldGuiRendering = false; public static boolean showUnusedSlots = false; public static boolean manualSlotSelection = false; @@ -39,6 +42,8 @@ public class BaublesConfig { ).getIntList(); //categoryMenu + useOldGuiButton = config.getBoolean("useOldGGuiButton", categoryMenu, useOldGuiButton, "Use the old Baubles Button texture and location instead.\n"); + useOldGuiRendering = config.getBoolean("useOldRendering", categoryMenu, useOldGuiRendering, "Display the old Bauble GUI instead of the new sidebar.\n"); showUnusedSlots = config.getBoolean("showUnusedSlots", categoryMenu, showUnusedSlots, "Display unused Bauble slots.\n"); manualSlotSelection = config.getBoolean("manualSlotSelection", categoryMenu, manualSlotSelection, "Manually override slot assignments.\n!Bauble slot types must be configured manually with this option enabled!\n" diff --git a/src/main/java/baubles/common/container/ContainerPlayerExpanded.java b/src/main/java/baubles/common/container/ContainerPlayerExpanded.java index 5f09544..9b28597 100644 --- a/src/main/java/baubles/common/container/ContainerPlayerExpanded.java +++ b/src/main/java/baubles/common/container/ContainerPlayerExpanded.java @@ -23,19 +23,17 @@ import net.minecraft.util.IIcon; import javax.annotation.Nonnull; +import static baubles.common.BaublesConfig.useOldGuiRendering; + public class ContainerPlayerExpanded extends Container { public InventoryCrafting craftMatrix = new InventoryCrafting(this, 2, 2); public IInventory craftResult = new InventoryCraftResult(); public InventoryBaubles baubles; - private int lastScrollIndex; - - public boolean isLocalWorld; private final EntityPlayer thePlayer; public ContainerPlayerExpanded(InventoryPlayer playerInv, boolean par2, EntityPlayer player) { - this.isLocalWorld = player.worldObj.isRemote; this.thePlayer = player; baubles = new InventoryBaubles(player); baubles.setEventHandler(this); @@ -43,14 +41,16 @@ public class ContainerPlayerExpanded extends Container { baubles.stackList = PlayerHandler.getPlayerBaubles(player).stackList; } - this.addSlotToContainer(new SlotCrafting(playerInv.player, this.craftMatrix, this.craftResult, 0, 144, 36)); - int i; int j; - for (i = 0; i < 2; ++i) { - for (j = 0; j < 2; ++j) { - this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 2, 88 + j * 18, 26 + i * 18)); + if (!useOldGuiRendering) { + this.addSlotToContainer(new SlotCrafting(playerInv.player, this.craftMatrix, this.craftResult, 0, 144, 36)); + + for (i = 0; i < 2; ++i) { + for (j = 0; j < 2; ++j) { + this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 2, 88 + j * 18, 26 + i * 18)); + } } } @@ -76,17 +76,21 @@ public class ContainerPlayerExpanded extends Container { } final int slotOffset = 18; + final int slotStartX = 80; + final int slotStartY = 8; //Bauble Slots for(i = 0; i < BaubleExpandedSlots.slotLimit; i++) { String slotType = BaubleExpandedSlots.getSlotType(i); if(BaublesConfig.showUnusedSlots || !slotType.equals(BaubleExpandedSlots.unknownType)) { - addSlotToContainer(new SlotBauble(baubles, slotType, i, -18, 12 + (slotOffset * i))); + if (useOldGuiRendering) { + addSlotToContainer(new SlotBauble(baubles, slotType, i, slotStartX + (slotOffset * (i / 4)), slotStartY + (slotOffset * (i % 4)))); + } else { + addSlotToContainer(new SlotBauble(baubles, slotType, i, -18, 12 + (slotOffset * i))); + } } } - final int slotStartY = 8; - //inventory slots for (i = 0; i < 3; ++i) { for (j = 0; j < 9; ++j) { @@ -99,29 +103,33 @@ public class ContainerPlayerExpanded extends Container { this.addSlotToContainer(new Slot(playerInv, i, slotStartY + i * slotOffset, 142)); } - this.onCraftMatrixChanged(this.craftMatrix); - this.scrollTo(0); + if (!useOldGuiRendering) { + this.onCraftMatrixChanged(this.craftMatrix); + this.scrollTo(0); + } } @Override public void onCraftMatrixChanged(IInventory par1IInventory) { + if (!useOldGuiRendering) { this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.thePlayer.worldObj)); + } } @Override public void onContainerClosed(EntityPlayer player) { super.onContainerClosed(player); - for (int i = 0; i < 4; ++i) { - ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); + if (!useOldGuiRendering) { + for (int i = 0; i < 4; ++i) { + ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); - if (itemstack != null) { - player.dropPlayerItemWithRandomChoice(itemstack, false); + if (itemstack != null) { + player.dropPlayerItemWithRandomChoice(itemstack, false); + } } - } - this.craftResult.setInventorySlotContents(0, (ItemStack)null); - if (!player.worldObj.isRemote) { - PlayerHandler.setPlayerBaubles(player, baubles); + this.craftResult.setInventorySlotContents(0, (ItemStack) null); + //if (!player.worldObj.isRemote) {PlayerHandler.setPlayerBaubles(player, baubles);} } } @@ -156,7 +164,7 @@ public class ContainerPlayerExpanded extends Container { } public boolean canScroll() { - if (BaubleExpandedSlots.slotsCurrentlyUsed() > 8) { + if (BaubleExpandedSlots.slotsCurrentlyUsed() > 8 && !useOldGuiRendering) { return true; } return false; @@ -175,7 +183,10 @@ public class ContainerPlayerExpanded extends Container { public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) { ItemStack returnStack = null; Slot slot = (Slot) inventorySlots.get(slotIndex); - final int visibleBaubleSlots = BaublesConfig.showUnusedSlots ? BaubleExpandedSlots.slotLimit : BaubleExpandedSlots.slotsCurrentlyUsed(); + int visibleBaubleSlots = BaublesConfig.showUnusedSlots ? BaubleExpandedSlots.slotLimit : BaubleExpandedSlots.slotsCurrentlyUsed(); + if (useOldGuiRendering) { + visibleBaubleSlots -= -5; + } if(slot != null && slot.getHasStack()) { ItemStack originalStack = slot.getStack();