From 7250547e056dc4ed7ed12f5288b0c32bbfb2d10d Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 8 Dec 2015 16:27:46 -0800 Subject: [PATCH 1/5] Fix bottom row of items is hidden when item page is slightly past full --- src/main/java/mezz/jei/gui/ItemListOverlay.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/mezz/jei/gui/ItemListOverlay.java b/src/main/java/mezz/jei/gui/ItemListOverlay.java index 6b2297e51..c84fdc6e2 100644 --- a/src/main/java/mezz/jei/gui/ItemListOverlay.java +++ b/src/main/java/mezz/jei/gui/ItemListOverlay.java @@ -310,7 +310,7 @@ public boolean onKeyPressed(int keyCode) { private int getCountPerPage() { int xArea = width - (guiLeft + xSize + (2 * borderPadding)); - int yArea = height - (buttonHeight + (2 * borderPadding)); + int yArea = height - (buttonHeight + searchHeight + (4 * borderPadding)); int xCount = xArea / itemStackWidth; int yCount = yArea / itemStackHeight; From e7dec50621da79d4b93ee47487513159276cf55a Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 9 Dec 2015 01:59:35 -0800 Subject: [PATCH 2/5] Center the item stack list in the available space next to the gui --- .../java/mezz/jei/gui/ItemListOverlay.java | 47 +++++++++++-------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/src/main/java/mezz/jei/gui/ItemListOverlay.java b/src/main/java/mezz/jei/gui/ItemListOverlay.java index c84fdc6e2..2ba8a14f5 100644 --- a/src/main/java/mezz/jei/gui/ItemListOverlay.java +++ b/src/main/java/mezz/jei/gui/ItemListOverlay.java @@ -56,9 +56,9 @@ public class ItemListOverlay implements IShowsRecipeFocuses, IMouseHandler, IKey // properties of the gui we're beside private int guiLeft; - private int xSize; - private int width; - private int height; + private int guiXSize; + private int screenWidth; + private int screenHeight; private boolean open = false; private boolean enabled = true; @@ -69,9 +69,9 @@ public ItemListOverlay(ItemFilter itemFilter) { public void initGui(@Nonnull GuiContainer guiContainer) { this.guiLeft = guiContainer.guiLeft; - this.xSize = guiContainer.xSize; - this.width = guiContainer.width; - this.height = guiContainer.height; + this.guiXSize = guiContainer.xSize; + this.screenWidth = guiContainer.width; + this.screenHeight = guiContainer.height; String next = StatCollector.translateToLocal("jei.button.next"); String back = StatCollector.translateToLocal("jei.button.back"); @@ -81,14 +81,18 @@ public void initGui(@Nonnull GuiContainer guiContainer) { final int backButtonWidth = 10 + fontRenderer.getStringWidth(back); buttonHeight = 5 + fontRenderer.FONT_HEIGHT; - int rightEdge = createItemButtons(); + int columns = getColumns(); + int xSize = columns * itemStackWidth + (2 * itemStackPadding); + int xEmptySpace = screenWidth - guiLeft - guiXSize - xSize; - int leftEdge = this.guiLeft + this.xSize + borderPadding; + int leftEdge = guiLeft + guiXSize + (xEmptySpace / 2); + + int rightEdge = createItemButtons(leftEdge); nextButton = new GuiButtonExt(0, rightEdge - nextButtonWidth, 0, nextButtonWidth, buttonHeight, next); backButton = new GuiButtonExt(1, leftEdge, 0, backButtonWidth, buttonHeight, back); - searchField = new GuiTextField(0, fontRenderer, leftEdge, this.height - searchHeight - (2 * borderPadding), rightEdge - leftEdge, searchHeight); + searchField = new GuiTextField(0, fontRenderer, leftEdge, screenHeight - searchHeight - (2 * borderPadding), rightEdge - leftEdge, searchHeight); searchField.setMaxStringLength(maxSearchLength); setKeyboardFocus(false); searchField.setText(itemFilter.getFilterText()); @@ -97,17 +101,16 @@ public void initGui(@Nonnull GuiContainer guiContainer) { } // creates buttons and returns the x value of the right edge of the rightmost button - private int createItemButtons() { + private int createItemButtons(int xStart) { guiItemStacks.clear(); - final int xStart = guiLeft + xSize + borderPadding; final int yStart = buttonHeight + (2 * borderPadding); int x = xStart; int y = yStart; int maxX = 0; - while (y + itemStackHeight + borderPadding <= height - searchHeight) { + while (y + itemStackHeight + borderPadding <= screenHeight - searchHeight) { if (x > maxX) { maxX = x; } @@ -115,7 +118,7 @@ private int createItemButtons() { guiItemStacks.add(GuiItemStackGroup.createGuiItemStack(false, x, y, itemStackPadding)); x += itemStackWidth; - if (x + itemStackWidth + borderPadding > width) { + if (x + itemStackWidth + borderPadding > screenWidth) { x = xStart; y += itemStackHeight; } @@ -209,7 +212,7 @@ public void handleTick() { @Override public boolean isMouseOver(int mouseX, int mouseY) { - return isOpen() && (mouseX >= guiLeft + xSize); + return isOpen() && (mouseX >= guiLeft + guiXSize); } @Override @@ -308,14 +311,18 @@ public boolean onKeyPressed(int keyCode) { return false; } - private int getCountPerPage() { - int xArea = width - (guiLeft + xSize + (2 * borderPadding)); - int yArea = height - (buttonHeight + searchHeight + (4 * borderPadding)); + private int getColumns() { + int xArea = screenWidth - (guiLeft + guiXSize + (2 * borderPadding)); + return xArea / itemStackWidth; + } - int xCount = xArea / itemStackWidth; - int yCount = yArea / itemStackHeight; + private int getRows() { + int yArea = screenHeight - (buttonHeight + searchHeight + (4 * borderPadding)); + return yArea / itemStackHeight; + } - return xCount * yCount; + private int getCountPerPage() { + return getColumns() * getRows(); } private void updatePageCount() { From 7ddebe753e3005c25719607a5253fc4b00cbe586 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 9 Dec 2015 02:05:28 -0800 Subject: [PATCH 3/5] Make "all recipes" click area smaller --- src/main/java/mezz/jei/gui/RecipesGui.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/mezz/jei/gui/RecipesGui.java b/src/main/java/mezz/jei/gui/RecipesGui.java index 712d563ec..2e0d2fba1 100644 --- a/src/main/java/mezz/jei/gui/RecipesGui.java +++ b/src/main/java/mezz/jei/gui/RecipesGui.java @@ -161,12 +161,14 @@ public boolean handleMouseClicked(int mouseX, int mouseY, int mouseButton) { Log.error("IOException on mouse click.", e); } - if (!guiActionPerformed && (mouseY < guiTop + titleHeight)) { - boolean success = logic.setCategoryFocus(); - if (success) { - updateLayout(); + if (!guiActionPerformed) { + if ((mouseY < guiTop + titleHeight) && (mouseX > guiLeft + borderPadding + buttonWidth + 12) && (mouseX < guiLeft + xSize - borderPadding - buttonWidth - 12)) { + boolean success = logic.setCategoryFocus(); + if (success) { + updateLayout(); + } + return success; } - return success; } return guiActionPerformed; From 7e4eabf8c220c294942bbbda8da5cf4a9f850842 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 9 Dec 2015 03:03:22 -0800 Subject: [PATCH 4/5] Save recipe viewing history, go back with backspace --- src/main/java/mezz/jei/gui/Focus.java | 84 ++++++---- .../java/mezz/jei/gui/IRecipeGuiLogic.java | 4 +- .../java/mezz/jei/gui/ItemListOverlay.java | 2 +- .../java/mezz/jei/gui/RecipeGuiLogic.java | 146 +++++++++++------- src/main/java/mezz/jei/gui/RecipeLayout.java | 4 +- src/main/java/mezz/jei/gui/RecipesGui.java | 12 +- .../jei/gui/ingredients/GuiIngredient.java | 8 +- .../gui/ingredients/GuiIngredientGroup.java | 9 +- .../jei/gui/ingredients/IGuiIngredient.java | 4 +- .../java/mezz/jei/input/InputHandler.java | 3 + 10 files changed, 173 insertions(+), 103 deletions(-) diff --git a/src/main/java/mezz/jei/gui/Focus.java b/src/main/java/mezz/jei/gui/Focus.java index 78f65902d..b525a78b0 100644 --- a/src/main/java/mezz/jei/gui/Focus.java +++ b/src/main/java/mezz/jei/gui/Focus.java @@ -3,6 +3,7 @@ import com.google.common.collect.ImmutableList; import javax.annotation.Nonnull; +import java.util.List; import net.minecraft.item.ItemStack; @@ -12,8 +13,14 @@ import mezz.jei.api.recipe.IRecipeCategory; public class Focus { + public enum Mode { + INPUT, OUTPUT, NONE + } + private final ItemStack stack; private final Fluid fluid; + @Nonnull + private Mode mode = Mode.NONE; public Focus() { this.stack = null; @@ -55,52 +62,63 @@ public boolean isBlank() { return stack == null && fluid == null; } - @Override - public boolean equals(Object obj) { - if (!(obj instanceof Focus)) { - return false; - } - Focus other = (Focus) obj; - return ItemStack.areItemStacksEqual(this.stack, other.getStack()) && fluid == other.fluid; + public void setMode(@Nonnull Mode mode) { + this.mode = mode; } @Nonnull - public ImmutableList getCategoriesWithInput() { - if (stack != null) { - return JEIManager.recipeRegistry.getRecipeCategoriesWithInput(stack); - } else { - return JEIManager.recipeRegistry.getRecipeCategoriesWithInput(fluid); - } + public Mode getMode() { + return mode; } - @Nonnull - public ImmutableList getCategoriesWithOutput() { - if (stack != null) { - return JEIManager.recipeRegistry.getRecipeCategoriesWithOutput(stack); - } else { - return JEIManager.recipeRegistry.getRecipeCategoriesWithOutput(fluid); + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Focus)) { + return false; } + Focus other = (Focus) obj; + return ItemStack.areItemStacksEqual(this.stack, other.getStack()) && fluid == other.fluid && mode == other.mode; } @Nonnull - public ImmutableList getRecipesWithInput(IRecipeCategory recipeCategory) { - if (stack != null) { - return JEIManager.recipeRegistry.getRecipesWithInput(recipeCategory, stack); - } else { - return JEIManager.recipeRegistry.getRecipesWithInput(recipeCategory, fluid); + public ImmutableList getCategories() { + switch (mode) { + case INPUT: { + if (stack != null) { + return JEIManager.recipeRegistry.getRecipeCategoriesWithInput(stack); + } else { + return JEIManager.recipeRegistry.getRecipeCategoriesWithInput(fluid); + } + } + case OUTPUT: { + if (stack != null) { + return JEIManager.recipeRegistry.getRecipeCategoriesWithOutput(stack); + } else { + return JEIManager.recipeRegistry.getRecipeCategoriesWithOutput(fluid); + } + } } + return JEIManager.recipeRegistry.getRecipeCategories(); } @Nonnull - public ImmutableList getRecipesWithOutput(IRecipeCategory recipeCategory) { - if (stack != null) { - return JEIManager.recipeRegistry.getRecipesWithOutput(recipeCategory, stack); - } else { - return JEIManager.recipeRegistry.getRecipesWithOutput(recipeCategory, fluid); + public List getRecipes(IRecipeCategory recipeCategory) { + switch (mode) { + case INPUT: { + if (stack != null) { + return JEIManager.recipeRegistry.getRecipesWithInput(recipeCategory, stack); + } else { + return JEIManager.recipeRegistry.getRecipesWithInput(recipeCategory, fluid); + } + } + case OUTPUT: { + if (stack != null) { + return JEIManager.recipeRegistry.getRecipesWithOutput(recipeCategory, stack); + } else { + return JEIManager.recipeRegistry.getRecipesWithOutput(recipeCategory, fluid); + } + } } - } - - public enum Mode { - INPUT, OUTPUT, NONE + return JEIManager.recipeRegistry.getRecipes(recipeCategory); } } diff --git a/src/main/java/mezz/jei/gui/IRecipeGuiLogic.java b/src/main/java/mezz/jei/gui/IRecipeGuiLogic.java index e06f1a17e..824d58b8d 100644 --- a/src/main/java/mezz/jei/gui/IRecipeGuiLogic.java +++ b/src/main/java/mezz/jei/gui/IRecipeGuiLogic.java @@ -25,7 +25,9 @@ public interface IRecipeGuiLogic { void nextPage(); - boolean setFocus(@Nonnull Focus focus, @Nonnull Focus.Mode focusMode); + boolean setFocus(@Nonnull Focus focus); + + boolean back(); boolean setCategoryFocus(); diff --git a/src/main/java/mezz/jei/gui/ItemListOverlay.java b/src/main/java/mezz/jei/gui/ItemListOverlay.java index 2ba8a14f5..61046ec03 100644 --- a/src/main/java/mezz/jei/gui/ItemListOverlay.java +++ b/src/main/java/mezz/jei/gui/ItemListOverlay.java @@ -140,7 +140,7 @@ private void updateLayout() { itemButton.clear(); } else { ItemStack stack = itemList.get(i).getItemStack(); - itemButton.set(stack, new Focus(), Focus.Mode.NONE); + itemButton.set(stack, new Focus()); } i++; } diff --git a/src/main/java/mezz/jei/gui/RecipeGuiLogic.java b/src/main/java/mezz/jei/gui/RecipeGuiLogic.java index a46531426..ed441bae4 100644 --- a/src/main/java/mezz/jei/gui/RecipeGuiLogic.java +++ b/src/main/java/mezz/jei/gui/RecipeGuiLogic.java @@ -3,9 +3,11 @@ import com.google.common.collect.ImmutableList; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Stack; import net.minecraft.client.Minecraft; import net.minecraft.inventory.Container; @@ -18,12 +20,27 @@ import mezz.jei.util.MathUtil; public class RecipeGuiLogic implements IRecipeGuiLogic { - /* Whether this GUI is dispzzlaying input or output recipes */ - private Focus.Mode focusMode; + private static class State { + /* The focus of this GUI */ + @Nonnull + public final Focus focus; + public int recipeCategoryIndex; + public int pageIndex; + + public State(@Nonnull Focus focus, int recipeCategoryIndex, int pageIndex) { + this.focus = focus; + this.recipeCategoryIndex = recipeCategoryIndex; + this.pageIndex = pageIndex; + } + } - /* The focus of this GUI */ + /* The current state of this GUI */ + @Nullable + private State state = null; + + /* The previous states of this GUI */ @Nonnull - private Focus focus = new Focus(); + private Stack history = new Stack<>(); /* List of Recipe Categories that involve the focus */ @Nonnull @@ -34,46 +51,54 @@ public class RecipeGuiLogic implements IRecipeGuiLogic { private List recipes = Collections.emptyList(); private int recipesPerPage = 0; - private int recipeCategoryIndex = 0; - private int pageIndex = 0; @Override - public boolean setFocus(@Nonnull Focus focus, @Nonnull Focus.Mode focusMode) { - if (this.focus.equals(focus) && this.focusMode == focusMode) { + public boolean setFocus(@Nonnull Focus focus) { + return setFocus(focus, true); + } + + @Override + public boolean back() { + if (history.empty()) { + return false; + } + State state = history.pop(); + if (setFocus(state.focus, false)) { + this.state = state; return true; } + return false; + } - ImmutableList types = null; - switch (focusMode) { - case INPUT: - types = focus.getCategoriesWithInput(); - break; - case OUTPUT: - types = focus.getCategoriesWithOutput(); - break; + private boolean setFocus(@Nonnull Focus focus, boolean saveHistory) { + if (this.state != null && this.state.focus.equals(focus)) { + return true; } + + ImmutableList types = focus.getCategories(); if (types.isEmpty()) { return false; } this.recipeCategories = types; - this.focus = focus; - this.focusMode = focusMode; - - this.recipeCategoryIndex = 0; - this.pageIndex = 0; + int recipeCategoryIndex = 0; Container container = Minecraft.getMinecraft().thePlayer.openContainer; if (container != null) { for (int i = 0; i < recipeCategories.size(); i++) { IRecipeCategory recipeCategory = recipeCategories.get(i); if (JEIManager.recipeRegistry.getRecipeTransferHelper(container, recipeCategory) != null) { - this.recipeCategoryIndex = i; + recipeCategoryIndex = i; break; } } } + if (this.state != null && saveHistory) { + history.push(this.state); + } + this.state = new State(focus, recipeCategoryIndex, 0); + updateRecipes(); return true; @@ -86,15 +111,18 @@ public boolean setCategoryFocus() { return false; } - if (this.focus.isBlank()) { - return false; + if (this.state != null) { + if (this.state.focus.isBlank()) { + return false; + } + history.push(this.state); } this.recipeCategories = JEIManager.recipeRegistry.getRecipeCategories(); - this.focus = new Focus(); - this.recipeCategoryIndex = this.recipeCategories.indexOf(recipeCategory); - this.pageIndex = 0; + int recipeCategoryIndex = this.recipeCategories.indexOf(recipeCategory); + + this.state = new State(new Focus(), recipeCategoryIndex, 0); updateRecipes(); @@ -103,9 +131,12 @@ public boolean setCategoryFocus() { @Override public void setRecipesPerPage(int recipesPerPage) { + if (state == null) { + return; + } if (this.recipesPerPage != recipesPerPage) { - int recipeIndex = pageIndex * this.recipesPerPage; - this.pageIndex = recipeIndex / recipesPerPage; + int recipeIndex = state.pageIndex * this.recipesPerPage; + state.pageIndex = recipeIndex / recipesPerPage; this.recipesPerPage = recipesPerPage; updateRecipes(); @@ -113,32 +144,28 @@ public void setRecipesPerPage(int recipesPerPage) { } private void updateRecipes() { - IRecipeCategory recipeCategory = getRecipeCategory(); - if (focus.isBlank()) { - recipes = JEIManager.recipeRegistry.getRecipes(recipeCategory); - } else { - switch (focusMode) { - case INPUT: - recipes = focus.getRecipesWithInput(recipeCategory); - break; - case OUTPUT: - recipes = focus.getRecipesWithOutput(recipeCategory); - break; - } + if (state == null) { + return; } + IRecipeCategory recipeCategory = getRecipeCategory(); + recipes = state.focus.getRecipes(recipeCategory); } @Override public IRecipeCategory getRecipeCategory() { - if (recipeCategories.size() == 0) { + if (state == null || recipeCategories.size() == 0) { return null; } - return recipeCategories.get(recipeCategoryIndex); + return recipeCategories.get(state.recipeCategoryIndex); } @Override @Nonnull public List getRecipeWidgets(int posX, int posY, int spacingY) { + if (state == null) { + return Collections.emptyList(); + } + List recipeWidgets = new ArrayList<>(); IRecipeCategory recipeCategory = getRecipeCategory(); @@ -147,7 +174,7 @@ public List getRecipeWidgets(int posX, int posY, int spacingY) { } int recipeWidgetIndex = 0; - for (int recipeIndex = pageIndex * recipesPerPage; recipeIndex < recipes.size() && recipeWidgets.size() < recipesPerPage; recipeIndex++) { + for (int recipeIndex = state.pageIndex * recipesPerPage; recipeIndex < recipes.size() && recipeWidgets.size() < recipesPerPage; recipeIndex++) { Object recipe = recipes.get(recipeIndex); IRecipeHandler recipeHandler = JEIManager.recipeRegistry.getRecipeHandler(recipe.getClass()); if (recipeHandler == null) { @@ -158,7 +185,7 @@ public List getRecipeWidgets(int posX, int posY, int spacingY) { @SuppressWarnings("unchecked") IRecipeWrapper recipeWrapper = recipeHandler.getRecipeWrapper(recipe); - RecipeLayout recipeWidget = new RecipeLayout(recipeWidgetIndex++, posX, posY, recipeCategory, recipeWrapper, focus, focusMode); + RecipeLayout recipeWidget = new RecipeLayout(recipeWidgetIndex++, posX, posY, recipeCategory, recipeWrapper, state.focus); recipeWidgets.add(recipeWidget); posY += spacingY; @@ -169,9 +196,12 @@ public List getRecipeWidgets(int posX, int posY, int spacingY) { @Override public void nextRecipeCategory() { + if (state == null) { + return; + } int recipesTypesCount = recipeCategories.size(); - recipeCategoryIndex = (recipeCategoryIndex + 1) % recipesTypesCount; - pageIndex = 0; + state.recipeCategoryIndex = (state.recipeCategoryIndex + 1) % recipesTypesCount; + state.pageIndex = 0; updateRecipes(); } @@ -182,23 +212,32 @@ public boolean hasMultiplePages() { @Override public void previousRecipeCategory() { + if (state == null) { + return; + } int recipesTypesCount = recipeCategories.size(); - recipeCategoryIndex = (recipesTypesCount + recipeCategoryIndex - 1) % recipesTypesCount; - pageIndex = 0; + state.recipeCategoryIndex = (recipesTypesCount + state.recipeCategoryIndex - 1) % recipesTypesCount; + state.pageIndex = 0; updateRecipes(); } @Override public void nextPage() { + if (state == null) { + return; + } int pageCount = pageCount(recipesPerPage); - pageIndex = (pageIndex + 1) % pageCount; + state.pageIndex = (state.pageIndex + 1) % pageCount; updateRecipes(); } @Override public void previousPage() { + if (state == null) { + return; + } int pageCount = pageCount(recipesPerPage); - pageIndex = (pageCount + pageIndex - 1) % pageCount; + state.pageIndex = (pageCount + state.pageIndex - 1) % pageCount; updateRecipes(); } @@ -213,7 +252,10 @@ private int pageCount(int recipesPerPage) { @Override @Nonnull public String getPageString() { - return (pageIndex + 1) + "/" + pageCount(recipesPerPage); + if (state == null) { + return "1/1"; + } + return (state.pageIndex + 1) + "/" + pageCount(recipesPerPage); } @Override diff --git a/src/main/java/mezz/jei/gui/RecipeLayout.java b/src/main/java/mezz/jei/gui/RecipeLayout.java index 4c75c84e1..51df3c6c8 100644 --- a/src/main/java/mezz/jei/gui/RecipeLayout.java +++ b/src/main/java/mezz/jei/gui/RecipeLayout.java @@ -34,7 +34,7 @@ public class RecipeLayout implements IRecipeLayout { private final int posX; private final int posY; - public RecipeLayout(int index, int posX, int posY, @Nonnull IRecipeCategory recipeCategory, @Nonnull IRecipeWrapper recipeWrapper, @Nonnull Focus focus, @Nonnull Focus.Mode focusMode) { + public RecipeLayout(int index, int posX, int posY, @Nonnull IRecipeCategory recipeCategory, @Nonnull IRecipeWrapper recipeWrapper, @Nonnull Focus focus) { this.recipeCategory = recipeCategory; this.guiItemStackGroup = new GuiItemStackGroup(); this.guiFluidStackGroup = new GuiFluidStackGroup(); @@ -45,7 +45,7 @@ public RecipeLayout(int index, int posX, int posY, @Nonnull IRecipeCategory reci this.posY = posY; this.recipeWrapper = recipeWrapper; - this.guiItemStackGroup.setFocus(focus, focusMode); + this.guiItemStackGroup.setFocus(focus); this.recipeCategory.setRecipe(this, recipeWrapper); } diff --git a/src/main/java/mezz/jei/gui/RecipesGui.java b/src/main/java/mezz/jei/gui/RecipesGui.java index 2e0d2fba1..f3630d581 100644 --- a/src/main/java/mezz/jei/gui/RecipesGui.java +++ b/src/main/java/mezz/jei/gui/RecipesGui.java @@ -208,19 +208,27 @@ public boolean isOpen() { } public void showRecipes(@Nonnull Focus focus) { - if (logic.setFocus(focus, Focus.Mode.OUTPUT)) { + focus.setMode(Focus.Mode.OUTPUT); + if (logic.setFocus(focus)) { updateLayout(); open(); } } public void showUses(@Nonnull Focus focus) { - if (logic.setFocus(focus, Focus.Mode.INPUT)) { + focus.setMode(Focus.Mode.INPUT); + if (logic.setFocus(focus)) { updateLayout(); open(); } } + public void back() { + if (logic.back()) { + updateLayout(); + } + } + @Override protected void actionPerformed(@Nonnull GuiButton guibutton) { boolean updateLayout = true; diff --git a/src/main/java/mezz/jei/gui/ingredients/GuiIngredient.java b/src/main/java/mezz/jei/gui/ingredients/GuiIngredient.java index 771d09f20..1cbfd766d 100644 --- a/src/main/java/mezz/jei/gui/ingredients/GuiIngredient.java +++ b/src/main/java/mezz/jei/gui/ingredients/GuiIngredient.java @@ -78,16 +78,16 @@ public List getAll() { } @Override - public void set(@Nonnull T contained, @Nonnull Focus focus, @Nonnull Focus.Mode focusMode) { - set(Collections.singleton(contained), focus, focusMode); + public void set(@Nonnull T contained, @Nonnull Focus focus) { + set(Collections.singleton(contained), focus); } @Override - public void set(@Nonnull Collection contained, @Nonnull Focus focus, @Nonnull Focus.Mode focusMode) { + public void set(@Nonnull Collection contained, @Nonnull Focus focus) { this.contained.clear(); contained = ingredientHelper.expandSubtypes(contained); T match = null; - if ((isInput() && focusMode == Focus.Mode.INPUT) || (!isInput() && focusMode == Focus.Mode.OUTPUT)) { + if ((isInput() && focus.getMode() == Focus.Mode.INPUT) || (!isInput() && focus.getMode() == Focus.Mode.OUTPUT)) { match = ingredientHelper.getMatch(contained, focus); } if (match != null) { diff --git a/src/main/java/mezz/jei/gui/ingredients/GuiIngredientGroup.java b/src/main/java/mezz/jei/gui/ingredients/GuiIngredientGroup.java index 28dbdd726..c7762beb5 100644 --- a/src/main/java/mezz/jei/gui/ingredients/GuiIngredientGroup.java +++ b/src/main/java/mezz/jei/gui/ingredients/GuiIngredientGroup.java @@ -16,26 +16,23 @@ public abstract class GuiIngredientGroup> implemen protected final Map guiIngredients = new HashMap<>(); @Nonnull protected Focus focus = new Focus(); - @Nonnull - protected Focus.Mode focusMode = Focus.Mode.OUTPUT; /** * If focus is set and any of the guiIngredients contains focus * they will only display focus instead of rotating through all their values. */ - public void setFocus(@Nonnull Focus focus, @Nonnull Focus.Mode focusMode) { + public void setFocus(@Nonnull Focus focus) { this.focus = focus; - this.focusMode = focusMode; } @Override public void set(int slotIndex, @Nonnull Collection values) { - guiIngredients.get(slotIndex).set(values, focus, focusMode); + guiIngredients.get(slotIndex).set(values, focus); } @Override public void set(int slotIndex, @Nonnull V value) { - guiIngredients.get(slotIndex).set(value, focus, focusMode); + guiIngredients.get(slotIndex).set(value, focus); } @Nonnull diff --git a/src/main/java/mezz/jei/gui/ingredients/IGuiIngredient.java b/src/main/java/mezz/jei/gui/ingredients/IGuiIngredient.java index 7d7bef139..03f79374b 100644 --- a/src/main/java/mezz/jei/gui/ingredients/IGuiIngredient.java +++ b/src/main/java/mezz/jei/gui/ingredients/IGuiIngredient.java @@ -10,9 +10,9 @@ import mezz.jei.gui.Focus; public interface IGuiIngredient { - void set(@Nonnull T contained, @Nonnull Focus focus, @Nonnull Focus.Mode focusMode); + void set(@Nonnull T contained, @Nonnull Focus focus); - void set(@Nonnull Collection contained, @Nonnull Focus focus, @Nonnull Focus.Mode focusMode); + void set(@Nonnull Collection contained, @Nonnull Focus focus); void clear(); diff --git a/src/main/java/mezz/jei/input/InputHandler.java b/src/main/java/mezz/jei/input/InputHandler.java index 3d7e4930d..d31f11aea 100644 --- a/src/main/java/mezz/jei/input/InputHandler.java +++ b/src/main/java/mezz/jei/input/InputHandler.java @@ -215,6 +215,9 @@ private boolean handleKeyDown(int eventKey) { } else if (eventKey == Keyboard.KEY_F && GuiScreen.isCtrlKeyDown()) { itemListOverlay.setKeyboardFocus(true); return true; + } else if (eventKey == Keyboard.KEY_BACK) { + recipesGui.back(); + return true; } for (IKeyable keyable : keyables) { From b0474ec0427c5a6afee8ccc8e89c38d9cdb84ff0 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 9 Dec 2015 03:04:11 -0800 Subject: [PATCH 5/5] bump version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 1fc40f042..8b12a470c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,5 +2,5 @@ mcversion=1.8 forgeversion=11.14.4.1577 version_major=1 -version_minor=4 +version_minor=5 version_patch=0