Enum based dialogue field solution for showing different portaits?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
jlhacode
Posts: 77
Joined: Fri Jul 03, 2020 6:23 am

Enum based dialogue field solution for showing different portaits?

Post by jlhacode »

I wanted to explore making a solution for showing portraits that didn't involve prepending dialogue text with [pic={#}]. My preferred solution would be something along the lines of creating a dialogue entry field with a type that matches a PortraitEmotion enum (e.g. {Happy, Neutral, Sad}), and just setting it in the DialogueEntry editor.

Also, this pseudocode represents the logic I want my subtitle panels to follow:

Code: Select all

speakerHasPortraitImage ? usePortraitSubtitleUI() : usePlainSubtitleUI();
What would be the best way to determine the speakerHasPortraitImage bool, and what would be the best way to handle panel activation based off it?
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Enum based dialogue field solution for showing different portaits?

Post by Tony Li »

Hi,

For the enum field, use a custom field type.

Add a script with an OnConversationLine() method to the Dialogue Manager. In it, check the dialogue entry's fields:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    string fieldValue = Field.LookupValue(subtitle.dialogueEntry.fields, "PortraitEmotion"); // Will be empty string if no field.
    bool speakerHasPortraitImage = !string.IsNullOrEmpty(fieldValue);
    if (speakerHasPortraitImage)
    {
        // Set pic=# value:
        subtitle.formattedText.pic = // some value according to your logic
        
        // Can also change which subtitle panel to use:
        subtitle.formattedText.subtitlePanelNumber = //something according to your logic
    }
}
Post Reply