From b3590134ab6c446e6902ee0a29d9303f9510d40a Mon Sep 17 00:00:00 2001 From: zethnest <16971676+zethnest@users.noreply.github.com> Date: Sat, 30 May 2020 01:58:44 +0800 Subject: [PATCH] [QOL] Search Ignore Symbols (#2079) * autofocus implementation * fuzzy match schematic search implementation * enter to select first schematic implementation * fix duplicate variable fix setting check * no fuzzy match * Update SchematicsDialog.java useless t.update * fix no schematic match --- core/src/mindustry/ui/dialogs/SchematicsDialog.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/src/mindustry/ui/dialogs/SchematicsDialog.java b/core/src/mindustry/ui/dialogs/SchematicsDialog.java index d4f3aa8c9a..fc5635d100 100644 --- a/core/src/mindustry/ui/dialogs/SchematicsDialog.java +++ b/core/src/mindustry/ui/dialogs/SchematicsDialog.java @@ -71,17 +71,20 @@ public class SchematicsDialog extends BaseDialog{ rebuildPane[0] = () -> { t.clear(); int i = 0; + String regex = "[`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?]"; + String searchString = search.toLowerCase().replaceAll(regex," "); - if(!schematics.all().contains(s -> search.isEmpty() || s.name().toLowerCase().contains(search.toLowerCase()))){ + if(!schematics.all().contains(s -> search.isEmpty() || s.name().toLowerCase().replaceAll(regex," ").contains(searchString))){ t.add("$none"); + return; } firstSchematic = null; for(Schematic s : schematics.all()){ - if(!search.isEmpty() && !s.name().toLowerCase().contains(search.toLowerCase())) continue; - if(firstSchematic == null) - firstSchematic = s; + + if(!search.isEmpty() && !s.name().toLowerCase().replaceAll(regex," ").contains(searchString)) continue; + if(firstSchematic == null) firstSchematic = s; Button[] sel = {null}; sel[0] = t.button(b -> {