mirror of
https://github.com/sinbad/StevesUEHelpers.git
synced 2025-02-23 17:45:23 +00:00
Implemented fallback to lesser terminators for line splitting
This commit is contained in:
parent
4805f49ccb
commit
c20d1113c1
@ -208,16 +208,32 @@ bool UTypewriterTextWidget::IsSentenceTerminator(TCHAR Letter)
|
|||||||
return Letter == '.' || Letter == '!' || Letter == '?';
|
return Letter == '.' || Letter == '!' || Letter == '?';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UTypewriterTextWidget::IsClauseTerminator(TCHAR Letter)
|
||||||
|
{
|
||||||
|
return Letter == ',' || Letter == ';';
|
||||||
|
}
|
||||||
|
|
||||||
int UTypewriterTextWidget::FindLastTerminator(const FString& CurrentLineString, int Count)
|
int UTypewriterTextWidget::FindLastTerminator(const FString& CurrentLineString, int Count)
|
||||||
{
|
{
|
||||||
// TODO Jonas: Find lesser terminators like commas or spaces if no sentence terminator can be found.
|
|
||||||
int TerminatorIndex = CurrentLineString.FindLastCharByPredicate(IsSentenceTerminator, Count);
|
int TerminatorIndex = CurrentLineString.FindLastCharByPredicate(IsSentenceTerminator, Count);
|
||||||
if (TerminatorIndex != INDEX_NONE)
|
if (TerminatorIndex != INDEX_NONE)
|
||||||
{
|
{
|
||||||
return TerminatorIndex;
|
return TerminatorIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Count;
|
TerminatorIndex = CurrentLineString.FindLastCharByPredicate(IsClauseTerminator, Count);
|
||||||
|
if (TerminatorIndex != INDEX_NONE)
|
||||||
|
{
|
||||||
|
return TerminatorIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
TerminatorIndex = CurrentLineString.FindLastCharByPredicate(FText::IsWhitespace, Count);
|
||||||
|
if (TerminatorIndex != INDEX_NONE)
|
||||||
|
{
|
||||||
|
return TerminatorIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (Count - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int UTypewriterTextWidget::CalculateMaxLength(int MaxNumberOfLines)
|
int UTypewriterTextWidget::CalculateMaxLength(int MaxNumberOfLines)
|
||||||
|
@ -131,6 +131,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void PlayNextLetter();
|
void PlayNextLetter();
|
||||||
static bool IsSentenceTerminator(TCHAR Letter);
|
static bool IsSentenceTerminator(TCHAR Letter);
|
||||||
|
static bool IsClauseTerminator(TCHAR Letter);
|
||||||
static int FindLastTerminator(const FString& CurrentLineString, int Count);
|
static int FindLastTerminator(const FString& CurrentLineString, int Count);
|
||||||
|
|
||||||
int CalculateMaxLength(int MaxNumberOfLines);
|
int CalculateMaxLength(int MaxNumberOfLines);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user