From a605736710202a17d1ec240e09374a675adefe45 Mon Sep 17 00:00:00 2001 From: tterrag1098 Date: Thu, 29 Jan 2015 13:15:26 -0500 Subject: [PATCH] Fix tooltips rendering under IO config, also fix changing NEI lighting --- .../enderio/gui/IoConfigRenderer.java | 4 +- .../java/crazypants/gui/GuiContainerBase.java | 48 +++++++++++++------ 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/main/java/crazypants/enderio/gui/IoConfigRenderer.java b/src/main/java/crazypants/enderio/gui/IoConfigRenderer.java index e1b7aa8b..d408e3bc 100644 --- a/src/main/java/crazypants/enderio/gui/IoConfigRenderer.java +++ b/src/main/java/crazypants/enderio/gui/IoConfigRenderer.java @@ -230,6 +230,7 @@ public class IoConfigRenderer { if(!updateCamera(partialTick, vp.x, vp.y, vp.width, vp.height)) { return; } + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); applyCamera(partialTick); TravelController.instance.setSelectionEnabled(false); renderScene(); @@ -237,6 +238,7 @@ public class IoConfigRenderer { renderSelection(); renderOverlay(par1, par2); + GL11.glPopAttrib(); } private void renderSelection() { @@ -287,6 +289,7 @@ public class IoConfigRenderer { mx -= vpx; my -= vpy; + if(mx >= x && mx <= x + IconEIO.IO_WHATSIT.width && my >= y && my <= y + IconEIO.IO_WHATSIT.height) { RenderUtil.renderQuad2D(x, y, 0, IconEIO.IO_WHATSIT.width, IconEIO.IO_WHATSIT.height, new Vector4f(0.4f,0.4f,0.4f,0.6f)); @@ -298,7 +301,6 @@ public class IoConfigRenderer { GL11.glColor3f(1, 1, 1); IconEIO.IO_WHATSIT.renderIcon(x, y, true); - if(selection != null) { IconEIO ioIcon = null; // INPUT diff --git a/src/main/java/crazypants/gui/GuiContainerBase.java b/src/main/java/crazypants/gui/GuiContainerBase.java index 791c90a7..94d8138e 100644 --- a/src/main/java/crazypants/gui/GuiContainerBase.java +++ b/src/main/java/crazypants/gui/GuiContainerBase.java @@ -1,5 +1,6 @@ package crazypants.gui; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -10,6 +11,7 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.inventory.Container; +import net.minecraft.util.Timer; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; @@ -22,6 +24,8 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe protected ToolTipManager ttMan = new ToolTipManager(); protected List overlays = new ArrayList(); + + private Field timer = null; protected GuiContainerBase(Container par1Container) { super(par1Container); @@ -94,18 +98,44 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe public void removeOverlay(IGuiOverlay overlay) { overlays.remove(overlay); } + + private int realMx, realMy; @Override protected final void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { drawForegroundImpl(mouseX, mouseY); - ttMan.drawTooltips(this, mouseX, mouseY); + + Timer t = null; + try { + if(timer == null) { + timer = Minecraft.class.getDeclaredField("timer"); + timer.setAccessible(true); + } + t = (Timer) timer.get(this.mc); + } catch (Exception e) { + e.printStackTrace(); + return; + } + + GL11.glPushMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_DEPTH_TEST); + for (IGuiOverlay overlay : overlays) { + if(overlay != null && overlay.isVisible()) { + overlay.draw(realMx, realMy, t.renderPartialTicks); + } + } + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glPopMatrix(); + + ttMan.drawTooltips(this, realMx, realMy); } @Override public void drawScreen(int par1, int par2, float par3) { - int mx = par1; - int my = par2; + int mx = realMx = par1; + int my = realMy = par2; for(IGuiOverlay overlay : overlays) { if(overlay != null && overlay.isVisible() && isMouseInOverlay(par1, par2, overlay)) { mx = -5000; @@ -114,18 +144,6 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe } super.drawScreen(mx, my, par3); - - GL11.glPushMatrix(); - GL11.glTranslatef(guiLeft, guiTop, 0.0F); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glDisable(GL11.GL_DEPTH_TEST); - for(IGuiOverlay overlay : overlays) { - if(overlay != null && overlay.isVisible()) { - overlay.draw(par1, par2, par3); - } - } - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glPopMatrix(); } private boolean isMouseInOverlay(int mouseX, int mouseY, IGuiOverlay overlay) {