///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // D E R E L I C T // /// // (c) 2003..2024 using Godot; using System; [GlobalClass] public partial class RichTextAnim : RichTextLabel { [Export] public string TextPrefix = ""; [Export] public string TextSuffix = ""; [Export] public double MSPerChar = 100; [Export] public string OriginalText = "{BAD ERROR}"; [ExportCategory( "Animation" )] [Export] public int StartingOffset = 0; [Export] public int EndingOffset = 0; [Export] public int CharCount = 0; [Export] public double TimeTillNextChar = 0; // Called when the node enters the scene tree for the first time. public override void _Ready() { OriginalText = Text; Text = ""; TimeTillNextChar = MSPerChar / 1000.0; } // Called every frame. 'delta' is the elapsed time since the previous frame. public override void _Process( double delta ) { TimeTillNextChar -= delta; if( TimeTillNextChar <= 0 ) { TimeTillNextChar += ( MSPerChar / 1000.0 ); if( CharCount < OriginalText.Length ) { Text = TextPrefix + OriginalText.Substring( 0, CharCount ) + TextSuffix; ++CharCount; } else { Text = TextPrefix + OriginalText + TextSuffix; ProcessMode = ProcessModeEnum.Disabled; } } } }