mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-18 03:25:38 +00:00
Cleaned and generalised item loading/searching
Reimplemented subsets Added regex searching Fixed format error on delete all Fixed GuiButton handling clicks before NEI widgets could override Re-Implemented banned blocks implementation Added brewing recipes again note test obf ASM beacons Fixed some calls being intercepted by item panel when mouse was over a gui element Fixed crash on closing potion window with escape Disabled fast transfer, scrolling, and drag 'n' drop in creative Added item panel sorting Removed TMI uninstaller Fixed /give command Updated to 1.7.10
This commit is contained in:
1 parent
3c9ebc6961
commit
3c84527806
67 files changed
+3251
-2319
No files matched your search
@@ -1,15 +1,40 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import codechicken.nei.ItemList.EverythingItemFilter;
|
||||
import codechicken.nei.ItemList.PatternItemFilter;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import codechicken.nei.api.ItemFilter.ItemFilterProvider;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.drawGradientRect;
|
||||
import static codechicken.lib.gui.GuiDraw.drawRect;
|
||||
import static codechicken.nei.NEIClientConfig.world;
|
||||
|
||||
public class SearchField extends TextField
|
||||
public class SearchField extends TextField implements ItemFilterProvider
|
||||
{
|
||||
/**
|
||||
* Interface for returning a custom filter based on search field text
|
||||
*/
|
||||
public static interface ISearchProvider
|
||||
{
|
||||
/**
|
||||
* Return null to ignore this provider and use the normal searching protocol
|
||||
*/
|
||||
public ItemFilter getFilter(String searchText);
|
||||
}
|
||||
public static List<ISearchProvider> searchProviders = new LinkedList<ISearchProvider>();
|
||||
|
||||
long lastclicktime;
|
||||
|
||||
public SearchField(String ident) {
|
||||
super(ident);
|
||||
API.addItemFilter(this);
|
||||
}
|
||||
|
||||
public static boolean searchInventories() {
|
||||
@@ -19,10 +44,10 @@ public class SearchField extends TextField
|
||||
@Override
|
||||
public void drawBox() {
|
||||
if (searchInventories())
|
||||
drawGradientRect(x, y, width, height, 0xFFFFFF00, 0xFFC0B000);
|
||||
drawGradientRect(x, y, w, h, 0xFFFFFF00, 0xFFC0B000);
|
||||
else
|
||||
drawRect(x, y, width, height, 0xffA0A0A0);
|
||||
drawRect(x + 1, y + 1, width - 2, height - 2, 0xFF000000);
|
||||
drawRect(x, y, w, h, 0xffA0A0A0);
|
||||
drawRect(x + 1, y + 1, w - 2, h - 2, 0xFF000000);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,7 +66,7 @@ public class SearchField extends TextField
|
||||
@Override
|
||||
public void onTextChange(String oldText) {
|
||||
NEIClientConfig.setSearchExpression(text());
|
||||
ItemList.updateSearch();
|
||||
ItemList.updateFilter();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,5 +80,35 @@ public class SearchField extends TextField
|
||||
return EnumChatFormatting.getTextWithoutFormattingCodes(s);
|
||||
}
|
||||
|
||||
long lastclicktime;
|
||||
@Override
|
||||
public ItemFilter getFilter() {
|
||||
String s_filter = text().toLowerCase();
|
||||
|
||||
for(ISearchProvider p : searchProviders) {
|
||||
ItemFilter filter = p.getFilter(s_filter);
|
||||
if(filter != null)
|
||||
return filter;
|
||||
}
|
||||
|
||||
switch(NEIClientConfig.getIntSetting("inventory.searchmode")) {
|
||||
case 0://plain
|
||||
s_filter = "\\Q"+s_filter+"\\E";
|
||||
break;
|
||||
case 1:
|
||||
s_filter = s_filter
|
||||
.replace(".", "")
|
||||
.replace("?", ".")
|
||||
.replace("*", ".+?");
|
||||
break;
|
||||
}
|
||||
|
||||
Pattern pattern = null;
|
||||
try {
|
||||
pattern = Pattern.compile(s_filter);
|
||||
} catch (PatternSyntaxException ignored) {}
|
||||
if (pattern == null || pattern.toString().equals(""))
|
||||
return new EverythingItemFilter();
|
||||
|
||||
return new PatternItemFilter(pattern);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user