mirror of
https://github.com/sinbad/StevesUEHelpers.git
synced 2025-02-23 17:45:23 +00:00
Merge branch 'master' into line-splitting
This commit is contained in:
commit
e4ec937f1c
@ -116,8 +116,24 @@ void UTypewriterTextWidget::PlayNextLinePart(float Speed)
|
||||
bHasMoreLineParts = false;
|
||||
bHasFinishedPlaying = false;
|
||||
|
||||
LineText->SetText(FText());
|
||||
if (bFirstPlayLine)
|
||||
{
|
||||
// Delay the very first PlayLine after construction, CalculateWrappedString is not reliable until a couple
|
||||
// of UI geometry updates. At first the geometry is 0, then it's just wrong, and then finally it settles.
|
||||
FTimerHandle TempHandle;
|
||||
FTimerDelegate DelayDelegate;
|
||||
DelayDelegate.BindUObject(this, &ThisClass::StartPlayLine);
|
||||
TimerManager.SetTimer(TempHandle, DelayDelegate, 0.2f, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartPlayLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UTypewriterTextWidget::StartPlayLine()
|
||||
{
|
||||
CalculateWrappedString(RemainingLinePart);
|
||||
|
||||
if (NumberOfLines > MaxNumberOfLines)
|
||||
@ -133,13 +149,18 @@ void UTypewriterTextWidget::PlayNextLinePart(float Speed)
|
||||
bHasMoreLineParts = true;
|
||||
}
|
||||
|
||||
FTimerDelegate Delegate;
|
||||
Delegate.BindUObject(this, &ThisClass::PlayNextLetter);
|
||||
FTimerDelegate Delegate;
|
||||
Delegate.BindUObject(this, &ThisClass::PlayNextLetter);
|
||||
|
||||
TimerManager.SetTimer(LetterTimer, Delegate, LetterPlayTime/CurrentPlaySpeed, true);
|
||||
FTimerManager& TimerManager = GetWorld()->GetTimerManager();
|
||||
TimerManager.SetTimer(LetterTimer, Delegate, LetterPlayTime/CurrentPlaySpeed, true);
|
||||
|
||||
SetVisibility(ESlateVisibility::SelfHitTestInvisible);
|
||||
}
|
||||
SetVisibility(ESlateVisibility::SelfHitTestInvisible);
|
||||
|
||||
bFirstPlayLine = false;
|
||||
|
||||
PlayNextLetter();
|
||||
|
||||
}
|
||||
|
||||
void UTypewriterTextWidget::SkipToLineEnd()
|
||||
@ -158,6 +179,13 @@ void UTypewriterTextWidget::SkipToLineEnd()
|
||||
OnLineFinishedPlaying();
|
||||
}
|
||||
|
||||
void UTypewriterTextWidget::NativeConstruct()
|
||||
{
|
||||
Super::NativeConstruct();
|
||||
|
||||
bFirstPlayLine = true;
|
||||
}
|
||||
|
||||
void UTypewriterTextWidget::PlayNextLetter()
|
||||
{
|
||||
// Incorporate pauses as a multiple of play timer (may not be exact but close enough)
|
||||
|
@ -119,6 +119,8 @@ public:
|
||||
const FString& GetCurrentRunName() const { return CurrentRunName; }
|
||||
|
||||
protected:
|
||||
virtual void NativeConstruct() override;
|
||||
|
||||
/// Called when on or more letters are added, if subclasses want to override
|
||||
UFUNCTION(BlueprintImplementableEvent, Category = "Typewriter")
|
||||
void OnPlayLetter();
|
||||
@ -141,6 +143,7 @@ private:
|
||||
int CalculateMaxLength();
|
||||
void CalculateWrappedString(const FString& CurrentLineString);
|
||||
FString CalculateSegments(FString* OutCurrentRunName);
|
||||
void StartPlayLine();
|
||||
|
||||
UPROPERTY()
|
||||
FText CurrentLine;
|
||||
@ -173,4 +176,5 @@ private:
|
||||
FTimerHandle LetterTimer;
|
||||
float CurrentPlaySpeed = 1;
|
||||
float PauseTime = 0;
|
||||
bool bFirstPlayLine = true;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user