mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-03 19:06:27 +01:00
Fix TooltipHelper formatting
This commit is contained in:
parent
14154fe239
commit
5d0674067f
1 changed files with 6 additions and 8 deletions
|
@ -170,7 +170,7 @@ public class TooltipHelper {
|
|||
StringBuilder currentLine = new StringBuilder();
|
||||
int width = 0;
|
||||
for (String word : words) {
|
||||
int newWidth = font.getStringWidth(word);
|
||||
int newWidth = font.getStringWidth(word.replaceAll("_", ""));
|
||||
if (width + newWidth > maxWidthPerLine) {
|
||||
if (width > 0) {
|
||||
String line = currentLine.toString();
|
||||
|
@ -190,24 +190,22 @@ public class TooltipHelper {
|
|||
}
|
||||
|
||||
// Format
|
||||
IFormattableTextComponent lineStart = StringTextComponent.EMPTY.copy();
|
||||
for (int i = 0; i < indent; i++)
|
||||
lineStart.append(" ");
|
||||
IFormattableTextComponent lineStart = new StringTextComponent(Strings.repeat(" ", indent));
|
||||
lineStart.formatted(defaultColor);
|
||||
List<ITextComponent> formattedLines = new ArrayList<>(lines.size());
|
||||
Couple<TextFormatting> f = Couple.create(highlightColor, defaultColor);
|
||||
|
||||
|
||||
boolean currentlyHighlighted = false;
|
||||
for (String string : lines) {
|
||||
boolean currentlyHighlighted = false;
|
||||
IFormattableTextComponent currentComponent = lineStart.copy();
|
||||
String[] split = string.split("_");
|
||||
for (String part : split) {
|
||||
currentComponent.append(new StringTextComponent(part).formatted(f.get(currentlyHighlighted)));
|
||||
if (split.length != 1)
|
||||
currentlyHighlighted = !currentlyHighlighted;
|
||||
currentlyHighlighted = !currentlyHighlighted;
|
||||
}
|
||||
|
||||
formattedLines.add(currentComponent);
|
||||
currentlyHighlighted = !currentlyHighlighted;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue