From 3f4c717de5ebc9b942d65ae45ac87c43bdf8a31b Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Tue, 3 Feb 2015 21:09:09 +0000 Subject: Made a few modifications to some classes, added earrings and bracelets. Improved coloring algorithm and balanced the Thieving Glove --- java/darkknight/jewelrycraft/container/Page.java | 92 +++++++++++++++--------- 1 file changed, 60 insertions(+), 32 deletions(-) (limited to 'java/darkknight/jewelrycraft/container/Page.java') diff --git a/java/darkknight/jewelrycraft/container/Page.java b/java/darkknight/jewelrycraft/container/Page.java index 77a0fa2..69de204 100644 --- a/java/darkknight/jewelrycraft/container/Page.java +++ b/java/darkknight/jewelrycraft/container/Page.java @@ -1,20 +1,24 @@ package darkknight.jewelrycraft.container; import java.util.ArrayList; - -import org.lwjgl.opengl.GL11; +import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + import darkknight.jewelrycraft.client.GuiGuide; public class Page { - public static void addCraftingRecipeTextPage(GuiGuide gui, int x, int y, boolean isSmall, ArrayList text, ArrayList items, int mouseX, int mouseY) + public static void addCraftingRecipeTextPage(GuiGuide gui, int x, int y, boolean isSmall, String text, ArrayList items, int mouseX, int mouseY) { y += 5; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + items.get(0).getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(items.get(0).getDisplayName()) / 2) - 10, y - 2, 0); GL11.glColor4f(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("jewelrycraft", "textures/gui/guidePageFlip.png")); @@ -27,7 +31,9 @@ public class Page if (items.size() > 1 && items.get(1) != null) { gui.renderItem(items.get(1), x + 8, y + 16 + 10, 30f); - if (x - gui.getLeft() >= x + 8) gui.drawHoverString(text, x, y); + List list = new ArrayList(); + list.add(text); + if (x - gui.getLeft() >= x + 8) gui.drawHoverString(list, x, y); name.add(items.get(1).getDisplayName()); if (mouseX >= x && mouseX <= x + 16 && mouseY >= y + 10 && mouseY <= y + 26) gui.drawHoverString(name, x - 8, y + 10); name.removeAll(name); @@ -57,12 +63,11 @@ public class Page name.removeAll(name); GL11.glDisable(GL11.GL_LIGHTING); } - for (int i = 0; i < text.size(); i++) - gui.getFont().drawString(text.get(i), x, y + 55 + i * 12, 0); + drawText(gui, text, x, y + 25); } else { - gui.drawTexturedModalRect(x, y + 10, 145, 0, 111, 54); + gui.drawTexturedModalRect(x, y + 12, 145, 0, 111, 54); gui.renderItem(items.get(0), x + 91, y + 28 + 10, 30f); if (items.size() > 1 && items.get(1) != null) { @@ -114,80 +119,103 @@ public class Page } if (items.size() > 7 && items.get(7) != null) { - gui.renderItem(items.get(7), x + 8, y + 57, 30f); + gui.renderItem(items.get(7), x + 8, y + 54, 30f); name.add(items.get(7).getDisplayName()); - if (mouseX >= x && mouseX <= x + 16 && mouseY >= y + 47 && mouseY <= y + 47 + 16) gui.drawHoverString(name, x + 8, y + 47); + if (mouseX >= x && mouseX <= x + 16 && mouseY >= y + 44 && mouseY <= y + 44 + 16) gui.drawHoverString(name, x + 8, y + 44); name.removeAll(name); GL11.glDisable(GL11.GL_LIGHTING); } if (items.size() > 8 && items.get(8) != null) { - gui.renderItem(items.get(8), x + 28, y + 57, 30f); + gui.renderItem(items.get(8), x + 28, y + 54, 30f); name.add(items.get(8).getDisplayName()); - if (mouseX >= x + 20 && mouseX <= x + 16 + 20 && mouseY >= y + 47 && mouseY <= y + 47 + 16) gui.drawHoverString(name, x + 28, y + 47); + if (mouseX >= x + 20 && mouseX <= x + 16 + 20 && mouseY >= y + 44 && mouseY <= y + 44 + 16) gui.drawHoverString(name, x + 28, y + 44); name.removeAll(name); GL11.glDisable(GL11.GL_LIGHTING); } if (items.size() > 9 && items.get(9) != null) { - gui.renderItem(items.get(9), x + 45, y + 57, 30f); + gui.renderItem(items.get(9), x + 45, y + 54, 30f); name.add(items.get(9).getDisplayName()); - if (mouseX >= x + 40 && mouseX <= x + 16 + 40 && mouseY >= y + 47 && mouseY <= y + 47 + 16) gui.drawHoverString(name, x + 45, y + 47); + if (mouseX >= x + 40 && mouseX <= x + 16 + 40 && mouseY >= y + 44 && mouseY <= y + 44 + 16) gui.drawHoverString(name, x + 45, y + 44); name.removeAll(name); GL11.glDisable(GL11.GL_LIGHTING); } - for (int i = 0; i < text.size(); i++) - gui.getFont().drawString(text.get(i), x, y + 62 + i * 12, 0); + drawText(gui, text, x, y + 32); GL11.glColor4f(1, 1, 1, 1); } + GL11.glDisable(GL11.GL_BLEND); } - public static void addSmeltingRecipeTextPage(GuiGuide gui, int x, int y, ArrayList text, ArrayList items, int mouseX, int mouseY) + public static void addSmeltingRecipeTextPage(GuiGuide gui, int x, int y, String text, ArrayList items, int mouseX, int mouseY) { ArrayList name = new ArrayList(); - gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + items.get(1).getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(items.get(0).getDisplayName()) / 2), y + 2, 0); + gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + items.get(1).getDisplayName(), x + 30 - items.get(0).getDisplayName().length() / 2, y + 2, 0); GL11.glColor4f(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("jewelrycraft", "textures/gui/guidePageFlip" + ".png")); - gui.drawTexturedModalRect(x, y + 10, 145, 100, 111, 46); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + gui.drawTexturedModalRect(x, y + 10, 145, 100, 111, 56); - gui.renderItem(items.get(0), x + 13, y + 20 + 10, 50f); + gui.renderItem(items.get(0), x + 13, y + 20 + 10, 35f); name.add(items.get(0).getDisplayName()); if (mouseX >= x && mouseX <= x + 20 && mouseY >= y + 20 && mouseY <= y + 20 + 16) gui.drawHoverString(name, x, y + 20); name.removeAll(name); GL11.glDisable(GL11.GL_LIGHTING); - gui.renderItem(items.get(1), x + 77, y + 28 + 10, 50f); - - for (int i = 0; i < text.size(); i++) - gui.getFont().drawString(text.get(i), x, y + 60 + i * 12, 0); + gui.renderItem(items.get(1), x + 77, y + 28 + 10, 35f); + drawText(gui, text, x, y + 30); GL11.glColor4f(1, 1, 1, 1); + GL11.glDisable(GL11.GL_BLEND); } - public static void addImageTextPage(GuiGuide gui, int x, int y, ItemStack item, ArrayList text, float size) + public static void addImageTextPage(GuiGuide gui, int x, int y, ItemStack item, String text, float size) { y += 5; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + item.getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(item.getDisplayName()) / 2) - 10, y + 2, 0); GL11.glColor4f(1, 1, 1, 1); gui.renderItem(item, x + 13, y + 18, size); - for (int i = 0; i < text.size(); i++) - gui.getFont().drawString(text.get(i), x, y + 30 + i * 12, 0); + drawText(gui, text, x, y); + GL11.glDisable(GL11.GL_BLEND); } - public static void addImageTextPage(GuiGuide gui, int x, int y, ItemStack item, ArrayList text, float size, int txtX, int txtY, boolean showName, int imgX, int imgY) + public static void addImageTextPage(GuiGuide gui, int x, int y, ItemStack item, String text, float size, int txtX, int txtY, boolean showName, int imgX, int imgY) { y += 5; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); if (showName) gui.getFont().drawString(EnumChatFormatting.DARK_BLUE + "\u00a7n" + item.getDisplayName(), x + Math.abs(70 - gui.getFont().getStringWidth(item.getDisplayName()) / 2) - 10, y + 2, 0); GL11.glColor4f(1, 1, 1, 1); gui.renderItem(item, x + 13 + imgX, y + 18 + imgY, size); - for (int i = 0; i < text.size(); i++) - gui.getFont().drawString(text.get(i), x + txtX, y + 30 + txtY + i * 12, 0); + drawText(gui, text, x + txtX, y + txtY); + GL11.glDisable(GL11.GL_BLEND); } - public static void addTextPage(GuiGuide gui, int x, int y, ArrayList text) + public static void addTextPage(GuiGuide gui, int x, int y, String text) { y -= 25; - for (int i = 0; i < text.size(); i++) - gui.getFont().drawString(text.get(i), x, y + 30 + i * 12, 0); + drawText(gui, text, x, y); GL11.glColor4f(1, 1, 1, 1); } + + public static void drawText(GuiGuide gui, String text, int x, int y) + { + String[] s = text.split(" "); + String displayText = ""; + ArrayList textLines = new ArrayList(); + for (int i = 0; i < s.length; i++) + { + if ((displayText + s[i] + " ").length() <= 24) displayText += s[i] + " "; + else + { + textLines.add(displayText.trim()); + displayText = s[i] + " "; + } + } + textLines.add(displayText.trim()); + for (int i = 0; i < textLines.size(); i++) + gui.getFont().drawString(textLines.get(i), x, y + 30 + i * 12, 0); + } } -- cgit v1.2.3