Replies: 2 comments
-
You can do |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the project you are working on
A visual novel using Lobotomy Corporation assets
Describe the problem or limitation you are having in your project
Most visual novels display an indicator when the current line of dialogue has been fully written, in the case of Lobotomy Corp, this indicator is displayed slightly to the right at the end of the last line and has a blinking effect. Positionning the indicator can be easily done using the methods

get_content_width()
andget_content_height()
to know where to place an element like a TextureRect which would result in something such as this:Unfortunately, this only works if the last line of dialogue is equal or longer than the longest line. If the last line doesn't meet these criteria, the result look like this:

Looking through the properties and methods of RichTextLabel, I couldn't find anything that could solve this issue without feeling that the solution would be flawed.
The first solution I considered was using the add_image and update_image methods to first add the indicator at the end of the string and then create the blinkling effect. The main flaw with this approach is that if the effect were to become more complex ,or if an element like a button needed to be placed, this would simply not work.
Another possible solution would be to compute a value using the number of characters per line and the content width to predict where the indicator should be placed depending on the number of characters in the last line. However, this solution implicitly assumes that all the lines were created by auto wrap when reaching the node's boundary and any newline would break it. Beside it sounds like a terrible idea.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
The best solution I came up with would be to have a method similar to
get_content_width()
that returns the width of a specific line, allowing for proper positioning of elements based on the displayed content of a RichTextLabel.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
I examined existing methods that retrieve information from a specific line, such as
get_line_offset
andget_line_range
and noticed thattext_buf
(from the classTextParagraph
) already contains a methodget_line_width
.This method invokes functions with keywords like "shape line" and "shape text" which suggests it calculate the width of the line after it as been rendered on the screen.
Based on this, the
get_line_width
of RichTextLabel would like this:Additionnally, it wouldn't make sense to add a method to retrieve the line width without also being able to get its height.
Unforntunatly,
TextParagraph
doesn't have aget_line_height
method, so I'm unsure how it would be implemented if needed.Beta Was this translation helpful? Give feedback.
All reactions