Closed c272 closed 2 years ago
Since Code
supports a custom DrawCharacter method, you can simply add a text formatting code that only draws characters based on a certain time or maximum limit with exactly the same implementation that you proposed, so this doesn't need a separate implementation in the TokenizedString
class.
Behavior like that also wouldn't require a separate downstream branch!
(For reference, this part of WobblyCode
makes use of very similar behavior to what I'm proposing for a custom code: https://github.com/Ellpeck/MLEM/blob/main/MLEM/Formatting/Codes/WobblyCode.cs#L32-L35)
Thank you, my apologies, I didn't know about the code system's draw overrides... This makes things a lot simpler!
I'm attempting to create a dialogue box system similar to that of any visual novel, where the text slowly appears within the text box character by character using
TokenizedString
andToken
, however I've run into a few practical problems with the system:TokenizedString
andToken
both have internal constructor and are immutable.TokenizedString
for every character revealed, however this seems costly and is also not compatible with animation codes like<a wobble>
(as they are recreated every time, the animation is essentially frozen).This PR proposes a solution to this by allowing
Token
to have a visible span, outside of which characters are not drawn. Please let me know if this is something you'd want upstream, and if so what you'd want changing to merge in. If not I'm happy to keep this in my downstream branch.