diff --git a/src/main/java/com/hbm/wiaj/GuiWorldInAJar.java b/src/main/java/com/hbm/wiaj/GuiWorldInAJar.java index 75e847907..b9080b70c 100644 --- a/src/main/java/com/hbm/wiaj/GuiWorldInAJar.java +++ b/src/main/java/com/hbm/wiaj/GuiWorldInAJar.java @@ -1,11 +1,17 @@ package com.hbm.wiaj; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; import java.util.Map.Entry; +import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import com.hbm.blocks.ModBlocks; +import com.hbm.items.ModItems; import com.hbm.render.tileentity.RenderStirling; import com.hbm.wiaj.actions.ActionCreateActor; import com.hbm.wiaj.actions.ActionRotate; @@ -13,10 +19,12 @@ 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.ActorTileEntity; import com.hbm.wiaj.actors.ISpecialActor; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderBlocks; @@ -24,6 +32,7 @@ import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; //krass @@ -118,17 +127,8 @@ public class GuiWorldInAJar extends GuiScreen { brickScene.add(new ActionWait(20)); brickScene.add(new ActionUpdateActor(0, "speed", 15F)); brickScene.add(new ActionWait(20)); - brickScene.add(new ActionUpdateActor(0, "speed", 2F)); - brickScene.add(new ActionUpdateActor(0, "hasCog", false)); - brickScene.add(new ActionWait(20)); - brickScene.add(new ActionUpdateActor(0, "rotation", 4)); - brickScene.add(new ActionWait(10)); - brickScene.add(new ActionUpdateActor(0, "rotation", 3)); - brickScene.add(new ActionWait(10)); - brickScene.add(new ActionUpdateActor(0, "rotation", 5)); - brickScene.add(new ActionWait(10)); - brickScene.add(new ActionUpdateActor(0, "rotation", 2)); - brickScene.add(new ActionWait(100)); + + brickScene.add(new ActionCreateActor(1, new ActorBasicPanel(0, 0, new Object[]{ new ItemStack(ModItems.ammo_arty, 1, 5)," shit *and* piss" }))); this.testScript.addScene(startingScene).addScene(brickScene); } @@ -136,6 +136,7 @@ public class GuiWorldInAJar extends GuiScreen { @Override public void drawScreen(int mouseX, int mouseY, float f) { this.drawDefaultBackground(); + shittyHack = this; if(testScript != null) { testScript.run(); @@ -143,10 +144,25 @@ public class GuiWorldInAJar extends GuiScreen { this.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); GL11.glDisable(GL11.GL_LIGHTING); - //this.drawGuiContainerForegroundLayer(mouseX, mouseY); + this.drawGuiContainerForegroundLayer(mouseX, mouseY); GL11.glEnable(GL11.GL_LIGHTING); } + private void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + + if(Keyboard.isKeyDown(Keyboard.KEY_LMENU)) { + List list = new ArrayList(); + list.add(new Object[] { (mouseX - width / 2) + " / " + (mouseY - height / 2) }); + 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(); + } + } + private void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { GL11.glPushMatrix(); @@ -187,9 +203,9 @@ public class GuiWorldInAJar extends GuiScreen { private void setupRotation() { - double scale = -50; + double scale = -10; - GL11.glTranslated(width / 2, height / 2 + 70, 400); + GL11.glTranslated(width / 2, height / 2, 400); GL11.glScaled(scale, scale, scale); GL11.glScaled(1, 1, 0.5); //incredible flattening power @@ -198,13 +214,133 @@ public class GuiWorldInAJar extends GuiScreen { GL11.glRotated(pitch, 1, 0, 0); GL11.glRotated(yaw, 0, 1, 0); - GL11.glTranslated(-7, 0 , -7); - GL11.glTranslated(testScript.world.sizeX / 2D, 0 , testScript.world.sizeZ / 2D); - GL11.glTranslated(testScript.world.sizeX / -2D, 0 , testScript.world.sizeZ / -2D); + GL11.glTranslated(testScript.world.sizeX / -2D, -testScript.world.sizeY / 2D , testScript.world.sizeZ / -2D); } @Override public boolean doesGuiPauseGame() { return false; } + + public static GuiWorldInAJar shittyHack; + + public void drawStackText(List lines, int x, int y, FontRenderer font) { + + x += width / 2; + y += height / 2; + + if(!lines.isEmpty()) { + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + + int height = 0; + int longestline = 0; + Iterator iterator = lines.iterator(); + + while(iterator.hasNext()) { + Object[] line = (Object[]) iterator.next(); + int lineWidth = 0; + + boolean hasStack = false; + + for(Object o : line) { + + if(o instanceof String) { + lineWidth += font.getStringWidth((String) o); + } else { + lineWidth += 18; + hasStack = true; + } + } + + if(hasStack) { + height += 18; + } else { + height += 10; + } + + if(lineWidth > longestline) { + longestline = lineWidth; + } + } + + int minX = x + 12; + int minY = y - 12; + + if(minX + longestline > this.width) { + minX -= 28 + longestline; + } + + if(minY + height + 6 > this.height) { + minY = this.height - height - 6; + } + + this.zLevel = 300.0F; + itemRender.zLevel = 300.0F; + //int j1 = -267386864; + int colorBg = 0xF0100010; + this.drawGradientRect(minX - 3, minY - 4, minX + longestline + 3, minY - 3, colorBg, colorBg); + this.drawGradientRect(minX - 3, minY + height + 3, minX + longestline + 3, minY + height + 4, colorBg, colorBg); + this.drawGradientRect(minX - 3, minY - 3, minX + longestline + 3, minY + height + 3, colorBg, colorBg); + this.drawGradientRect(minX - 4, minY - 3, minX - 3, minY + height + 3, colorBg, colorBg); + this.drawGradientRect(minX + longestline + 3, minY - 3, minX + longestline + 4, minY + height + 3, colorBg, colorBg); + //int k1 = 1347420415; + int color0 = 0x505000FF; + //int l1 = (k1 & 16711422) >> 1 | k1 & -16777216; + int color1 = (color0 & 0xFEFEFE) >> 1 | color0 & 0xFF000000; + this.drawGradientRect(minX - 3, minY - 3 + 1, minX - 3 + 1, minY + height + 3 - 1, color0, color1); + this.drawGradientRect(minX + longestline + 2, minY - 3 + 1, minX + longestline + 3, minY + height + 3 - 1, color0, color1); + this.drawGradientRect(minX - 3, minY - 3, minX + longestline + 3, minY - 3 + 1, color0, color0); + this.drawGradientRect(minX - 3, minY + height + 2, minX + longestline + 3, minY + height + 3, color1, color1); + + for(int index = 0; index < lines.size(); ++index) { + + Object[] line = (Object[]) lines.get(index); + int indent = 0; + boolean hasStack = false; + + for(Object o : line) { + if(!(o instanceof String)) { + hasStack = true; + } + } + + for(Object o : line) { + + if(o instanceof String) { + font.drawStringWithShadow((String) o, minX + indent, minY + (hasStack ? 4 : 0), -1); + indent += font.getStringWidth((String) o) + 2; + } else { + ItemStack stack = (ItemStack) o; + GL11.glColor3f(1F, 1F, 1F); + + if(stack.stackSize == 0) { + this.drawGradientRect(minX + indent - 1, minY - 1, minX + indent + 17, minY + 17, 0xffff0000, 0xffff0000); + this.drawGradientRect(minX + indent, minY, minX + indent + 16, minY + 16, 0xffb0b0b0, 0xffb0b0b0); + } + itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), stack, minX + indent, minY); + itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), stack, minX + indent, minY, null); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_DEPTH_TEST); + indent += 18; + } + } + + if(index == 0) { + minY += 2; + } + + minY += hasStack ? 18 : 10; + } + + this.zLevel = 0.0F; + itemRender.zLevel = 0.0F; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderHelper.enableStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + } + } } diff --git a/src/main/java/com/hbm/wiaj/actors/ActorBasicPanel.java b/src/main/java/com/hbm/wiaj/actors/ActorBasicPanel.java new file mode 100644 index 000000000..55290e0bd --- /dev/null +++ b/src/main/java/com/hbm/wiaj/actors/ActorBasicPanel.java @@ -0,0 +1,201 @@ +package com.hbm.wiaj.actors; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +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.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ActorBasicPanel implements ISpecialActor { + + int x; + int y; + List lines; + + public ActorBasicPanel(int x, int y, Object[]... objects) { + this.x = x; + this.y = y; + this.lines = new ArrayList(); + + for(Object[] o : objects) { + this.lines.add(o); + } + } + + @Override + public void drawForegroundComponent(int w, int h, int ticks, float interp) { + drawStackText(lines, x, y, Minecraft.getMinecraft().fontRenderer, RenderItem.getInstance(), w, h); + } + + @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 drawStackText(List lines, int x, int y, FontRenderer font, RenderItem itemRender, int w, int h) { + + x += w / 2; + y += h / 2; + + if(!lines.isEmpty()) { + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + + int height = 0; + int longestline = 0; + Iterator iterator = lines.iterator(); + + while(iterator.hasNext()) { + Object[] line = (Object[]) iterator.next(); + int lineWidth = 0; + + boolean hasStack = false; + + for(Object o : line) { + + if(o instanceof String) { + lineWidth += font.getStringWidth((String) o); + } else { + lineWidth += 18; + hasStack = true; + } + } + + if(hasStack) { + height += 18; + } else { + height += 10; + } + + if(lineWidth > longestline) { + longestline = lineWidth; + } + } + + int minX = x + 12; + int minY = y - 12; + + if(minX + longestline > w) { + minX -= 28 + longestline; + } + + if(minY + height + 6 > h) { + minY = h - height - 6; + } + + itemRender.zLevel = 300.0F; + //int j1 = -267386864; + int colorBg = 0xF0100010; + this.drawGradientRect(minX - 3, minY - 4, minX + longestline + 3, minY - 3, colorBg, colorBg); + this.drawGradientRect(minX - 3, minY + height + 3, minX + longestline + 3, minY + height + 4, colorBg, colorBg); + this.drawGradientRect(minX - 3, minY - 3, minX + longestline + 3, minY + height + 3, colorBg, colorBg); + this.drawGradientRect(minX - 4, minY - 3, minX - 3, minY + height + 3, colorBg, colorBg); + this.drawGradientRect(minX + longestline + 3, minY - 3, minX + longestline + 4, minY + height + 3, colorBg, colorBg); + //int k1 = 1347420415; + int color0 = 0x505000FF; + //int l1 = (k1 & 16711422) >> 1 | k1 & -16777216; + int color1 = (color0 & 0xFEFEFE) >> 1 | color0 & 0xFF000000; + this.drawGradientRect(minX - 3, minY - 3 + 1, minX - 3 + 1, minY + height + 3 - 1, color0, color1); + this.drawGradientRect(minX + longestline + 2, minY - 3 + 1, minX + longestline + 3, minY + height + 3 - 1, color0, color1); + this.drawGradientRect(minX - 3, minY - 3, minX + longestline + 3, minY - 3 + 1, color0, color0); + this.drawGradientRect(minX - 3, minY + height + 2, minX + longestline + 3, minY + height + 3, color1, color1); + + for(int index = 0; index < lines.size(); ++index) { + + Object[] line = (Object[]) lines.get(index); + int indent = 0; + boolean hasStack = false; + + for(Object o : line) { + if(!(o instanceof String)) { + hasStack = true; + } + } + + for(Object o : line) { + + if(o instanceof String) { + font.drawStringWithShadow((String) o, minX + indent, minY + (hasStack ? 4 : 0), -1); + indent += font.getStringWidth((String) o) + 2; + } else { + ItemStack stack = (ItemStack) o; + GL11.glColor3f(1F, 1F, 1F); + + if(stack.stackSize == 0) { + this.drawGradientRect(minX + indent - 1, minY - 1, minX + indent + 17, minY + 17, 0xffff0000, 0xffff0000); + this.drawGradientRect(minX + indent, minY, minX + indent + 16, minY + 16, 0xffb0b0b0, 0xffb0b0b0); + } + itemRender.renderItemAndEffectIntoGUI(font, Minecraft.getMinecraft().getTextureManager(), stack, minX + indent, minY); + itemRender.renderItemOverlayIntoGUI(font, Minecraft.getMinecraft().getTextureManager(), stack, minX + indent, minY, null); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_DEPTH_TEST); + indent += 18; + } + } + + if(index == 0) { + minY += 2; + } + + minY += hasStack ? 18 : 10; + } + + itemRender.zLevel = 0.0F; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderHelper.enableStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + } + } + + protected void drawGradientRect(int p_73733_1_, int p_73733_2_, int p_73733_3_, int p_73733_4_, int p_73733_5_, int p_73733_6_) { + float zLevel = 300.0F; + float f = (float) (p_73733_5_ >> 24 & 255) / 255.0F; + float f1 = (float) (p_73733_5_ >> 16 & 255) / 255.0F; + float f2 = (float) (p_73733_5_ >> 8 & 255) / 255.0F; + float f3 = (float) (p_73733_5_ & 255) / 255.0F; + float f4 = (float) (p_73733_6_ >> 24 & 255) / 255.0F; + float f5 = (float) (p_73733_6_ >> 16 & 255) / 255.0F; + float f6 = (float) (p_73733_6_ >> 8 & 255) / 255.0F; + float f7 = (float) (p_73733_6_ & 255) / 255.0F; + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glShadeModel(GL11.GL_SMOOTH); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(f1, f2, f3, f); + tessellator.addVertex((double) p_73733_3_, (double) p_73733_2_, (double) zLevel); + tessellator.addVertex((double) p_73733_1_, (double) p_73733_2_, (double) zLevel); + tessellator.setColorRGBA_F(f5, f6, f7, f4); + tessellator.addVertex((double) p_73733_1_, (double) p_73733_4_, (double) zLevel); + tessellator.addVertex((double) p_73733_3_, (double) p_73733_4_, (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); + } +} diff --git a/src/main/java/com/hbm/wiaj/actors/ActorTileEntity.java b/src/main/java/com/hbm/wiaj/actors/ActorTileEntity.java index 0aeac2776..3cd80af1b 100644 --- a/src/main/java/com/hbm/wiaj/actors/ActorTileEntity.java +++ b/src/main/java/com/hbm/wiaj/actors/ActorTileEntity.java @@ -11,7 +11,7 @@ public class ActorTileEntity extends ActorBase { } @Override - public void drawForegroundComponent(int ticks, float interp) { } + public void drawForegroundComponent(int w, int h, int ticks, float interp) { } @Override public void drawBackgroundComponent(int ticks, float interp) { diff --git a/src/main/java/com/hbm/wiaj/actors/ISpecialActor.java b/src/main/java/com/hbm/wiaj/actors/ISpecialActor.java index 244620dea..a70be8389 100644 --- a/src/main/java/com/hbm/wiaj/actors/ISpecialActor.java +++ b/src/main/java/com/hbm/wiaj/actors/ISpecialActor.java @@ -12,7 +12,7 @@ import net.minecraft.nbt.NBTTagCompound; public interface ISpecialActor { /** Draws things in the foreground like text boxes */ - public void drawForegroundComponent(int ticks, float interp); + public void drawForegroundComponent(int w, int h, int ticks, float interp); /** Draws things in the background, fotted to the world renderer like TESRs */ public void drawBackgroundComponent(int ticks, float interp); /** Update ticks to emulate serverside ticking */ diff --git a/src/main/resources/assets/hbm/lang/de_DE.lang b/src/main/resources/assets/hbm/lang/de_DE.lang index 03636b45b..20d41b0b0 100644 --- a/src/main/resources/assets/hbm/lang/de_DE.lang +++ b/src/main/resources/assets/hbm/lang/de_DE.lang @@ -3803,7 +3803,7 @@ trait.rbmk.depletion=Erschöpfung: %s trait.rbmk.diffusion=Diffusion: %s trait.rbmk.fluxFunc=Flux-Funktion: %s trait.rbmk.funcType=Funktionstyp: %s -trait.rbmk.heat=Hitze pro Tick bei voller Kraft: %s +trait.rbmk.heat=Hitze pro 100 Flux: %s trait.rbmk.melt=Schmelzpunkt: %s trait.rbmk.neutron.any=Alle Neutronen trait.rbmk.neutron.fast=Schnelle Neutronen diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index 75ad64d4d..621753930 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -4244,7 +4244,7 @@ trait.rbmk.depletion=Depletion: %s trait.rbmk.diffusion=Diffusion: %s trait.rbmk.fluxFunc=Flux function: %s trait.rbmk.funcType=Function type: %s -trait.rbmk.heat=Heat per tick at full power: %s +trait.rbmk.heat=Heat per 100 flux: %s trait.rbmk.melt=Melting point: %s trait.rbmk.neutron.any=All Neutrons trait.rbmk.neutron.fast=Fast Neutrons