Conduit gui fixes (#76)

* Fix swapped insert/extract filter locations in the guis

* Fix filters sometimes causing dropping items and left clicking to clear ender fluid filters
This commit is contained in:
Raven Szewczyk authored and GitHub committed 2022-07-02 10:47:41 +02:00
1 parent 3ed88d87a6
commit 3358691fef
9 files changed
+39 -27

No files matched your search

@@ -117,14 +117,14 @@ public class BaseSettingsPanel implements ITabPanel {
filterExtractUpgradeTooltip = new GuiToolTip(new Rectangle(rightColumn, 70, 18, 18), EnderIO.lang.localize("gui.conduit.item.filterupgrade")) {
@Override
public boolean shouldDraw() {
return !gui.getContainer().hasFilterUpgrades(false) && super.shouldDraw();
return !gui.getContainer().hasFilterUpgrades(true) && super.shouldDraw();
}
};
filterInsertUpgradeTooltip = new GuiToolTip(new Rectangle(leftColumn, 70, 18, 18), EnderIO.lang.localize("gui.conduit.item.filterupgrade")) {
@Override
public boolean shouldDraw() {
return !gui.getContainer().hasFilterUpgrades(true) && super.shouldDraw();
return !gui.getContainer().hasFilterUpgrades(false) && super.shouldDraw();
}
};
@@ -58,13 +58,13 @@ public class ExternalConnectionContainer extends ContainerEnder<InventoryUpgrade
int y;
if (itemConduit != null) {
x = 113;
x = 23;
y = 71;
slotOutputFilterUpgrades = addSlotToContainer(new FilterSlot(getInv(), 3, x, y));
slotLocations.add(new Point(x, y));
bgSlots.add(new GhostBackgroundItemSlot(EnderIO.itemBasicFilterUpgrade, slotOutputFilterUpgrades));
x = 23;
x = 113;
y = 71;
slotInputFilterUpgrades = addSlotToContainer(new FilterSlot(getInv(), 2, x, y));
slotLocations.add(new Point(x, y));
@@ -139,19 +139,37 @@ public class GuiExternalConnection extends GuiContainerBaseEIO {
return false;
}
@Override
protected void mouseClicked(int x, int y, int par3) {
// handle out-of-bounds ghost slots
/**
* Returns true when slots outside of standard gui bounds are clicked to prevent
* setting ghost filters dropping items on the ground.
*/
private boolean handleOobClick(int x, int y, int button) {
boolean outOfBounds = x < guiLeft || y < guiTop || x >= guiLeft + xSize || y >= guiTop + ySize;
boolean hasItem = playerInv.getItemStack() != null;
if (outOfBounds && hasItem && !getGhostSlots().isEmpty()) {
GhostSlot slot = getGhostSlot(x, y);
if (slot != null) {
ghostSlotClicked(slot, x, y, par3);
return;
ghostSlotClicked(slot, x, y, button);
return true;
}
}
super.mouseClicked(x, y, par3);
return false;
}
@Override
protected void mouseMovedOrUp(int x, int y, int button) {
if (handleOobClick(x, y, button)) {
return;
}
super.mouseMovedOrUp(x, y, button);
}
@Override
protected void mouseClicked(int x, int y, int button) {
// handle out-of-bounds ghost slots
if (handleOobClick(x, y, button)) {
return;
}
int tabLeftX = xSize;
int tabRightX = tabLeftX + 22;
@@ -171,8 +189,8 @@ public class GuiExternalConnection extends GuiContainerBaseEIO {
return;
}
}
tabs.get(activeTab).mouseClicked(x, y, par3);
tabs.get(activeTab).mouseClicked(x, y, button);
super.mouseClicked(x + guiLeft, y + guiTop, button);
}
public void setSize(int x, int y) {
@@ -213,15 +213,11 @@ public class LiquidSettings extends BaseSettingsPanel {
}
@Override
public void mouseClicked(int x, int y, int par3) {
public void mouseClicked(int x, int y, int button) {
if(!isFilterVisible()) {
return;
}
ItemStack st = Minecraft.getMinecraft().thePlayer.inventory.getItemStack();
if (st == null && par3 == 0) {
return;
}
setFilterFromItem(x, y, st);
}
@@ -43,7 +43,7 @@ public class BasicItemFilterGui implements IItemFilterGui {
private boolean isInput;
public BasicItemFilterGui(GuiContainerBaseEIO gui, IItemFilterContainer filterContainer, boolean isStickyModeAvailable, boolean isInput) {
this(gui, filterContainer, isStickyModeAvailable, isInput, isInput ? 6 : 104, 96, isInput ? 0 : 256);
this(gui, filterContainer, isStickyModeAvailable, isInput, isInput ? 104 : 6, 96, isInput ? 0 : 256);
}
public BasicItemFilterGui(GuiContainerBaseEIO gui, IItemFilterContainer filterContainer, boolean isStickyModeAvailable,
@@ -45,7 +45,7 @@ public class BigItemFilterGui implements IItemFilterGui {
private int yOffset;
public BigItemFilterGui(GuiContainerBaseEIO gui, IItemFilterContainer filterContainer, boolean isStickyModeAvailable, boolean isInput) {
this(gui, filterContainer, isStickyModeAvailable, isInput, isInput ? 6 : 104, 96, isInput ? 0 : 256);
this(gui, filterContainer, isStickyModeAvailable, isInput, isInput ? 104 : 6, 96, isInput ? 0 : 256);
}
public BigItemFilterGui(GuiContainerBaseEIO gui, IItemFilterContainer filterContainer, boolean isStickyModeAvailable, boolean isInput,
@@ -96,10 +96,8 @@ public class BigItemFilterGui implements IItemFilterGui {
stickyB.setPaintSelectedBorder(false);
this.yOffset += 8;
if (isInput) {
if (!isInput) {
this.xOffset -= 50;
} else {
//
}
}
@@ -72,7 +72,7 @@ public class ExistingItemFilterGui implements IItemFilterGui {
filter = (ExistingItemFilter) itemConduit.getOutputFilter(gui.getDir());
}
int butLeft = isInput ? 6 : 104;
int butLeft = isInput ? 104 : 6;
int x = butLeft;
int y = 96;
@@ -147,7 +147,7 @@ public class ExistingItemFilterGui implements IItemFilterGui {
whiteListB.setToolTip(EnderIO.lang.localize("gui.conduit.item.whitelist"));
}
int butLeft = gui.getGuiLeft() + (isInput ? 5 : 104);
int butLeft = gui.getGuiLeft() + (isInput ? 104 : 5);
int x = butLeft;
int y = gui.getGuiTop() + 96 + 20;
@@ -48,7 +48,7 @@ public class ModItemFilterGui implements IItemFilterGui {
this.itemConduit = itemConduit;
this.isInput = isInput;
int butLeft = isInput ? 5 : 106;
int butLeft = isInput ? 106 : 5;
int x = butLeft;
int y = 96;
@@ -43,7 +43,7 @@ public class PowerItemFilterGui implements IItemFilterGui {
filter = (PowerItemFilter) itemConduit.getOutputFilter(gui.getDir());
}
int butLeft = isInput ? 5 : 106;
int butLeft = isInput ? 106 : 5;
int x = butLeft;
int y = 96 + 24;
@@ -82,7 +82,7 @@ public class PowerItemFilterGui implements IItemFilterGui {
stickyB.setSelected(filter.isSticky());
}
int x0 = gui.getGuiLeft() + (isInput ? 5 : 106);
int x0 = gui.getGuiLeft() + (isInput ? 106 : 5);
int y0 = gui.getGuiTop() + 96;
int x1 = x0 + 45;