Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.10-SNAPSHOT" apply false
id "me.modmuss50.mod-publish-plugin" version "2.0.0-beta.2"
id "me.modmuss50.mod-publish-plugin" version "2.1.0"
}

apply from: 'https://raw.githubusercontent.com/FTBTeam/mods-meta/main/gradle/changelog.gradle'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,13 @@ public void onEnterPressed() {
}

@Override
public boolean mouseScrolled(double scroll) {
return config.scrollValue(currentValue, scroll > 0).map(v -> {
public boolean mouseScrolled(double mouseX, double mouseY, double xDelta, double yDelta) {
var directionlessDelta = xDelta != 0 ? xDelta : yDelta;
return config.scrollValue(currentValue, directionlessDelta > 0).map(v -> {
textBox.setText(config.getStringFromValue(v));
Comment thread
MichaelHillcox marked this conversation as resolved.
textBox.setSelectionPos(textBox.getCursorPos());
return true;
}).orElse(super.mouseScrolled(scroll));
}).orElse(super.mouseScrolled(mouseX, mouseY, xDelta, yDelta));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package dev.ftb.mods.ftblibrary.config.ui.resource;

import com.google.common.base.Stopwatch;
import com.mojang.datafixers.util.Pair;
import dev.ftb.mods.ftblibrary.FTBLibrary;
import dev.ftb.mods.ftblibrary.config.ConfigCallback;
import dev.ftb.mods.ftblibrary.config.ResourceConfigValue;
Expand All @@ -21,6 +19,8 @@
import dev.ftb.mods.ftblibrary.ui.misc.SimpleToast;
import dev.ftb.mods.ftblibrary.util.SearchTerms;
import dev.ftb.mods.ftblibrary.util.TooltipList;
import com.google.common.base.Stopwatch;
import com.mojang.datafixers.util.Pair;
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -347,13 +347,15 @@ public CountTextBox() {
}

@Override
public boolean mouseScrolled(double scroll) {
public boolean mouseScrolled(double mouseX, double mouseY, double xDelta, double yDelta) {
if (!isMouseOver) return false;

var directionlessDelta = xDelta != 0 ? xDelta : yDelta;
if (isShiftKeyDown()) {
int adj = scroll > 0 ? getCount() : -getCount() / 2;
int adj = directionlessDelta > 0 ? getCount() : -getCount() / 2;
adjust(adj);
Comment thread
MichaelHillcox marked this conversation as resolved.
} else {
adjust((int) Math.signum(scroll));
adjust((int) Math.signum(directionlessDelta));
}
return true;
}
Expand Down
10 changes: 5 additions & 5 deletions common/src/main/java/dev/ftb/mods/ftblibrary/ui/BaseScreen.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package dev.ftb.mods.ftblibrary.ui;

import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.platform.Window;
import dev.ftb.mods.ftblibrary.icon.Color4I;
import dev.ftb.mods.ftblibrary.ui.input.Key;
import dev.ftb.mods.ftblibrary.ui.input.KeyModifiers;
Expand All @@ -10,6 +8,8 @@
import dev.ftb.mods.ftblibrary.util.BooleanConsumer;
import dev.ftb.mods.ftblibrary.util.TooltipList;
import dev.ftb.mods.ftblibrary.util.client.ClientUtils;
import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.platform.Window;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.ChatScreen;
Expand Down Expand Up @@ -468,11 +468,11 @@ public void mouseReleased(MouseButton button) {
}

@Override
public boolean mouseScrolled(double scroll) {
if (focusedWidget != null && focusedWidget.mouseScrolled(scroll)) {
public boolean mouseScrolled(double mouseX, double mouseY, double xDelta, double yDelta) {
if (focusedWidget != null && focusedWidget.mouseScrolled(mouseX, mouseY, xDelta, yDelta)) {
return true;
}
return modalPanels.isEmpty() ? super.mouseScrolled(scroll) : modalPanels.peekFirst().mouseScrolled(scroll);
return modalPanels.isEmpty() ? super.mouseScrolled(mouseX, mouseY, xDelta, yDelta) : modalPanels.peekFirst().mouseScrolled(mouseX, mouseY, xDelta, yDelta);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ public void onTextChanged() {
this.scrollBar = new PanelScrollBar(this, ScrollBar.Plane.VERTICAL, mainPanel);
}

@Override
public boolean scrollPanel(double scroll) {
return super.scrollPanel(scroll);
}

@Override
public void addWidgets() {
add(textBox);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ public void setMinMax(int min, int max) {
}

@Override
public boolean mouseScrolled(double scroll) {
public boolean mouseScrolled(double mouseX, double mouseY, double xDelta, double yDelta) {
var directionlessDelta = xDelta != 0 ? xDelta : yDelta;

if (allowInput()) {
setAmount(getIntValue() + (int) scroll);
setAmount(getIntValue() + (int) directionlessDelta);
return true;
Comment thread
MichaelHillcox marked this conversation as resolved.
}
return false;
Expand All @@ -69,4 +71,4 @@ public void ensureValue() {
setAmount(max);
}
}
}
}
26 changes: 15 additions & 11 deletions common/src/main/java/dev/ftb/mods/ftblibrary/ui/Panel.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,19 +331,19 @@ public void mouseReleased(MouseButton button) {
}

@Override
public boolean mouseScrolled(double scroll) {
public boolean mouseScrolled(double mouseX, double mouseY, double xDelta, double yDelta) {
setOffset(true);

for (var i = widgets.size() - 1; i >= 0; i--) {
var widget = widgets.get(i);

if (widget.isEnabled() && widget.mouseScrolled(scroll)) {
if (widget.isEnabled() && widget.mouseScrolled(mouseX, mouseY, xDelta, yDelta)) {
setOffset(false);
return true;
}
}

var scrollPanel = scrollPanel(scroll);
var scrollPanel = scrollPanel(xDelta, yDelta);
setOffset(false);
return scrollPanel;
}
Expand All @@ -365,15 +365,23 @@ public boolean mouseDragged(int button, double dragX, double dragY) {
return false;
}

public boolean scrollPanel(double scroll) {
public boolean scrollPanel(double xDelta, double yDelta) {
if (attachedScrollbar != null || !isMouseOver()) {
return false;
}

if (isDefaultScrollVertical() != isShiftKeyDown()) {
return movePanelScroll(0, -getScrollStep() * scroll);
// No scroll direction was given?
var directionlessDelta = yDelta != 0 ? yDelta : xDelta;
if (directionlessDelta == 0) {
return false;
}

// If the user is pressing shift, we'll always attempt to scroll horizontally, otherwise we'll just blindly apply both directions
if (isShiftKeyDown()) {
var scrollAmount = -getScrollStep() * directionlessDelta;
return movePanelScroll(scrollAmount, 0);
} else {
return movePanelScroll(-getScrollStep() * scroll, 0);
return movePanelScroll(-getScrollStep() * xDelta, -getScrollStep() * yDelta);
}
}

Expand Down Expand Up @@ -404,10 +412,6 @@ public boolean movePanelScroll(double dx, double dy) {
return getScrollX() != sx || getScrollY() != sy;
}

public boolean isDefaultScrollVertical() {
return true;
}

public double getScrollStep() {
return scrollStep;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package dev.ftb.mods.ftblibrary.ui;

import dev.architectury.platform.Platform;
import dev.ftb.mods.ftblibrary.ui.input.Key;
import dev.ftb.mods.ftblibrary.ui.input.KeyModifiers;
import dev.ftb.mods.ftblibrary.ui.input.MouseButton;
import dev.ftb.mods.ftblibrary.util.TooltipList;
import dev.architectury.platform.Platform;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -53,7 +53,9 @@ public boolean mouseReleased(double x, double y, int button) {

@Override
public boolean mouseScrolled(double x, double y, double dirX, double dirY) {
return wrappedGui.mouseScrolled(dirY) || super.mouseScrolled(x, y, dirX, dirY);
return wrappedGui.mouseScrolled(x, y, dirX, dirY) ||
wrappedGui.mouseScrolled(dirY) || // TODO: Remove this when all guis are updated to the new mouseScrolled method
super.mouseScrolled(x, y, dirX, dirY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ public boolean mousePressed(MouseButton button) {
}

@Override
public boolean mouseScrolled(double scroll) {
if (scroll != 0 && canMouseScrollPlane() && canMouseScroll()) {
setValue(getValue() - getScrollStep() * scroll);
public boolean mouseScrolled(double mouseX, double mouseY, double xDelta, double yDelta) {
// We don't care which direction the user scrolled, just apply it.
var scrollDelta = yDelta == 0 ? xDelta : yDelta;
if (scrollDelta != 0 && canMouseScrollPlane() && canMouseScroll()) {
setValue(getValue() - getScrollStep() * scrollDelta);
return true;
}

Expand Down
12 changes: 10 additions & 2 deletions common/src/main/java/dev/ftb/mods/ftblibrary/ui/Widget.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package dev.ftb.mods.ftblibrary.ui;

import com.mojang.blaze3d.platform.Window;
import dev.ftb.mods.ftblibrary.ui.input.Key;
import dev.ftb.mods.ftblibrary.ui.input.KeyModifiers;
import dev.ftb.mods.ftblibrary.ui.input.MouseButton;
import dev.ftb.mods.ftblibrary.util.TooltipList;
import dev.ftb.mods.ftblibrary.util.client.PositionedIngredient;
import com.mojang.blaze3d.platform.Window;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
Expand Down Expand Up @@ -192,10 +192,18 @@ public boolean mouseDoubleClicked(MouseButton button) {
public void mouseReleased(MouseButton button) {
}

public boolean mouseScrolled(double scroll) {
/**
* @deprecated use {@link #mouseScrolled(double, double, double, double)} instead
*/
@Deprecated
public boolean mouseScrolled(double yDelta) {
return false;
}

public boolean mouseScrolled(double mouseX, double mouseY, double xDelta, double yDelta) {
return this.mouseScrolled(yDelta);
}

public boolean mouseDragged(int button, double dragX, double dragY) {
return false;
}
Expand Down