Page 1 of 1

Scrolling accumulated text - old text gray

Posted: Thu Nov 02, 2023 3:10 pm
by ongre
Hello,

I followed the examples on how to setup a scrolling text like Disco Elysium and it works perfectly.

Now I'm trying to change the logic that puts all old text as gray to keep already set colors but I'm having trouble.

For example in this picture, the line "Virtue check success ! [Medium: Success]" when it shows is green <color=green>
but then of course the GrayAccumulatedText removes the color tag and wraps all accumulated text with gray when another line comes.

Image

I would like to keep such dialogue as green so of course I've tried playing with the different regex in GrayAccumulatedText to no avail.

Any help on this ?

Re: Scrolling accumulated text - old text gray

Posted: Thu Nov 02, 2023 3:38 pm
by Tony Li
Hi,

Please see this post.

Re: Scrolling accumulated text - old text gray

Posted: Thu Nov 02, 2023 4:36 pm
by ongre
Hello,

Thanks for fast reply.

But I'm already using GrayAccumulatedText class with provided code.

Code: Select all

        // Remove color tags from old accumulated text:
        const string pattern = @"<color=[#]?\w+>|</color>";
        subtitlePanel.accumulatedText = Regex.Replace(subtitlePanel.accumulatedText, pattern, string.Empty);

        // Wrap accumulated text in gray:
        subtitlePanel.accumulatedText = UITools.WrapTextInColor(subtitlePanel.accumulatedText, oldTextColor);
SetAccumulatedTextGray() function Regex.Replace call removes all color tags in accumulatedText, thus losing

<color=green>Virtue check success ! [Medium: Success]</color>

Image

I would like to keep color likes this :

Image

Instead of this :

Image

Removing the following lines

Code: Select all

        // Remove color tags from old accumulated text:
        const string pattern = @"<color=[#]?\w+>|</color>";
        subtitlePanel.accumulatedText = Regex.Replace(subtitlePanel.accumulatedText, pattern, string.Empty);
provides the correct behaviour but then color tags start to accumulate :

Image

Re: Scrolling accumulated text - old text gray

Posted: Thu Nov 02, 2023 7:39 pm
by Tony Li
Try removing only the outermost color tag -- "<color=7f7f7fff>" at the beginning of the string and "</color>" at the end.

Re: Scrolling accumulated text - old text gray

Posted: Fri Nov 03, 2023 5:22 am
by ongre
Indeed, I just needed more time I couldn't find the correct Regex.

Here is my solution for anyone stumbling on this that wants to keep color in the accumulated grey text :

Code: Select all

        string pattern = @"^(<color=[#]?\w+>)|(</color>)(?!\n.?|</color>)";
        subtitlePanel.accumulatedText = Regex.Replace(subtitlePanel.accumulatedText, pattern, string.Empty);
Don't know if it covers all cases but so far it works and doesn't accumulate any tags.

Re: Scrolling accumulated text - old text gray

Posted: Fri Nov 03, 2023 7:57 am
by Tony Li
Thanks for sharing!