mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-22 05:02:23 +00:00
Code cleanup, basic icon rendering support.
This commit is contained in:
1 parent
0ef5f65067
commit
904fe472b8
2 files changed
+40
-9
No files matched your search
@@ -20,10 +20,14 @@ import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorEntity;
|
||||
import mcp.mobius.waila.gui.truetyper.TrueTypeFont;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumMovingObjectType;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import static codechicken.core.gui.GuiDraw.*;
|
||||
|
||||
@@ -32,6 +36,7 @@ public class OverlayRenderer {
|
||||
protected static boolean hasBlending;
|
||||
protected static boolean hasLight;
|
||||
protected static int boundTexIndex;
|
||||
protected static RenderItem renderItem = new RenderItem();
|
||||
|
||||
public static void renderOverlay()
|
||||
{
|
||||
@@ -118,4 +123,30 @@ public class OverlayRenderer {
|
||||
drawGradientRect(x + 1, y + h - 1, w - 1, 1, grad2, grad2);
|
||||
}
|
||||
|
||||
public static void drawTexturedModalRect(int x, int y, int u, int v, int w, int h, int tw, int th)
|
||||
{
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
float zLevel = 0.0F;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV((double)(x + 0), (double)(y + h), (double)zLevel, (double)((float)(u + 0) * f), (double)((float)(v + th) * f1));
|
||||
tessellator.addVertexWithUV((double)(x + w), (double)(y + h), (double)zLevel, (double)((float)(u + tw) * f), (double)((float)(v + th) * f1));
|
||||
tessellator.addVertexWithUV((double)(x + w), (double)(y + 0), (double)zLevel, (double)((float)(u + tw) * f), (double)((float)(v + 0) * f1));
|
||||
tessellator.addVertexWithUV((double)(x + 0), (double)(y + 0), (double)zLevel, (double)((float)(u + 0) * f), (double)((float)(v + 0) * f1));
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public static void renderHeart(int x, int y, int sx, int sy){
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(Gui.icons);
|
||||
drawTexturedModalRect(x, y, 52, 9, sx, sy, 9, 9);
|
||||
drawTexturedModalRect(x, y, 52, 0, sx, sy, 9, 9);
|
||||
}
|
||||
|
||||
public static void renderHalfHeart(int x, int y, int sx, int sy){
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(Gui.icons);
|
||||
drawTexturedModalRect(x, y, 52, 9, sx, sy, 9, 9);
|
||||
drawTexturedModalRect(x, y, 61, 0, sx, sy, 9, 9);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import mcp.mobius.waila.Constants;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
@@ -15,7 +16,8 @@ import static codechicken.core.gui.GuiDraw.*;
|
||||
import static mcp.mobius.waila.SpecialChars.*;
|
||||
|
||||
public class Tooltip {
|
||||
List<String> textData = new ArrayList<String>();
|
||||
public static int TabSpacing = 8;
|
||||
|
||||
ArrayList<Line> lines = new ArrayList<Line>();
|
||||
int w,h,x,y,ty;
|
||||
int offsetX;
|
||||
@@ -67,14 +69,12 @@ public class Tooltip {
|
||||
for (int i = 0; i < l.ncolumns; i++)
|
||||
columnsWidth[i] = Math.max(columnsWidth[i], l.columnsWidth[i]);
|
||||
|
||||
maxStringW = Math.max(maxStringW, l.lineWidth + (l.ncolumns - 1) * 8);
|
||||
maxStringW = Math.max(maxStringW, l.lineWidth + (l.ncolumns - 1) * TabSpacing);
|
||||
}
|
||||
|
||||
for (int i = 0; i < ncolumns - 1; i++){
|
||||
for (int i = 0; i < ncolumns - 1; i++)
|
||||
columnsPos[i + 1] = columnsWidth[i] + columnsPos[i];
|
||||
}
|
||||
|
||||
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.hasIcon = hasIcon;
|
||||
@@ -85,19 +85,19 @@ public class Tooltip {
|
||||
|
||||
w = maxStringW + paddingW;
|
||||
|
||||
h = Math.max(paddingH, 10 + 10*textData.size());
|
||||
h = Math.max(paddingH, 10 + 10*lines.size());
|
||||
|
||||
Dimension size = displaySize();
|
||||
x = ((int)(size.width / OverlayConfig.scale)-w-1)*pos.x/10000;
|
||||
x = ((int)(size.width / OverlayConfig.scale)-w-1)*pos.x/10000;
|
||||
y = ((int)(size.height / OverlayConfig.scale)-h-1)*pos.y/10000;
|
||||
|
||||
ty = (h-10*textData.size())/2;
|
||||
ty = (h-10*lines.size())/2;
|
||||
}
|
||||
|
||||
public void drawStrings(){
|
||||
for (int i = 0; i < lines.size(); i++){
|
||||
for (int c = 0; c < lines.get(i).ncolumns; c++)
|
||||
drawString(lines.get(i).columns[c], x + offsetX + columnsPos[c] + 8*c, y + ty + 10*i, OverlayConfig.fontcolor, true);
|
||||
drawString(lines.get(i).columns[c], x + offsetX + columnsPos[c] + c*TabSpacing, y + ty + 10*i, OverlayConfig.fontcolor, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user