Page 1 of 1

Response option colors

Posted: Sun Sep 22, 2019 7:21 pm
by hellwalker
Hey!
What would be easiest way to change response option colors from a script? (Via OnConversationResponseMenu().)

Wrapping formatted text in rich text tags ignores the number text. And I think it might conflict with UI tint colors?
I guess accessing buttons themselves would be the cleanest way but is the OnConversationResponseMenu's "Response[] responses" ordering same as they would appear in the Response list? (So I can use Response[] array to match indexes with button list?)

My use case is that I have some response items that I want to mark as "Main", "Optional", "Starts Combat" etc. I wrote some custom tags to mark responses that way and now I want to apply special colors, icons and suffix texts to responses.

Re: Response option colors

Posted: Mon Sep 23, 2019 9:32 am
by Tony Li
Hi,

The StandardUIMenuPanel's SetResponseButton method adds the auto-numbers.

OnConversationResponseMenu is called before SetResponseButton.

If you need to include the auto-number inside your rich text tags, make a subclass of StandardUIMenuPanel. Override SetResponseButton. For example:

Code: Select all

public class MyMenuPanel : StandardUIMenuPanel
{
    protected override void SetResponseButton(StandardUIResponseButton button, Response response, Transform target, int buttonNumber)
    {
        base.SetResponseButton(button, response, target, buttonNumber);
        
        // If response's StartsCombat field is true, make the text red:
        if (Field.LookupBool(response.destinationEntry.fields, "StartsCombat"))
        {
            button.text = UITools.WrapTextInColor(button.text, Color.red);
        }
    }
}
I used UITools.WrapTextInColor instead adding tags to the string directly because WrapTextInColor properly handles nested rich text tags.