diff --git a/mcp/mobius/waila/overlay/OverlayRenderer.java b/mcp/mobius/waila/overlay/OverlayRenderer.java index d88f6af..782a08e 100644 --- a/mcp/mobius/waila/overlay/OverlayRenderer.java +++ b/mcp/mobius/waila/overlay/OverlayRenderer.java @@ -46,16 +46,16 @@ public class OverlayRenderer { if (RayTracing.instance().getTarget().typeOfHit == EnumMovingObjectType.TILE && RayTracing.instance().getTargetStack() != null) { - renderOverlay(RayTracing.instance().getTargetStack(), WailaTickHandler.instance().tooltip); + renderOverlay(WailaTickHandler.instance().tooltip); } if (RayTracing.instance().getTarget().typeOfHit == EnumMovingObjectType.ENTITY) { - renderOverlay(DataAccessorEntity.instance.getEntity(), WailaTickHandler.instance().tooltip); // Might need change for the override + renderOverlay(WailaTickHandler.instance().tooltip); } } - public static void renderOverlay(ItemStack stack, Tooltip tooltip) + public static void renderOverlay(Tooltip tooltip) { //TrueTypeFont font = (TrueTypeFont)mod_Waila.proxy.getFont(); @@ -73,44 +73,20 @@ public class OverlayRenderer { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA); for (int i = 0; i < tooltip.textData.size(); i++) - //FontHelper.drawString(textData.get(i), x + 24, y + ty + 10*i, font, 1.0f, 1.0f, new float[] {1.0f, 1.0f, 1.0f}); - drawString(tooltip.textData.get(i), tooltip.x + 24, tooltip.y + tooltip.ty + 10*i, OverlayConfig.fontcolor, true); + drawString(tooltip.textData.get(i), tooltip.x + tooltip.offsetX, tooltip.y + tooltip.ty + 10*i, OverlayConfig.fontcolor, true); GL11.glDisable(GL11.GL_BLEND); - RenderHelper.enableGUIStandardItemLighting(); + if (tooltip.hasIcon) + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); - if (stack.getItem() != null) - GuiContainerManager.drawItem(tooltip.x+5, tooltip.y+tooltip.h/2-8, stack); + if (tooltip.hasIcon && tooltip.stack != null && tooltip.stack.getItem() != null) + GuiContainerManager.drawItem(tooltip.x+5, tooltip.y+tooltip.h/2-8, tooltip.stack); GL11.glPopMatrix(); } - public static void renderOverlay(Entity entity, Tooltip tooltip) - { - GL11.glPushMatrix(); - - GL11.glScalef(OverlayConfig.scale, OverlayConfig.scale, 1.0f); - - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - - drawTooltipBox(tooltip.x, tooltip.y, tooltip.w, tooltip.h, OverlayConfig.bgcolor, OverlayConfig.gradient1, OverlayConfig.gradient2); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA); - for (int i = 0; i < tooltip.textData.size(); i++) - drawString(tooltip.textData.get(i), tooltip.x + 6, tooltip.y + tooltip.ty + 10*i, OverlayConfig.fontcolor, true); - GL11.glDisable(GL11.GL_BLEND); - - //RenderHelper.enableGUIStandardItemLighting(); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - - GL11.glPopMatrix(); - } - public static void saveGLState(){ hasBlending = GL11.glGetBoolean(GL11.GL_BLEND); hasLight = GL11.glGetBoolean(GL11.GL_LIGHTING); diff --git a/mcp/mobius/waila/overlay/Tooltip.java b/mcp/mobius/waila/overlay/Tooltip.java index dd93218..4d7a634 100644 --- a/mcp/mobius/waila/overlay/Tooltip.java +++ b/mcp/mobius/waila/overlay/Tooltip.java @@ -5,6 +5,7 @@ import java.util.List; import java.awt.Dimension; import java.awt.Point; +import net.minecraft.item.ItemStack; import net.minecraftforge.common.Configuration; import mcp.mobius.waila.Constants; import mcp.mobius.waila.api.impl.ConfigHandler; @@ -13,16 +14,31 @@ import static codechicken.core.gui.GuiDraw.*; public class Tooltip { public List textData = new ArrayList(); int w,h,x,y,ty; + int offsetX; Point pos; + boolean hasIcon = false; + ItemStack stack; + + public Tooltip(List textData, ItemStack stack){ + this(textData, true); + this.stack = stack; + } - public Tooltip(List textData){ + public Tooltip(List textData, boolean hasIcon){ this.textData = textData; - this.pos = new Point(ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSX,0), ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSY,0)); + this.pos = new Point(ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSX,0), + ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSY,0)); + this.hasIcon = hasIcon; + + int offsetW = hasIcon ? 29 : 13; + int offsetH = hasIcon ? 24 : 0; + offsetX = hasIcon ? 24 : 6; + w = 0; for (String s : textData) - w = Math.max(w, getStringWidth(s)+29); - h = Math.max(24, 10 + 10*textData.size()); + w = Math.max(w, getStringWidth(s) + offsetW); + h = Math.max(offsetH, 10 + 10*textData.size()); Dimension size = displaySize(); x = ((int)(size.width / OverlayConfig.scale)-w-1)*pos.x/10000; diff --git a/mcp/mobius/waila/overlay/WailaTickHandler.java b/mcp/mobius/waila/overlay/WailaTickHandler.java index 5465c5d..42f1d78 100644 --- a/mcp/mobius/waila/overlay/WailaTickHandler.java +++ b/mcp/mobius/waila/overlay/WailaTickHandler.java @@ -70,7 +70,7 @@ public class WailaTickHandler implements ITickHandler { this.currenttip = handler.handleBlockTextData(targetStack, world, player, target, accessor, currenttip, Layout.HEADER); this.currenttip = handler.handleBlockTextData(targetStack, world, player, target, accessor, currenttip, Layout.BODY); this.currenttip = handler.handleBlockTextData(targetStack, world, player, target, accessor, currenttip, Layout.FOOTER); - this.tooltip = new Tooltip(this.currenttip); + this.tooltip = new Tooltip(this.currenttip, targetStack); } } else if (target != null && target.typeOfHit == EnumMovingObjectType.ENTITY){ @@ -85,7 +85,7 @@ public class WailaTickHandler implements ITickHandler { this.currenttip = handler.handleEntityTextData(targetEnt, world, player, target, accessor, currenttip, Layout.HEADER); this.currenttip = handler.handleEntityTextData(targetEnt, world, player, target, accessor, currenttip, Layout.BODY); this.currenttip = handler.handleEntityTextData(targetEnt, world, player, target, accessor, currenttip, Layout.FOOTER); - this.tooltip = new Tooltip(this.currenttip); + this.tooltip = new Tooltip(this.currenttip, false); } } }