aboutsummaryrefslogtreecommitdiff
path: root/mod/src/main/java/kr
diff options
context:
space:
mode:
authorsyeyoung <cyoung06@naver.com>2023-01-25 17:54:09 +0900
committersyeyoung <cyoung06@naver.com>2023-01-25 17:54:09 +0900
commit0a4adfe9cd45e977f7ee6a917a4e46e0623abef6 (patch)
treed9bdbaa1d16fc9361e387b58b78d1e2cbf7f6b71 /mod/src/main/java/kr
parent471faf2df582d9a0d00c0b3e0addf93c6cfb903e (diff)
downloadSkyblock-Dungeons-Guide-0a4adfe9cd45e977f7ee6a917a4e46e0623abef6.tar.gz
Skyblock-Dungeons-Guide-0a4adfe9cd45e977f7ee6a917a4e46e0623abef6.tar.bz2
Skyblock-Dungeons-Guide-0a4adfe9cd45e977f7ee6a917a4e46e0623abef6.zip
- Text delegate to rich text
Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'mod/src/main/java/kr')
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/Text.java2
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/RichText.java10
2 files changed, 8 insertions, 4 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/Text.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/Text.java
index bd04ab42..341a0282 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/Text.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/Text.java
@@ -48,7 +48,7 @@ public class Text extends AnnotatedExportOnlyWidget {
@Export(attributeName = "text")
public final BindableAttribute<String> text = new BindableAttribute<>(String.class, "");
- private final ParentDelegatingTextStyle textStyle = new ParentDelegatingTextStyle();
+ private final ParentDelegatingTextStyle textStyle = ParentDelegatingTextStyle.ofDefault();
private final RichText richText = new RichText(new TextSpan(textStyle, ""), BreakWord.WORD, true,RichText.TextAlign.LEFT);
@Override
public List<Widget> build(DomElement buildContext) {
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/RichText.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/RichText.java
index 614158fe..cc651a9d 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/RichText.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/RichText.java
@@ -159,15 +159,19 @@ public class RichText extends Widget implements Layouter, Renderer {
public double getMaxIntrinsicHeight(DomElement buildContext, double width) {
LinkedList<FlatTextSpan> flatTextSpans = new LinkedList<>();
rootSpan.flattenTextSpan(flatTextSpans::add);
- double remaining = width;
+ double remaining = width == 0 ? Double.POSITIVE_INFINITY : width;
double maxHeight = 0;
double sumHeight = 0;
while (!flatTextSpans.isEmpty()) {
FlatTextSpan first = flatTextSpans.pollFirst();
- BrokenWordData brokenWordData = first.breakWord(remaining, width, breakWord);
+ BrokenWordData brokenWordData = first.breakWord(remaining, width == 0 ? Double.POSITIVE_INFINITY : width, breakWord);
remaining -= brokenWordData.getFirstWidth();
+ if (brokenWordData.getFirst().value.length == 0 && first.value.length != 0 && remaining == width) {
+ return 0;
+ }
+
maxHeight = Math.max(maxHeight, first.getHeight());
if (brokenWordData.getSecond() != null) {
@@ -175,7 +179,7 @@ public class RichText extends Widget implements Layouter, Renderer {
}
if (brokenWordData.isBroken()) {
- remaining = width;
+ remaining = width == 0 ? Double.POSITIVE_INFINITY : width;
sumHeight += maxHeight;
maxHeight = 0;
}