Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/java/mezz/jei/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/mezz/jei/config/ConfigValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> categoryUidOrder = new ArrayList<>();
Expand Down
70 changes: 52 additions & 18 deletions src/main/java/mezz/jei/gui/overlay/IngredientGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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);
Comment thread
tttsaurus marked this conversation as resolved.
}

public IngredientGrid(GridAlignment alignment) { // Left in for compatibility with JEI Utilities
this(new IngredientListBatchRenderer(), alignment);
this(new IngredientListBatchRenderer(), alignment, false);
}

public int size() {
Expand All @@ -78,23 +82,38 @@ public boolean updateBounds(Rectangle availableArea, int minWidth, Collection<Re
this.area = new Rectangle(x, y, width, height);
this.guiIngredientSlots.clear();

if (historyProvider.isEnabled()) {
historyProvider.updateColumns(columns);
historyProvider.clearHistorySlots();
}

if (rows == 0 || columns < Config.smallestNumColumns) {
return false;
}

for (int row = 0; row < rows; row++) {
List<IngredientListSlot> 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<IngredientListSlot> 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;
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
}
}
}
Expand Down Expand Up @@ -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
Expand Down
Loading