Add back search mode settings and add ingame setting for prefixes

This commit is contained in:
glowredman committed 2024-08-25 23:40:42 +02:00
1 parent 87f71b6ef9
commit 9feb9d72ce
9 files changed
+337 -59

No files matched your search

@@ -1,6 +1,9 @@
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;
@@ -182,105 +185,312 @@ 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") {
@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);
}
@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 && 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);
.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") {
@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);
}
@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("");
.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 = "";
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 = "";
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") {
@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);
}
@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("");
.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 = "";
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 = "";
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 = "";
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") {
@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);
}
@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("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 = "";
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 = "";
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 = "";
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 = "";
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") {
@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);
}
@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;
}
};
}
});
tag.getTag("inventory.bookmarks.enabled").setComment("Enable/Disable Bookmark Panel").getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.bookmarks.enabled", true));