From 94e6085d2d49e7fe38871c9548774c4e50a2f422 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 6 Jun 2019 16:09:48 +0800 Subject: this is still not working --- .../shedaniel/rei/gui/ContainerScreenOverlay.java | 27 +++++++++------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java') 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 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 list1, List list2) { -- cgit