GUI to select a single word from a list for a single dialogue UI ?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
dfernand
Posts: 6
Joined: Thu Oct 15, 2020 7:53 pm

GUI to select a single word from a list for a single dialogue UI ?

Post by dfernand »

My objective is for the player to be able to select a single word in a Dialogue System menu GUI out of a potential list of words, rather like a drop down combo box or say, a spinning up and down text box.

So for example, we have the Dialogue System player UI menu / choice when conversing with a NPC:

"Well, regarding the death of Harold I am feeling rather <variable word> today after the funeral."

Where <variable word> could be either "happy", "sad", "elated", "miserable", "despondent" etc.

the <variable word> would be selected via some GUI control such as a text drop down combo box, list or say up/down test list spinner.

Is this possible with some tool or construct I am missing in Dialogue System ? would it need me to extend classes and write some GUI code ? am I missing something obvious ?
User avatar
Tony Li
Posts: 20534
Joined: Thu Jul 18, 2013 1:27 pm

Re: GUI to select a single word from a list for a single dialogue UI ?

Post by Tony Li »

That sounds like how We Should Talk works. (To my knowledge, We Should Talk doesn't use the Dialogue System.)

Others have implement similar interfaces in their games that use the Dialogue System, but there isn't a built-in solution for it.

You could add a custom field to the NPC's preceding line that contains the prompt, with a special string to indicate where to show the spinner. Like this:

weShouldTalkLike1.png
weShouldTalkLike1.png (7.06 KiB) Viewed 169 times

I'm using '@@@' to indicate the location of the spinner. To make that field appear in the main edit section, I added it to the Templates section's Dialogue Entries foldout and ticked the Main checkbox. (I also snipped some unused fields from the screenshot to make it smaller.)

Then follow it with the response options:

weShouldTalkLike2.png
weShouldTalkLike2.png (19.63 KiB) Viewed 169 times

Make a subclass of StandardDialogueUI. Override the ShowResponses() method. (Alternatively, override StandardUIMenuPanel and override its ShowResponsesNow() instead.)

ShowResponses() receives the preceding subtitle and an array of responses. If the preceding subtitle has a Prompt field, show the responses as a spinner. Rough example:

Code: Select all

public class MyDialogueUI : StandardDialogueUI
{
  public override void ShowResponses(Subtitle subtitle, Response[] responses, float timeout)
  {
      string prompt = Field.LookupValue(subtitle.dialogueEntry.fields, "Prompt");
      if (string.IsNullOrEmpty(prompt))
      {
          base.ShowResponses(subtitle, responses, timeout);
      }
      else
     {
         // Has prompt, so show spinner style.
         // Show spinner in place of '@@@;'.
         // Populate spinner with text in responses[] array.
     }
  }
}
Post Reply