Cleaned up schematic dialog code

This commit is contained in:
Anuken 2020-05-29 14:01:27 -04:00
parent 35679925d2
commit be5ba03142

View File

@ -71,18 +71,12 @@ public class SchematicsDialog extends BaseDialog{
rebuildPane[0] = () -> { rebuildPane[0] = () -> {
t.clear(); t.clear();
int i = 0; int i = 0;
String regex = "[`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?]"; String regex = "[`~!@#$%^&*()-_=+[{]}|;:'\",<.>/?]";
String searchString = search.toLowerCase().replaceAll(regex, " "); String searchString = search.toLowerCase().replaceAll(regex, " ");
if(!schematics.all().contains(s -> search.isEmpty() || s.name().toLowerCase().replaceAll(regex," ").contains(searchString))){
t.add("$none");
return;
}
firstSchematic = null; firstSchematic = null;
for(Schematic s : schematics.all()){ for(Schematic s : schematics.all()){
if(!search.isEmpty() && !s.name().toLowerCase().replaceAll(regex, " ").contains(searchString)) continue; if(!search.isEmpty() && !s.name().toLowerCase().replaceAll(regex, " ").contains(searchString)) continue;
if(firstSchematic == null) firstSchematic = s; if(firstSchematic == null) firstSchematic = s;
@ -160,6 +154,10 @@ public class SchematicsDialog extends BaseDialog{
t.row(); t.row();
} }
} }
if(firstSchematic == null){
t.add("$none");
}
}; };
rebuildPane[0].run(); rebuildPane[0].run();