use of network.rs485.logisticspipes.property.IBitSet in project LogisticsPipes by RS485.
the class LogisticsBaseGuiScreen method onRenderSlot.
private void onRenderSlot(Slot slot) {
if (slot instanceof IFuzzySlot) {
final IBitSet set = ((IFuzzySlot) slot).getFuzzyFlags();
int x1 = slot.xPos;
int y1 = slot.yPos;
GL11.glDisable(GL11.GL_LIGHTING);
final boolean useOreDict = FuzzyUtil.INSTANCE.get(set, FuzzyFlag.USE_ORE_DICT);
if (useOreDict) {
Gui.drawRect(x1 + 8, y1 - 1, x1 + 17, y1, 0xFFFF4040);
Gui.drawRect(x1 + 16, y1, x1 + 17, y1 + 8, 0xFFFF4040);
}
final boolean ignoreDamage = FuzzyUtil.INSTANCE.get(set, FuzzyFlag.IGNORE_DAMAGE);
if (ignoreDamage) {
Gui.drawRect(x1 - 1, y1 - 1, x1 + 8, y1, 0xFF40FF40);
Gui.drawRect(x1 - 1, y1, x1, y1 + 8, 0xFF40FF40);
}
final boolean ignoreNBT = FuzzyUtil.INSTANCE.get(set, FuzzyFlag.IGNORE_NBT);
if (ignoreNBT) {
Gui.drawRect(x1 - 1, y1 + 16, x1 + 8, y1 + 17, 0xFF4040FF);
Gui.drawRect(x1 - 1, y1 + 8, x1, y1 + 17, 0xFF4040FF);
}
final boolean useOreCategory = FuzzyUtil.INSTANCE.get(set, FuzzyFlag.USE_ORE_CATEGORY);
if (useOreCategory) {
Gui.drawRect(x1 + 8, y1 + 16, x1 + 17, y1 + 17, 0xFF7F7F40);
Gui.drawRect(x1 + 16, y1 + 8, x1 + 17, y1 + 17, 0xFF7F7F40);
}
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(GL11.GL_LIGHTING);
final boolean mouseOver = this.isMouseOverSlot(slot, currentDrawScreenMouseX, currentDrawScreenMouseY);
if (mouseOver) {
if (fuzzySlot == slot) {
fuzzySlotGuiHoverTime++;
if (fuzzySlotGuiHoverTime >= 10) {
fuzzySlotActiveGui = true;
}
} else {
fuzzySlot = (IFuzzySlot) slot;
fuzzySlotGuiHoverTime = 0;
fuzzySlotActiveGui = false;
}
}
if (fuzzySlotActiveGui && fuzzySlot == slot) {
if (!mouseOver) {
// Check within FuzzyGui
if (!isPointInRegion(slot.xPos, slot.yPos + 16, 60, 52, currentDrawScreenMouseX, currentDrawScreenMouseY)) {
fuzzySlotActiveGui = false;
fuzzySlot = null;
}
}
final int posX = slot.xPos + guiLeft;
final int posY = slot.yPos + 17 + guiTop;
renderAtTheEnd.add(() -> {
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_LIGHTING);
GuiGraphics.drawGuiBackGround(mc, posX, posY, posX + 61, posY + 47, zLevel, true, true, true, true, true);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
final String PREFIX = "gui.crafting.";
mc.fontRenderer.drawString(TextUtil.translate(PREFIX + "OreDict"), posX + 5, posY + 5, (useOreDict ? 0xFF4040 : 0x404040));
mc.fontRenderer.drawString(TextUtil.translate(PREFIX + "IgnDamage"), posX + 5, posY + 15, (ignoreDamage ? 0x40FF40 : 0x404040));
mc.fontRenderer.drawString(TextUtil.translate(PREFIX + "IgnNBT"), posX + 5, posY + 25, (ignoreNBT ? 0x4040FF : 0x404040));
mc.fontRenderer.drawString(TextUtil.translate(PREFIX + "OrePrefix"), posX + 5, posY + 35, (useOreCategory ? 0x7F7F40 : 0x404040));
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
});
}
}
}
use of network.rs485.logisticspipes.property.IBitSet in project LogisticsPipes by RS485.
the class LogisticsBaseGuiScreen method mouseClicked.
@Override
protected void mouseClicked(int par1, int par2, int par3) throws IOException {
for (IRenderSlot slot : slots) {
int mouseX = par1 - guiLeft;
int mouseY = par2 - guiTop;
int mouseXMax = mouseX - slot.getSize();
int mouseYMax = mouseY - slot.getSize();
if (slot.getXPos() < mouseX && slot.getXPos() > mouseXMax && slot.getYPos() < mouseY && slot.getYPos() > mouseYMax) {
slot.mouseClicked(par3);
return;
}
}
if (isMouseInFuzzyPanel(par1, par2)) {
final int posX = fuzzySlot.getX() + guiLeft;
final int posY = fuzzySlot.getY() + 17 + guiTop;
int sel = -1;
if (par1 >= posX + 5 && par1 <= posX + 56) {
if (par2 >= posY + 5 && par2 <= posY + 45) {
sel = (par2 - posY - 4) / 10;
}
}
IBitSet set = fuzzySlot.getFuzzyFlags();
FuzzyFlag flag = null;
switch(sel) {
case 0:
flag = FuzzyFlag.USE_ORE_DICT;
break;
case 1:
flag = FuzzyFlag.IGNORE_DAMAGE;
break;
case 2:
flag = FuzzyFlag.IGNORE_NBT;
break;
case 3:
flag = FuzzyFlag.USE_ORE_CATEGORY;
break;
}
if (flag == null)
return;
set.flip(flag.getBit());
MainProxy.sendPacketToServer(PacketHandler.getPacket(FuzzySlotSettingsPacket.class).setSlotNumber(fuzzySlot.getSlotId()).setFlags(set.copyValue()));
return;
}
boolean handledButton = false;
if (par3 == 0) {
for (Object aButtonList : buttonList) {
GuiButton guibutton = (GuiButton) aButtonList;
if (guibutton.mousePressed(mc, par1, par2)) {
selectedButton = guibutton;
guibutton.playPressSound(mc.getSoundHandler());
actionPerformed(guibutton);
handledButton = true;
break;
}
}
}
if (!handledButton) {
super.mouseClicked(par1, par2, par3);
}
if (par3 == 0 && par1 < guiLeft && !mouseCanPressButton(par1, par2) && !isOverSlot(par1, par2)) {
extentionControllerLeft.mouseClicked(par1, par2, par3);
}
if (par3 == 0 && par1 > guiLeft + xSize && !mouseCanPressButton(par1, par2) && !isOverSlot(par1, par2)) {
extentionControllerRight.mouseClicked(par1, par2, par3);
}
}
Aggregations