mirror of
https://github.com/sinbad/StevesUEHelpers.git
synced 2025-02-23 09:35:25 +00:00
Promoted MaxNumberOfLines
to a property
This commit is contained in:
parent
c20d1113c1
commit
40398ef851
@ -120,11 +120,9 @@ void UTypewriterTextWidget::PlayNextLinePart(float Speed)
|
||||
|
||||
CalculateWrappedString(RemainingLinePart);
|
||||
|
||||
// TODO Jonas: Promote MaxLines to variable. Might want MaxLines = 1 for text before choices.
|
||||
int MaxLines = 3;
|
||||
if (NumberOfLines > MaxLines)
|
||||
if (NumberOfLines > MaxNumberOfLines)
|
||||
{
|
||||
int MaxLength = CalculateMaxLength(MaxLines);
|
||||
int MaxLength = CalculateMaxLength();
|
||||
int TerminatorIndex = FindLastTerminator(RemainingLinePart, MaxLength);
|
||||
int Length = TerminatorIndex + 1;
|
||||
const FString& FirstLinePart = RemainingLinePart.Left(Length);
|
||||
@ -236,14 +234,13 @@ int UTypewriterTextWidget::FindLastTerminator(const FString& CurrentLineString,
|
||||
return (Count - 1);
|
||||
}
|
||||
|
||||
int UTypewriterTextWidget::CalculateMaxLength(int MaxNumberOfLines)
|
||||
int UTypewriterTextWidget::CalculateMaxLength()
|
||||
{
|
||||
int MaxLength = 0;
|
||||
int CurrentNumberOfLines = 1;
|
||||
for (int i = 0; i < Segments.Num(); i++)
|
||||
{
|
||||
const FTypewriterTextSegment& Segment = Segments[i];
|
||||
// TODO Jonas: Mark line break segments as such in CalculateWrappedString instead.
|
||||
if (Segment.Text.Equals(FString(TEXT("\n"))))
|
||||
{
|
||||
CurrentNumberOfLines++;
|
||||
|
@ -84,6 +84,10 @@ public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Typewriter")
|
||||
float PauseTimeAtSentenceTerminators = 0.5f;
|
||||
|
||||
/// How many lines of text at most to print at once.
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Typewriter")
|
||||
int MaxNumberOfLines = 3;
|
||||
|
||||
/// Set Text immediately
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetText(const FText& InText);
|
||||
@ -134,7 +138,7 @@ private:
|
||||
static bool IsClauseTerminator(TCHAR Letter);
|
||||
static int FindLastTerminator(const FString& CurrentLineString, int Count);
|
||||
|
||||
int CalculateMaxLength(int MaxNumberOfLines);
|
||||
int CalculateMaxLength();
|
||||
void CalculateWrappedString(const FString& CurrentLineString);
|
||||
FString CalculateSegments(FString* OutCurrentRunName);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user