Skip to content
Merged
Show file tree
Hide file tree
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 @@ -32,6 +32,7 @@ public class MultilineTextField extends WidgetGroup {
private final Supplier<String> textSupplier;
private final Consumer<String> textConsumer;
private final Component placeholder;
private final Supplier<Integer> borderColorSupplier;

private int maxLength = DEFAULT_MAX_LENGTH;

Expand All @@ -50,18 +51,28 @@ public MultilineTextField(
int x, int y, int width, int height,
Supplier<String> textSupplier,
Consumer<String> textConsumer) {
this(x, y, width, height, textSupplier, textConsumer, Component.empty());
this(x, y, width, height, textSupplier, textConsumer, Component.empty(), null);
}

public MultilineTextField(
int x, int y, int width, int height,
Supplier<String> textSupplier,
Consumer<String> textConsumer,
Component placeholder) {
this(x, y, width, height, textSupplier, textConsumer, placeholder, null);
}

public MultilineTextField(
int x, int y, int width, int height,
Supplier<String> textSupplier,
Consumer<String> textConsumer,
Component placeholder,
Supplier<Integer> borderColorSupplier) {
super(new Position(x, y), new Size(width, height));
this.textSupplier = textSupplier;
this.textConsumer = textConsumer;
this.placeholder = placeholder == null ? Component.empty() : placeholder;
this.borderColorSupplier = borderColorSupplier;

String init = safe(textSupplier.get());
this.lastSent = init;
Expand Down Expand Up @@ -467,7 +478,8 @@ public void drawInBackground(net.minecraft.client.gui.GuiGraphics graphics, int
int h = getSize().height;

int bg = 0xFF202020;
int border = hasFocus ? 0xFFFFFFFF : 0xFF808080;
Integer suppliedBorder = borderColorSupplier != null ? borderColorSupplier.get() : null;
int border = suppliedBorder != null ? suppliedBorder : hasFocus ? 0xFFFFFFFF : 0xFF808080;

graphics.fill(x0 - 1, y0 - 1, x0 + w + 1, y0 + h + 1, 0xAA000000);
graphics.fill(x0, y0, x0 + w, y0 + h, bg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@
import it.unimi.dsi.fastutil.objects.Object2LongMap;
import org.jetbrains.annotations.Nullable;

import java.util.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
Expand All @@ -75,6 +79,12 @@ public class MEEnlargedTagStockingInputBusPartMachine extends MEStockingBusPartM
@DescSynced
protected String blacklistExpr = "";

@DescSynced
protected boolean whitelistBadSyntax = false;

@DescSynced
protected boolean blacklistBadSyntax = false;

@DescSynced
protected String Wltmp = "";

Expand Down Expand Up @@ -168,11 +178,13 @@ private void ensureCompiledUpToDate() {
if (!Objects.equals(wl, wlLast)) {
wlLast = wl;
wlCompiled = TagMatcher.compile(wl);
whitelistBadSyntax = !wlCompiled.isValid();
decisionCache.clear();
}
if (!Objects.equals(bl, blLast)) {
blLast = bl;
blCompiled = TagMatcher.compile(bl);
blacklistBadSyntax = !blCompiled.isValid();
decisionCache.clear();
}

Expand All @@ -183,6 +195,7 @@ private void ensureCompiledUpToDate() {

protected boolean isAllowed(AEItemKey key) {
ensureCompiledUpToDate();
if (whitelistBadSyntax || blacklistBadSyntax) return false;

if ((wlLast == null || wlLast.isEmpty()) && (blLast == null || blLast.isEmpty())) return false;

Expand Down Expand Up @@ -380,15 +393,17 @@ public boolean mouseWheelMove(double mouseX, double mouseY, double wheelDelta) {
7, y, 160, 25,
() -> Wltmp,
v -> { Wltmp = v; },
Component.literal("Whitelist tags..."));
Component.literal("Whitelist tags..."),
() -> whitelistBadSyntax ? 0xFFFF0000 : null);
group.addWidget(WLField);

y += 29;
var BLField = new MultilineTextField(
7, y, 160, 25,
() -> Bltmp,
v -> { Bltmp = v; },
Component.literal("Blacklist tags..."));
Component.literal("Blacklist tags..."),
() -> blacklistBadSyntax ? 0xFFFF0000 : null);
group.addWidget(BLField);

WLField.setDirectly(whitelistExpr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
import com.gregtechceu.gtceu.config.ConfigHolder;
import com.gregtechceu.gtceu.integration.ae2.gui.widget.AEFluidConfigWidget;
import com.gregtechceu.gtceu.integration.ae2.machine.MEStockingHatchPartMachine;
import com.gregtechceu.gtceu.integration.ae2.slot.*;
import com.gregtechceu.gtceu.integration.ae2.slot.ExportOnlyAEFluidList;
import com.gregtechceu.gtceu.integration.ae2.slot.ExportOnlyAEFluidSlot;
import com.gregtechceu.gtceu.integration.ae2.slot.ExportOnlyAESlot;
import com.gregtechceu.gtceu.integration.ae2.utils.AEUtil;

import com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup;
Expand Down Expand Up @@ -50,7 +52,11 @@
import it.unimi.dsi.fastutil.objects.Object2LongMap;
import org.jetbrains.annotations.Nullable;

import java.util.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Predicate;
Expand All @@ -75,6 +81,12 @@ public class MEEnlargedTagStockingInputHatchPartMachine extends MEStockingHatchP
@DescSynced
protected String Bltmp = "";

@DescSynced
protected boolean whitelistBadSyntax = false;

@DescSynced
protected boolean blacklistBadSyntax = false;

private Predicate<GenericStack> tagAutoPullTest = ($) -> true;

private transient String wlLast = null;
Expand Down Expand Up @@ -161,11 +173,13 @@ private void ensureCompiledUpToDate() {
if (!Objects.equals(wl, wlLast)) {
wlLast = wl;
wlCompiled = TagMatcher.compile(wl);
whitelistBadSyntax = !wlCompiled.isValid();
decisionCache.clear();
}
if (!Objects.equals(bl, blLast)) {
blLast = bl;
blCompiled = TagMatcher.compile(bl);
blacklistBadSyntax = !blCompiled.isValid();
decisionCache.clear();
}

Expand All @@ -176,6 +190,7 @@ private void ensureCompiledUpToDate() {

protected boolean isAllowed(AEFluidKey key) {
ensureCompiledUpToDate();
if (whitelistBadSyntax || blacklistBadSyntax) return false;

if ((wlLast == null || wlLast.isEmpty()) && (blLast == null || blLast.isEmpty())) return false;

Expand Down Expand Up @@ -367,15 +382,17 @@ public boolean mouseWheelMove(double mouseX, double mouseY, double wheelDelta) {
7, y, 160, 25,
() -> Wltmp,
v -> { Wltmp = v; },
Component.literal("Whitelist tags..."));
Component.literal("Whitelist tags..."),
() -> whitelistBadSyntax ? 0xFFFF0000 : null);
group.addWidget(WLField);

y += 29;
var BLField = new MultilineTextField(
7, y, 160, 25,
() -> Bltmp,
v -> { Bltmp = v; },
Component.literal("Blacklist tags..."));
Component.literal("Blacklist tags..."),
() -> blacklistBadSyntax ? 0xFFFF0000 : null);
group.addWidget(BLField);

WLField.setDirectly(whitelistExpr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ public class METagStockingInputBusPartMachine extends MEStockingBusPartMachine {
@DescSynced
protected String Bltmp = "";

@DescSynced
protected boolean whitelistBadSyntax = false;

@DescSynced
protected boolean blacklistBadSyntax = false;

private Predicate<GenericStack> tagAutoPullTest = ($) -> true;

private transient String wlLast = null;
Expand Down Expand Up @@ -159,11 +165,13 @@ private void ensureCompiledUpToDate() {
if (!Objects.equals(wl, wlLast)) {
wlLast = wl;
wlCompiled = TagMatcher.compile(wl);
whitelistBadSyntax = !wlCompiled.isValid();
decisionCache.clear();
}
if (!Objects.equals(bl, blLast)) {
blLast = bl;
blCompiled = TagMatcher.compile(bl);
blacklistBadSyntax = !blCompiled.isValid();
decisionCache.clear();
}

Expand All @@ -174,6 +182,7 @@ private void ensureCompiledUpToDate() {

protected boolean isAllowed(AEItemKey key) {
ensureCompiledUpToDate();
if (whitelistBadSyntax || blacklistBadSyntax) return false;

if ((wlLast == null || wlLast.isEmpty()) && (blLast == null || blLast.isEmpty())) return false;

Expand Down Expand Up @@ -283,7 +292,8 @@ public Widget createUIWidget() {
v -> {
Wltmp = v;
},
Component.literal("Whitelist tags..."));
Component.literal("Whitelist tags..."),
() -> whitelistBadSyntax ? 0xFFFF0000 : null);
group.addWidget(WLField);

y += 29;
Expand All @@ -293,7 +303,8 @@ public Widget createUIWidget() {
v -> {
Bltmp = v;
},
Component.literal("Blacklist tags..."));
Component.literal("Blacklist tags..."),
() -> blacklistBadSyntax ? 0xFFFF0000 : null);
group.addWidget(BLField);

WLField.setDirectly(whitelistExpr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
import com.gregtechceu.gtceu.integration.ae2.gui.widget.AEFluidConfigWidget;
import com.gregtechceu.gtceu.integration.ae2.machine.MEHatchPartMachine;
import com.gregtechceu.gtceu.integration.ae2.machine.MEStockingHatchPartMachine;
import com.gregtechceu.gtceu.integration.ae2.slot.*;
import com.gregtechceu.gtceu.integration.ae2.slot.ExportOnlyAEFluidList;
import com.gregtechceu.gtceu.integration.ae2.slot.ExportOnlyAEFluidSlot;
import com.gregtechceu.gtceu.integration.ae2.slot.ExportOnlyAESlot;
import com.gregtechceu.gtceu.integration.ae2.utils.AEUtil;

import com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup;
Expand Down Expand Up @@ -75,6 +77,12 @@ public class METagStockingInputHatchPartMachine extends MEStockingHatchPartMachi
@DescSynced
protected String Bltmp = "";

@DescSynced
protected boolean whitelistBadSyntax = false;

@DescSynced
protected boolean blacklistBadSyntax = false;

private Predicate<GenericStack> tagAutoPullTest = ($) -> true;

private transient String wlLast = null;
Expand Down Expand Up @@ -157,11 +165,13 @@ private void ensureCompiledUpToDate() {
if (!Objects.equals(wl, wlLast)) {
wlLast = wl;
wlCompiled = TagMatcher.compile(wl);
whitelistBadSyntax = !wlCompiled.isValid();
decisionCache.clear();
}
if (!Objects.equals(bl, blLast)) {
blLast = bl;
blCompiled = TagMatcher.compile(bl);
blacklistBadSyntax = !wlCompiled.isValid();
decisionCache.clear();
}

Expand All @@ -172,6 +182,7 @@ private void ensureCompiledUpToDate() {

protected boolean isAllowed(AEFluidKey key) {
ensureCompiledUpToDate();
if (whitelistBadSyntax || blacklistBadSyntax) return false;

if ((wlLast == null || wlLast.isEmpty()) && (blLast == null || blLast.isEmpty())) return false;

Expand Down Expand Up @@ -282,7 +293,8 @@ public Widget createUIWidget() {
v -> {
Wltmp = v;
},
Component.literal("Whitelist tags..."));
Component.literal("Whitelist tags..."),
() -> whitelistBadSyntax ? 0xFFFF0000 : null);
group.addWidget(WLField);

y += 29;
Expand All @@ -292,7 +304,8 @@ public Widget createUIWidget() {
v -> {
Bltmp = v;
},
Component.literal("Blacklist tags..."));
Component.literal("Blacklist tags..."),
() -> blacklistBadSyntax ? 0xFFFF0000 : null);
group.addWidget(BLField);

WLField.setDirectly(whitelistExpr);
Expand Down
Loading