-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement visible characters enter/exit FX in RichTextLabel #91749
base: master
Are you sure you want to change the base?
Conversation
0063849
to
1313b79
Compare
1313b79
to
d5f2edd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will only work with "Characters After Shaping" mode, since it's assuming that visible range is character indices, but in other modes these are glyph indices (and should track processed_glyphs_step
instead of character index).
Screen.Recording.2024-05-09.at.11.34.51.mov
While this is a good plan (when I attempted this I didn't cap it, and it got... very bad), I do think that setting a hard cap doesn't make a ton of sense. A better option might be to add this as a variable to the class (such as (Though if it has to be a hardcoded cap, make it a power of 2. This is a programming thing after all :p) |
<return type="bool" /> | ||
<param index="0" name="char_fx" type="CharFXTransform" /> | ||
<description> | ||
Override this method to animate new characters shown when [member RichTextLabel.visible_characters] increases. Modified properties in [param char_fx] will be applied until this method returns [code]true[/code]. Return [code]true[/code] when the enter fx has finished. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it makes more sense to return false when finished, to better match the way it's done in RichTextEffect. Instead of treating it as done = true
treat it as processing effect = false
. This means less problems when converting from richtexteffect. Same goes for _process_exit_effects
.
This PR might help towards fixing godotengine/godot-proposals#6286 (by allowing detecting on when exactly a specific character got revealed)
Agreed on this point, for a use-case like this it would be important to run the transition for every character. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to what I've done in #66600, it would be nice to create a GDScript template for RichTextTransition
as well.
d5f2edd
to
0308422
Compare
Force pushing the branch closed the PR for some reason? Unsure why that happened. |
Resolves godotengine/godot-proposals#9137
Adds
visibility_transition
property toRichTextLabel
, which takes aRichTextTransition
resource.This resource functions similarly to
RichTextEffect
, but instead of_process_custom_fx
, there are 2 separate funcs for enter or exit fx.Example
Implementation Details
When a
visibility_transition
is set, making changes tovisible_characters
orvisible_ratio
will call_update_characters_to_transition
, which will calculate the characters removed or added, and map aCharacterToTransition
struct to the character. TheCharacterToTransition
struct contains data on if the character is entering or exiting, along with the transition's time elapsed. Before FX is processed, theRichTextLabel
will check if the character currently being drawn is in thecharacters_to_transition
map, and use theCharacterToTransition
struct to call either_process_enter_fx
or_process_exit_fx
on the assignedRichTextTransition
. If either of these methods returntrue
, the character is done transitioning, and removed from the "to transition" map. Due to the nature ofVisibleCharactersBehaviour::CHARS_BEFORE_SHAPING
, having aRichTextTransition
assigned restricts the visible character clipping behaviour to after shaping, to allow for exit fx.