diff --git a/src/main/java/com/hbm/inventory/gui/GUIScreenGuide.java b/src/main/java/com/hbm/inventory/gui/GUIScreenGuide.java index 9f88cc91e..aa0ada45f 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIScreenGuide.java +++ b/src/main/java/com/hbm/inventory/gui/GUIScreenGuide.java @@ -7,7 +7,9 @@ import org.apache.commons.lang3.math.NumberUtils; import org.lwjgl.opengl.GL11; import com.hbm.items.tool.ItemGuideBook.BookType; +import com.hbm.items.tool.ItemGuideBook.GuideImage; import com.hbm.items.tool.ItemGuideBook.GuidePage; +import com.hbm.items.tool.ItemGuideBook.GuideText; import com.hbm.lib.RefStrings; import com.hbm.util.I18nUtil; @@ -133,67 +135,77 @@ public class GUIScreenGuide extends GuiScreen { if(defacto < this.type.pages.size()) { - GuidePage page = this.type.pages.get(defacto); + GuidePage page = this.type.pages.get(defacto); - float scale = page.scale; - String text = I18nUtil.resolveKey(page.text); - int width = 100; - - int widthScaled = (int) (width * scale); - List lines = new ArrayList(); - String[] words = text.split(" "); - - lines.add(words[0]); - int indent = this.fontRendererObj.getStringWidth(words[0]); - - for(int w = 1; w < words.length; w++) { - - indent += this.fontRendererObj.getStringWidth(" " + words[w]); - - if(indent <= widthScaled) { - String last = lines.get(lines.size() - 1); - lines.set(lines.size() - 1, last += (" " + words[w])); - } else { - lines.add(words[w]); - indent = this.fontRendererObj.getStringWidth(words[w]); - } - } - - float titleScale = getOverrideScale(page.titleScale, page.title + ".scale"); - - GL11.glPushMatrix(); - GL11.glScalef(1F/scale, 1F/scale, 1F); - - float topOffset = page.title == null ? 0 : 6 / titleScale; - - for(int l = 0; l < lines.size(); l++) { - this.fontRendererObj.drawString(lines.get(l), (int)((guiLeft + 20 + i * sideOffset) * scale), (int)((guiTop + 30 + topOffset) * scale + (12 * l)), 4210752); - } - - GL11.glPopMatrix(); + for(GuideText textBox : page.texts) { + float scale = textBox.scale; + String text = I18nUtil.resolveKey(textBox.text); + int width = textBox.width; + + int widthScaled = (int) (width * scale); + List lines = new ArrayList(); + String[] words = text.split(" "); + + lines.add(words[0]); + int indent = this.fontRendererObj.getStringWidth(words[0]); + + for(int w = 1; w < words.length; w++) { + + indent += this.fontRendererObj.getStringWidth(" " + words[w]); + + if(indent <= widthScaled) { + String last = lines.get(lines.size() - 1); + lines.set(lines.size() - 1, last += (" " + words[w])); + } else { + lines.add(words[w]); + indent = this.fontRendererObj.getStringWidth(words[w]); + } + } + + float titleScale = getOverrideScale(page.titleScale, page.title + ".scale"); + + GL11.glPushMatrix(); + GL11.glScalef(1F/scale, 1F/scale, 1F); + + float topOffset; + + if(textBox.y == -1) { + topOffset = page.title == null ? 0 : 6 / titleScale; + } else { + topOffset = textBox.y; + } + + for(int l = 0; l < lines.size(); l++) { + this.fontRendererObj.drawString(lines.get(l), (int)((guiLeft + 20 + i * sideOffset + textBox.xOffset) * scale), (int)((guiTop + 30 + topOffset) * scale + (12 * l)), 4210752); + } + + GL11.glPopMatrix(); + } if(page.title != null) { - float tScale = titleScale; + float tScale = page.titleScale; String titleLoc = I18nUtil.resolveKey(page.title); GL11.glPushMatrix(); GL11.glScalef(1F/tScale, 1F/tScale, 1F); - this.fontRendererObj.drawString(titleLoc, (int)((guiLeft + 20 + i * sideOffset + ((width / 2) - (this.fontRendererObj.getStringWidth(titleLoc) / 2 / tScale))) * tScale), (int)((guiTop + 20) * tScale), page.titleColor); + this.fontRendererObj.drawString(titleLoc, (int)((guiLeft + 20 + i * sideOffset + ((100 / 2) - (this.fontRendererObj.getStringWidth(titleLoc) / 2 / tScale))) * tScale), (int)((guiTop + 20) * tScale), page.titleColor); GL11.glPopMatrix(); } - if(page.image != null) { - GL11.glColor4f(1F, 1F, 1F, 1F); - Minecraft.getMinecraft().getTextureManager().bindTexture(page.image); - - int ix = page.x; - - if(ix == -1) - ix = width / 2 - page.sizeX / 2; - - drawImage(guiLeft + 20 + ix + sideOffset * i, guiTop + page.y, page.sizeX, page.sizeY); + if(!page.images.isEmpty()) { + for(GuideImage image : page.images) { + GL11.glColor4f(1F, 1F, 1F, 1F); + Minecraft.getMinecraft().getTextureManager().bindTexture(image.image); + + int ix = image.x; + + if(ix == -1) + ix = 100 / 2 - image.sizeX / 2; + + drawImage(guiLeft + 20 + ix + sideOffset * i, guiTop + image.y, image.sizeX, image.sizeY); + } } String pageLabel = (defacto + 1) + "/" + (this.type.pages.size()); diff --git a/src/main/java/com/hbm/items/tool/ItemGuideBook.java b/src/main/java/com/hbm/items/tool/ItemGuideBook.java index 545354fd7..de2796e40 100644 --- a/src/main/java/com/hbm/items/tool/ItemGuideBook.java +++ b/src/main/java/com/hbm/items/tool/ItemGuideBook.java @@ -70,20 +70,69 @@ public class ItemGuideBook extends Item { public static List statFacTest() { List pages = new ArrayList(); - pages.add(new GuidePage("book.test.page1").addTitle("Title LMAO", 0x800000, 1F).setScale(2F).addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/smileman.png"), 100, 40, 40)); + /*pages.add(new GuidePage("book.test.page1").addTitle("Title LMAO", 0x800000, 1F).setScale(2F).addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/smileman.png"), 100, 40, 40)); pages.add(new GuidePage("book.test.page1").addTitle("LA SEXO", 0x800000, 0.5F).setScale(1.75F).addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/smileman.png"), 100, 40, 40)); pages.add(new GuidePage("test test")); pages.add(new GuidePage("test test test")); pages.add(new GuidePage("test test")); pages.add(new GuidePage("test test test")); - pages.add(new GuidePage("test test")); + pages.add(new GuidePage("test test"));*/ return pages; } + //TODO: Make sure this is all correct public static List statFacRBMK() { List pages = new ArrayList(); - pages.add(new GuidePage("book.rbmk.page1").setScale(2F).addTitle("book.rbmk.title1", 0x800000, 1F) + pages.add(new GuidePage().addTitle("book.rbmk.title1", 0x800000, 1F) + .addText("book.rbmk.page1", 2F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk1.png"), 90, 80, 60)); + pages.add(new GuidePage().addTitle("book.rbmk.title2", 0x800000, 1F) + .addText("book.rbmk.page2", 2F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk2.png"), 95, 52, 52)); + pages.add(new GuidePage().addTitle("book.rbmk.title3", 0x800000, 1F) + .addText("book.rbmk.page3", 2F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk3.png"), 95, 88, 52)); + pages.add(new GuidePage().addTitle("book.rbmk.title4", 0x800000, 1F) + .addText("book.rbmk.page4", 2F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk4.png"), 95, 88, 52)); + pages.add(new GuidePage().addTitle("book.rbmk.title5", 0x800000, 1F) + .addText("book.rbmk.page5", 2F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk5.png"), 95, 80, 42)); + pages.add(new GuidePage().addTitle("book.rbmk.title6", 0x800000, 1F) + .addText("book.rbmk.page6", 2F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk6.png"), 90, 100, 60)); + pages.add(new GuidePage().addTitle("book.rbmk.title7", 0x800000, 1F) + .addText("book.rbmk.page7", 2F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk7.png"), 95, 52, 52)); + pages.add(new GuidePage().addTitle("book.rbmk.title8", 0x800000, 1F) + .addText("book.rbmk.page8", 2F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk8.png"), 95, 88, 52)); + pages.add(new GuidePage().addTitle("book.rbmk.title9", 0x800000, 1F) + .addText("book.rbmk.page9", 2F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk9.png"), 95, 88, 52)); + pages.add(new GuidePage().addTitle("book.rbmk.title10", 0x800000, 1F) + .addText("book.rbmk.page10", 2F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk10.png"), 95, 88, 52)); + pages.add(new GuidePage().addTitle("book.rbmk.title11", 0x800000, 1F) + .addText("book.rbmk.page11", 2F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk11.png"), 75, 85, 72)); + pages.add(new GuidePage().addTitle("book.rbmk.title12", 0x800000, 1F) + .addText("book.rbmk.page12", 2F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk12.png"), 90, 80, 60)); + pages.add(new GuidePage().addTitle("book.rbmk.title13", 0x800000, 1F) + .addText("book.rbmk.page13", 2F)); + pages.add(new GuidePage() + .addText("book.rbmk.page14", 2F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk13.png"), 70, 103, 78)); + pages.add(new GuidePage().addTitle("book.rbmk.title15", 0x800000, 1F) + .addText("book.rbmk.page15", 2F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk15.png"), 100, 48, 48)); + pages.add(new GuidePage().addTitle("book.rbmk.title16", 0x800000, 1F) + .addText("book.rbmk.page16", 2F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk16.png"), 50, 70, 100)); + + /*pages.add(new GuidePage("book.rbmk.page1").setScale(2F).addTitle("book.rbmk.title1", 0x800000, 1F) .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk1.png"), 90, 80, 60)); pages.add(new GuidePage("book.rbmk.page2").setScale(2F).addTitle("book.rbmk.title2", 0x800000, 1F) .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk2.png"), 95, 52, 52)); @@ -113,7 +162,7 @@ public class ItemGuideBook extends Item { pages.add(new GuidePage("book.rbmk.page15").setScale(2F).addTitle("book.rbmk.title15", 0x800000, 1F) .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk15.png"), 100, 48, 48)); pages.add(new GuidePage("book.rbmk.page16").setScale(2F).addTitle("book.rbmk.title16", 0x800000, 1F) - .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk16.png"), 50, 70, 100)); + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/rbmk16.png"), 50, 70, 100));*/ return pages; } @@ -122,9 +171,13 @@ public class ItemGuideBook extends Item { List pages = new ArrayList(); for(int i = 1; i <= 9; i++) { - pages.add(new GuidePage("book.error.page" + i).setScale(2F).addTitle("book.error.title" + i, 0x800000, 1F)); + pages.add(new GuidePage().addTitle("book.error.title" + i, 0x800000, 1F).addText("book.error.page" + i, 2F)); } + /*for(int i = 1; i <= 9; i++) { + pages.add(new GuidePage("book.error.page" + i).setScale(2F).addTitle("book.error.title" + i, 0x800000, 1F)); + }*/ + return pages; } @@ -135,9 +188,28 @@ public class ItemGuideBook extends Item { List pages = new ArrayList(); - //TODO: Figure out why non-whole scales stretch and fuck up the text - pages.add(new GuidePage("book.starter.page1").setScale(2F).addTitle("book.starter.title1", 0x800000, 1F) - .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/starter1.png"), 95, 100, 56)); + pages.add(new GuidePage().addTitle("book.starter.title1", 0x800000, 1F) + .addText("book.starter.page1", 2F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/starter1.png"), 96, 101, 56)); + pages.add(new GuidePage().addTitle("book.starter.title2", 0x800000, 1F) + .addText("book.starter.page2", 2F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/starter2.png"), 105, 82, 40)); + pages.add(new GuidePage().addTitle("book.starter.title3", 0x800000, 1F) + .addText("book.starter.page3", 2F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/starter3a.png"), 10, 95, 39, 54) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/starter3b.png"), 55, 95, 39, 54)); + pages.add(new GuidePage().addTitle("book.starter.title4", 0x800000, 1F) + .addText("book.starter.page4", 1.4F, 0, 0, 64) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/items/stamp_iron_flat.png"), 72, 30, 32, 32) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/items/assembly_template.png"), 72, 78, 32, 32) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/items/chemistry_template.png"), 72, 127, 32, 32)); + + /*pages.add(new GuidePage("book.starter.page1").setScale(2F).addTitle("book.starter.title1", 0x800000, 1F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/starter1.png"), 96, 101, 56)); + pages.add(new GuidePage("book.starter.page2").setScale(2F).addTitle("book.starter.title2", 0x800000, 1F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/starter2.png"), 105, 82, 40)); + pages.add(new GuidePage("book.starter.page3").setScale(2F).addTitle("book.starter.title3", 0x800000, 1F) + .addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/starter3.png"), 105, 82, 40));*/ return pages; } @@ -147,17 +219,58 @@ public class ItemGuideBook extends Item { public String title; public int titleColor; public float titleScale; - public String text; + + public List texts = new ArrayList(); + public List images = new ArrayList(); + + /*public String text; public ResourceLocation image; public float scale = 1F; public int x; public int y; public int sizeX; - public int sizeY; + public int sizeY;*/ public GuidePage() { } - public GuidePage(String text) { + public GuidePage addTitle(String title, int color, float scale) { + this.title = title; + this.titleColor = color; + this.titleScale = scale; + return this; + } + + public GuidePage addText(String text) { + texts.add(new GuideText(text)); + return this; + } + + public GuidePage addText(String text, float scale) { + texts.add(new GuideText(text).setScale(scale)); + return this; + } + + public GuidePage addText(String text, int xOffset, int y, int width) { + texts.add(new GuideText(text).setSize(xOffset, y, width)); + return this; + } + + public GuidePage addText(String text, float scale, int xOffset, int y, int width) { + texts.add(new GuideText(text).setSize(xOffset, y, width).setScale(scale)); + return this; + } + + public GuidePage addImage(ResourceLocation image, int x, int y, int sizeX, int sizeY) { + images.add(new GuideImage(image, x, y, sizeX, sizeY)); + return this; + } + + public GuidePage addImage(ResourceLocation image, int y, int sizeX, int sizeY) { + images.add(new GuideImage(image, -1, y, sizeX, sizeY)); + return this; + } + + /*public GuidePage(String text) { this.text = text; } @@ -186,6 +299,46 @@ public class ItemGuideBook extends Item { //if the x-coord is -1 then it will automatically try to center the image horizontally public GuidePage addImage(ResourceLocation image, int y, int sizeX, int sizeY) { return addImage(image, -1, y, sizeX, sizeY); + }*/ + } + + public static class GuideText { + public String text; + public float scale = 1F; + public int xOffset = 0; + public int y = -1; + public int width = 100; + + public GuideText(String text) { + this.text = text; + } + + public GuideText setScale(float scale) { + this.scale = scale; + return this; + } + + public GuideText setSize(int xOffset, int y, int width) { + this.xOffset = xOffset; + this.y = y; + this.width = width; + return this; + } + } + + public static class GuideImage { + public ResourceLocation image; + public int x; + public int y; + public int sizeX; + public int sizeY; + + public GuideImage(ResourceLocation image, int x, int y, int sizeX, int sizeY) { + this.image = image; + this.x = x; + this.y = y; + this.sizeX = sizeX; + this.sizeY = sizeY; } } } diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index 5cafcd361..8ae4e4cf5 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -207,6 +207,12 @@ book.rbmk.page16=§4§lAVOID. book.starter.cover=An Industrialist's$Guide to Rebuilding$Society book.starter.title1=Introduction book.starter.page1=If you're reading this, it's highly likely that society, in one way or another, has collapsed entirely. Governments, countries, and authority are a concept of the past - along with all of the amenities of civilized life. As such, this guide will inform you how to change that by recreating the industry and technology of the past for the improvement of your own life. +book.starter.title2=Coal & Mustard Gas +book.starter.page2=Whilst it is impossible to predict the actual state of the world in a post-apocalyptic time, it's not unlikely that war and industry in its current form may not have ended. To protect your own lungs, an effective and cheap way is to urinate on some cloth to make a trench mask, to protect you from coal dust or mustard gas, if you ever encounter either. +book.starter.title3=Anvils & Presses +book.starter.page3=The quintessentials to beginning your industrial revitalization is an anvil and a burner press. The anvil will allow you to manually craft together early machinery such as the Assembler, whilst the burner press will let you make plates, wires, and circuits that you cannot hammer together with an anvil. +book.starter.title4=Templates +book.starter.page4=In order to stamp metal into useful shapes, assemble machinery, and perform chemical reactions, you will need to create a Machine Template Folder to create the various stamps and templates shown to the right. #book.rbmk.cover=HOW 2 RBMK:$The Basics$of Reactor$Construction #book.rbmk.title1=Introduction diff --git a/src/main/resources/assets/hbm/textures/gui/book/starter2.png b/src/main/resources/assets/hbm/textures/gui/book/starter2.png new file mode 100644 index 000000000..7f25fe03d Binary files /dev/null and b/src/main/resources/assets/hbm/textures/gui/book/starter2.png differ diff --git a/src/main/resources/assets/hbm/textures/gui/book/starter3a.png b/src/main/resources/assets/hbm/textures/gui/book/starter3a.png new file mode 100644 index 000000000..67c47814e Binary files /dev/null and b/src/main/resources/assets/hbm/textures/gui/book/starter3a.png differ diff --git a/src/main/resources/assets/hbm/textures/gui/book/starter3b.png b/src/main/resources/assets/hbm/textures/gui/book/starter3b.png new file mode 100644 index 000000000..4fca61b9d Binary files /dev/null and b/src/main/resources/assets/hbm/textures/gui/book/starter3b.png differ