diff --git a/src/main/java/com/hbm/handler/nei/CentrifugeRecipeHandler.java b/src/main/java/com/hbm/handler/nei/CentrifugeRecipeHandler.java index d2558d5ea..ab15345f9 100644 --- a/src/main/java/com/hbm/handler/nei/CentrifugeRecipeHandler.java +++ b/src/main/java/com/hbm/handler/nei/CentrifugeRecipeHandler.java @@ -138,19 +138,14 @@ public class CentrifugeRecipeHandler extends TemplateRecipeHandler { Map recipes = CentrifugeRecipes.getRecipes(); for(Map.Entry recipe : recipes.entrySet()) { + if(recipe.getKey() instanceof List) { - if(recipe.getKey() instanceof ItemStack) { - - if(NEIServerUtils.areStacksSameType(ingredient, (ItemStack) recipe.getKey())) - this.arecipes.add(new RecipeSet(recipe.getKey(), RecipesCommon.objectToStackArray(recipe.getValue()))); - - } else if(recipe.getKey() instanceof ArrayList) { - - for(Object o : (ArrayList) recipe.getKey()) { + for(Object o : (List) recipe.getKey()) { ItemStack stack = (ItemStack) o; - if(NEIServerUtils.areStacksSameType(ingredient, stack)) + if(NEIServerUtils.areStacksSameType(ingredient, stack)) { this.arecipes.add(new RecipeSet(stack, RecipesCommon.objectToStackArray(recipe.getValue()))); + } } } } diff --git a/src/main/java/com/hbm/wiaj/GuiWorldInAJar.java b/src/main/java/com/hbm/wiaj/GuiWorldInAJar.java index 5afb45c20..c555b6ba4 100644 --- a/src/main/java/com/hbm/wiaj/GuiWorldInAJar.java +++ b/src/main/java/com/hbm/wiaj/GuiWorldInAJar.java @@ -10,19 +10,22 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import com.hbm.blocks.ModBlocks; -import com.hbm.items.ModItems; +import com.hbm.lib.RefStrings; import com.hbm.render.tileentity.RenderStirling; import com.hbm.wiaj.actions.ActionCreateActor; +import com.hbm.wiaj.actions.ActionOffsetBy; import com.hbm.wiaj.actions.ActionRotateBy; import com.hbm.wiaj.actions.ActionSetActorData; import com.hbm.wiaj.actions.ActionSetBlock; import com.hbm.wiaj.actions.ActionUpdateActor; import com.hbm.wiaj.actions.ActionWait; -import com.hbm.wiaj.actors.ActorBasicPanel; +import com.hbm.wiaj.actors.ActorFancyPanel; import com.hbm.wiaj.actors.ActorTileEntity; import com.hbm.wiaj.actors.ISpecialActor; +import com.hbm.wiaj.actors.ActorFancyPanel.Orientation; import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.OpenGlHelper; @@ -33,16 +36,19 @@ import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; //krass public class GuiWorldInAJar extends GuiScreen { - RenderBlocks renderer; + private static final ResourceLocation guiUtil = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_utility.png"); + RenderBlocks renderer; JarScript testScript; public GuiWorldInAJar() { super(); + this.fontRendererObj = Minecraft.getMinecraft().fontRenderer; WorldInAJar world = new WorldInAJar(15, 15, 15); renderer = new RenderBlocks(world); renderer.enableAO = true; @@ -105,11 +111,6 @@ public class GuiWorldInAJar extends GuiScreen { } brickScene.add(new ActionRotateBy(-90, 0, 10)); - brickScene.add(new ActionWait(20)); - brickScene.add(new ActionRotateBy(45, 30, 10)); - brickScene.add(new ActionWait(20)); - brickScene.add(new ActionRotateBy(-45, -30, 10)); - brickScene.add(new ActionWait(20)); brickScene.add(new ActionCreateActor(0, new ActorTileEntity(new RenderStirling()))); NBTTagCompound stirling = new NBTTagCompound(); @@ -123,20 +124,18 @@ public class GuiWorldInAJar extends GuiScreen { brickScene.add(new ActionUpdateActor(0, "speed", 5F)); brickScene.add(new ActionWait(10)); brickScene.add(new ActionUpdateActor(0, "speed", 10F)); + brickScene.add(new ActionOffsetBy(1, 0, 0, 10)); brickScene.add(new ActionWait(10)); - brickScene.add(new ActionUpdateActor(0, "speed", 15F)); - brickScene.add(new ActionWait(10)); - brickScene.add(new ActionUpdateActor(0, "speed", 20F)); - brickScene.add(new ActionWait(10)); - brickScene.add(new ActionUpdateActor(0, "speed", 25F)); - brickScene.add(new ActionWait(10)); - brickScene.add(new ActionUpdateActor(0, "hasCog", false)); - brickScene.add(new ActionUpdateActor(0, "speed", 5F)); - brickScene.add(new ActionWait(20)); + brickScene.add(new ActionOffsetBy(0, 0, 1, 10)); - brickScene.add(new ActionCreateActor(1, new ActorBasicPanel(0, 0, new Object[]{ new ItemStack(ModItems.ammo_arty, 1, 5)," shit *and* piss" }))); + //brickScene.add(new ActionCreateActor(1, new ActorBasicPanel(0, 0, new Object[]{ new ItemStack(ModItems.ammo_arty, 1, 5)," shit *and* piss" }))); + + brickScene.add(new ActionCreateActor(1, new ActorFancyPanel(this.fontRendererObj, 0, 30, new Object[][] {{"I've come to make an announcement: Shadow the Hedgehog's a bitch-ass motherfucker. He pissed on my fucking wife. That's right. He took his hedgehog fuckin' quilly dick out and he pissed on my FUCKING wife, and he said his dick was THIS BIG, and I said that's disgusting. So I'm making a callout post on my Twitter.com. Shadow the Hedgehog, you got a small dick. It's the size of this walnut except WAY smaller. And guess what? Here's what my dong looks like. That's right, baby. Tall points, no quills, no pillows, look at that, it looks like two balls and a bong. He fucked my wife, so guess what, I'm gonna fuck the earth. That's right, this is what you get! My SUPER LASER PISS! Except I'm not gonna piss on the earth. I'm gonna go higher. I'm pissing on the MOOOON! How do you like that, OBAMA? I PISSED ON THE MOON, YOU IDIOT! You have twenty-three hours before the piss DROPLETS hit the fucking earth, now get out of my fucking sight before I piss on you too! "}}, 450) + .setColors(0xFFFDCA88, 0xFFD57C4F, 0xFFAB4223, 0xff1A1F22).setOrientation(Orientation.BOTTOM))); + brickScene.add(new ActionWait(200)); this.testScript.addScene(startingScene).addScene(brickScene); + //SKY BLUE: 0xffA5D9FF, 0xff39ACFF, 0xff1A6CA7, 0xff1A1F22 } @Override @@ -153,8 +152,44 @@ public class GuiWorldInAJar extends GuiScreen { this.drawGuiContainerForegroundLayer(mouseX, mouseY); GL11.glEnable(GL11.GL_LIGHTING); } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + + if(width / 2 - 12 <= mouseX && width / 2 - 12 + 24 > mouseX && height - 36 < mouseY && height - 36 + 24 >= mouseY) { + mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + + if(this.testScript.isPaused()) { + this.testScript.unpause(); + } else { + this.testScript.pause(); + } + } + + if(width / 2 - 12 - 36 <= mouseX && width / 2 - 12 - 36 + 24 > mouseX && height - 36 < mouseY && height - 36 + 24 >= mouseY) { + + if(this.testScript.sceneNumber > 0) { + this.testScript.rewindOne(); + mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + } + } + + if(width / 2 - 12 + 36 <= mouseX && width / 2 - 12 + 36 + 24 > mouseX && height - 36 < mouseY && height - 36 + 24 >= mouseY) { + + if(this.testScript.sceneNumber < this.testScript.scenes.size()) { + this.testScript.forwardOne(); + mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + } + } + } private void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + + for(Entry actor : this.testScript.actors.entrySet()) { + GL11.glPushMatrix(); + actor.getValue().drawForegroundComponent(this.width, this.height, this.testScript.ticksElapsed, this.testScript.interp); + GL11.glPopMatrix(); + } if(Keyboard.isKeyDown(Keyboard.KEY_LMENU)) { List list = new ArrayList(); @@ -162,11 +197,32 @@ public class GuiWorldInAJar extends GuiScreen { this.drawStackText(list, mouseX - width / 2, mouseY - height / 2, this.fontRendererObj); } - for(Entry actor : this.testScript.actors.entrySet()) { - GL11.glPushMatrix(); - actor.getValue().drawForegroundComponent(this.width, this.height, this.testScript.ticksElapsed, this.testScript.interp); - GL11.glPopMatrix(); - } + Minecraft.getMinecraft().getTextureManager().bindTexture(guiUtil); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_DEPTH_TEST); + + int playButton = this.testScript.isPaused() ? 64 : 40; + + if(width / 2 - 12 <= mouseX && width / 2 - 12 + 24 > mouseX && height - 36 < mouseY && height - 36 + 24 >= mouseY) + this.drawTexturedModalRect(width / 2 - 12, height - 36, playButton, 24, 24, 24); + else + this.drawTexturedModalRect(width / 2 - 12, height - 36, playButton, 48, 24, 24); + + if(this.testScript.sceneNumber == 0) + this.drawTexturedModalRect(width / 2 - 12 - 36, height - 36, 88, 72, 24, 24); + else if(width / 2 - 12 - 36 <= mouseX && width / 2 - 12 - 36 + 24 > mouseX && height - 36 < mouseY && height - 36 + 24 >= mouseY) + this.drawTexturedModalRect(width / 2 - 12 - 36, height - 36, 88, 24, 24, 24); + else + this.drawTexturedModalRect(width / 2 - 12 - 36, height - 36, 88, 48, 24, 24); + + if(this.testScript.sceneNumber >= this.testScript.scenes.size()) + this.drawTexturedModalRect(width / 2 - 12 + 36, height - 36, 112, 72, 24, 24); + else if(width / 2 - 12 + 36 <= mouseX && width / 2 - 12 + 36 + 24 > mouseX && height - 36 < mouseY && height - 36 + 24 >= mouseY) + this.drawTexturedModalRect(width / 2 - 12 + 36, height - 36, 112, 24, 24, 24); + else + this.drawTexturedModalRect(width / 2 - 12 + 36, height - 36, 112, 48, 24, 24); + + GL11.glEnable(GL11.GL_DEPTH_TEST); } private void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { diff --git a/src/main/java/com/hbm/wiaj/JarScene.java b/src/main/java/com/hbm/wiaj/JarScene.java index e6af1ae44..ec62493f2 100644 --- a/src/main/java/com/hbm/wiaj/JarScene.java +++ b/src/main/java/com/hbm/wiaj/JarScene.java @@ -16,7 +16,7 @@ public class JarScene { public List actions = new ArrayList(); public JarScript script; - private int actionNumber = 0; + public int actionNumber = 0; public IJarAction currentAction; //the action that is currently happening public int currentActionStart = 0; //time in ticks since init diff --git a/src/main/java/com/hbm/wiaj/JarScript.java b/src/main/java/com/hbm/wiaj/JarScript.java index d5592e816..5261c39db 100644 --- a/src/main/java/com/hbm/wiaj/JarScript.java +++ b/src/main/java/com/hbm/wiaj/JarScript.java @@ -6,17 +6,19 @@ import java.util.List; import java.util.Map.Entry; import com.hbm.util.BobMathUtil; +import com.hbm.wiaj.actions.IJarAction; import com.hbm.wiaj.actors.ISpecialActor; +import net.minecraft.init.Blocks; import net.minecraft.util.MathHelper; public class JarScript { public WorldInAJar world; - private List scenes = new ArrayList(); + public List scenes = new ArrayList(); public HashMap actors = new HashMap(); - private JarScene currentScene; - private int sceneNumber = 0; + public JarScene currentScene; + public int sceneNumber = 0; public double lastRotationYaw = -45D, rotationYaw = -45D; public double lastRotationPitch = -30D, rotationPitch = -30D; @@ -46,6 +48,9 @@ public class JarScript { /**supposed to be called every frame, it calculates tick times and interp values */ public void run() { + + if(this.isPaused && !freeRun) return; + long now = System.currentTimeMillis(); boolean nextTick = false; @@ -55,7 +60,7 @@ public class JarScript { nextTick = true; } - if(this.lastTick + 50 < now) { + if(this.lastTick + 50 < now || freeRun) { this.lastTick = now; this.ticksElapsed++; nextTick = true; @@ -95,7 +100,7 @@ public class JarScript { if(this.sceneNumber < this.scenes.size()) { this.currentScene = this.scenes.get(sceneNumber); - this.currentScene.currentActionStart = this.ticksElapsed; + this.currentScene.reset(); } else { this.currentScene = null; } @@ -118,6 +123,72 @@ public class JarScript { return this.isPaused; } + private void ffw() { + + this.reset(); + + freeRun = true; + int i = 0; + + while(this.sceneNumber < ffwTarget && this.currentScene != null && i < 10_000) { + this.run(); + i++; + } + + if(i > 0) { //i don't know why it needs one more cycle but it does + this.run(); + } + + freeRun = false; + } + + /** how far we want to fast forward */ + public static int ffwTarget = 0; + /** flag set during FFW, skips tick delay checks which means ticks during run() are always executed */ + public static boolean freeRun = false; + + public void reset() { + + this.actors.clear(); + this.world.nuke(); + + this.currentScene = this.scenes.get(0); + this.sceneNumber = 0; + this.ticksElapsed = 0; + this.lastTick = 0; + + this.lastOffsetX = this.offsetX = 0D; + this.lastOffsetY = this.offsetY = 0D; + this.lastOffsetZ = this.offsetZ = 0D; + this.lastRotationYaw = this.rotationYaw = -45D; + this.lastRotationPitch = this.rotationPitch = -30D; + + for(JarScene scene : this.scenes) { + scene.reset(); + } + } + + public void rewindOne() { + + if(this.sceneNumber > 0) { + this.ffwTarget = this.sceneNumber - 1; + } else { + this.ffwTarget = 0; + } + + ffw(); + } + + public void forwardOne() { + if(this.sceneNumber < this.scenes.size()) { + this.ffwTarget = this.sceneNumber + 1; + } else { + this.ffwTarget = this.scenes.size(); + } + + ffw(); + } + public double yaw() { return BobMathUtil.interp(this.lastRotationYaw, this.rotationYaw, interp); } public double pitch() { return BobMathUtil.interp(this.lastRotationPitch, this.rotationPitch, interp); } public double offsetX() { return BobMathUtil.interp(this.lastOffsetX, this.offsetX, interp); } diff --git a/src/main/java/com/hbm/wiaj/WorldInAJar.java b/src/main/java/com/hbm/wiaj/WorldInAJar.java index 34b25bc2d..b83622160 100644 --- a/src/main/java/com/hbm/wiaj/WorldInAJar.java +++ b/src/main/java/com/hbm/wiaj/WorldInAJar.java @@ -33,6 +33,13 @@ public class WorldInAJar implements IBlockAccess { this.meta = new short[x][y][z]; this.tiles = new TileEntity[x][y][z]; } + + public void nuke() { + + this.blocks = new Block[sizeX][sizeY][sizeZ]; + this.meta = new short[sizeX][sizeY][sizeZ]; + this.tiles = new TileEntity[sizeX][sizeY][sizeZ]; + } @Override public Block getBlock(int x, int y, int z) { diff --git a/src/main/java/com/hbm/wiaj/actions/ActionSetActorData.java b/src/main/java/com/hbm/wiaj/actions/ActionSetActorData.java index b39c5888e..fdab377b9 100644 --- a/src/main/java/com/hbm/wiaj/actions/ActionSetActorData.java +++ b/src/main/java/com/hbm/wiaj/actions/ActionSetActorData.java @@ -22,6 +22,6 @@ public class ActionSetActorData implements IJarAction { @Override public void act(WorldInAJar world, JarScene scene) { - scene.script.actors.get(id).setActorData(data); + scene.script.actors.get(id).setActorData((NBTTagCompound) data.copy()); } } diff --git a/src/main/java/com/hbm/wiaj/actors/ActorFancyPanel.java b/src/main/java/com/hbm/wiaj/actors/ActorFancyPanel.java index 8b87888ff..3bf696701 100644 --- a/src/main/java/com/hbm/wiaj/actors/ActorFancyPanel.java +++ b/src/main/java/com/hbm/wiaj/actors/ActorFancyPanel.java @@ -1,29 +1,389 @@ package com.hbm.wiaj.actors; +import java.util.ArrayList; +import java.util.List; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import com.hbm.lib.RefStrings; +import com.hbm.util.I18nUtil; import com.hbm.wiaj.JarScene; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; public class ActorFancyPanel implements ISpecialActor { - public ActorFancyPanel() { + static final ResourceLocation guiUtil = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_utility.png"); + + List lines = new ArrayList(); + RenderItem itemRender = new RenderItem(); + TextureManager texman = Minecraft.getMinecraft().getTextureManager(); + FontRenderer font; + + int x; + int y; + + boolean consistentHeight = false; + int lineDist = 2; + int tallestElement = 0; + static final int STACK_HEIGHT = 18; + + Orientation o = Orientation.CENTER; + int colorBrighter = 0xFFCCCCCC; + int colorDarker = 0xFF7D7D7D; + int colorFrame = 0xFFA0A0A0; + int colorBg = 0xFF302E36; + + public ActorFancyPanel(FontRenderer font, int x, int y, Object[][] raw, int autowrap) { + this.font = font; + this.x = x; + this.y = y; + + if(autowrap <= 0) { //if autowrap is off, just add the lines 1:1 + for(Object[] o : raw) { + lines.add(o); + } + } else { + + for(Object[] line : raw) { + + if(line.length == 1 && line[0] instanceof String) { //auto wrap can only apply to text-only lines + List frags = I18nUtil.autoBreak(font, (String)line[0], autowrap); + for(String s : frags) { + lines.add(new Object[] { s }); + } + } else { + lines.add(line); + } + } + } + } + + public ActorFancyPanel enforceConsistentHeight() { + this.consistentHeight = true; + return this; + } + + public ActorFancyPanel setLineDist(int dist) { + this.lineDist = dist; + return this; + } + + public ActorFancyPanel setOrientation(Orientation o) { + this.o = o; + return this; + } + + public ActorFancyPanel setColors(int brighter, int frame, int darker, int background) { + this.colorBrighter = brighter; + this.colorFrame = frame; + this.colorDarker = darker; + this.colorBg = background; + return this; + } + + public int getTallestElement() { + if(this.tallestElement > 0) { + return this.tallestElement; + } + + for(Object[] line : this.lines) { + for(Object element : line) { + + int height = getElementHeight(element); + + if(height > this.tallestElement) { + this.tallestElement = height; + } + } + } + + return this.tallestElement; + } + + public int getElementHeight(Object element) { + + if(element instanceof String) { + return this.font.FONT_HEIGHT; + } + + if(element instanceof ItemStack) { + return STACK_HEIGHT; + } + + if(element instanceof Object[]) { + Object[] scaledStack = (Object[]) element; //[0] ItemStack, [1] double + return (int) Math.ceil(STACK_HEIGHT * (double) scaledStack[1]); + } + + return 0; + } + + public int getElementWidth(Object element) { + + if(element instanceof String) { + return this.font.getStringWidth((String) element); + } + + if(element instanceof ItemStack) { + return STACK_HEIGHT; + } + + if(element instanceof Object[]) { + Object[] scaledStack = (Object[]) element; //[0] ItemStack, [1] double + return (int) Math.ceil(STACK_HEIGHT * (double) scaledStack[1]); + } + + return 0; + } + + int blockHeight = 0; + private int getBlockHeight() { + + if(this.blockHeight > 0) { + return this.blockHeight; + } + + for(Object[] line : this.lines) { + + if(this.blockHeight > 0) { + this.blockHeight += this.lineDist; + } + + int lineHeight = this.font.FONT_HEIGHT; + + if(this.consistentHeight) { + lineHeight = Math.max(lineHeight, getTallestElement()); + } else { + + for(Object o : line) { + lineHeight = Math.max(lineHeight, getElementHeight(o)); + } + } + + this.blockHeight += lineHeight; + } + + return this.blockHeight; + } + + int blockWidth = 0; + private int getBlockWidth() { + + if(this.blockWidth > 0) { + return this.blockWidth; + } + + for(Object[] line : this.lines) { + + int lineWidth = 0; + + for(Object o : line) { + + if(lineWidth > 0) { + lineWidth += 2; + } + + lineWidth += getElementWidth(o); + } + + if(lineWidth > this.blockWidth) { + this.blockWidth = lineWidth; + } + } + + return this.blockWidth; } @Override - public void drawForegroundComponent(int w, int h, int ticks, float interp) { } + public void drawForegroundComponent(int w, int h, int ticks, float interp) { + + int height = this.getBlockHeight(); + int width = this.getBlockWidth(); + + int posX = w / 2 + x; + int posY = h / 2 + y; + + switch(o) { + case TOP: + posX -= width / 2; + posY += 15; + break; + case BOTTOM: + posX -= width / 2; + posY -= height + 15; + break; + case LEFT: + posX += 15; + posY -= height / 2; + break; + case RIGHT: + posX -= width + 15; + posY -= height / 2; + break; + case CENTER: + posX -= width / 2; + posY -= height / 2; + break; + } - @Override - public void drawBackgroundComponent(int ticks, float interp) { } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + + this.drawRect(posX - 5, posY - 5, posX + width + 5, posY + height + 5, colorFrame); + + this.drawRect(posX - 5, posY - 5, posX - 4, posY + height + 4, colorBrighter); + this.drawRect(posX - 5, posY - 5, posX + width + 4, posY - 4, colorBrighter); + this.drawRect(posX + width + 2, posY - 2, posX + width + 3, posY + height + 3, colorBrighter); + this.drawRect(posX - 2, posY + height + 2, posX + width + 3, posY + height + 3, colorBrighter); + + this.drawRect(posX - 3, posY - 3, posX - 2, posY + height + 2, colorDarker); + this.drawRect(posX - 3, posY - 3, posX + width + 2, posY - 2, colorDarker); + this.drawRect(posX + width + 4, posY - 4, posX + width + 5, posY + height + 5, colorDarker); + this.drawRect(posX - 4, posY + height + 4, posX + width + 5, posY + height + 5, colorDarker); + + this.drawRect(posX - 2, posY - 2, posX + width + 2, posY + height + 2, colorBg); - @Override - public void updateActor(JarScene scene) { } + Minecraft.getMinecraft().getTextureManager().bindTexture(guiUtil); + + int off = 28; + + switch(o) { + case TOP: + this.drawTexturedModalRect(posX + width / 2 - 7, posY - 15, 40 + off, 14, 14, 10); + break; + case BOTTOM: + this.drawTexturedModalRect(posX + width / 2 - 7, posY + height + 5, 54 + off, 14, 14, 10); + break; + case LEFT: + this.drawTexturedModalRect(posX - 15, posY + height / 2 - 7, 40 + off, 0, 10, 14); + break; + case RIGHT: + this.drawTexturedModalRect(posX + width + 5, posY + height / 2 - 7, 50 + off, 0, 10, 14); + break; + case CENTER: break; + } + + int offsetY = 0; + + for(Object[] line : this.lines) { + + if(offsetY > 0) offsetY+= this.lineDist; + int lineHeight = 0; + for(Object element : line) lineHeight = Math.max(lineHeight, this.getElementHeight(element)); + + int indent = 0; + for(Object element : line) { + + if(indent > 0) { + indent += 2; + } + + drawElement(posX + indent, posY + offsetY + lineHeight / 2, element); + indent += getElementWidth(element); + } + + offsetY += lineHeight; + } - @Override - public void setActorData(NBTTagCompound data) { } + itemRender.zLevel = 0.0F; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderHelper.enableStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + } + + private void drawElement(int x, int y, Object element) { + + if(element instanceof String) { + String text = (String) element; + this.font.drawString(text, x, y - this.font.FONT_HEIGHT / 2, 0xffffff); + + } else if(element instanceof ItemStack) { + + ItemStack stack = (ItemStack) element; + GL11.glColor3f(1F, 1F, 1F); - @Override - public void setDataPoint(String tag, Object o) { } + if(stack.stackSize == 0) { + this.drawGradientRect(x - 1, y - 1 - 8, x + 17, y + 17, 0xffff0000, 0xffff0000); + this.drawGradientRect(x, y - 8, x + 16, y + 16, 0xffb0b0b0, 0xffb0b0b0); + } + itemRender.renderItemAndEffectIntoGUI(this.font, texman, stack, x, y - 8); + itemRender.renderItemOverlayIntoGUI(this.font, texman, stack, x, y - 8, null); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_DEPTH_TEST); + } //TODO: scaled stacks + } + + @Override public void drawBackgroundComponent(int ticks, float interp) { } + @Override public void updateActor(JarScene scene) { } + @Override public void setActorData(NBTTagCompound data) { } + @Override public void setDataPoint(String tag, Object o) { } + + protected void drawRect(int minX, int minY, int maxX, int maxY, int color) { + drawGradientRect(minX, minY, maxX, maxY, color, color); + } + + protected void drawGradientRect(int minX, int minY, int maxX, int maxY, int color1, int color2) { + + double zLevel = 300D; + float a1 = (float) (color1 >> 24 & 255) / 255.0F; + float r1 = (float) (color1 >> 16 & 255) / 255.0F; + float g1 = (float) (color1 >> 8 & 255) / 255.0F; + float b1 = (float) (color1 & 255) / 255.0F; + float a2 = (float) (color2 >> 24 & 255) / 255.0F; + float r2 = (float) (color2 >> 16 & 255) / 255.0F; + float g2 = (float) (color2 >> 8 & 255) / 255.0F; + float b2 = (float) (color2 & 255) / 255.0F; + + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glShadeModel(GL11.GL_SMOOTH); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(r1, g1, b1, a1); + tessellator.addVertex((double) maxX, (double) minY, (double) zLevel); + tessellator.addVertex((double) minX, (double) minY, (double) zLevel); + tessellator.setColorRGBA_F(r2, g2, b2, a2); + tessellator.addVertex((double) minX, (double) maxY, (double) zLevel); + tessellator.addVertex((double) maxX, (double) maxY, (double) zLevel); + tessellator.draw(); + + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + public void drawTexturedModalRect(int posX, int posY, int u, int v, int sizeX, int sizeY) { + double zLevel = 300D; + float f = 0.00390625F; + float f1 = 0.00390625F; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(posX + 0, posY + sizeY, zLevel, (u + 0) * f, (v + sizeY) * f1); + tessellator.addVertexWithUV(posX + sizeX, posY + sizeY, zLevel, (u + sizeX) * f, (v + sizeY) * f1); + tessellator.addVertexWithUV(posX + sizeX, posY + 0, zLevel, (u + sizeX) * f, (v + 0) * f1); + tessellator.addVertexWithUV(posX + 0, posY + 0, zLevel, (u + 0) * f, (v + 0) * f); + tessellator.draw(); + } /** where the arrow should be or if the box should be centered around the home position */ public static enum Orientation { diff --git a/src/main/resources/assets/hbm/textures/gui/gui_utility.png b/src/main/resources/assets/hbm/textures/gui/gui_utility.png index 8cb3cbc26..c25197051 100644 Binary files a/src/main/resources/assets/hbm/textures/gui/gui_utility.png and b/src/main/resources/assets/hbm/textures/gui/gui_utility.png differ