From 5317fe49f4de0c8b924d01a466b4710378a2179c Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 10 Nov 2015 19:11:03 -0800 Subject: [PATCH] Fix the 'O' hotkey to toggle item overlay --- src/main/java/mezz/jei/gui/ItemListOverlay.java | 16 ++++++++++------ src/main/java/mezz/jei/input/InputHandler.java | 3 +++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/mezz/jei/gui/ItemListOverlay.java b/src/main/java/mezz/jei/gui/ItemListOverlay.java index cf6033f81..2e240f45d 100644 --- a/src/main/java/mezz/jei/gui/ItemListOverlay.java +++ b/src/main/java/mezz/jei/gui/ItemListOverlay.java @@ -55,7 +55,8 @@ public class ItemListOverlay implements IShowsItemStacks, IClickable, IKeyable { private int width; private int height; - private boolean isOpen = false; + private boolean open = false; + private boolean enabled = true; public ItemListOverlay(ItemFilter itemFilter) { this.itemFilter = itemFilter; @@ -169,7 +170,7 @@ private void backPage() { } public void drawScreen(@Nonnull Minecraft minecraft, int mouseX, int mouseY) { - if (!isOpen) { + if (!isOpen()) { return; } @@ -202,7 +203,7 @@ public void handleTick() { @Override @Nullable public ItemStack getStackUnderMouse(int mouseX, int mouseY) { - if (!isOpen) { + if (!isOpen()) { return null; } for (GuiItemStack guiItemStack : guiItemStacks) { @@ -294,19 +295,22 @@ private void setPageNum(int pageNum) { @Override public void open() { - isOpen = true; + open = true; searchField.setFocused(false); } @Override public void close() { - isOpen = false; + open = false; searchField.setFocused(false); } @Override public boolean isOpen() { - return isOpen; + return open && enabled; } + public void toggleEnabled() { + enabled = !enabled; + } } diff --git a/src/main/java/mezz/jei/input/InputHandler.java b/src/main/java/mezz/jei/input/InputHandler.java index 50cf84c95..750efe85a 100644 --- a/src/main/java/mezz/jei/input/InputHandler.java +++ b/src/main/java/mezz/jei/input/InputHandler.java @@ -192,6 +192,9 @@ private boolean handleKeyDown(int eventKey) { recipesGui.showUses(itemStack); return true; } + } else if (eventKey == KeyBindings.toggleOverlay.getKeyCode()) { + itemListOverlay.toggleEnabled(); + return false; } for (IKeyable keyable : keyables) {