mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-26 06:53:24 +00:00
Merge remote-tracking branch 'origin/master' into Telepad
Conflicts: src/main/java/crazypants/gui/GuiContainerBase.java
This commit is contained in:
commit
de55e3336c
21 files changed
+936
-69
No files matched your search
@@ -19,11 +19,12 @@ import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import codechicken.nei.VisiblityData;
|
||||
import codechicken.nei.api.INEIGuiHandler;
|
||||
import codechicken.nei.api.TaggedInventoryArea;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import crazypants.enderio.gui.IGuiOverlay;
|
||||
import crazypants.enderio.gui.TextFieldEIO;
|
||||
@@ -38,6 +39,9 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe
|
||||
protected ToolTipManager ttMan = new ToolTipManager();
|
||||
protected List<IGuiOverlay> overlays = new ArrayList<IGuiOverlay>();
|
||||
protected List<TextFieldEIO> textFields = Lists.newArrayList();
|
||||
protected List<GhostSlot> ghostSlots = new ArrayList<GhostSlot>();
|
||||
|
||||
protected GhostSlot hoverGhostSlot;
|
||||
|
||||
protected GuiContainerBase(Container par1Container) {
|
||||
super(par1Container);
|
||||
@@ -137,10 +141,18 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int p_73864_3_) {
|
||||
super.mouseClicked(x, y, p_73864_3_);
|
||||
for (GuiTextField f : textFields) {
|
||||
f.mouseClicked(x, y, p_73864_3_);
|
||||
}
|
||||
if(!ghostSlots.isEmpty()) {
|
||||
GhostSlot slot = getGhostSlot(x, y);
|
||||
if(slot != null) {
|
||||
ItemStack st = Minecraft.getMinecraft().thePlayer.inventory.getItemStack();
|
||||
slot.putStack(st);
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.mouseClicked(x, y, p_73864_3_);
|
||||
}
|
||||
|
||||
public void addOverlay(IGuiOverlay overlay) {
|
||||
@@ -154,7 +166,7 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe
|
||||
private int realMx, realMy;
|
||||
|
||||
@Override
|
||||
public final void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
protected final void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
drawForegroundImpl(mouseX, mouseY);
|
||||
|
||||
Timer t = RenderUtil.getTimer();
|
||||
@@ -176,15 +188,16 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int mouseX, int mouseY) {
|
||||
for (GuiTextField f : textFields) {
|
||||
f.drawTextBox();
|
||||
}
|
||||
drawGhostSlots(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int par1, int par2, float par3) {
|
||||
|
||||
hoverGhostSlot = null;
|
||||
int mx = realMx = par1;
|
||||
int my = realMy = par2;
|
||||
for (IGuiOverlay overlay : overlays) {
|
||||
@@ -196,6 +209,13 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe
|
||||
}
|
||||
|
||||
super.drawScreen(mx, my, par3);
|
||||
|
||||
if(hoverGhostSlot != null && mc.thePlayer.inventory.getItemStack() == null) {
|
||||
ItemStack stack = hoverGhostSlot.getStack();
|
||||
if(stack != null) {
|
||||
renderToolTip(stack, par1, par2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// copied from super with hate
|
||||
@@ -217,13 +237,80 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe
|
||||
itemRender.zLevel = 0.0F;
|
||||
}
|
||||
|
||||
protected void drawFakeItemsStart() {
|
||||
zLevel = 100.0F;
|
||||
itemRender.zLevel = 100.0F;
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
}
|
||||
|
||||
protected void drawFakeItemStack(int x, int y, ItemStack stack) {
|
||||
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.renderEngine, stack, x, y);
|
||||
}
|
||||
|
||||
protected void drawFakeItemHover(int x, int y) {
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glColorMask(true, true, true, false);
|
||||
drawGradientRect(x, y, x + 16, y + 16, 0x80FFFFFF, 0x80FFFFFF);
|
||||
GL11.glColorMask(true, true, true, true);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
}
|
||||
|
||||
protected void drawFakeItemsEnd() {
|
||||
GL11.glPopAttrib();
|
||||
itemRender.zLevel = 0.0F;
|
||||
zLevel = 0.0F;
|
||||
}
|
||||
|
||||
protected void drawGhostSlots(int mouseX, int mouseY) {
|
||||
if(ghostSlots.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
int sx = getGuiLeft();
|
||||
int sy = getGuiTop();
|
||||
drawFakeItemsStart();
|
||||
try {
|
||||
hoverGhostSlot = null;
|
||||
for(GhostSlot slot : ghostSlots) {
|
||||
ItemStack stack = slot.getStack();
|
||||
if(slot.isVisible()) {
|
||||
if(stack != null) {
|
||||
drawFakeItemStack(slot.x + sx, slot.y + sy, stack);
|
||||
}
|
||||
if(slot.isMouseOver(mouseX - sx, mouseY - sy)) {
|
||||
hoverGhostSlot = slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(hoverGhostSlot != null) {
|
||||
// draw hover last to prevent it from affecting rendering of other slots ...
|
||||
drawFakeItemHover(hoverGhostSlot.x + sx, hoverGhostSlot.y + sy);
|
||||
}
|
||||
} finally {
|
||||
drawFakeItemsEnd();
|
||||
}
|
||||
}
|
||||
|
||||
protected GhostSlot getGhostSlot(int mouseX, int mouseY) {
|
||||
mouseX -= getGuiLeft();
|
||||
mouseY -= getGuiTop();
|
||||
for(GhostSlot slot : ghostSlots) {
|
||||
if(slot.isVisible() && slot.isMouseOver(mouseX, mouseY)) {
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isMouseInOverlay(int mouseX, int mouseY, IGuiOverlay overlay) {
|
||||
int x = mouseX - getGuiLeft();
|
||||
int y = mouseY - getGuiTop();
|
||||
if(overlay.getBounds().contains(x, y)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return overlay.getBounds().contains(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user