Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import brachy.modularui.api.drawable.IDrawable;
import brachy.modularui.api.drawable.Text;
import brachy.modularui.api.widget.IWidget;
import brachy.modularui.drawable.GuiTextures;
import brachy.modularui.drawable.Rectangle;
import brachy.modularui.factory.GuiData;
import brachy.modularui.factory.SidedPosGuiData;
Expand All @@ -37,6 +38,7 @@
import brachy.modularui.utils.Alignment;
import brachy.modularui.utils.Color;
import brachy.modularui.utils.MouseData;
import brachy.modularui.utils.MutableSingletonList;
import brachy.modularui.utils.serialization.network.IByteBufAdapter;
import brachy.modularui.value.sync.*;
import brachy.modularui.widget.EmptyWidget;
Expand All @@ -51,6 +53,7 @@
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.function.IntSupplier;
import java.util.function.Predicate;
import java.util.regex.Pattern;

@SuppressWarnings("SameParameterValue")
Expand Down Expand Up @@ -225,9 +228,12 @@ public void pasteConfig(ServerPlayer player, CompoundTag tag) {
super.pasteConfig(player, tag);
}

private List<VirtualEntry> getVirtualEntries() {
private List<VirtualEntry> getVirtualEntries(Predicate<VirtualEntry> filter) {
return VirtualEnderRegistry.get((ServerLevel) coverHolder.getLevel()).getEntries(getOwner(), getEntryType())
.values().stream().toList();
.values()
.stream()
.filter(filter)
.toList();
}

protected enum Permissions {
Expand Down Expand Up @@ -277,9 +283,11 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage
.tooltip(1, t -> t.addLine(Text.lang(Permissions.PROTECTED.tooltip)))
.tooltip(2, t -> t.addLine(Text.lang(Permissions.PRIVATE.tooltip)))
.value(new EnumSyncValue<>(Permissions.class, this::getPermission,
this::setPermission)))
this::setPermission)
.allowC2S()))
.child(new TextFieldWidget()
.value(new StringSyncValue(this::getColorStr, this::setColorStr))
.value(new StringSyncValue(this::getColorStr, this::setColorStr)
.allowC2S())
.setMaxLength(8)
.setValidator(str -> COLOR_INPUT_PATTERN.matcher(str).replaceAll(""))
.addTooltipLine(Text.lang("cover.ender_link.tooltip.channel_name")))
Expand All @@ -294,7 +302,8 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage
.setMaxLength(32)
.widthRel(1f)
.addTooltipLine(Text.lang("cover.ender_link.tooltip.channel_description"))
.value(new StringSyncValue(this::getDescription, this::setDescription))));
.value(new StringSyncValue(this::getDescription, this::setDescription)
.allowC2S())));

Flow bottomRow = coverUIRow();
bottomRow.child(GTMuiWidgets.createPowerButton(this));
Expand Down Expand Up @@ -347,8 +356,24 @@ protected ModularPanel<?> createChannelManagerPanel(GuiData data, PanelSyncManag
.closeOnOutOfBoundsClick(true)
.child(GTMuiWidgets.createTitleBar(() -> getAttachItem(), 176, GTGuiTextures.BACKGROUND));

MutableSingletonList<String> searchString = new MutableSingletonList<>("");
var searchSync = SyncHandlers.string(searchString::get, searchString::set)
.allowC2S();
Flow col = Flow.col()
.childPadding(4)
.widthRel(1)
.marginTop(7);
panel.child(col);
col.child(Flow.row()
.coverChildrenHeight()
.widthRel(0.8f)
.child(GuiTextures.SEARCH.asWidget())
.child(new TextFieldWidget()
.widthRelOffset(1f, -20)
.value(searchSync)));

var entries = new GenericListSyncHandler.Builder<VirtualEntry>()
.getter(this::getVirtualEntries)
.getter(() -> this.getVirtualEntries(entry -> entry.getDescription().contains(searchString.get())))
.adapter(new VirtualEntryAdapter())
.build();
syncManager.syncValue("entries", entries);
Expand Down Expand Up @@ -377,9 +402,8 @@ protected ModularPanel<?> createChannelManagerPanel(GuiData data, PanelSyncManag
}
});

panel.child(new DynamicSyncedWidget<>()
.syncHandler(dynamicLinkedSyncHandler)
.top(7).margin(7, 0)
col.child(new DynamicSyncedWidget<>()
.syncHandler(dynamicLinkedSyncHandler).margin(7, 0)
.widthRel(1.0f).coverChildrenHeight());

return panel;
Expand Down
Loading