mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-16 18:54:45 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2507634196 | ||
|
|
e0171adc65 |
No files matched your search
+1
-1
@@ -41,7 +41,7 @@ developmentEnvironmentUserName = Developer
|
||||
|
||||
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
|
||||
# See https://github.com/bsideup/jabel for details on how this works.
|
||||
enableModernJavaSyntax = false
|
||||
enableModernJavaSyntax = true
|
||||
|
||||
# Enables injecting missing generics into the decompiled source code for a better coding experience.
|
||||
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
|
||||
|
||||
@@ -110,7 +110,10 @@ public class HeldItemHandler implements IContainerInputHandler, IContainerToolti
|
||||
|
||||
if (contains(mousex, mousey)) {
|
||||
currenttip.clear();
|
||||
currenttip.add(EnumChatFormatting.RED + translate("itempanel.deleteItem"));
|
||||
|
||||
if (NEIClientConfig.canPerformAction("delete") && NEIClientConfig.canPerformAction("item")) {
|
||||
currenttip.add(EnumChatFormatting.RED + translate("itempanel.deleteItem"));
|
||||
}
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
|
||||
@@ -24,6 +24,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.ClassDiscoverer;
|
||||
@@ -238,6 +241,20 @@ public class NEIClientConfig {
|
||||
|
||||
});
|
||||
|
||||
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));
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -30,16 +31,11 @@ public class SearchTokenParser {
|
||||
NEVER;
|
||||
|
||||
public static SearchMode fromInt(int value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return ALWAYS;
|
||||
case 1:
|
||||
return PREFIX;
|
||||
case 2:
|
||||
return NEVER;
|
||||
default:
|
||||
return ALWAYS;
|
||||
}
|
||||
return switch (value) {
|
||||
case 0 -> ALWAYS;
|
||||
case 1 -> PREFIX;
|
||||
default -> NEVER;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,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;
|
||||
@@ -114,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);
|
||||
}
|
||||
|
||||
@@ -133,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()) {
|
||||
|
||||
@@ -72,7 +72,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
if (slot < sorted.size()) {
|
||||
SubsetTag tag = sorted.get(slot);
|
||||
if (NEIClientUtils.shiftKey()) {
|
||||
codechicken.nei.LayoutManager.searchField.setText("%" + tag.fullname);
|
||||
LayoutManager.searchField.setText("%" + tag.fullname);
|
||||
} else if (button == 0 && count >= 2) {
|
||||
SubsetWidget.showOnly(tag);
|
||||
} else {
|
||||
@@ -94,7 +94,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
Rectangle4i r = new Rectangle4i(x, y, w, getSlotHeight(slot));
|
||||
if (slot < sorted.size()) {
|
||||
SubsetTag tag = sorted.get(slot);
|
||||
codechicken.nei.LayoutManager.getLayoutStyle()
|
||||
LayoutManager.getLayoutStyle()
|
||||
.drawSubsetTag(tag.displayName(), x, y, r.w, r.h, tag.state.state, r.contains(mx, my));
|
||||
} else {
|
||||
ItemStack stack = state.items.get(slot - sorted.size());
|
||||
@@ -103,8 +103,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
int itemx = w / 2 - 8;
|
||||
int itemy = 1;
|
||||
|
||||
codechicken.nei.LayoutManager.getLayoutStyle()
|
||||
.drawSubsetTag(null, x, y, r.w, r.h, hidden ? 0 : 2, false);
|
||||
LayoutManager.getLayoutStyle().drawSubsetTag(null, x, y, r.w, r.h, hidden ? 0 : 2, false);
|
||||
|
||||
GuiContainerManager.drawItem(x + itemx, y + itemy, stack);
|
||||
if (new Rectangle4i(itemx, itemy, 16, 16).contains(mx, my)) SubsetWidget.hoverStack = stack;
|
||||
|
||||
@@ -141,11 +141,7 @@ public class ItemInfo {
|
||||
|
||||
private static void addSearchProviders() {
|
||||
API.addSearchProvider(
|
||||
new SearchParserProvider(
|
||||
'\0',
|
||||
"default",
|
||||
EnumChatFormatting.RESET,
|
||||
(pattern) -> new PatternItemFilter(pattern)) {
|
||||
new SearchParserProvider('\0', "default", EnumChatFormatting.RESET, PatternItemFilter::new) {
|
||||
|
||||
@Override
|
||||
public SearchMode getSearchMode() {
|
||||
@@ -154,29 +150,12 @@ public class ItemInfo {
|
||||
|
||||
});
|
||||
API.addSearchProvider(
|
||||
new SearchParserProvider(
|
||||
'@',
|
||||
"modName",
|
||||
EnumChatFormatting.LIGHT_PURPLE,
|
||||
(pattern) -> new ModNameFilter(pattern)));
|
||||
new SearchParserProvider('@', "modName", EnumChatFormatting.LIGHT_PURPLE, ModNameFilter::new));
|
||||
API.addSearchProvider(
|
||||
new SearchParserProvider(
|
||||
'$',
|
||||
"oreDict",
|
||||
EnumChatFormatting.AQUA,
|
||||
(pattern) -> new OreDictionaryFilter(pattern)));
|
||||
new SearchParserProvider('$', "oreDict", EnumChatFormatting.AQUA, OreDictionaryFilter::new));
|
||||
API.addSearchProvider(new SearchParserProvider('#', "tooltip", EnumChatFormatting.YELLOW, TooltipFilter::new));
|
||||
API.addSearchProvider(
|
||||
new SearchParserProvider(
|
||||
'#',
|
||||
"tooltip",
|
||||
EnumChatFormatting.YELLOW,
|
||||
(pattern) -> new TooltipFilter(pattern)));
|
||||
API.addSearchProvider(
|
||||
new SearchParserProvider(
|
||||
'&',
|
||||
"identifier",
|
||||
EnumChatFormatting.GOLD,
|
||||
(pattern) -> new IdentifierFilter(pattern)));
|
||||
new SearchParserProvider('&', "identifier", EnumChatFormatting.GOLD, IdentifierFilter::new));
|
||||
}
|
||||
|
||||
private static void addIDDumps() {
|
||||
|
||||
@@ -11,30 +11,29 @@ import codechicken.nei.config.GuiOptionList.OptionScrollSlot;
|
||||
|
||||
public class OptionTextField extends Option {
|
||||
|
||||
private TextField textField = new TextField("test") {
|
||||
protected final TextField textField = new TextField("test") {
|
||||
|
||||
{
|
||||
this.h = 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChange(String oldText) {
|
||||
if (focused() && isValidValue(text())) if (!defaulting() || !text().equals(getTag().getValue())) // don't
|
||||
// override
|
||||
// global
|
||||
// if text
|
||||
// hasn't
|
||||
// changed
|
||||
// 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);
|
||||
textField.h = 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -104,6 +104,26 @@ nei.options.inventory.search.patternMode=Suchmodus
|
||||
nei.options.inventory.search.patternMode.0=Gewöhnlich
|
||||
nei.options.inventory.search.patternMode.1=Erweitert
|
||||
nei.options.inventory.search.patternMode.2=Regex
|
||||
nei.options.inventory.search.modNameSearchMode=Modname Suchmodus
|
||||
nei.options.inventory.search.modNameSearchMode.0=Immer
|
||||
nei.options.inventory.search.modNameSearchMode.1=Präfix: %s
|
||||
nei.options.inventory.search.modNameSearchMode.2=Nie
|
||||
nei.options.inventory.search.tooltipSearchMode=Tooltip Suchmodus
|
||||
nei.options.inventory.search.tooltipSearchMode.0=Immer
|
||||
nei.options.inventory.search.tooltipSearchMode.1=Präfix: %s
|
||||
nei.options.inventory.search.tooltipSearchMode.2=Nie
|
||||
nei.options.inventory.search.identifierSearchMode=Identifikator Suchmodus
|
||||
nei.options.inventory.search.identifierSearchMode.0=Immer
|
||||
nei.options.inventory.search.identifierSearchMode.1=Präfix: %s
|
||||
nei.options.inventory.search.identifierSearchMode.2=Nie
|
||||
nei.options.inventory.search.oreDictSearchMode=OreDict Suchmodus
|
||||
nei.options.inventory.search.oreDictSearchMode.0=Immer
|
||||
nei.options.inventory.search.oreDictSearchMode.1=Präfix: %s
|
||||
nei.options.inventory.search.oreDictSearchMode.2=Nie
|
||||
nei.options.inventory.search.subsetsSearchMode=Item-SubSet Suchmodus
|
||||
nei.options.inventory.search.subsetsSearchMode.0=Immer
|
||||
nei.options.inventory.search.subsetsSearchMode.1=Präfix: %s
|
||||
nei.options.inventory.search.subsetsSearchMode.2=Nie
|
||||
nei.options.inventory.utilities=Nützliches
|
||||
nei.options.inventory.utilities.tip=Wähle Inhalte für den Mehrzweckmodus
|
||||
nei.options.inventory.utilities.time=Zeit
|
||||
|
||||
Reference in new issue
Block a user