Skip to content

Commit

Permalink
Conduit gui fixes (#76)
Browse files Browse the repository at this point in the history
* Fix swapped insert/extract filter locations in the guis

* Fix filters sometimes causing dropping items and left clicking to clear ender fluid filters
  • Loading branch information
eigenraven authored Jul 2, 2022
1 parent 3ed88d8 commit 3358691
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ protected BaseSettingsPanel(@Nonnull IWidgetIcon icon, @Nonnull String typeName,
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();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ public ExternalConnectionContainer(InventoryPlayer playerInv, IConduitBundle bun
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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,37 @@ public boolean doesGuiPauseGame() {
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;
Expand All @@ -171,8 +189,8 @@ protected void mouseClicked(int x, int y, int par3) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,11 @@ private void toggleBlacklist(boolean isInput) {
}

@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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -96,10 +96,8 @@ public BigItemFilterGui(GuiContainerBaseEIO gui, IItemFilterContainer filterCont
stickyB.setPaintSelectedBorder(false);

this.yOffset += 8;
if (isInput) {
if (!isInput) {
this.xOffset -= 50;
} else {
//
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public ExistingItemFilterGui(GuiExternalConnection gui, IItemConduit itemConduit
filter = (ExistingItemFilter) itemConduit.getOutputFilter(gui.getDir());
}

int butLeft = isInput ? 6 : 104;
int butLeft = isInput ? 104 : 6;
int x = butLeft;
int y = 96;

Expand Down Expand Up @@ -147,7 +147,7 @@ public void updateButtons() {
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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ModItemFilterGui(GuiExternalConnection gui, IItemConduit itemConduit, boo
this.itemConduit = itemConduit;
this.isInput = isInput;

int butLeft = isInput ? 5 : 106;
int butLeft = isInput ? 106 : 5;
int x = butLeft;
int y = 96;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public PowerItemFilterGui(GuiExternalConnection gui, IItemConduit itemConduit, b
filter = (PowerItemFilter) itemConduit.getOutputFilter(gui.getDir());
}

int butLeft = isInput ? 5 : 106;
int butLeft = isInput ? 106 : 5;
int x = butLeft;
int y = 96 + 24;

Expand Down Expand Up @@ -82,7 +82,7 @@ public void updateButtons() {
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;

Expand Down

0 comments on commit 3358691

Please sign in to comment.