-
Notifications
You must be signed in to change notification settings - Fork 397
[MUI] Conveyor and Simple Filter #4128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
61087b5
machine controller covers and start of conveyors
YoungOnionMC b810a45
conveyor updates
Spicierspace153 34f3d27
working UI from componentItems
Spicierspace153 09913b3
working item filters w/mui ui
Spicierspace153 eff87fe
filter slots, button, texture (nyi opening popup)
Spicierspace153 624961e
test popup panel
Spicierspace153 8d3623a
more filter cover api and todos
YoungOnionMC f6bee83
test stuff for item filter panel
YoungOnionMC c411283
Merge branch 'mui2-refactor' of https://github.com/GregTechCEu/GregTe…
YoungOnionMC 4705177
more work on the filter dynamic widget
YoungOnionMC 0d696e4
more filter testing
YoungOnionMC 658acc3
Merge branch 'mui2-refactor' into kath/mui/filters
jurrejelle a31b556
actually write item to matches list
jurrejelle f998831
Fix saving to nbt
jurrejelle 7fe0172
Merge branch 'mui2-refactor' of https://github.com/GregTechCEu/GregTe…
YoungOnionMC 34a9209
filters properly work :lets:
YoungOnionMC 3c73bfb
spot
YoungOnionMC f071887
fixes
YoungOnionMC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,18 @@ | ||
| package com.gregtechceu.gtceu.api.cover.filter; | ||
|
|
||
| import com.gregtechceu.gtceu.api.gui.GuiTextures; | ||
| import com.gregtechceu.gtceu.api.gui.widget.PhantomSlotWidget; | ||
| import com.gregtechceu.gtceu.api.gui.widget.ToggleButtonWidget; | ||
| import com.gregtechceu.gtceu.api.mui.value.sync.PanelSyncManager; | ||
| import com.gregtechceu.gtceu.api.mui.value.sync.PhantomItemSlotSyncHandler; | ||
| import com.gregtechceu.gtceu.api.mui.widgets.Dialog; | ||
| import com.gregtechceu.gtceu.api.mui.widgets.SlotGroupWidget; | ||
| import com.gregtechceu.gtceu.api.mui.widgets.layout.Flow; | ||
| import com.gregtechceu.gtceu.api.mui.widgets.layout.Grid; | ||
| import com.gregtechceu.gtceu.api.mui.widgets.slot.ModularSlot; | ||
| import com.gregtechceu.gtceu.api.mui.widgets.slot.PhantomItemSlot; | ||
| import com.gregtechceu.gtceu.api.transfer.item.CustomItemStackHandler; | ||
| import com.gregtechceu.gtceu.client.mui.screen.ModularPanel; | ||
| import com.gregtechceu.gtceu.common.data.GTItems; | ||
| import com.gregtechceu.gtceu.common.data.mui.GTMuiWidgets; | ||
| import com.gregtechceu.gtceu.common.mui.GTGuiTextures; | ||
| import com.gregtechceu.gtceu.utils.GTUtil; | ||
|
|
||
| import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; | ||
|
|
@@ -15,6 +24,7 @@ | |
| import net.minecraft.world.item.ItemStack; | ||
|
|
||
| import lombok.Getter; | ||
| import org.jetbrains.annotations.NotNull; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.function.Consumer; | ||
|
|
@@ -97,42 +107,76 @@ public void setIgnoreNbt(boolean ingoreNbt) { | |
| onUpdated.accept(this); | ||
| } | ||
|
|
||
| @Override | ||
| public WidgetGroup openConfigurator(int x, int y) { | ||
| WidgetGroup group = new WidgetGroup(x, y, 18 * 3 + 25, 18 * 3); // 80 55 | ||
| for (int i = 0; i < 3; i++) { | ||
| for (int j = 0; j < 3; j++) { | ||
| final int index = i * 3 + j; | ||
|
|
||
| var handler = new CustomItemStackHandler(matches[index]); | ||
|
|
||
| var slot = new PhantomSlotWidget(handler, 0, i * 18, j * 18) { | ||
|
|
||
| @Override | ||
| public void updateScreen() { | ||
| super.updateScreen(); | ||
| setMaxStackSize(maxStackSize); | ||
| } | ||
|
|
||
| @Override | ||
| public void detectAndSendChanges() { | ||
| super.detectAndSendChanges(); | ||
| setMaxStackSize(maxStackSize); | ||
| } | ||
| }; | ||
|
|
||
| slot.setChangeListener(() -> { | ||
| matches[index] = handler.getStackInSlot(0); | ||
| onUpdated.accept(this); | ||
| }).setBackground(GuiTextures.SLOT); | ||
|
|
||
| group.addWidget(slot); | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public ModularPanel getPanel(PanelSyncManager syncManager) { | ||
| FilterItemStackHandler handler = new FilterItemStackHandler(matches, this); | ||
|
|
||
| Grid filterGrid = new Grid() | ||
| .coverChildren() | ||
| .mapTo(3, 9, i -> new PhantomItemSlot() | ||
| .size(16) | ||
| .syncHandler(new PhantomItemSlotSyncHandler(new ModularSlot(handler, i) | ||
| .changeListener((stack, amount, client, init) -> { | ||
| handler.setStackInSlot(i, stack); | ||
| }).ignoreMaxStackSize(true).accessibility(true, false)))); | ||
|
|
||
| return new Dialog<>("simple_item_filter") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should have a hash of the current data of some sort, so you can open two dialogs of two different item filters at the same time |
||
| .setDisablePanelsBelow(false) | ||
| .setDraggable(true) | ||
| .setCloseOnOutOfBoundsClick(true) | ||
| .child(GTMuiWidgets.createTitleBar(GTItems.ITEM_FILTER.asStack(), 176, GTGuiTextures.BACKGROUND)) | ||
| .child(Flow.row() | ||
| .top(10) | ||
| .coverChildrenHeight() | ||
| .child(filterGrid.horizontalCenter())) | ||
| .child(SlotGroupWidget.playerInventory(false).left(7).bottom(7)); | ||
| } | ||
|
|
||
| private static class FilterItemStackHandler extends CustomItemStackHandler { | ||
|
|
||
| private ItemStack[] matches; | ||
| private SimpleItemFilter filter; | ||
|
|
||
| public FilterItemStackHandler(ItemStack[] matches, SimpleItemFilter simpleItemFilter) { | ||
| super(matches.length); | ||
| this.matches = matches; | ||
| this.filter = simpleItemFilter; | ||
| } | ||
|
|
||
| @Override | ||
| public @NotNull ItemStack getStackInSlot(int slot) { | ||
| return matches[slot]; | ||
| } | ||
|
|
||
| @Override | ||
| protected int getStackLimit(int slot, @NotNull ItemStack stack) { | ||
| return 1; | ||
| } | ||
|
|
||
| @Override | ||
| public @NotNull ItemStack extractItem(int slot, int amount, boolean simulate) { | ||
| if (amount >= matches[slot].getCount()) { | ||
| matches[slot] = ItemStack.EMPTY; | ||
| } | ||
| return matches[slot]; | ||
| } | ||
|
|
||
| @Override | ||
| public @NotNull ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) { | ||
| return stack; | ||
| } | ||
|
|
||
| @Override | ||
| public void setStackInSlot(int slot, @NotNull ItemStack stack) { | ||
| super.setStackInSlot(slot, stack); | ||
| matches[slot] = stack.copyWithCount(1); | ||
| filter.onUpdated.accept(filter); | ||
| } | ||
| group.addWidget(new ToggleButtonWidget(18 * 3 + 5, 0, 20, 20, | ||
| GuiTextures.BUTTON_BLACKLIST, this::isBlackList, this::setBlackList)); | ||
| group.addWidget(new ToggleButtonWidget(18 * 3 + 5, 20, 20, 20, | ||
| GuiTextures.BUTTON_FILTER_NBT, this::isIgnoreNbt, this::setIgnoreNbt)); | ||
| return group; | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.