aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
diff options
context:
space:
mode:
authorUnknown <shekwancheung0528@gmail.com>2019-06-06 16:09:48 +0800
committerUnknown <shekwancheung0528@gmail.com>2019-06-06 16:09:48 +0800
commit94e6085d2d49e7fe38871c9548774c4e50a2f422 (patch)
tree8de1c84b88a61ecd79810ede9adcd1a5727ca852 /src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
parent9755812e75e7fa357dd0ae55bb36b9e3a7d86822 (diff)
downloadRoughlyEnoughItems-94e6085d2d49e7fe38871c9548774c4e50a2f422.tar.gz
RoughlyEnoughItems-94e6085d2d49e7fe38871c9548774c4e50a2f422.tar.bz2
RoughlyEnoughItems-94e6085d2d49e7fe38871c9548774c4e50a2f422.zip
this is still not working
Diffstat (limited to 'src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java')
-rw-r--r--src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
index fe4824ca9..c286dbec9 100644
--- a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
+++ b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java
@@ -373,28 +373,24 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra
QUEUED_TOOLTIPS.clear();
}
+ @SuppressWarnings("deprecation")
public void renderTooltip(QueuedTooltip tooltip) {
- renderTooltip(tooltip.getText(), tooltip.getX(), tooltip.getY());
+ if (tooltip.getConsumer() == null)
+ renderTooltip(tooltip.getText(), tooltip.getX(), tooltip.getY());
+ else
+ tooltip.getConsumer().accept(tooltip);
}
public void renderTooltip(List<String> lines, int mouseX, int mouseY) {
+ if (lines.isEmpty())
+ return;
TextRenderer font = MinecraftClient.getInstance().textRenderer;
- if (!lines.isEmpty()) {
+ int width = lines.stream().map(font::getStringWidth).max(Integer::compareTo).get();
+ int height = lines.size() <= 1 ? 8 : lines.size() * 10;
+ ScreenHelper.drawHoveringWidget(mouseX, mouseY, (x, y, aFloat) -> {
GlStateManager.disableRescaleNormal();
GuiLighting.disable();
GlStateManager.disableLighting();
- int width = 0;
- for(String line : lines)
- if (font.getStringWidth(line) > width)
- width = font.getStringWidth(line);
- int height = lines.size() <= 1 ? 8 : lines.size() * 10;
- int x = Math.max(mouseX + 12, 6);
- int y = Math.min(mouseY - 12, window.getScaledHeight() - height - 6);
- if (x + width > window.getScaledWidth())
- x -= 24 + width;
- if (y < 6)
- y += 24;
-
this.blitOffset = 1000;
this.fillGradient(x - 3, y - 4, x + width + 3, y - 3, -267386864, -267386864);
this.fillGradient(x - 3, y + height + 3, x + width + 3, y + height + 4, -267386864, -267386864);
@@ -405,7 +401,6 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra
this.fillGradient(x + width + 2, y - 3 + 1, x + width + 3, y + height + 3 - 1, 1347420415, 1344798847);
this.fillGradient(x - 3, y - 3, x + width + 3, y - 3 + 1, 1347420415, 1347420415);
this.fillGradient(x - 3, y + height + 2, x + width + 3, y + height + 3, 1344798847, 1344798847);
-
int currentY = y;
for(int lineIndex = 0; lineIndex < lines.size(); lineIndex++) {
GlStateManager.disableDepthTest();
@@ -417,7 +412,7 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra
GlStateManager.enableLighting();
GuiLighting.enable();
GlStateManager.enableRescaleNormal();
- }
+ }, width, height, 0);
}
private boolean hasSameListContent(List<ItemStack> list1, List<ItemStack> list2) {