mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-12 08:27:37 +00:00
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:
1 parent
ad86d8f9c5
commit
e8094794c3
2 files changed
+26
-2
No files matched your search
@@ -388,6 +388,8 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
// the value of the height field will be different from in other mouseover methods, which
|
||||
// could be confusing...
|
||||
|
||||
if (recipeTabs.mouseScrolled(i)) return;
|
||||
|
||||
for (int recipe : getRecipeIndices()) if (handler.mouseScrolled(this, i, recipe)) return;
|
||||
|
||||
if (new Rectangle(guiLeft, guiTop, xSize, ySize).contains(GuiDraw.getMousePosition())) {
|
||||
@@ -462,11 +464,11 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
|
||||
if (page < 0) page = (handler.numRecipes() - 1) / getRecipesPerPage();
|
||||
}
|
||||
|
||||
private void nextType() {
|
||||
protected void nextType() {
|
||||
setRecipePage(++recipetype);
|
||||
}
|
||||
|
||||
private void prevType() {
|
||||
protected void prevType() {
|
||||
setRecipePage(--recipetype);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user