Adjust recipe handler scrolling again (#393)

* Update buildscript

* Rework recipe handler tab scrolling again

Move the recipe handler tab scrolling before the handler-specific
scrolling again. This ensures that tab scrolling while hovering over the
tab bar will always be possible, regardless of how a recipe handler
handles scrolling itself. This mostly reverts back to how this feature
was implemented originally with one change: the Shift-scrolling behavior
is moved outside the recipe tabs scroll handler after the recipe
handler-specific scroll handling to prevent this from overwriting any
other behavior.
This commit is contained in:
Wilhelm Schuster authored and GitHub committed 2023-06-24 12:01:21 +02:00
1 parent f3aa12483d
commit 1ab3350eb8
3 files changed
+24 -16

No files matched your search

@@ -388,10 +388,22 @@ 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...
for (int recipe : getRecipeIndices()) if (handler.mouseScrolled(this, i, recipe)) return;
// First, invoke scroll handling over recipe handler tabbar. Makes sure it is not overwritten by recipe
// handler-specific scroll behavior.
if (recipeTabs.mouseScrolled(i)) return;
for (int recipe : getRecipeIndices()) if (handler.mouseScrolled(this, i, recipe)) return;
// If shift is held, try switching to the next recipe handler. Replicates the GuiRecipeTabs.mouseScrolled()
// without the checking for the cursor being inside the tabbar.
if (NEIClientUtils.shiftKey()) {
if (i < 0) nextType();
else prevType();
return;
}
// Finally, if nothing else has handled scrolling, try changing to the next recipe page.
if (new Rectangle(guiLeft, guiTop, xSize, ySize).contains(GuiDraw.getMousePosition())) {
if (i > 0) prevPage();
else nextPage();
@@ -6,8 +6,6 @@ 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;
@@ -200,12 +198,8 @@ public class GuiRecipeTabs {
protected boolean mouseScrolled(int i) {
Point mousePosition = 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()
&& (mousePosition.x >= area.x && mousePosition.x <= (area.x + area.width)
&& mousePosition.y >= area.y
&& mousePosition.y <= (area.y + area.height)))) {
// Switch between recipe handlers if the cursor is over the tabbar.
if (NEIClientConfig.areJEIStyleTabsVisible() && area.contains(mousePosition)) {
if (i < 0) guiRecipe.nextType();
else guiRecipe.prevType();