mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-24 05:54:32 +00:00
Merge remote-tracking branch 'origin/any-prefix' into dev
This commit is contained in:
8 files changed
+92
-343
No files matched your search
@@ -1,9 +1,6 @@
|
||||
package codechicken.nei;
|
||||
|
||||
import static codechicken.lib.gui.GuiDraw.drawString;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -18,6 +15,7 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.storage.SaveFormatComparator;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@@ -27,6 +25,9 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
import codechicken.core.CCUpdateChecker;
|
||||
import codechicken.core.ClientUtils;
|
||||
@@ -181,313 +182,75 @@ public class NEIClientConfig {
|
||||
tag.getTag("inventory.search.quoteDropItemName").setComment("Quote Drop Item Name").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.search.quoteDropItemName", true));
|
||||
|
||||
tag.getTag("inventory.search.modNameSearchMode").setComment("Search mode for Mod Names").getIntValue(1);
|
||||
API.addOption(new OptionCycled("inventory.search.modNameSearchMode", 3, true));
|
||||
|
||||
String preModName = tag.getTag("inventory.search.modNameSearchPrefix").setComment(
|
||||
"Search prefix for Mod Names (leave empty to always search for Mod Names, enter anything longer than one character to disable)")
|
||||
.getValue("@");
|
||||
if (preModName.length() != 1) {
|
||||
logger.warn("Search prefix inventory.search.modNameSearchPrefix has invalid length! Resetting to default.");
|
||||
preModName = "@";
|
||||
tag.getTag("inventory.search.modNameSearchPrefix").setValue(preModName);
|
||||
}
|
||||
API.addOption(new OptionTextField("inventory.search.modNameSearchPrefix") {
|
||||
tag.getTag("inventory.search.modNameSearchMode").setComment("Search mode for Mod Names (prefix: @)")
|
||||
.getIntValue(1);
|
||||
API.addOption(new OptionCycled("inventory.search.modNameSearchMode", 3, true) {
|
||||
|
||||
@Override
|
||||
public void draw(int mousex, int mousey, float frame) {
|
||||
drawString(getPrefix(), 10, 6, -1);
|
||||
textField.w = 60;
|
||||
textField.x = slot.slotWidth() - textField.w;
|
||||
textField.draw(mousex, mousey);
|
||||
public String getButtonText() {
|
||||
return translateN(name + "." + value(), EnumChatFormatting.LIGHT_PURPLE + "@");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidValue(String s) {
|
||||
if (s.length() == 1) {
|
||||
return !Arrays.asList(
|
||||
getTag("inventory.search.tooltipSearchPrefix").getValue(),
|
||||
getTag("inventory.search.identifierSearchPrefix").getValue(),
|
||||
getTag("inventory.search.oreDictSearchPrefix").getValue(),
|
||||
getTag("inventory.search.subsetsSearchPrefix").getValue()).contains(s);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextField createTextField() {
|
||||
return new DefaultOptionTextField() {
|
||||
|
||||
@Override
|
||||
public int getTextColour() {
|
||||
return isValidValue(text()) ? 0xFF55FF : 0xAA0000;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
tag.getTag("inventory.search.tooltipSearchMode").setComment("Search mode for Tooltips").getIntValue(0);
|
||||
API.addOption(new OptionCycled("inventory.search.tooltipSearchMode", 3, true));
|
||||
|
||||
String preTooltip = tag.getTag("inventory.search.tooltipSearchPrefix").setComment(
|
||||
"Search mode for Tooltips (leave empty to always search for Tooltips, enter anything longer than one character to disable)")
|
||||
.getValue("#");
|
||||
if (preTooltip.length() == 1) {
|
||||
if (preTooltip.equals(preModName)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.tooltipSearchPrefix conflicts with inventory.search.modNameSearchPrefix ({})! Resetting to default.",
|
||||
preTooltip);
|
||||
preTooltip = "#";
|
||||
tag.getTag("inventory.search.tooltipSearchPrefix").setValue(preTooltip);
|
||||
}
|
||||
} else {
|
||||
logger.warn("Search prefix inventory.search.tooltipSearchPrefix has invalid length! Resetting to default.");
|
||||
preModName = "#";
|
||||
tag.getTag("inventory.search.tooltipSearchPrefix").setValue(preModName);
|
||||
}
|
||||
API.addOption(new OptionTextField("inventory.search.tooltipSearchPrefix") {
|
||||
tag.getTag("inventory.search.tooltipSearchMode").setComment("Search mode for Tooltips (prefix: #)")
|
||||
.getIntValue(0);
|
||||
API.addOption(new OptionCycled("inventory.search.tooltipSearchMode", 3, true) {
|
||||
|
||||
@Override
|
||||
public void draw(int mousex, int mousey, float frame) {
|
||||
drawString(getPrefix(), 10, 6, -1);
|
||||
textField.w = 60;
|
||||
textField.x = slot.slotWidth() - textField.w;
|
||||
textField.draw(mousex, mousey);
|
||||
public String getButtonText() {
|
||||
return translateN(name + "." + value(), EnumChatFormatting.YELLOW + "#");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidValue(String s) {
|
||||
if (s.length() == 1) {
|
||||
return !Arrays.asList(
|
||||
getTag("inventory.search.modNameSearchPrefix").getValue(),
|
||||
getTag("inventory.search.identifierSearchPrefix").getValue(),
|
||||
getTag("inventory.search.oreDictSearchPrefix").getValue(),
|
||||
getTag("inventory.search.subsetsSearchPrefix").getValue()).contains(s);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextField createTextField() {
|
||||
return new DefaultOptionTextField() {
|
||||
|
||||
@Override
|
||||
public int getTextColour() {
|
||||
return isValidValue(text()) ? 0xFFFF55 : 0xAA0000;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
tag.getTag("inventory.search.identifierSearchMode").setComment("Search mode for identifier (prefix: &)")
|
||||
.getIntValue(0);
|
||||
API.addOption(new OptionCycled("inventory.search.identifierSearchMode", 3, true));
|
||||
|
||||
String preIdentifier = tag.getTag("inventory.search.identifierSearchPrefix").setComment(
|
||||
"Search mode for identifier (leave empty to always search for identifier, enter anything longer than one character to disable)")
|
||||
.getValue("&");
|
||||
if (preIdentifier.length() == 1) {
|
||||
if (preIdentifier.equals(preModName)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.identifierSearchPrefix conflicts with inventory.search.modNameSearchPrefix ({})! Resetting to default.",
|
||||
preIdentifier);
|
||||
preIdentifier = "&";
|
||||
tag.getTag("inventory.search.identifierSearchPrefix").setValue(preIdentifier);
|
||||
} else if (preIdentifier.equals(preTooltip)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.identifierSearchPrefix conflicts with inventory.search.tooltipSearchPrefix ({})! Resetting to default.",
|
||||
preIdentifier);
|
||||
preIdentifier = "&";
|
||||
tag.getTag("inventory.search.identifierSearchPrefix").setValue(preIdentifier);
|
||||
}
|
||||
} else {
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.identifierSearchPrefix has invalid length! Resetting to default.");
|
||||
preModName = "&";
|
||||
tag.getTag("inventory.search.identifierSearchPrefix").setValue(preModName);
|
||||
}
|
||||
API.addOption(new OptionTextField("inventory.search.identifierSearchPrefix") {
|
||||
API.addOption(new OptionCycled("inventory.search.identifierSearchMode", 3, true) {
|
||||
|
||||
@Override
|
||||
public void draw(int mousex, int mousey, float frame) {
|
||||
drawString(getPrefix(), 10, 6, -1);
|
||||
textField.w = 60;
|
||||
textField.x = slot.slotWidth() - textField.w;
|
||||
textField.draw(mousex, mousey);
|
||||
public String getButtonText() {
|
||||
return translateN(name + "." + value(), EnumChatFormatting.GOLD + "&");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidValue(String s) {
|
||||
if (s.length() == 1) {
|
||||
return !Arrays.asList(
|
||||
getTag("inventory.search.modNameSearchPrefix").getValue(),
|
||||
getTag("inventory.search.tooltipSearchPrefix").getValue(),
|
||||
getTag("inventory.search.oreDictSearchPrefix").getValue(),
|
||||
getTag("inventory.search.subsetsSearchPrefix").getValue()).contains(s);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextField createTextField() {
|
||||
return new DefaultOptionTextField() {
|
||||
|
||||
@Override
|
||||
public int getTextColour() {
|
||||
return isValidValue(text()) ? 0xFFAA00 : 0xAA0000;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
tag.getTag("inventory.search.oreDictSearchMode").setComment("Search mode for Tag Names (prefix: $)")
|
||||
.getIntValue(0);
|
||||
API.addOption(new OptionCycled("inventory.search.oreDictSearchMode", 3, true));
|
||||
|
||||
String preODName = tag.getTag("inventory.search.oreDictSearchPrefix").setComment(
|
||||
"Search mode for Ore Dictionary Tags (leave empty to always search for Ore Dictionary Tags, enter anything longer than one character to disable)")
|
||||
.getValue("$");
|
||||
if (preODName.length() == 1) {
|
||||
if (preODName.equals(preModName)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.oreDictSearchPrefix conflicts with inventory.search.modNameSearchPrefix ({})! Resetting to default.",
|
||||
preIdentifier);
|
||||
preODName = "$";
|
||||
tag.getTag("inventory.search.oreDictSearchPrefix").setValue(preODName);
|
||||
} else if (preODName.equals(preTooltip)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.oreDictSearchPrefix conflicts with inventory.search.tooltipSearchPrefix ({})! Resetting to default.",
|
||||
preIdentifier);
|
||||
preODName = "$";
|
||||
tag.getTag("inventory.search.oreDictSearchPrefix").setValue(preODName);
|
||||
} else if (preODName.equals(preIdentifier)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.oreDictSearchPrefix conflicts with inventory.search.identifierSearchPrefix ({})! Resetting to default.",
|
||||
preIdentifier);
|
||||
preODName = "$";
|
||||
tag.getTag("inventory.search.oreDictSearchPrefix").setValue(preODName);
|
||||
}
|
||||
} else {
|
||||
logger.warn("Search prefix inventory.search.oreDictSearchPrefix has invalid length! Resetting to default.");
|
||||
preModName = "$";
|
||||
tag.getTag("inventory.search.oreDictSearchPrefix").setValue(preModName);
|
||||
}
|
||||
API.addOption(new OptionTextField("inventory.search.oreDictSearchPrefix") {
|
||||
API.addOption(new OptionCycled("inventory.search.oreDictSearchMode", 3, true) {
|
||||
|
||||
@Override
|
||||
public void draw(int mousex, int mousey, float frame) {
|
||||
drawString(getPrefix(), 10, 6, -1);
|
||||
textField.w = 60;
|
||||
textField.x = slot.slotWidth() - textField.w;
|
||||
textField.draw(mousex, mousey);
|
||||
public String getButtonText() {
|
||||
return translateN(name + "." + value(), EnumChatFormatting.AQUA + "$");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidValue(String s) {
|
||||
if (s.length() == 1) {
|
||||
return !Arrays.asList(
|
||||
getTag("inventory.search.modNameSearchPrefix").getValue(),
|
||||
getTag("inventory.search.tooltipSearchPrefix").getValue(),
|
||||
getTag("inventory.search.identifierSearchPrefix").getValue(),
|
||||
getTag("inventory.search.subsetsSearchPrefix").getValue()).contains(s);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextField createTextField() {
|
||||
return new DefaultOptionTextField() {
|
||||
|
||||
@Override
|
||||
public int getTextColour() {
|
||||
return isValidValue(text()) ? 0x55FFFF : 0xAA0000;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
tag.getTag("inventory.search.subsetsSearchMode").setComment("Search mode for Item Subsets (prefix: %)")
|
||||
.getIntValue(2);
|
||||
API.addOption(new OptionCycled("inventory.search.subsetsSearchMode", 3, true));
|
||||
|
||||
String preSubset = tag.getTag("inventory.search.subsetsSearchPrefix").setComment(
|
||||
"Search mode for Item Subsets (leave empty to always search for Item Subsets, enter anything longer than one character to disable)")
|
||||
.getValue("%");
|
||||
if (preSubset.length() == 1) {
|
||||
if (preSubset.equals(preModName)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.subsetsSearchPrefix conflicts with inventory.search.modNameSearchPrefix ({})! Resetting to default.",
|
||||
preIdentifier);
|
||||
preSubset = "%";
|
||||
tag.getTag("inventory.search.subsetsSearchPrefix").setValue(preSubset);
|
||||
} else if (preSubset.equals(preTooltip)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.subsetsSearchPrefix conflicts with inventory.search.tooltipSearchPrefix ({})! Resetting to default.",
|
||||
preIdentifier);
|
||||
preSubset = "%";
|
||||
tag.getTag("inventory.search.subsetsSearchPrefix").setValue(preSubset);
|
||||
} else if (preSubset.equals(preIdentifier)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.subsetsSearchPrefix conflicts with inventory.search.identifierSearchPrefix ({})! Resetting to default.",
|
||||
preIdentifier);
|
||||
preSubset = "%";
|
||||
tag.getTag("inventory.search.subsetsSearchPrefix").setValue(preSubset);
|
||||
} else if (preSubset.equals(preODName)) {
|
||||
// conflicting prefix char
|
||||
logger.warn(
|
||||
"Search prefix inventory.search.subsetsSearchPrefix conflicts with inventory.search.oreDictSearchPrefix ({})! Resetting to default.",
|
||||
preIdentifier);
|
||||
preSubset = "%";
|
||||
tag.getTag("inventory.search.subsetsSearchPrefix").setValue(preSubset);
|
||||
}
|
||||
} else {
|
||||
logger.warn("Search prefix inventory.search.subsetsSearchPrefix has invalid length! Resetting to default.");
|
||||
preModName = "%";
|
||||
tag.getTag("inventory.search.subsetsSearchPrefix").setValue(preModName);
|
||||
}
|
||||
API.addOption(new OptionTextField("inventory.search.subsetsSearchPrefix") {
|
||||
API.addOption(new OptionCycled("inventory.search.subsetsSearchMode", 3, true) {
|
||||
|
||||
@Override
|
||||
public void draw(int mousex, int mousey, float frame) {
|
||||
drawString(getPrefix(), 10, 6, -1);
|
||||
textField.w = 60;
|
||||
textField.x = slot.slotWidth() - textField.w;
|
||||
textField.draw(mousex, mousey);
|
||||
public String getButtonText() {
|
||||
return translateN(name + "." + value(), EnumChatFormatting.DARK_PURPLE + "%");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidValue(String s) {
|
||||
if (s.length() == 1) {
|
||||
return !Arrays.asList(
|
||||
getTag("inventory.search.modNameSearchPrefix").getValue(),
|
||||
getTag("inventory.search.tooltipSearchPrefix").getValue(),
|
||||
getTag("inventory.search.identifierSearchPrefix").getValue(),
|
||||
getTag("inventory.search.oreDictSearchPrefix").getValue()).contains(s);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextField createTextField() {
|
||||
return new DefaultOptionTextField() {
|
||||
|
||||
@Override
|
||||
public int getTextColour() {
|
||||
return isValidValue(text()) ? 0xAA00AA : 0xAA0000;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
String prefixRedefinitions = tag.getTag("inventory.search.prefixRedefinitions").setComment(
|
||||
"Redefine search prefixes by providing a char-to-char map (JSON). The keys are the original prefixes, the values the new ones. Example: { \"$\": \"€\", \"#\": \"+\", \"@\": \"°\", \"%\": \"!\" }")
|
||||
.getValue("{}");
|
||||
try {
|
||||
TypeToken<Map<Character, Character>> typeToken = new TypeToken<Map<Character, Character>>() {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
};
|
||||
Map<Character, Character> charMap = new Gson().fromJson(prefixRedefinitions, typeToken.getType());
|
||||
SearchField.searchParser.prefixRedefinitions.putAll(charMap);
|
||||
} catch (JsonParseException e) {
|
||||
logger.warn("Failed to convert prefix redefinitions from JSON to CharToCharMap:", e);
|
||||
}
|
||||
|
||||
tag.getTag("inventory.bookmarks.enabled").setComment("Enable/Disable Bookmark Panel").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.bookmarks.enabled", true));
|
||||
|
||||
|
||||
@@ -44,12 +44,12 @@ public class SearchField extends TextField implements ItemFilterProvider {
|
||||
|
||||
protected final Function<Pattern, ItemFilter> createFilter;
|
||||
protected final String name;
|
||||
protected final char defaultPrefix;
|
||||
protected final char prefix;
|
||||
protected final EnumChatFormatting highlightedColor;
|
||||
|
||||
public SearchParserProvider(char defaultPrefix, String name, EnumChatFormatting highlightedColor,
|
||||
public SearchParserProvider(char prefix, String name, EnumChatFormatting highlightedColor,
|
||||
Function<Pattern, ItemFilter> createFilter) {
|
||||
this.defaultPrefix = defaultPrefix;
|
||||
this.prefix = prefix;
|
||||
this.name = name;
|
||||
this.highlightedColor = highlightedColor;
|
||||
this.createFilter = createFilter;
|
||||
@@ -74,8 +74,7 @@ public class SearchField extends TextField implements ItemFilterProvider {
|
||||
|
||||
@Override
|
||||
public char getPrefix() {
|
||||
String prefix = NEIClientConfig.getStringSetting("inventory.search." + this.name + "SearchPrefix");
|
||||
return prefix.length() == 0 ? this.defaultPrefix : prefix.charAt(0);
|
||||
return this.prefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -20,6 +19,8 @@ import codechicken.nei.ItemList.EverythingItemFilter;
|
||||
import codechicken.nei.ItemList.NegatedItemFilter;
|
||||
import codechicken.nei.ItemList.NothingItemFilter;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
import gnu.trove.map.TCharCharMap;
|
||||
import gnu.trove.map.hash.TCharCharHashMap;
|
||||
|
||||
public class SearchTokenParser {
|
||||
|
||||
@@ -71,6 +72,7 @@ public class SearchTokenParser {
|
||||
|
||||
protected final List<ISearchParserProvider> searchProviders;
|
||||
protected final ProvidersCache providersCache = new ProvidersCache();
|
||||
protected final TCharCharMap prefixRedefinitions = new TCharCharHashMap();
|
||||
|
||||
public SearchTokenParser(List<ISearchParserProvider> searchProviders) {
|
||||
this.searchProviders = searchProviders;
|
||||
@@ -109,7 +111,9 @@ public class SearchTokenParser {
|
||||
|
||||
public ISearchParserProvider getProvider(char ch) {
|
||||
return getProviders().stream()
|
||||
.filter(provider -> provider.getSearchMode() == SearchMode.PREFIX && provider.getPrefix() == ch)
|
||||
.filter(
|
||||
provider -> provider.getSearchMode() == SearchMode.PREFIX
|
||||
&& getRedefinedPrefix(provider.getPrefix()) == ch)
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
@@ -128,18 +132,24 @@ public class SearchTokenParser {
|
||||
}
|
||||
|
||||
public Pattern getSplitPattern() {
|
||||
StringJoiner prefixes = new StringJoiner("");
|
||||
prefixes.add(String.valueOf('\0'));
|
||||
StringBuilder prefixes = new StringBuilder().append('\0');
|
||||
|
||||
for (ISearchParserProvider provider : getProviders()) {
|
||||
if (provider.getSearchMode() == SearchMode.PREFIX) {
|
||||
prefixes.add(String.valueOf(provider.getPrefix()));
|
||||
prefixes.append(getRedefinedPrefix(provider.getPrefix()));
|
||||
}
|
||||
}
|
||||
|
||||
return Pattern.compile("((-*)([" + Pattern.quote(prefixes.toString()) + "]*)(\\\".*?(?:\\\"|$)|\\S+))");
|
||||
}
|
||||
|
||||
private char getRedefinedPrefix(char prefix) {
|
||||
if (this.prefixRedefinitions.containsKey(prefix)) {
|
||||
return this.prefixRedefinitions.get(prefix);
|
||||
}
|
||||
return prefix;
|
||||
}
|
||||
|
||||
private ItemFilter parseSearchText(String filterText) {
|
||||
|
||||
if (filterText.isEmpty()) {
|
||||
|
||||
@@ -380,8 +380,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
}
|
||||
|
||||
public char getPrefix() {
|
||||
String prefix = NEIClientConfig.getStringSetting("inventory.search.subsetsSearchPrefix");
|
||||
return prefix.length() == 0 ? '%' : prefix.charAt(0);
|
||||
return '%';
|
||||
}
|
||||
|
||||
public EnumChatFormatting getHighlightedColor() {
|
||||
|
||||
@@ -144,11 +144,6 @@ public class ItemInfo {
|
||||
API.addSearchProvider(
|
||||
new SearchParserProvider('\0', "default", EnumChatFormatting.RESET, PatternItemFilter::new) {
|
||||
|
||||
@Override
|
||||
public char getPrefix() {
|
||||
return defaultPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchMode getSearchMode() {
|
||||
return SearchMode.ALWAYS;
|
||||
|
||||
@@ -11,7 +11,26 @@ import codechicken.nei.config.GuiOptionList.OptionScrollSlot;
|
||||
|
||||
public class OptionTextField extends Option {
|
||||
|
||||
protected final TextField textField = createTextField();
|
||||
protected final TextField textField = new TextField("test") {
|
||||
|
||||
{
|
||||
this.h = 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChange(String oldText) {
|
||||
// don't override global if text hasn't changed
|
||||
if (focused() && isValidValue(text()) && (!defaulting() || !text().equals(getTag().getValue()))) {
|
||||
getTag().setValue(text());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFocus(boolean focus) {
|
||||
if (!focus && !isValidValue(text())) setText(renderTag().getValue());
|
||||
super.setFocus(focus);
|
||||
}
|
||||
};
|
||||
|
||||
public OptionTextField(String name) {
|
||||
super(name);
|
||||
@@ -72,30 +91,4 @@ public class OptionTextField extends Option {
|
||||
public boolean isValidValue(String s) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected TextField createTextField() {
|
||||
return new DefaultOptionTextField();
|
||||
}
|
||||
|
||||
protected class DefaultOptionTextField extends TextField {
|
||||
|
||||
public DefaultOptionTextField() {
|
||||
super("test");
|
||||
this.h = 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChange(String oldText) {
|
||||
// don't override global if text hasn't changed
|
||||
if (focused() && isValidValue(text()) && (!defaulting() || !text().equals(getTag().getValue()))) {
|
||||
getTag().setValue(text());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFocus(boolean focus) {
|
||||
if (!focus && !isValidValue(text())) setText(renderTag().getValue());
|
||||
super.setFocus(focus);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user