Scrolling accumulated text - old text gray

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
ongre
Posts: 3
Joined: Thu Nov 02, 2023 1:57 pm

Scrolling accumulated text - old text gray

Post 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 ?
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Scrolling accumulated text - old text gray

Post by Tony Li »

Hi,

Please see this post.
ongre
Posts: 3
Joined: Thu Nov 02, 2023 1:57 pm

Re: Scrolling accumulated text - old text gray

Post 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
Last edited by ongre on Thu Nov 02, 2023 4:58 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Scrolling accumulated text - old text gray

Post by Tony Li »

Try removing only the outermost color tag -- "<color=7f7f7fff>" at the beginning of the string and "</color>" at the end.
ongre
Posts: 3
Joined: Thu Nov 02, 2023 1:57 pm

Re: Scrolling accumulated text - old text gray

Post 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.
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Scrolling accumulated text - old text gray

Post by Tony Li »

Thanks for sharing!
Post Reply