Allow scrolling through recipe handlers (#379)

In addition to scrolling through all recipes of a single handler, you
can now scroll through all the recipe handlers while hovering over the
handler tab bar (or anywhere in the recipe area while holding left
shift).
This commit is contained in:
Wilhelm Schuster authored and GitHub committed 2023-05-09 21:57:27 +02:00
1 parent ad86d8f9c5
commit e8094794c3
2 files changed
+26 -2

No files matched your search

@@ -1,9 +1,13 @@
package codechicken.nei.recipe;
import static codechicken.lib.gui.GuiDraw.getMousePosition;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.input.Keyboard;
import codechicken.nei.Button;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.NEIClientUtils;
@@ -192,4 +196,22 @@ public class GuiRecipeTabs {
}
return false;
}
protected boolean mouseScrolled(int i) {
Point mPos = getMousePosition();
// Switch recipe handler tabs if either left shift is held or the tab
// bar is enable and the mouse cursor is positioned over said tab bar.
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)
|| (NEIClientConfig.areJEIStyleTabsVisible() && (mPos.x >= area.x && mPos.x <= (area.x + area.width)
&& mPos.y >= area.y
&& mPos.y <= (area.y + area.height)))) {
if (i < 0) guiRecipe.nextType();
else guiRecipe.prevType();
return true;
}
return false;
}
}