2013-08-27 00:49:32 +02:00
|
|
|
package mekanism.client.gui;
|
2013-08-26 02:54:34 +02:00
|
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
2013-11-07 22:59:37 +01:00
|
|
|
import mekanism.common.ObfuscatedNames;
|
|
|
|
import mekanism.common.util.MekanismUtils;
|
2013-08-26 02:54:34 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.gui.FontRenderer;
|
|
|
|
import net.minecraft.client.gui.GuiScreen;
|
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
|
|
|
|
public abstract class GuiElement
|
|
|
|
{
|
|
|
|
protected static Minecraft mc = Minecraft.getMinecraft();
|
|
|
|
|
|
|
|
protected ResourceLocation RESOURCE;
|
|
|
|
|
2013-10-26 06:02:57 +02:00
|
|
|
public GuiScreen guiObj;
|
2013-08-26 02:54:34 +02:00
|
|
|
|
|
|
|
public TileEntity tileEntity;
|
|
|
|
|
|
|
|
public ResourceLocation defaultLocation;
|
|
|
|
|
2013-10-26 06:02:57 +02:00
|
|
|
public GuiElement(ResourceLocation resource, GuiScreen gui, TileEntity tile, ResourceLocation def)
|
2013-08-26 02:54:34 +02:00
|
|
|
{
|
|
|
|
RESOURCE = resource;
|
2013-10-26 06:02:57 +02:00
|
|
|
guiObj = gui;
|
2013-08-26 02:54:34 +02:00
|
|
|
tileEntity = tile;
|
|
|
|
defaultLocation = def;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void displayTooltip(String s, int xAxis, int yAxis)
|
|
|
|
{
|
|
|
|
try {
|
2013-11-07 22:59:37 +01:00
|
|
|
Method m = MekanismUtils.getPrivateMethod(GuiContainer.class, ObfuscatedNames.GuiContainer_drawCreativeTabHoveringText, String.class, Integer.TYPE, Integer.TYPE);
|
2013-08-26 02:54:34 +02:00
|
|
|
m.setAccessible(true);
|
2013-10-26 06:02:57 +02:00
|
|
|
m.invoke(guiObj, s, xAxis, yAxis);
|
2013-08-26 02:54:34 +02:00
|
|
|
} catch(Exception e) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void offsetX(int xSize)
|
|
|
|
{
|
2013-10-26 06:02:57 +02:00
|
|
|
if(guiObj instanceof GuiContainer)
|
|
|
|
{
|
|
|
|
try {
|
2013-11-07 22:59:37 +01:00
|
|
|
int size = (Integer)MekanismUtils.getPrivateValue(guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_xSize);
|
|
|
|
MekanismUtils.setPrivateValue(guiObj, size+xSize, GuiContainer.class, ObfuscatedNames.GuiContainer_xSize);
|
2013-10-26 06:02:57 +02:00
|
|
|
} catch(Exception e) {}
|
|
|
|
}
|
2013-08-26 02:54:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void offsetY(int ySize)
|
|
|
|
{
|
2013-10-26 06:02:57 +02:00
|
|
|
if(guiObj instanceof GuiContainer)
|
|
|
|
{
|
|
|
|
try {
|
2013-11-07 22:59:37 +01:00
|
|
|
int size = (Integer)MekanismUtils.getPrivateValue(guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_ySize);
|
|
|
|
MekanismUtils.setPrivateValue(guiObj, size+ySize, GuiContainer.class, ObfuscatedNames.GuiContainer_ySize);
|
2013-10-26 06:02:57 +02:00
|
|
|
} catch(Exception e) {}
|
|
|
|
}
|
2013-08-26 02:54:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected FontRenderer getFontRenderer()
|
|
|
|
{
|
|
|
|
try {
|
2013-11-07 22:59:37 +01:00
|
|
|
return (FontRenderer)MekanismUtils.getPrivateValue(guiObj, GuiScreen.class, ObfuscatedNames.GuiScreen_fontRenderer);
|
2013-08-26 02:54:34 +02:00
|
|
|
} catch(Exception e) {}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight);
|
|
|
|
|
|
|
|
public abstract void renderForeground(int xAxis, int yAxis);
|
|
|
|
|
2013-08-27 00:28:55 +02:00
|
|
|
public abstract void preMouseClicked(int xAxis, int yAxis, int button);
|
|
|
|
|
|
|
|
public abstract void mouseClicked(int xAxis, int yAxis, int button);
|
2013-08-26 02:54:34 +02:00
|
|
|
}
|