aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-06-17 17:57:45 +0800
committershedaniel <daniel@shedaniel.me>2022-06-17 17:57:45 +0800
commitd7ee88942e2085f9f5d4856c3de6de475b8b7733 (patch)
tree5acbda4f02caee0af9aa52a1a4c28f3c3b099ab6
parentd8b8a083eac13e1a1bc46c256a80497f70c1f03d (diff)
downloadRoughlyEnoughItems-d7ee88942e2085f9f5d4856c3de6de475b8b7733.tar.gz
RoughlyEnoughItems-d7ee88942e2085f9f5d4856c3de6de475b8b7733.tar.bz2
RoughlyEnoughItems-d7ee88942e2085f9f5d4856c3de6de475b8b7733.zip
Fix favorites panels queuing tooltips even when it is out of bounds
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FavoritesPanel.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelEmptyRow.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelEntriesRow.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelRow.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelSectionRow.java53
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelSeparatorRow.java3
6 files changed, 36 insertions, 31 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FavoritesPanel.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FavoritesPanel.java
index 6271768e4..f23bb2c10 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FavoritesPanel.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FavoritesPanel.java
@@ -98,7 +98,7 @@ public class FavoritesPanel extends WidgetWithBounds {
matrices.translate(0, -scroller.scrollAmount(), 0);
int y = innerBounds.y;
for (FavoritesPanelRow row : rows.get()) {
- row.render(matrices, innerBounds.x, y, innerBounds.width, row.getRowHeight(), mouseX, mouseY + scroller.scrollAmountInt(), delta);
+ row.render(matrices, innerBounds, innerBounds.x, y, innerBounds.width, row.getRowHeight(), mouseX, mouseY + scroller.scrollAmountInt(), delta);
y += row.getRowHeight();
}
matrices.popPose();
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelEmptyRow.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelEmptyRow.java
index 9858fe096..91fd38b36 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelEmptyRow.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelEmptyRow.java
@@ -24,6 +24,7 @@
package me.shedaniel.rei.impl.client.gui.widget.favorites.panel.rows;
import com.mojang.blaze3d.vertex.PoseStack;
+import me.shedaniel.math.Rectangle;
import net.minecraft.client.gui.components.events.GuiEventListener;
import java.util.Collections;
@@ -42,7 +43,7 @@ public class FavoritesPanelEmptyRow extends FavoritesPanelRow {
}
@Override
- public void render(PoseStack matrices, int x, int y, int rowWidth, int rowHeight, int mouseX, int mouseY, float delta) {
+ public void render(PoseStack matrices, Rectangle innerBounds, int x, int y, int rowWidth, int rowHeight, int mouseX, int mouseY, float delta) {
}
@Override
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelEntriesRow.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelEntriesRow.java
index 365f74159..9f68a8d72 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelEntriesRow.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelEntriesRow.java
@@ -28,6 +28,7 @@ import me.shedaniel.clothconfig2.api.animator.NumberAnimator;
import me.shedaniel.clothconfig2.api.animator.ValueAnimator;
import me.shedaniel.math.FloatingPoint;
import me.shedaniel.math.Point;
+import me.shedaniel.math.Rectangle;
import me.shedaniel.math.impl.PointHelper;
import me.shedaniel.rei.api.client.config.ConfigObject;
import me.shedaniel.rei.api.client.favorites.FavoriteEntry;
@@ -81,7 +82,7 @@ public class FavoritesPanelEntriesRow extends FavoritesPanelRow {
}
@Override
- public void render(PoseStack matrices, int x, int y, int rowWidth, int rowHeight, int mouseX, int mouseY, float delta) {
+ public void render(PoseStack matrices, Rectangle innerBounds, int x, int y, int rowWidth, int rowHeight, int mouseX, int mouseY, float delta) {
this.lastY = y;
int entrySize = entrySize();
boolean fastEntryRendering = ConfigObject.getInstance().doesFastEntryRendering();
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelRow.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelRow.java
index 732598623..54e3964d5 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelRow.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelRow.java
@@ -24,10 +24,11 @@
package me.shedaniel.rei.impl.client.gui.widget.favorites.panel.rows;
import com.mojang.blaze3d.vertex.PoseStack;
+import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.gui.AbstractContainerEventHandler;
public abstract class FavoritesPanelRow extends AbstractContainerEventHandler {
public abstract int getRowHeight();
- public abstract void render(PoseStack matrices, int x, int y, int rowWidth, int rowHeight, int mouseX, int mouseY, float delta);
+ public abstract void render(PoseStack matrices, Rectangle innerBounds, int x, int y, int rowWidth, int rowHeight, int mouseX, int mouseY, float delta);
} \ No newline at end of file
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelSectionRow.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelSectionRow.java
index c9f0504e3..2c7a7fe6a 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelSectionRow.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelSectionRow.java
@@ -24,6 +24,7 @@
package me.shedaniel.rei.impl.client.gui.widget.favorites.panel.rows;
import com.mojang.blaze3d.vertex.PoseStack;
+import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.events.GuiEventListener;
@@ -33,29 +34,29 @@ import java.util.Collections;
import java.util.List;
public class FavoritesPanelSectionRow extends FavoritesPanelRow {
- private final Component sectionText;
- private final Component styledText;
-
- public FavoritesPanelSectionRow(Component sectionText, Component styledText) {
- this.sectionText = sectionText;
- this.styledText = styledText;
- }
-
- @Override
- public int getRowHeight() {
- return 11;
- }
-
- @Override
- public void render(PoseStack matrices, int x, int y, int rowWidth, int rowHeight, int mouseX, int mouseY, float delta) {
- if (mouseX >= x && mouseY >= y && mouseX <= x + rowWidth && mouseY <= y + rowHeight) {
- Tooltip.create(sectionText).queue();
- }
- Minecraft.getInstance().font.draw(matrices, styledText, x, y + 1, 0xFFFFFFFF);
- }
-
- @Override
- public List<? extends GuiEventListener> children() {
- return Collections.emptyList();
- }
- } \ No newline at end of file
+ private final Component sectionText;
+ private final Component styledText;
+
+ public FavoritesPanelSectionRow(Component sectionText, Component styledText) {
+ this.sectionText = sectionText;
+ this.styledText = styledText;
+ }
+
+ @Override
+ public int getRowHeight() {
+ return 11;
+ }
+
+ @Override
+ public void render(PoseStack matrices, Rectangle innerBounds, int x, int y, int rowWidth, int rowHeight, int mouseX, int mouseY, float delta) {
+ if (innerBounds.contains(mouseX, mouseY) && mouseX >= x && mouseY >= y && mouseX <= x + rowWidth && mouseY <= y + rowHeight) {
+ Tooltip.create(sectionText).queue();
+ }
+ Minecraft.getInstance().font.draw(matrices, styledText, x, y + 1, 0xFFFFFFFF);
+ }
+
+ @Override
+ public List<? extends GuiEventListener> children() {
+ return Collections.emptyList();
+ }
+} \ No newline at end of file
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelSeparatorRow.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelSeparatorRow.java
index a9f31fdc1..7367ca9be 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelSeparatorRow.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/rows/FavoritesPanelSeparatorRow.java
@@ -24,6 +24,7 @@
package me.shedaniel.rei.impl.client.gui.widget.favorites.panel.rows;
import com.mojang.blaze3d.vertex.PoseStack;
+import me.shedaniel.math.Rectangle;
import net.minecraft.client.gui.components.events.GuiEventListener;
import java.util.Collections;
@@ -36,7 +37,7 @@ public class FavoritesPanelSeparatorRow extends FavoritesPanelRow {
}
@Override
- public void render(PoseStack matrices, int x, int y, int rowWidth, int rowHeight, int mouseX, int mouseY, float delta) {
+ public void render(PoseStack matrices, Rectangle innerBounds, int x, int y, int rowWidth, int rowHeight, int mouseX, int mouseY, float delta) {
fillGradient(matrices, x, y + 2, x + rowWidth, y + 3, -571806998, -571806998);
}