Page 1 of 1

Enum based dialogue field solution for showing different portaits?

Posted: Tue Sep 27, 2022 3:22 pm
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?

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

Posted: Tue Sep 27, 2022 8:38 pm
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
    }
}