Added OR search operator to the Grid with "|", fixes #1759
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
### 1.5.34
|
||||
- Allow crafters to be daisy-chained (tomKPZ)
|
||||
- Empty patterns can no longer be inserted in the pattern result slot in the Pattern Grid with hoppers (raoulvdberge)
|
||||
- Added OR search operator to the Grid with "|" (raoulvdberge)
|
||||
|
||||
### 1.5.33
|
||||
- Added Crafter Manager (raoulvdberge)
|
||||
|
@@ -104,8 +104,8 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware {
|
||||
// Allow in slot 0
|
||||
// Disallow in slot 1
|
||||
// Only allow in slot 1 when it isn't a blank pattern
|
||||
// This makes it so that written patterns can be re-inserted in the slot to be overwritten again
|
||||
// This makes it so that blank patterns can't be inserted through hoppers.
|
||||
// This makes it so that written patterns can be re-inserted in slot 1 to be overwritten again
|
||||
// This makes it so that blank patterns can't be inserted in slot 1 through hoppers.
|
||||
if (slot == 0 || stack.getTagCompound() != null) {
|
||||
return super.insertItem(slot, stack, simulate);
|
||||
}
|
||||
|
@@ -0,0 +1,27 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.grid.filtering;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class GridFilterOr implements Predicate<IGridStack> {
|
||||
private List<List<Predicate<IGridStack>>> orPartFilters;
|
||||
|
||||
public GridFilterOr(List<List<Predicate<IGridStack>>> orPartFilters) {
|
||||
this.orPartFilters = orPartFilters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(IGridStack gridStack) {
|
||||
for (List<Predicate<IGridStack>> orPart : orPartFilters) {
|
||||
for (Predicate<IGridStack> part : orPart) {
|
||||
if (part.test(gridStack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -11,18 +11,21 @@ import java.util.function.Predicate;
|
||||
|
||||
public final class GridFilterParser {
|
||||
public static List<Predicate<IGridStack>> getFilters(@Nullable IGrid grid, String query, List<IFilter> filters) {
|
||||
List<Predicate<IGridStack>> gridFilters = new LinkedList<>();
|
||||
List<Predicate<IGridStack>> gridFilters;
|
||||
|
||||
for (String part : query.toLowerCase().trim().split(" ")) {
|
||||
if (part.startsWith("@")) {
|
||||
gridFilters.add(new GridFilterMod(part.substring(1)));
|
||||
} else if (part.startsWith("#")) {
|
||||
gridFilters.add(new GridFilterTooltip(part.substring(1)));
|
||||
} else if (part.startsWith("$")) {
|
||||
gridFilters.add(new GridFilterOreDict(part.substring(1)));
|
||||
} else {
|
||||
gridFilters.add(new GridFilterName(part));
|
||||
String[] orParts = query.split("\\|");
|
||||
|
||||
if (orParts.length == 1) {
|
||||
gridFilters = getFilters(query);
|
||||
} else {
|
||||
List<List<Predicate<IGridStack>>> orPartFilters = new LinkedList<>();
|
||||
|
||||
for (String orPart : orParts) {
|
||||
orPartFilters.add(getFilters(orPart));
|
||||
}
|
||||
|
||||
gridFilters = new LinkedList<>();
|
||||
gridFilters.add(new GridFilterOr(orPartFilters));
|
||||
}
|
||||
|
||||
if (grid != null) {
|
||||
@@ -39,4 +42,22 @@ public final class GridFilterParser {
|
||||
|
||||
return gridFilters;
|
||||
}
|
||||
|
||||
private static List<Predicate<IGridStack>> getFilters(String query) {
|
||||
List<Predicate<IGridStack>> gridFilters = new LinkedList<>();
|
||||
|
||||
for (String part : query.toLowerCase().trim().split(" ")) {
|
||||
if (part.startsWith("@")) {
|
||||
gridFilters.add(new GridFilterMod(part.substring(1)));
|
||||
} else if (part.startsWith("#")) {
|
||||
gridFilters.add(new GridFilterTooltip(part.substring(1)));
|
||||
} else if (part.startsWith("$")) {
|
||||
gridFilters.add(new GridFilterOreDict(part.substring(1)));
|
||||
} else {
|
||||
gridFilters.add(new GridFilterName(part));
|
||||
}
|
||||
}
|
||||
|
||||
return gridFilters;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user