Add event for when the run name changes

This commit is contained in:
Steve Streeting 2023-01-09 13:10:48 +00:00
parent 068810dc61
commit 9aad397561
2 changed files with 12 additions and 1 deletions

View File

@ -147,12 +147,19 @@ void UTypewriterTextWidget::PlayNextLetter()
return;
}
FString WrappedString = CalculateSegments(&CurrentRunName);
FString NewRunName;
const FString WrappedString = CalculateSegments(&NewRunName);
if (IsValid(LineText))
{
LineText->SetText(FText::FromString(WrappedString));
}
if (NewRunName != CurrentRunName)
{
CurrentRunName = NewRunName;
OnTypewriterRunNameChanged.Broadcast(this, NewRunName);
}
// TODO: How do we keep indexing of text i18n-friendly?
if (CurrentLetterIndex < MaxLetterIndex)
{

View File

@ -18,6 +18,7 @@
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnTypewriterLineFinished, class UTypewriterTextWidget*, Widget);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnTypewriterLetterAdded, class UTypewriterTextWidget*, Widget);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnTypewriterRunNameChanged, class UTypewriterTextWidget*, Widget, const FString&, NewRunName);
/**
* A text block that exposes more information about text layout for typewriter widget.
*/
@ -63,6 +64,9 @@ public:
UPROPERTY(BlueprintAssignable)
FOnTypewriterLetterAdded OnTypewriterLetterAdded;
/// Event called when the "run name" of the text changes aka the rich text style markup. Also called when reverts to default.
FOnTypewriterRunNameChanged OnTypewriterRunNameChanged;
UPROPERTY(BlueprintReadOnly, meta = (BindWidget))
URichTextBlockForTypewriter* LineText;