Fixed array tooltips, removed \n from lang#47
Fixed array tooltips, removed \n from lang#47JackOfNoneTrades wants to merge 4 commits intoCarbon-Config-Project:1.7.10from
Conversation
|
@JackOfNoneTrades could you please show the difference in both? |
|
@JackOfNoneTrades yeah i would rather fix the underlying issue instead of removing new lines. |
| if (code == 'r') { | ||
| active.setLength(0); | ||
| resetFound = true; | ||
| } else if ("0123456789abcdefklmnor".indexOf(code) != -1) { |
There was a problem hiding this comment.
please make that a char >= '0' && char <= 'r' instead of an indexOf
There was a problem hiding this comment.
hmm I want to know if the char is a valid code, 0123456789abcdefklmnor are three separate ranges put together. do I do three range checks?
There was a problem hiding this comment.
I know you stroke this through, but 3 checks would be still faster than a indexOf which is a brute force iteration.
| active.setLength(0); | ||
| resetFound = true; | ||
| } else if ("0123456789abcdefklmnor".indexOf(code) != -1) { | ||
| if (!resetFound && active.indexOf("§" + code) == -1) { |
There was a problem hiding this comment.
Please track this separatly. Instead of doing indexOf
| for (int i = 0; i < rawLines.length; ++i) { | ||
| String line = rawLines[i]; | ||
|
|
||
| if (!line.matches("^§[0-9a-frk-orA-FK-OR].*")) { |
There was a problem hiding this comment.
so when a style is set, for example here:
new ChatComponentTranslation("gui.carbonconfig.warn.changed").getFormattedText(), new ChatComponentTranslation("gui.carbonconfig.warn.changed.desc").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GRAY)).getFormattedText(), 0));
if the formatted line is split, minecrafts style syntax doesn't carry to remaining lines. It needs to be carried, plus needs to work if any amount of styles is applied to the text.
There was a problem hiding this comment.
Yeah ok, makes sense, but i would add a check before hand if the format isn't "empty" because why check for missing formatting if no formatting would be applied anyways.
| public void drawScreen(int mouseX, int mouseY, float partialTicks) { | ||
| super.drawScreen(mouseX, mouseY, partialTicks); | ||
|
|
||
| String[] rawLines = this.multiLineMessage.split("\\\\n"); |
There was a problem hiding this comment.
It's what works. I tried evaluating different expressions under the debugger and "\n", "\n" etc don't work 🤷. Must be something with regex
| String line = lines[i]; | ||
|
|
||
| if (!line.matches("^§[0-9a-frk-orA-FK-OR].*")) { | ||
| line = activeFormatting + line; |
There was a problem hiding this comment.
This shouldn't be applied here. Since the listFormattedStringToWidth would destroy this anyways again.
You can keep track of the flag but other than that this is to early to apply
|
@JackOfNoneTrades i would suggest you make this a helper function that inserts a input string and converts multiple lines out of it as a output, that way we have consistent implementations between both usecases. Overall thank you :) |
| int lineHeight = this.fontRendererObj.FONT_HEIGHT + 2; | ||
| int startY = 90; | ||
| String activeFormatting = ""; | ||
| String[] messages = FormattingUtil.listFormattedStringToWidthRespectingNewlines(this.fontRendererObj, message, this.width - 50); |
There was a problem hiding this comment.
throw that line into the init function, font renderer and width are accessible once the init is called.
|
i will integrate this pr next week. |





Title says it all. The \n removal is because yes no guis only support a title and one line of text. I thought about subclassing it and adding support for an arbitrary amount of lines (+ custom background), but it would require more effort + approval.
I am aware that
this instanceof ArrayElement && ((ArrayElement) this).node != nullmight not be the most idiomatic way for the array tooltip fix, if I should change it please tell.