mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-16 18:54:45 +00:00
Small fixes & changes (#523)
* fix hotkeys * code cleanup * fix recipe tooltip overlay * search item by original name * overlay button refactoring * fix subset filter * change keyname; issue 524 * cleanup code * move overlayformat logic --------- Co-authored-by: slprime <[email protected]>
This commit is contained in:
1 parent
bd5e991a84
commit
65652e5896
15 files changed
+166
-98
No files matched your search
@@ -2500,20 +2500,19 @@ public class BookmarkPanel extends PanelWidget {
|
||||
translate("bookmark.group.toggle_crafting_chain.key"),
|
||||
translate("bookmark.group.toggle_crafting_chain"));
|
||||
|
||||
String keyName = NEIClientConfig.getKeyName(NEIClientConfig.getKeyBinding("gui.remove_recipe"), true);
|
||||
String keyName = NEIClientConfig.getKeyName("gui.remove_recipe");
|
||||
if (keyName != null) {
|
||||
hotkeys.put(keyName, translate("bookmark.group.remove_recipe"));
|
||||
}
|
||||
|
||||
if (BookmarkContainerInfo.getBookmarkContainerHandler(gui) != null) {
|
||||
|
||||
keyName = NEIClientConfig.getKeyName(NEIClientConfig.getKeyBinding("gui.bookmark_pull_items"), true);
|
||||
keyName = NEIClientConfig.getKeyName("gui.bookmark_pull_items");
|
||||
if (keyName != null) {
|
||||
hotkeys.put(keyName, translate("bookmark.group.pull_items"));
|
||||
}
|
||||
|
||||
keyName = NEIClientConfig
|
||||
.getKeyName(NEIClientConfig.getKeyBinding("gui.bookmark_pull_items_ingredients"), true);
|
||||
keyName = NEIClientConfig.getKeyName("gui.bookmark_pull_items_ingredients");
|
||||
if (keyName != null) {
|
||||
hotkeys.put(keyName, translate("bookmark.group.pull_items_ingredients"));
|
||||
}
|
||||
@@ -2536,20 +2535,19 @@ public class BookmarkPanel extends PanelWidget {
|
||||
hotkeys.put(translate("bookmark.group.sorting.key"), translate("bookmark.group.sorting"));
|
||||
}
|
||||
|
||||
String keyName = NEIClientConfig.getKeyName(NEIClientConfig.getKeyBinding("gui.remove_recipe"), true);
|
||||
String keyName = NEIClientConfig.getKeyName("gui.remove_recipe");
|
||||
if (keyName != null) {
|
||||
hotkeys.put(keyName, translate("bookmark.group.remove_recipe"));
|
||||
}
|
||||
|
||||
if (BookmarkContainerInfo.getBookmarkContainerHandler(gui) != null) {
|
||||
keyName = NEIClientConfig.getKeyName(NEIClientConfig.getKeyBinding("gui.bookmark_pull_items"), true);
|
||||
keyName = NEIClientConfig.getKeyName("gui.bookmark_pull_items");
|
||||
|
||||
if (keyName != null) {
|
||||
hotkeys.put(keyName, translate("bookmark.group.pull_items"));
|
||||
}
|
||||
|
||||
keyName = NEIClientConfig
|
||||
.getKeyName(NEIClientConfig.getKeyBinding("gui.bookmark_pull_items_ingredients"), true);
|
||||
keyName = NEIClientConfig.getKeyName("gui.bookmark_pull_items_ingredients");
|
||||
if (keyName != null) {
|
||||
hotkeys.put(keyName, translate("bookmark.group.pull_items_ingredients"));
|
||||
}
|
||||
|
||||
@@ -235,7 +235,6 @@ public class ClientHandler {
|
||||
|
||||
public static void postInit() {
|
||||
loadHandlerOrdering();
|
||||
loadPluginsList();
|
||||
GuiContainerManager.registerReloadResourceListener();
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,19 @@ public class ItemList {
|
||||
@Override
|
||||
public boolean matches(ItemStack item) {
|
||||
String displayName = EnumChatFormatting.getTextWithoutFormattingCodes(item.getDisplayName());
|
||||
return !displayName.isEmpty() && pattern.matcher(displayName).find();
|
||||
|
||||
if (!displayName.isEmpty() && pattern.matcher(displayName).find()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.hasDisplayName()) {
|
||||
displayName = EnumChatFormatting
|
||||
.getTextWithoutFormattingCodes(item.getItem().getItemStackDisplayName(item));
|
||||
|
||||
return !displayName.isEmpty() && pattern.matcher(displayName).find();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,11 +73,10 @@ public class ItemZoom extends Widget implements IContainerInputHandler {
|
||||
|
||||
if (NEIClientConfig.getBooleanSetting("inventory.itemzoom.enabled")
|
||||
&& NEIClientConfig.getBooleanSetting("inventory.itemzoom.helpText")) {
|
||||
int key = NEIClientConfig.getKeyBinding("gui.itemzoom_toggle");
|
||||
String keyName = NEIClientConfig.getKeyName("gui.itemzoom_toggle");
|
||||
|
||||
if (key > 0) {
|
||||
String helpText = NEIClientUtils
|
||||
.translate("itemzoom.toggle", NEIClientConfig.getKeyName(key, true));
|
||||
if (keyName != null) {
|
||||
String helpText = NEIClientUtils.translate("itemzoom.toggle", keyName);
|
||||
List<String> lines = fontRenderer.listFormattedStringToWidth(helpText, this.availableAreaWidth);
|
||||
|
||||
for (String line : lines) {
|
||||
|
||||
@@ -227,7 +227,7 @@ public class NEIClientConfig {
|
||||
});
|
||||
|
||||
tag.getTag("inventory.search.subsetsSearchMode").setComment("Search mode for Item Subsets (prefix: %)")
|
||||
.getIntValue(2);
|
||||
.getIntValue(1);
|
||||
API.addOption(new OptionCycled("inventory.search.subsetsSearchMode", 3, true) {
|
||||
|
||||
@Override
|
||||
@@ -631,34 +631,14 @@ public class NEIClientConfig {
|
||||
return hash != Keyboard.CHAR_NONE && hash == NEIClientUtils.getKeyHash();
|
||||
}
|
||||
|
||||
public static String getKeyName(int keyBind, boolean useHash) {
|
||||
return getKeyName(keyBind, useHash, false);
|
||||
}
|
||||
public static String getKeyName(String keyBind) {
|
||||
final int hash = getKeyBinding(keyBind);
|
||||
|
||||
public static String getKeyName(int keyBind, boolean useHash, boolean showOnlyHash) {
|
||||
String keyText = "";
|
||||
|
||||
if (useHash) {
|
||||
final String DELIMITER = " + ";
|
||||
if ((keyBind & NEIClientUtils.CTRL_HASH) != 0) {
|
||||
keyText += NEIClientUtils.translate(Minecraft.isRunningOnMac ? "key.ctrl.mac" : "key.ctrl") + DELIMITER;
|
||||
}
|
||||
if ((keyBind & NEIClientUtils.SHIFT_HASH) != 0) {
|
||||
keyText += "SHIFT" + DELIMITER;
|
||||
}
|
||||
if ((keyBind & NEIClientUtils.ALT_HASH) != 0) {
|
||||
keyText += "ALT" + DELIMITER;
|
||||
}
|
||||
if (hash == Keyboard.CHAR_NONE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!showOnlyHash) {
|
||||
keyText += Keyboard.getKeyName(unHashKey(keyBind));
|
||||
}
|
||||
return keyText;
|
||||
}
|
||||
|
||||
public static int unHashKey(int keyBind) {
|
||||
return keyBind & ~(NEIClientUtils.CTRL_HASH | NEIClientUtils.SHIFT_HASH | NEIClientUtils.ALT_HASH);
|
||||
return NEIClientUtils.getKeyName(hash);
|
||||
}
|
||||
|
||||
public static void bootNEI(World world) {
|
||||
@@ -685,7 +665,7 @@ public class NEIClientConfig {
|
||||
config.loadConfig();
|
||||
NEIModContainer.plugins.add(config);
|
||||
logger.debug("Loaded {}", clazz.getName());
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
logger.error("Failed to Load {}", clazz.getName(), e);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -450,6 +451,44 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
return Keyboard.CHAR_NONE;
|
||||
}
|
||||
|
||||
public static String getKeyHashName(int keyBind) {
|
||||
StringJoiner keyText = new StringJoiner(" + ");
|
||||
|
||||
if ((keyBind & CTRL_HASH) != 0) {
|
||||
keyText.add(translate(Minecraft.isRunningOnMac ? "key.ctrl.mac" : "key.ctrl"));
|
||||
}
|
||||
|
||||
if ((keyBind & SHIFT_HASH) != 0) {
|
||||
keyText.add(translate("key.shift"));
|
||||
}
|
||||
|
||||
if ((keyBind & ALT_HASH) != 0) {
|
||||
keyText.add(translate("key.alt"));
|
||||
}
|
||||
|
||||
return keyText.toString();
|
||||
}
|
||||
|
||||
public static String getKeyName(int keyBind) {
|
||||
StringJoiner keyText = new StringJoiner(" + ");
|
||||
String hashText = getKeyHashName(keyBind);
|
||||
int keyID = unHashKey(keyBind);
|
||||
|
||||
if (!hashText.isEmpty()) {
|
||||
keyText.add(hashText);
|
||||
}
|
||||
|
||||
if (keyID != Keyboard.CHAR_NONE || hashText.isEmpty()) {
|
||||
keyText.add(Keyboard.getKeyName(keyID));
|
||||
}
|
||||
|
||||
return keyText.toString();
|
||||
}
|
||||
|
||||
public static int unHashKey(int keyBind) {
|
||||
return keyBind & ~(CTRL_HASH | SHIFT_HASH | ALT_HASH);
|
||||
}
|
||||
|
||||
public static void playClickSound() {
|
||||
mc().getSoundHandler()
|
||||
.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
|
||||
@@ -127,6 +127,7 @@ public class NEIModContainer extends DummyModContainer {
|
||||
public void loadComplete(FMLLoadCompleteEvent event) {
|
||||
if (CommonUtils.isClient()) {
|
||||
GuiRecipeTab.loadHandlerInfo();
|
||||
ClientHandler.loadPluginsList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -243,18 +243,18 @@ public class SearchField extends TextField implements ItemFilterProvider {
|
||||
search = search.substring(2, search.length() - 1);
|
||||
} else {
|
||||
final Matcher matcher = Pattern.compile("(\\?|\\*)").matcher(search);
|
||||
String cleanedString = "";
|
||||
StringBuilder cleanedString = new StringBuilder();
|
||||
int lastEndIndex = 0;
|
||||
|
||||
while (matcher.find()) {
|
||||
cleanedString += Pattern.quote(search.substring(lastEndIndex, matcher.start()));
|
||||
cleanedString.append(Pattern.quote(search.substring(lastEndIndex, matcher.start())));
|
||||
|
||||
switch (matcher.group(0).charAt(0)) {
|
||||
case '?':
|
||||
cleanedString += ".";
|
||||
cleanedString.append(".");
|
||||
break;
|
||||
case '*':
|
||||
cleanedString += ".+?";
|
||||
cleanedString.append(".+?");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -266,6 +266,8 @@ public class SearchField extends TextField implements ItemFilterProvider {
|
||||
search = cleanedString + Pattern.quote(search.substring(lastEndIndex, search.length()));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!search.isEmpty()) {
|
||||
@@ -300,6 +302,8 @@ public class SearchField extends TextField implements ItemFilterProvider {
|
||||
case 2:
|
||||
text = text.replaceAll("[{}()\\[\\].+*?^$\\\\|]", "\\\\$0");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (text.contains(" ") && NEIClientConfig.getBooleanSetting("inventory.search.quoteDropItemName")) {
|
||||
|
||||
@@ -71,7 +71,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
if (slot < sorted.size()) {
|
||||
SubsetTag tag = sorted.get(slot);
|
||||
if (NEIClientUtils.shiftKey()) {
|
||||
LayoutManager.searchField.setText("%" + tag.fullname);
|
||||
LayoutManager.searchField.setText("%" + tag.fullname.replaceAll("\\s+", ""));
|
||||
} else if (button == 0 && count >= 2) {
|
||||
SubsetWidget.showOnly(tag);
|
||||
} else {
|
||||
@@ -175,7 +175,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
private SubsetTag getTag(String name) {
|
||||
int idx = name.indexOf('.');
|
||||
String childname = idx > 0 ? name.substring(0, idx) : name;
|
||||
SubsetTag child = children.get(childname.replaceAll(" ", "").toLowerCase());
|
||||
SubsetTag child = children.get(childname.replaceAll("\\s+", "").toLowerCase());
|
||||
if (child == null) return null;
|
||||
|
||||
return idx > 0 ? child.getTag(name.substring(idx + 1)) : child;
|
||||
@@ -192,7 +192,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
int idx = name.indexOf('.');
|
||||
|
||||
if (idx < 0) { // add or replace tag
|
||||
SubsetTag prev = children.put(name.replaceAll(" ", "").toLowerCase(), tag);
|
||||
SubsetTag prev = children.put(name.replaceAll("\\s+", "").toLowerCase(), tag);
|
||||
if (prev != null) { // replaced, load children
|
||||
tag.children = prev.children;
|
||||
tag.sorted = prev.sorted;
|
||||
@@ -200,10 +200,10 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
|
||||
recacheChildren();
|
||||
} else {
|
||||
String childname = name.substring(0, idx);
|
||||
SubsetTag child = children.get(childname.replaceAll(" ", "").toLowerCase());
|
||||
SubsetTag child = children.get(childname.replaceAll("\\s+", "").toLowerCase());
|
||||
if (child == null) {
|
||||
children.put(
|
||||
childname.replaceAll(" ", "").toLowerCase(),
|
||||
childname.replaceAll("\\s+", "").toLowerCase(),
|
||||
child = new SubsetTag(fullname == null ? childname : fullname + '.' + childname));
|
||||
}
|
||||
recacheChildren();
|
||||
|
||||
@@ -6,20 +6,20 @@ import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.GuiOverlayButton.ItemOverlayState;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
|
||||
public interface IOverlayHandler {
|
||||
|
||||
void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift);
|
||||
|
||||
default List<Boolean> presenceOverlay(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex) {
|
||||
final List<Boolean> itemPresenceSlots = new ArrayList<>();
|
||||
default List<ItemOverlayState> presenceOverlay(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex) {
|
||||
final List<ItemOverlayState> itemPresenceSlots = new ArrayList<>();
|
||||
final List<PositionedStack> ingredients = recipe.getIngredientStacks(recipeIndex);
|
||||
final List<ItemStack> invStacks = ((List<Slot>) firstGui.inventorySlots.inventorySlots).stream()
|
||||
final List<ItemStack> invStacks = firstGui.inventorySlots.inventorySlots.stream()
|
||||
.filter(
|
||||
s -> s != null && s.getStack() != null
|
||||
&& s.getStack().stackSize > 0
|
||||
@@ -29,9 +29,9 @@ public interface IOverlayHandler {
|
||||
|
||||
for (PositionedStack stack : ingredients) {
|
||||
Optional<ItemStack> used = invStacks.stream().filter(is -> is.stackSize > 0 && stack.contains(is))
|
||||
.findFirst();
|
||||
.findAny();
|
||||
|
||||
itemPresenceSlots.add(used.isPresent());
|
||||
itemPresenceSlots.add(new ItemOverlayState(stack, used.isPresent()));
|
||||
|
||||
if (used.isPresent()) {
|
||||
ItemStack is = used.get();
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.awt.Rectangle;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
|
||||
public class OptionKeyBind extends OptionButton {
|
||||
@@ -122,8 +121,12 @@ public class OptionKeyBind extends OptionButton {
|
||||
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
final int metahash = Math.max(editing ? NEIClientUtils.getMetaHash() : getValue(), 0);
|
||||
return NEIClientConfig.getKeyName(metahash, useHash, editing);
|
||||
|
||||
if (editing) {
|
||||
return NEIClientUtils.getKeyHashName(NEIClientUtils.getMetaHash());
|
||||
}
|
||||
|
||||
return NEIClientUtils.getKeyName(Math.max(getValue(), 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -568,7 +568,7 @@ public class GuiContainerManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (tooltip.size() > 0) tooltip.set(0, tooltip.get(0) + GuiDraw.TOOLTIP_LINESPACE); // add space after 'title'
|
||||
if (!tooltip.isEmpty()) tooltip.set(0, tooltip.get(0) + GuiDraw.TOOLTIP_LINESPACE); // add space after 'title'
|
||||
|
||||
synchronized (instanceTooltipHandlers) {
|
||||
for (IContainerTooltipHandler handler : instanceTooltipHandlers) {
|
||||
@@ -577,25 +577,27 @@ public class GuiContainerManager {
|
||||
}
|
||||
|
||||
if (!hotkeys.isEmpty()) {
|
||||
List<String> hotkeystips = new ArrayList<>();
|
||||
|
||||
if (!NEIClientUtils.altKey()) {
|
||||
tooltip.add(
|
||||
1,
|
||||
EnumChatFormatting.GRAY + translate(
|
||||
"showHotkeys",
|
||||
"" + EnumChatFormatting.GOLD + "ALT" + EnumChatFormatting.GRAY));
|
||||
hotkeystips.add(
|
||||
EnumChatFormatting.GRAY
|
||||
+ translate("showHotkeys", EnumChatFormatting.GOLD + "ALT" + EnumChatFormatting.GRAY));
|
||||
} else {
|
||||
List<String> hotkeystips = new LinkedList<>();
|
||||
|
||||
for (String key : hotkeys.keySet()) {
|
||||
hotkeystips.add(getHotkeyTip(key, hotkeys.get(key)));
|
||||
for (Map.Entry<String, String> entry : hotkeys.entrySet()) {
|
||||
hotkeystips.add(getHotkeyTip(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
|
||||
hotkeystips.sort((a, b) -> Integer.compare(a.indexOf(" - "), b.indexOf(" - ")));
|
||||
hotkeystips.set(
|
||||
hotkeystips.size() - 1,
|
||||
hotkeystips.get(hotkeystips.size() - 1) + GuiDraw.TOOLTIP_LINESPACE);
|
||||
}
|
||||
|
||||
if (tooltip.isEmpty()) {
|
||||
tooltip.addAll(hotkeystips);
|
||||
} else {
|
||||
tooltip.addAll(1, hotkeystips);
|
||||
}
|
||||
}
|
||||
@@ -623,7 +625,7 @@ public class GuiContainerManager {
|
||||
"inventory.tooltip.page",
|
||||
tooltipPage + 1,
|
||||
tooltips.size(),
|
||||
NEIClientConfig.getKeyName(NEIClientConfig.getKeyBinding("gui.next_tooltip"), true)));
|
||||
NEIClientConfig.getKeyName("gui.next_tooltip")));
|
||||
}
|
||||
drawMultilineTip(font, x, y, tooltips.get(tooltipPage));
|
||||
}
|
||||
|
||||
@@ -62,7 +62,44 @@ public class GuiOverlayButton extends GuiNEIButton {
|
||||
}
|
||||
}
|
||||
|
||||
private final static int OVERLAY_BUTTON_ID_START = 4;
|
||||
public enum ItemOverlayFormat {
|
||||
|
||||
BACKGROUND,
|
||||
ICON;
|
||||
|
||||
public static ItemOverlayFormat from(int overlay) {
|
||||
return overlay == 2 ? ItemOverlayFormat.BACKGROUND : ItemOverlayFormat.ICON;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ItemOverlayState {
|
||||
|
||||
protected PositionedStack slot;
|
||||
protected boolean isPresent;
|
||||
|
||||
public ItemOverlayState(PositionedStack slot, boolean isPresent) {
|
||||
this.slot = slot;
|
||||
this.isPresent = isPresent;
|
||||
}
|
||||
|
||||
public boolean isPresent() {
|
||||
return this.isPresent;
|
||||
}
|
||||
|
||||
public PositionedStack getSlot() {
|
||||
return this.slot;
|
||||
}
|
||||
|
||||
public void draw(ItemOverlayFormat format) {
|
||||
LayoutManager.drawItemPresenceOverlay(
|
||||
this.slot.relx,
|
||||
this.slot.rely,
|
||||
this.isPresent,
|
||||
format == ItemOverlayFormat.BACKGROUND);
|
||||
}
|
||||
}
|
||||
|
||||
private static final int OVERLAY_BUTTON_ID_START = 4;
|
||||
|
||||
public final GuiContainer firstGui;
|
||||
public final IRecipeHandler handler;
|
||||
@@ -71,7 +108,7 @@ public class GuiOverlayButton extends GuiNEIButton {
|
||||
protected ItemsTooltipLineHandler missedMaterialsTooltipLineHandler;
|
||||
|
||||
protected final IOverlayHandler overlayHandler;
|
||||
protected final List<Boolean> itemPresenceCache = new ArrayList<>();
|
||||
protected final List<ItemOverlayState> itemPresenceCache = new ArrayList<>();
|
||||
protected boolean requireShiftForOverlayRecipe = true;
|
||||
protected boolean useOverlayRenderer = false;
|
||||
protected boolean hasOverlay = false;
|
||||
@@ -113,26 +150,26 @@ public class GuiOverlayButton extends GuiNEIButton {
|
||||
|
||||
public Map<String, String> handleHotkeys(GuiContainer gui, int mousex, int mousey, Map<String, String> hotkeys) {
|
||||
|
||||
if (this.requireShiftForOverlayRecipe) {
|
||||
if (this.requireShiftForOverlayRecipe && this.useOverlayRenderer) {
|
||||
hotkeys.put(translate("recipe.overlay.fillCraftingGrid.key"), translate("recipe.overlay.fillCraftingGrid"));
|
||||
}
|
||||
|
||||
String keyName = NEIClientConfig.getKeyName(NEIClientConfig.getKeyBinding("gui.bookmark"), true);
|
||||
String keyName = NEIClientConfig.getKeyName("gui.bookmark");
|
||||
if (keyName != null) {
|
||||
hotkeys.put(keyName, translate("recipe.overlay.bookmark"));
|
||||
}
|
||||
|
||||
keyName = NEIClientConfig.getKeyName(NEIClientConfig.getKeyBinding("gui.bookmark_recipe"), true);
|
||||
keyName = NEIClientConfig.getKeyName("gui.bookmark_recipe");
|
||||
if (keyName != null) {
|
||||
hotkeys.put(keyName, translate("recipe.overlay.bookmarkRecipe"));
|
||||
}
|
||||
|
||||
keyName = NEIClientConfig.getKeyName(NEIClientConfig.getKeyBinding("gui.bookmark_count"), true);
|
||||
keyName = NEIClientConfig.getKeyName("gui.bookmark_count");
|
||||
if (keyName != null) {
|
||||
hotkeys.put(keyName, translate("recipe.overlay.bookmarkAmount"));
|
||||
}
|
||||
|
||||
keyName = NEIClientConfig.getKeyName(NEIClientConfig.getKeyBinding("gui.bookmark_recipe_count"), true);
|
||||
keyName = NEIClientConfig.getKeyName("gui.bookmark_recipe_count");
|
||||
if (keyName != null) {
|
||||
hotkeys.put(keyName, translate("recipe.overlay.bookmarkRecipeAndAmount"));
|
||||
}
|
||||
@@ -151,20 +188,16 @@ public class GuiOverlayButton extends GuiNEIButton {
|
||||
public void drawItemPresenceOverlay() {
|
||||
final int presenceOverlay = NEIClientConfig.itemPresenceOverlay();
|
||||
final boolean highlightPresentItem = NEIClientConfig.isSlotHighlightPresent();
|
||||
final List<PositionedStack> ingredients = this.handler.getIngredientStacks(recipeIndex);
|
||||
final List<Boolean> itemPresenceCache = ingredientsOverlay();
|
||||
final ItemOverlayFormat format = ItemOverlayFormat.from(presenceOverlay);
|
||||
|
||||
for (int j = 0; j < ingredients.size(); j++) {
|
||||
PositionedStack stack = ingredients.get(j);
|
||||
Boolean isPresent = j < itemPresenceCache.size() ? itemPresenceCache.get(j) : null;
|
||||
|
||||
if (isPresent != null && (highlightPresentItem || !isPresent)) {
|
||||
LayoutManager.drawItemPresenceOverlay(stack.relx, stack.rely, isPresent, presenceOverlay == 2);
|
||||
for (ItemOverlayState overlay : ingredientsOverlay()) {
|
||||
if (highlightPresentItem || !overlay.isPresent()) {
|
||||
overlay.draw(format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected List<Boolean> ingredientsOverlay() {
|
||||
protected List<ItemOverlayState> ingredientsOverlay() {
|
||||
List<PositionedStack> ingredients = this.handler.getIngredientStacks(recipeIndex);
|
||||
|
||||
if (this.itemPresenceCache.size() != ingredients.size()) {
|
||||
@@ -177,13 +210,8 @@ public class GuiOverlayButton extends GuiNEIButton {
|
||||
this.itemPresenceCache.addAll(presenceOverlay(ingredients));
|
||||
}
|
||||
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
|
||||
for (int j = 0; j < ingredients.size(); j++) {
|
||||
if (j >= this.itemPresenceCache.size() || !this.itemPresenceCache.get(j)) {
|
||||
items.add(ingredients.get(j).item);
|
||||
}
|
||||
}
|
||||
List<ItemStack> items = this.itemPresenceCache.stream().filter(state -> !state.isPresent())
|
||||
.map(state -> state.getSlot().item).collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
if (!items.isEmpty()) {
|
||||
this.missedMaterialsTooltipLineHandler = new ItemsTooltipLineHandler(
|
||||
@@ -220,8 +248,8 @@ public class GuiOverlayButton extends GuiNEIButton {
|
||||
return this.hasOverlay;
|
||||
}
|
||||
|
||||
private List<Boolean> presenceOverlay(List<PositionedStack> ingredients) {
|
||||
final List<Boolean> itemPresenceSlots = new ArrayList<>();
|
||||
private List<ItemOverlayState> presenceOverlay(List<PositionedStack> ingredients) {
|
||||
final List<ItemOverlayState> itemPresenceSlots = new ArrayList<>();
|
||||
final List<ItemStack> invStacks = this.firstGui.inventorySlots.inventorySlots.stream()
|
||||
.filter(
|
||||
s -> s != null && s.getStack() != null
|
||||
@@ -232,9 +260,9 @@ public class GuiOverlayButton extends GuiNEIButton {
|
||||
|
||||
for (PositionedStack stack : ingredients) {
|
||||
Optional<ItemStack> used = invStacks.stream().filter(is -> is.stackSize > 0 && stack.contains(is))
|
||||
.findFirst();
|
||||
.findAny();
|
||||
|
||||
itemPresenceSlots.add(used.isPresent());
|
||||
itemPresenceSlots.add(new ItemOverlayState(stack, used.isPresent()));
|
||||
|
||||
if (used.isPresent()) {
|
||||
ItemStack is = used.get();
|
||||
|
||||
@@ -1098,8 +1098,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
.filter(b -> b.recipeIndex == recipeIndex).findAny().orElse(null);
|
||||
|
||||
if (overlayButton != null && overlayButton.enabled) {
|
||||
final String overlayKeyName = NEIClientConfig
|
||||
.getKeyName(NEIClientConfig.getKeyBinding("gui.overlay_use"), true);
|
||||
final String overlayKeyName = NEIClientConfig.getKeyName("gui.overlay_use");
|
||||
|
||||
if (overlayKeyName != null) {
|
||||
fontRendererObj.drawStringWithShadow(
|
||||
@@ -1108,6 +1107,8 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
handlerInfo.getHeight() - fontRendererObj.FONT_HEIGHT,
|
||||
0xffffff);
|
||||
}
|
||||
|
||||
overlayButton.drawItemPresenceOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user