diff --git a/src/main/java/mezz/jei/config/Config.java b/src/main/java/mezz/jei/config/Config.java index f6965568..6d675425 100644 --- a/src/main/java/mezz/jei/config/Config.java +++ b/src/main/java/mezz/jei/config/Config.java @@ -385,6 +385,14 @@ public static boolean hideBottomLeftCornerBookmarkButton() { return values.hideBottomLeftCornerBookmarkButton; } + public static boolean enableHistoryPanel() { + return values.enableHistoryPanel; + } + + public static boolean isHistoryPanelOnLeft() { + return values.isHistoryPanelOnLeft; + } + public static int getRecipeBookmarkGroupColor() { return values.recipeBookmarkGroupColor; } @@ -584,6 +592,10 @@ private static boolean syncConfig() { values.hideBottomLeftCornerBookmarkButton = config.getBoolean(CATEGORY_MISC, "hideBottomLeftCornerBookmarkButton", defaultValues.hideBottomLeftCornerBookmarkButton); + values.enableHistoryPanel = config.getBoolean(CATEGORY_MISC, "enableHistoryPanel", defaultValues.enableHistoryPanel); + + values.isHistoryPanelOnLeft = config.getBoolean(CATEGORY_MISC, "isHistoryPanelOnLeft", defaultValues.isHistoryPanelOnLeft); + { boolean prev = values.collapsibleGroupsEnabled; values.collapsibleGroupsEnabled = config.getBoolean(CATEGORY_COLLAPSIBLE, "collapsibleGroupsEnabled", defaultValues.collapsibleGroupsEnabled); diff --git a/src/main/java/mezz/jei/config/ConfigValues.java b/src/main/java/mezz/jei/config/ConfigValues.java index 50fced31..4af84146 100644 --- a/src/main/java/mezz/jei/config/ConfigValues.java +++ b/src/main/java/mezz/jei/config/ConfigValues.java @@ -53,6 +53,8 @@ public class ConfigValues { public boolean skipShowingProgressBar = false; public boolean hideBottomRightCornerConfigButton = false; public boolean hideBottomLeftCornerBookmarkButton = false; + public boolean enableHistoryPanel = true; + public boolean isHistoryPanelOnLeft = true; // category public List categoryUidOrder = new ArrayList<>(); diff --git a/src/main/java/mezz/jei/gui/overlay/IngredientGrid.java b/src/main/java/mezz/jei/gui/overlay/IngredientGrid.java index 9f43f44a..73583f28 100644 --- a/src/main/java/mezz/jei/gui/overlay/IngredientGrid.java +++ b/src/main/java/mezz/jei/gui/overlay/IngredientGrid.java @@ -26,12 +26,14 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.util.text.TextFormatting; import net.minecraftforge.items.ItemHandlerHelper; import javax.annotation.Nullable; import java.awt.*; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; /** @@ -45,14 +47,16 @@ public class IngredientGrid implements IShowsRecipeFocuses { private Rectangle area = new Rectangle(); protected final IngredientListBatchRenderer guiIngredientSlots; + protected final IngredientGridHistoryProvider historyProvider; - public IngredientGrid(IngredientListBatchRenderer guiIngredientSlots, GridAlignment alignment) { + public IngredientGrid(IngredientListBatchRenderer guiIngredientSlots, GridAlignment alignment, boolean enableHistory) { this.alignment = alignment; this.guiIngredientSlots = guiIngredientSlots; + this.historyProvider = new IngredientGridHistoryProvider(enableHistory); } public IngredientGrid(GridAlignment alignment) { // Left in for compatibility with JEI Utilities - this(new IngredientListBatchRenderer(), alignment); + this(new IngredientListBatchRenderer(), alignment, false); } public int size() { @@ -78,23 +82,38 @@ public boolean updateBounds(Rectangle availableArea, int minWidth, Collection ingredientRow = new ArrayList<>(); - int y1 = y + (row * INGREDIENT_HEIGHT); - for (int column = 0; column < columns; column++) { - int x1 = xOffset + (column * INGREDIENT_WIDTH); - IngredientListSlot ingredientListSlot = new IngredientListSlot(x1, y1, INGREDIENT_PADDING); - Rectangle stackArea = ingredientListSlot.getArea(); - final boolean blocked = MathUtil.intersects(exclusionAreas, stackArea); - ingredientListSlot.setBlocked(blocked); - ingredientRow.add(ingredientListSlot); + if (!historyProvider.updateBoundsExtra( + columns, + rows, + y, + xOffset, + exclusionAreas, + this.guiIngredientSlots)) { + + for (int row = 0; row < rows; row++) { + List ingredientRow = new ArrayList<>(); + int y1 = y + (row * INGREDIENT_HEIGHT); + for (int column = 0; column < columns; column++) { + int x1 = xOffset + (column * INGREDIENT_WIDTH); + IngredientListSlot ingredientListSlot = new IngredientListSlot(x1, y1, INGREDIENT_PADDING); + Rectangle stackArea = ingredientListSlot.getArea(); + final boolean blocked = MathUtil.intersects(exclusionAreas, stackArea); + ingredientListSlot.setBlocked(blocked); + ingredientRow.add(ingredientListSlot); + } + this.guiIngredientSlots.add(ingredientRow); } - this.guiIngredientSlots.add(ingredientRow); } + return true; } @@ -112,6 +131,10 @@ public void draw(Minecraft minecraft, int mouseX, int mouseY) { guiIngredientSlots.render(minecraft); guiIngredientSlots.renderExpandedGroupOutlines(); + if (historyProvider.isEnabled()) { + historyProvider.drawExtra(minecraft); + } + if (!shouldDeleteItemOnClick(minecraft, mouseX, mouseY) && isMouseOver(mouseX, mouseY)) { CollapsedGroupRenderer collapsedHovered = guiIngredientSlots.getHoveredCollapsed(mouseX, mouseY); if (collapsedHovered != null) { @@ -141,13 +164,16 @@ public void drawTooltips(Minecraft minecraft, int mouseX, int mouseY) { if (hovered != null) { CollapsedGroupIngredient expandedGroup = guiIngredientSlots.getExpandedCollapsedGroupAt(mouseX, mouseY); if (expandedGroup != null) { - String hint = net.minecraft.util.text.TextFormatting.YELLOW - + mezz.jei.util.Translator.translateToLocal("hei.tooltip.collapsed.collapse"); - hovered.drawTooltip(minecraft, mouseX, mouseY, java.util.Collections.singletonList(hint)); + String hint = TextFormatting.YELLOW + Translator.translateToLocal("hei.tooltip.collapsed.collapse"); + hovered.drawTooltip(minecraft, mouseX, mouseY, Collections.singletonList(hint)); } else { hovered.drawTooltip(minecraft, mouseX, mouseY); } } + + if (historyProvider.isEnabled()) { + historyProvider.drawTooltipsExtra(minecraft, mouseX, mouseY); + } } } } @@ -222,14 +248,22 @@ public IIngredientListElement getElementUnderMouse() { @Override @Nullable public IClickedIngredient getIngredientUnderMouse(int mouseX, int mouseY) { + IClickedIngredient result; if (isMouseOver(mouseX, mouseY)) { ClickedIngredient clicked = guiIngredientSlots.getIngredientUnderMouse(mouseX, mouseY); if (clicked != null) { clicked.setAllowsCheating(); } - return clicked; + result = clicked; + } else { + result = null; } - return null; + + if (historyProvider.isEnabled()) { + result = historyProvider.getIngredientUnderMouseExtra(result, mouseX, mouseY); + } + + return result; } @Override diff --git a/src/main/java/mezz/jei/gui/overlay/IngredientGridHistoryProvider.java b/src/main/java/mezz/jei/gui/overlay/IngredientGridHistoryProvider.java new file mode 100644 index 00000000..9a643759 --- /dev/null +++ b/src/main/java/mezz/jei/gui/overlay/IngredientGridHistoryProvider.java @@ -0,0 +1,315 @@ +package mezz.jei.gui.overlay; + +import mezz.jei.Internal; +import mezz.jei.api.ingredients.IIngredientHelper; +import mezz.jei.api.recipe.IFocus; +import mezz.jei.config.Config; +import mezz.jei.gui.ingredients.IIngredientListElement; +import mezz.jei.ingredients.IngredientListElement; +import mezz.jei.input.ClickedIngredient; +import mezz.jei.input.IClickedIngredient; +import mezz.jei.render.IngredientListBatchRenderer; +import mezz.jei.render.IngredientListSlot; +import mezz.jei.render.IngredientRenderer; +import mezz.jei.startup.ForgeModIdHelper; +import mezz.jei.util.LegacyUtil; +import mezz.jei.util.MathUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; +import org.lwjgl.opengl.GL11; + +import javax.annotation.Nullable; +import java.awt.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; + +import static mezz.jei.gui.overlay.IngredientGrid.*; +import static mezz.jei.ingredients.IngredientListElementFactory.ORDER_TRACKER; +import static mezz.jei.plugins.jei.JEIInternalPlugin.ingredientRegistry; + +/** + * Extends the original layout logic from JEI to support history rows. + * Original implementation by vfyjxf JEI-Utilities. + */ +public class IngredientGridHistoryProvider { + + private static final List GLOBAL_HISTORY_CONTAINER = new ArrayList<>(); + + public static final int USE_ROWS = 2; + public static final int MIN_ROWS = 6; + public static final int BACKGROUND_COLOR = 0xee555555; + public static final boolean HISTORY_MATCH_NBT = true; + + private final boolean enabled; + + public boolean isEnabled() { + return enabled; + } + + private int columns; + private final IngredientListBatchRenderer guiHistoryIngredientSlots; + @SuppressWarnings("rawtypes") + private final List historyIngredientElements = new ArrayList<>(); + + private boolean showHistory; + + public IngredientGridHistoryProvider(boolean enabled) { + this.enabled = enabled; + this.guiHistoryIngredientSlots = new IngredientListBatchRenderer(); + + GLOBAL_HISTORY_CONTAINER.add(this); + } + + /** + * @see mezz.jei.gui.recipes.RecipesGui#show(IFocus) + */ + public static void onSetFocus(IFocus focus) { + for (IngredientGridHistoryProvider historyProvider : GLOBAL_HISTORY_CONTAINER) { + if (historyProvider.isEnabled()) { + historyProvider.addHistoryIngredient(focus.getValue()); + } + } + } + + public void addHistoryIngredient(@Nullable Object value) { + if (!enabled) { + return; + } + if (value == null) { + return; + } + if (ignoreIngredient(value)) { + return; + } + + Object normalized = normalizeIngredient(value); + IIngredientHelper helper = Objects.requireNonNull(ingredientRegistry).getIngredientHelper(normalized); + + IIngredientListElement ingredient = IngredientListElement.create( + normalized, + helper, + ingredientRegistry.getIngredientRenderer(normalized), + ForgeModIdHelper.getInstance(), + ORDER_TRACKER.getOrderIndex(normalized, helper)); + + historyIngredientElements.removeIf(element -> areIngredientsEqual(element.getIngredient(), normalized, HISTORY_MATCH_NBT)); + historyIngredientElements.add(0, ingredient); + + while (historyIngredientElements.size() > USE_ROWS * Config.largestNumColumns) { + historyIngredientElements.remove(historyIngredientElements.size() - 1); + } + + guiHistoryIngredientSlots.set(0, historyIngredientElements); + } + + public void removeElement(int index) { + if (!enabled) { + return; + } + + historyIngredientElements.remove(index); + guiHistoryIngredientSlots.set(0, historyIngredientElements); + } + + // internal methods + + public void updateColumns(int columns) { + if (!enabled) { + return; + } + + this.columns = columns; + } + + public void clearHistorySlots() { + if (!enabled) { + return; + } + + guiHistoryIngredientSlots.clear(); + } + + public boolean updateBoundsExtra( + int columns, + int rows, + int y, + int xOffset, + Collection exclusionAreas, + IngredientListBatchRenderer guiIngredientSlots) { + + if (!enabled) { + return false; + } + + this.columns = columns; + + if (rows >= MIN_ROWS) { + rows = rows - USE_ROWS; + showHistory = true; + } else { + showHistory = false; + } + + if (!showHistory) { + return false; + } + + for (int row = 0; row < rows; row++) { + List ingredientRow = new ArrayList<>(); + int y1 = y + (row * INGREDIENT_HEIGHT); + for (int column = 0; column < columns; column++) { + int x1 = xOffset + (column * INGREDIENT_WIDTH); + IngredientListSlot ingredientListSlot = new IngredientListSlot(x1, y1, INGREDIENT_PADDING); + Rectangle stackArea = ingredientListSlot.getArea(); + final boolean blocked = MathUtil.intersects(exclusionAreas, stackArea); + ingredientListSlot.setBlocked(blocked); + ingredientRow.add(ingredientListSlot); + } + guiIngredientSlots.add(ingredientRow); + } + + for (int row = 0; row < USE_ROWS; row++) { + List ingredientRow = new ArrayList<>(); + int y1 = y + ((row + rows) * INGREDIENT_HEIGHT); + for (int column = 0; column < columns; column++) { + int x1 = xOffset + (column * INGREDIENT_WIDTH); + IngredientListSlot ingredientListSlot = new IngredientListSlot(x1, y1, INGREDIENT_PADDING); + Rectangle stackArea = ingredientListSlot.getArea(); + final boolean blocked = MathUtil.intersects(exclusionAreas, stackArea); + ingredientListSlot.setBlocked(blocked); + ingredientRow.add(ingredientListSlot); + } + guiHistoryIngredientSlots.add(ingredientRow); + } + + guiHistoryIngredientSlots.set(0, historyIngredientElements); + + return true; + } + + public void drawExtra(Minecraft minecraft) { + if (!enabled) { + return; + } + if (!showHistory) { + return; + } + + Rectangle firstRect = guiHistoryIngredientSlots.getAllGuiIngredientSlots().get(0).getArea(); + + drawSpillingArea( + firstRect.x, firstRect.y, + firstRect.width * columns, + firstRect.height * USE_ROWS, + BACKGROUND_COLOR); + + guiHistoryIngredientSlots.render(minecraft); + } + + @SuppressWarnings("rawtypes") + public void drawTooltipsExtra(Minecraft minecraft, int mouseX, int mouseY) { + if (!enabled) { + return; + } + if (!showHistory) { + return; + } + + IngredientRenderer hoveredHistory = guiHistoryIngredientSlots.getHovered(mouseX, mouseY); + if (hoveredHistory != null) { + hoveredHistory.drawTooltip(minecraft, mouseX, mouseY); + } + } + + @Nullable + public IClickedIngredient getIngredientUnderMouseExtra( + @Nullable IClickedIngredient result, + int mouseX, + int mouseY) { + + if (result != null) { + return result; + } + if (!enabled) { + return null; + } + if (!showHistory) { + return null; + } + + ClickedIngredient clickedHistory = guiHistoryIngredientSlots.getIngredientUnderMouse(mouseX, mouseY); + if (clickedHistory != null) { + clickedHistory.setAllowsCheating(); + } + return clickedHistory; + } + + // helper methods + + private static boolean areIngredientsEqual(Object ingredient1, Object ingredient2, boolean matchesNbt) { + if (ingredient1 == ingredient2) { + return true; + } + + if (ingredient1.getClass() == ingredient2.getClass()) { + IIngredientHelper ingredientHelper = Objects.requireNonNull(ingredientRegistry).getIngredientHelper(ingredient1); + if (matchesNbt) { + return ingredientHelper.getUniqueId(ingredient1).equals(ingredientHelper.getUniqueId(ingredient2)); + } + return ingredientHelper.getWildcardId(ingredient1).equals(ingredientHelper.getWildcardId(ingredient2)); + } + + return false; + } + + private static boolean ignoreIngredient(Object ingredient) { + return Internal.getHelpers().getIngredientBlacklist().isIngredientBlacklisted(ingredient); + } + + private static T normalizeIngredient(T ingredient) { + IIngredientHelper ingredientHelper = Objects.requireNonNull(ingredientRegistry).getIngredientHelper(ingredient); + T copy = LegacyUtil.getIngredientCopy(ingredient, ingredientHelper); + if (copy instanceof ItemStack) { + ((ItemStack) copy).setCount(1); + } else if (copy instanceof FluidStack) { + ((FluidStack) copy).amount = 1000; + } + return copy; + } + + private static void drawSpillingArea(int x, int y, int width, int height, int color) { + float alpha = (float) (color >> 24 & 255) / 255f; + float red = (float) (color >> 16 & 255) / 255f; + float green = (float) (color >> 8 & 255) / 255f; + float blue = (float) (color & 255) / 255f; + + GlStateManager.pushMatrix(); + + GlStateManager.disableTexture2D(); + GL11.glEnable(GL11.GL_LINE_STIPPLE); + GlStateManager.color(red, green, blue, alpha); + GL11.glLineWidth(2F); + GL11.glLineStipple(2, (short) 0x00FF); + + GL11.glBegin(GL11.GL_LINE_LOOP); + + GL11.glVertex2i(x, y); + GL11.glVertex2i(x + width, y); + GL11.glVertex2i(x + width, y + height); + GL11.glVertex2i(x, y + height); + + GL11.glEnd(); + + GL11.glLineStipple(2, (short) 0xFFFF); + GL11.glLineWidth(2F); + GL11.glDisable(GL11.GL_LINE_STIPPLE); + GlStateManager.enableTexture2D(); + GlStateManager.color(1F, 1F, 1F, 1F); + + GlStateManager.popMatrix(); + } +} diff --git a/src/main/java/mezz/jei/gui/overlay/IngredientGridWithNavigation.java b/src/main/java/mezz/jei/gui/overlay/IngredientGridWithNavigation.java index 5c8830b7..b149777e 100644 --- a/src/main/java/mezz/jei/gui/overlay/IngredientGridWithNavigation.java +++ b/src/main/java/mezz/jei/gui/overlay/IngredientGridWithNavigation.java @@ -40,7 +40,7 @@ public class IngredientGridWithNavigation implements IShowsRecipeFocuses, IMouse private Rectangle area = new Rectangle(); public IngredientGridWithNavigation(IIngredientGridSource ingredientSource, GuiScreenHelper guiScreenHelper, GridAlignment alignment) { - this.ingredientGrid = new IngredientGrid(new IngredientListBatchRenderer(), alignment); + this.ingredientGrid = new IngredientGrid(new IngredientListBatchRenderer(), alignment, Config.enableHistoryPanel() && !Config.isHistoryPanelOnLeft()); this.ingredientSource = ingredientSource; this.guiScreenHelper = guiScreenHelper; this.pageDelegate = new IngredientGridPaged(); diff --git a/src/main/java/mezz/jei/gui/overlay/bookmarks/BookmarkGrid.java b/src/main/java/mezz/jei/gui/overlay/bookmarks/BookmarkGrid.java index e6db8812..bda0d993 100644 --- a/src/main/java/mezz/jei/gui/overlay/bookmarks/BookmarkGrid.java +++ b/src/main/java/mezz/jei/gui/overlay/bookmarks/BookmarkGrid.java @@ -21,10 +21,11 @@ public class BookmarkGrid extends IngredientGrid { private Rectangle area = new Rectangle(); public BookmarkGrid(GridAlignment alignment, BookmarkGroupOrganizer groupOrganizer) { - super(new BookmarkListBatchRenderer(groupOrganizer), alignment); + super(new BookmarkListBatchRenderer(groupOrganizer), alignment, Config.enableHistoryPanel() && Config.isHistoryPanelOnLeft()); this.alignment = alignment; } + @Override public boolean updateBounds(Rectangle availableArea, int minWidth, Collection exclusionAreas) { final int columns = Math.min(availableArea.width / INGREDIENT_WIDTH, Config.getMaxColumns()); final int rows = availableArea.height / INGREDIENT_HEIGHT; @@ -44,23 +45,38 @@ public boolean updateBounds(Rectangle availableArea, int minWidth, Collection ingredientRow = new ArrayList<>(); - for (int column = 0; column < columns; column++) { - int x1 = xOffset + (column * INGREDIENT_WIDTH); - IngredientListSlot ingredientListSlot = new IngredientListSlot(x1, y1, INGREDIENT_PADDING); - Rectangle stackArea = ingredientListSlot.getArea(); - final boolean blocked = MathUtil.intersects(exclusionAreas, stackArea); - ingredientListSlot.setBlocked(blocked); - ingredientRow.add(ingredientListSlot); + if (!historyProvider.updateBoundsExtra( + columns, + rows, + y, + xOffset, + exclusionAreas, + this.guiIngredientSlots)) { + + for (int row = 0; row < rows; row++) { + int y1 = y + (row * INGREDIENT_HEIGHT); + List ingredientRow = new ArrayList<>(); + for (int column = 0; column < columns; column++) { + int x1 = xOffset + (column * INGREDIENT_WIDTH); + IngredientListSlot ingredientListSlot = new IngredientListSlot(x1, y1, INGREDIENT_PADDING); + Rectangle stackArea = ingredientListSlot.getArea(); + final boolean blocked = MathUtil.intersects(exclusionAreas, stackArea); + ingredientListSlot.setBlocked(blocked); + ingredientRow.add(ingredientListSlot); + } + this.guiIngredientSlots.add(ingredientRow); } - this.guiIngredientSlots.add(ingredientRow); } + return true; } diff --git a/src/main/java/mezz/jei/gui/recipes/RecipesGui.java b/src/main/java/mezz/jei/gui/recipes/RecipesGui.java index aabcfbc7..2f8c072d 100644 --- a/src/main/java/mezz/jei/gui/recipes/RecipesGui.java +++ b/src/main/java/mezz/jei/gui/recipes/RecipesGui.java @@ -15,6 +15,7 @@ import mezz.jei.gui.elements.DrawableNineSliceTexture; import mezz.jei.gui.elements.GuiIconButtonSmall; import mezz.jei.gui.ingredients.GuiIngredient; +import mezz.jei.gui.overlay.IngredientGridHistoryProvider; import mezz.jei.gui.overlay.IngredientListOverlay; import mezz.jei.ingredients.IngredientRegistry; import mezz.jei.input.ClickedIngredient; @@ -417,6 +418,8 @@ public void show(IFocus focus) { if (logic.setFocus(focus)) { open(); } + + IngredientGridHistoryProvider.onSetFocus(focus); } @Override diff --git a/src/main/java/mezz/jei/ingredients/IngredientListElementFactory.java b/src/main/java/mezz/jei/ingredients/IngredientListElementFactory.java index 83e5bd42..879845bf 100644 --- a/src/main/java/mezz/jei/ingredients/IngredientListElementFactory.java +++ b/src/main/java/mezz/jei/ingredients/IngredientListElementFactory.java @@ -15,7 +15,7 @@ import mezz.jei.startup.IModIdHelper; public final class IngredientListElementFactory { - private static final IngredientOrderTracker ORDER_TRACKER = new IngredientOrderTracker(); + public static final IngredientOrderTracker ORDER_TRACKER = new IngredientOrderTracker(); private IngredientListElementFactory() { } diff --git a/src/main/java/mezz/jei/render/CollapsedGroupRenderer.java b/src/main/java/mezz/jei/render/CollapsedGroupRenderer.java index 1fe80374..a95036d0 100644 --- a/src/main/java/mezz/jei/render/CollapsedGroupRenderer.java +++ b/src/main/java/mezz/jei/render/CollapsedGroupRenderer.java @@ -205,21 +205,28 @@ public void drawTooltip(Minecraft minecraft, int mouseX, int mouseY) { int total = ingredients.size(); int shown = Math.min(total, MAX_VISIBLE); int overflow = total - shown; + int overflowPadding = 0; int numRows = shown <= COLS ? 1 : shown <= COLS * 2 ? 2 : 3; int gridCols = numRows > 1 ? COLS : shown; int gridW = gridCols * SLOT; int gridH = numRows * SLOT; + if (overflow > 0) { + String overStr = "+" + overflow; + int overWidth = font.getStringWidth(overStr) + 2; + overflowPadding = Math.max(0, overWidth - SLOT); + } + String header = TextFormatting.GOLD + collapsedStack.getDisplayName() - + TextFormatting.GRAY + " (" + total + " items)"; + + TextFormatting.GRAY + " (" + total + " items)"; // In OPEN_GROUP mode, alt+click uses first item; show that as the hint. // In FIRST_ITEM mode, alt+click expands; show that instead. String hint = TextFormatting.YELLOW + Translator.translateToLocal( - Config.getCollapsedClickAction() == CollapsedClickAction.OPEN_GROUP - ? "hei.tooltip.collapsed.expand.firstItem" - : "hei.tooltip.collapsed.expand"); + Config.getCollapsedClickAction() == CollapsedClickAction.OPEN_GROUP + ? "hei.tooltip.collapsed.expand.firstItem" + : "hei.tooltip.collapsed.expand"); - int tw = Math.max(Math.max(font.getStringWidth(header), font.getStringWidth(hint)), gridW); + int tw = Math.max(Math.max(font.getStringWidth(header), font.getStringWidth(hint)), gridW) + overflowPadding; int th = 12 + gridH + 10; ScaledResolution sr = new ScaledResolution(minecraft); @@ -237,15 +244,15 @@ public void drawTooltip(Minecraft minecraft, int mouseX, int mouseY) { // Draw tooltip background (MC-style dark purple box with gradient border) final int z = 300; int bg = 0xF0100010, bs = 0x505000FF, be = (bs & 0xFEFEFE) >> 1 | (bs & 0xFF000000); - GuiUtils.drawGradientRect(z, tx-3, ty-4, tx+tw+3, ty-3, bg, bg); - GuiUtils.drawGradientRect(z, tx-3, ty+th+3, tx+tw+3, ty+th+4, bg, bg); - GuiUtils.drawGradientRect(z, tx-3, ty-3, tx+tw+3, ty+th+3, bg, bg); - GuiUtils.drawGradientRect(z, tx-4, ty-3, tx-3, ty+th+3, bg, bg); - GuiUtils.drawGradientRect(z, tx+tw+3, ty-3, tx+tw+4, ty+th+3, bg, bg); - GuiUtils.drawGradientRect(z, tx-3, ty-2, tx-2, ty+th+2, bs, be); - GuiUtils.drawGradientRect(z, tx+tw+2, ty-2, tx+tw+3, ty+th+2, bs, be); - GuiUtils.drawGradientRect(z, tx-3, ty-3, tx+tw+3, ty-2, bs, bs); - GuiUtils.drawGradientRect(z, tx-3, ty+th+2, tx+tw+3, ty+th+3, be, be); + GuiUtils.drawGradientRect(z, tx - 3, ty - 4, tx + tw + 3, ty - 3, bg, bg); + GuiUtils.drawGradientRect(z, tx - 3, ty + th + 3, tx + tw + 3, ty + th + 4, bg, bg); + GuiUtils.drawGradientRect(z, tx - 3, ty - 3, tx + tw + 3, ty + th + 3, bg, bg); + GuiUtils.drawGradientRect(z, tx - 4, ty - 3, tx - 3, ty + th + 3, bg, bg); + GuiUtils.drawGradientRect(z, tx + tw + 3, ty - 3, tx + tw + 4, ty + th + 3, bg, bg); + GuiUtils.drawGradientRect(z, tx - 3, ty - 2, tx - 2, ty + th + 2, bs, be); + GuiUtils.drawGradientRect(z, tx + tw + 2, ty - 2, tx + tw + 3, ty + th + 2, bs, be); + GuiUtils.drawGradientRect(z, tx - 3, ty - 3, tx + tw + 3, ty - 2, bs, bs); + GuiUtils.drawGradientRect(z, tx - 3, ty + th + 2, tx + tw + 3, ty + th + 3, be, be); // Title font.drawStringWithShadow(header, tx, ty, -1); @@ -265,8 +272,10 @@ public void drawTooltip(Minecraft minecraft, int mouseX, int mouseY) { if (ing instanceof ItemStack) { renderItem.renderItemAndEffectIntoGUI((ItemStack) ing, ix, iy); } else { - try { renderIngredient(minecraft, ix, iy, element); } - catch (RuntimeException | LinkageError ignored) {} + try { + renderIngredient(minecraft, ix, iy, element); + } catch (RuntimeException | LinkageError ignored) { + } } } RenderHelper.disableStandardItemLighting(); diff --git a/src/main/resources/assets/jei/lang/en_us.lang b/src/main/resources/assets/jei/lang/en_us.lang index ec43e52b..f7c3e3c7 100644 --- a/src/main/resources/assets/jei/lang/en_us.lang +++ b/src/main/resources/assets/jei/lang/en_us.lang @@ -189,6 +189,12 @@ config.jei.misc.hideBottomRightCornerConfigButton.comment=Whether to hide the bo config.jei.misc.hideBottomLeftCornerBookmarkButton=Hide Bottom-Left Corner Bookmark Button config.jei.misc.hideBottomLeftCornerBookmarkButton.comment=Whether to hide the bottom-left corner bookmark button +config.jei.misc.enableHistoryPanel=Enable History Panel +config.jei.misc.enableHistoryPanel.comment=Whether to enable the history panel + +config.jei.misc.isHistoryPanelOnLeft=Is History Panel On Left +config.jei.misc.isHistoryPanelOnLeft.comment=The history panel can be on either the left or the right (true=left, false=right) + config.hei.collapsible=Collapsible Groups config.hei.collapsible.comment=Options for collapsing groups of ingredients into a single slot in the ingredient list. config.hei.collapsible.collapsibleGroupsEnabled=Enable Collapsible Groups