Skip to content

Commit

Permalink
use change listener instead of update
Browse files Browse the repository at this point in the history
simplify on pressed logic
  • Loading branch information
ghzdude committed Feb 18, 2024
1 parent 4557573 commit 63dcf5e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,27 +119,24 @@ public ModularPanel createUI(ModularPanel mainPanel, GuiSyncManager syncManager)
.child(new ItemSlot()
.slot(SyncHandlers.itemSlot(this, 0)
.filter(FilterTypeRegistry::isFluidFilter)
.singletonSlotGroup(101))
.onUpdateListener(w -> {
if (!hasFilter() && panel.isPanelOpen()) {
panel.closePanel();
}
}, true)
.singletonSlotGroup(101)
.changeListener((newItem, onlyAmountChanged, client, init) -> {
if (!FilterTypeRegistry.isFilter(newItem) && panel.isPanelOpen()) {
panel.closePanel();
}
}))
.size(18).marginRight(2)
.background(GTGuiTextures.SLOT, GTGuiTextures.FILTER_SLOT_OVERLAY))
.child(filterButton
.setEnabledIf(w -> hasFilter())
.onMousePressed(i -> {
boolean success = false;
if (!panel.isPanelOpen()) {
panel.openPanel();
success = true;
} else if (panel.isValid()) {
} else {
panel.closePanel();
success = true;
}
Interactable.playButtonClickSound();
return success;
return true;
}))
.child(IKey.dynamic(() -> hasFilter() ?
getFilterStack().getDisplayName() :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,27 +108,24 @@ public ModularPanel createUI(ModularPanel mainPanel, GuiSyncManager syncManager)
.child(new ItemSlot()
.slot(SyncHandlers.itemSlot(this, 0)
.filter(FilterTypeRegistry::isItemFilter)
.singletonSlotGroup(101))
.onUpdateListener(w -> {
if (!hasFilter() && panel.isPanelOpen()) {
panel.closePanel();
}
}, true)
.singletonSlotGroup(101)
.changeListener((newItem, onlyAmountChanged, client, init) -> {
if (!FilterTypeRegistry.isFilter(newItem) && panel.isPanelOpen()) {
panel.closePanel();
}
}))
.size(18).marginRight(2)
.background(GTGuiTextures.SLOT, GTGuiTextures.FILTER_SLOT_OVERLAY))
.child(filterButton
.setEnabledIf(w -> hasFilter())
.onMousePressed(i -> {
boolean success = false;
if (!panel.isPanelOpen()) {
panel.openPanel();
success = true;
} else if (panel.isValid()) {
} else {
panel.closePanel();
success = true;
}
Interactable.playButtonClickSound();
return success;
return true;
}))
.child(IKey.dynamic(() -> hasFilter() ?
getFilterStack().getDisplayName() :
Expand Down

0 comments on commit 63dcf5e

Please sign in to comment.