diff options
| author | Anthony Hilyard <anthony.hilyard@gmail.com> | 2022-09-26 00:29:41 -0700 |
|---|---|---|
| committer | Anthony Hilyard <anthony.hilyard@gmail.com> | 2022-09-26 00:29:41 -0700 |
| commit | cda06cf996cb8a0df2340b14b2a43d5a2a6ab13a (patch) | |
| tree | 10b53d9f4f94e7b37253ee635c7942ce5360f656 /src/main/java/com/anthonyhilyard/iceberg/util | |
| parent | 6d01463c32ea14f48ce273e9daf753905f101946 (diff) | |
| download | Iceberg-cda06cf996cb8a0df2340b14b2a43d5a2a6ab13a.tar.gz Iceberg-cda06cf996cb8a0df2340b14b2a43d5a2a6ab13a.tar.bz2 Iceberg-cda06cf996cb8a0df2340b14b2a43d5a2a6ab13a.zip | |
Added support for Configured 2.x.
Diffstat (limited to 'src/main/java/com/anthonyhilyard/iceberg/util')
| -rw-r--r-- | src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java b/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java index 63ec096..6bcb2b0 100644 --- a/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java +++ b/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java @@ -40,6 +40,7 @@ import net.minecraftforge.common.MinecraftForge; public class Tooltips { + private static final FormattedCharSequence SPACE = FormattedCharSequence.forward(" ", Style.EMPTY); private static ItemRenderer itemRenderer = null; public static class TooltipInfo @@ -56,6 +57,7 @@ public class Tooltips } public int getTooltipWidth() { return tooltipWidth; } + public int getTooltipHeight() { return components.size() > titleLines ? components.size() * 10 + 2 : 8; } public int getTitleLines() { return titleLines; } public Font getFont() { return font; } public List<ClientTooltipComponent> getComponents() { return components; } @@ -64,16 +66,21 @@ public class Tooltips public int getMaxLineWidth() { - int width = 0; + return getMaxLineWidth(0); + } + + public int getMaxLineWidth(int minWidth) + { + int textWidth = minWidth; for (ClientTooltipComponent component : components) { int componentWidth = component.getWidth(font); - if (componentWidth > width) + if (componentWidth > textWidth) { - width = componentWidth; + textWidth = componentWidth; } } - return width; + return textWidth; } } @@ -179,7 +186,7 @@ public class Tooltips for (int componentNumber = 0; componentNumber < info.getComponents().size(); ++componentNumber) { ClientTooltipComponent imageComponent = info.getComponents().get(componentNumber); - imageComponent.renderImage(preEvent.getFont(), rectX, tooltipTop, poseStack, itemRenderer, 400); + imageComponent.renderImage(preEvent.getFont(), rectX, tooltipTop, poseStack, itemRenderer, zLevel); tooltipTop += imageComponent.getHeight() + (componentNumber == 0 ? 2 : 0); } @@ -348,10 +355,9 @@ public class Tooltips List<ClientTooltipComponent> result = new ArrayList<>(components); FormattedCharSequence title = Language.getInstance().getVisualOrder(recomposedLines.get(0)); - FormattedCharSequence space = FormattedCharSequence.forward(" ", Style.EMPTY); while (result.get(0).getWidth(font) < tooltipWidth) { - title = FormattedCharSequence.fromList(List.of(space, title, space)); + title = FormattedCharSequence.fromList(List.of(SPACE, title, SPACE)); if (title == null) { break; |
