Does word wrap exist?

Good day.

I am just starting out in c++ and I am trying to write a short introduction setting for this game and word wrap would be very helpful! Instead I am making all the sentences start from the beginning and it’s very time consuming if word wrap was in play that could be a whole new ballgame!

Thanks!

Finally! I feel vindicated.

I pointed this out rather early in the development of this section and wrote a fix for word wrapping behaviour. If you go into Source/BullCowGame/Console/Terminal.cpp

Change WrapLines to this

TArray<FString> UTerminal::WrapLines(const TArray<FString>& Lines) const
{
    TArray<FString> WrappedLines;
    for (auto CurrentLine : Lines)
    {
        do
        {
            if (CurrentLine.Len() <= MaxColumns)
            {
                WrappedLines.Add(MoveTemp(CurrentLine));
                CurrentLine.Empty();
            }
            else
            {
                int32 Index = CurrentLine.Find(TEXT(" "), ESearchCase::IgnoreCase, ESearchDir::FromEnd, MaxColumns + 1);
                Index = Index == INDEX_NONE ? MaxColumns : Index;
                WrappedLines.Add(CurrentLine.Left(Index));
                CurrentLine = CurrentLine.RightChop(Index).TrimStart();
            }
        } while (CurrentLine.Len() > 0);
    }
    return WrappedLines;
}

I haven’t tested it on anything besides 4.22 but it should still work.

Sam’s reasoning for not taking this behaviour was because terminals don’t typically word wrap.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms