mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-21 20:52:42 +00:00
Added 'show snapshot' button to existing item filter.
This commit is contained in:
1 parent
746c849235
commit
0ece5698f3
3 files changed
+103
-9
No files matched your search
@@ -1,14 +1,33 @@
|
||||
package crazypants.enderio.conduit.gui.item;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import crazypants.enderio.conduit.gui.GuiExternalConnection;
|
||||
import crazypants.enderio.conduit.item.IItemConduit;
|
||||
import crazypants.enderio.conduit.item.filter.ExistingItemFilter;
|
||||
import crazypants.enderio.conduit.packet.PacketItemConduitFilter;
|
||||
import crazypants.enderio.gui.IGuiOverlay;
|
||||
import crazypants.enderio.gui.IconEIO;
|
||||
import crazypants.enderio.gui.ToggleButtonEIO;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.gui.IGuiScreen;
|
||||
import crazypants.render.ColorUtil;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.util.Lang;
|
||||
import crazypants.vecmath.Vector4f;
|
||||
|
||||
public class ExistingItemFilterGui implements IItemFilterGui {
|
||||
|
||||
@@ -19,6 +38,7 @@ public class ExistingItemFilterGui implements IItemFilterGui {
|
||||
|
||||
private static final int ID_SNAPSHOT = GuiExternalConnection.nextButtonId();
|
||||
private static final int ID_CLEAR = GuiExternalConnection.nextButtonId();
|
||||
private static final int ID_SHOW = GuiExternalConnection.nextButtonId();
|
||||
|
||||
|
||||
private IItemConduit itemConduit;
|
||||
@@ -31,6 +51,8 @@ public class ExistingItemFilterGui implements IItemFilterGui {
|
||||
|
||||
private GuiButton snapshotB;
|
||||
private GuiButton clearB;
|
||||
private GuiButton showB;
|
||||
private SnapshotOverlay snapshotOverlay;
|
||||
|
||||
boolean isInput;
|
||||
|
||||
@@ -78,6 +100,8 @@ public class ExistingItemFilterGui implements IItemFilterGui {
|
||||
useOreDictB.setUnselectedToolTip(Lang.localize("gui.conduit.item.oreDicDisabled"));
|
||||
useOreDictB.setPaintSelectedBorder(false);
|
||||
|
||||
snapshotOverlay = new SnapshotOverlay();
|
||||
gui.addOverlay(snapshotOverlay);
|
||||
|
||||
|
||||
}
|
||||
@@ -104,14 +128,19 @@ public class ExistingItemFilterGui implements IItemFilterGui {
|
||||
int y = gui.getGuiTop() + 65;
|
||||
snapshotB = new GuiButton(ID_SNAPSHOT, x, y, 60, 20, "Snapshot");
|
||||
|
||||
x += 65;
|
||||
showB = new GuiButton(ID_SHOW, x, y, 40, 20, "Show");
|
||||
|
||||
x = gui.getGuiLeft() + 80;
|
||||
y += 22;
|
||||
clearB = new GuiButton(ID_CLEAR, x, y, 60, 20, "Clear");
|
||||
|
||||
clearB.enabled = filter.getSnapshot() != null;
|
||||
showB.enabled = clearB.enabled;
|
||||
|
||||
gui.addButton(snapshotB);
|
||||
gui.addButton(clearB);
|
||||
|
||||
clearB.enabled = filter.getSnapshot() != null;
|
||||
|
||||
gui.addButton(showB);
|
||||
|
||||
}
|
||||
|
||||
@@ -133,9 +162,15 @@ public class ExistingItemFilterGui implements IItemFilterGui {
|
||||
sendSnapshotPacket(false);
|
||||
} else if(guiButton.id == ID_CLEAR) {
|
||||
sendSnapshotPacket(true);
|
||||
} else if(guiButton.id == ID_SHOW) {
|
||||
showSnapshotOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
private void showSnapshotOverlay() {
|
||||
snapshotOverlay.setVisible(true);
|
||||
}
|
||||
|
||||
private void sendSnapshotPacket(boolean isClear) {
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketExistingItemFilterSnapshot(itemConduit, gui.getDir(),isInput,isClear));
|
||||
}
|
||||
@@ -162,4 +197,69 @@ public class ExistingItemFilterGui implements IItemFilterGui {
|
||||
// gui.drawTexturedModalRect(gui.getGuiLeft() + 32, gui.getGuiTop() + 86, 0, 238, 18 * 5, 18);
|
||||
// }
|
||||
}
|
||||
|
||||
class SnapshotOverlay implements IGuiOverlay {
|
||||
|
||||
boolean visible;
|
||||
|
||||
@Override
|
||||
public void init(IGuiScreen screen) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle getBounds() {
|
||||
return new Rectangle(0,0,gui.width,gui.height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int mouseX, int mouseY, float partialTick) {
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
RenderUtil.renderQuad2D(4, 4, 0, gui.getXSize() - 9, gui.getYSize() - 8, new Vector4f(0,0,0,1));
|
||||
RenderUtil.renderQuad2D(6, 6, 0, gui.getXSize() - 13, gui.getYSize() - 12, new Vector4f(0.6,0.6,0.6,1));
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
RenderItem itemRenderer = new RenderItem();
|
||||
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
List<ItemStack> snapshot = filter.getSnapshot();
|
||||
int x = 15;
|
||||
int y = 10;
|
||||
int count = 0;
|
||||
for(ItemStack st : snapshot) {
|
||||
if(st != null) {
|
||||
itemRenderer.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), st, x, y);
|
||||
//itemRender.renderItemOverlayIntoGUI(mc.fontRenderer, mc.getTextureManager(), st, x, y, s);
|
||||
}
|
||||
x += 20;
|
||||
count++;
|
||||
if(count % 9 == 0) {
|
||||
x = 15;
|
||||
y += 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean visible) {
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleMouseInput(int x, int y, int b) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMouseInBounds(int mouseX, int mouseY) {
|
||||
return getBounds().contains(mouseX, mouseY);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ public interface IGuiOverlay {
|
||||
|
||||
void init(IGuiScreen screen);
|
||||
|
||||
IIcon getIcon();
|
||||
|
||||
Rectangle getBounds();
|
||||
|
||||
|
||||
@@ -39,11 +39,6 @@ public class GuiOverlayIoConfig implements IGuiOverlay {
|
||||
coords.addAll(bc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon() {
|
||||
return EnderIOTab.tabEnderIO.getIconItemStack().getIconIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(IGuiScreen screen) {
|
||||
this.screen = screen;
|
||||
|
||||
Reference in new issue
Block a user