How to bypass menu if no choices are "available"?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

How to bypass menu if no choices are "available"?

Post by Abelius »

Hi there,

Not sure if this has been answered already (quite possibly), but I can't find it.

I'd like to implement a way to, once you reach a node in a conversation, get a menu with X possible choices, each of them subject to be shown or not according to their specific conditions (quest states, most likely). They'd be things like returning a quest item, asking about specific info, etc...

In this case, as I don't want those choices appearing at all, their nodes are set with "Show Invalid" = False.

Then, at the bottom of those choices, there would be an "Continue" option for the conversation going on until the end.

I know how to do all that, okay... but what I don't know is how to bypass that menu entirely IF ALL of those choices end up being invalid at that moment, and just continue as if the "Continue" button was clicked.

But with my current setup, if all choices are invalid, I get a "Continue" button...

...and as I was writing this, I've realized maybe I should uncheck that "Always Force Response Menu" option, lol... :lol:

I don't know if that will mess up with another part of my setup, so I'll enable it just on this conversation and cross my fingers.

I'll still publish this thread in case it's useful for someone, and in case you have something to add.

----------------------------------------------------------

These are my Controller settings:

Image
Image

And it should be noted I'm using a script you sent me some time ago...:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class HandleInvalidTags : MonoBehaviour
{
    public void OnConversationResponseMenu(Response[] responses)
    {
        // If any responses' text contains "{invalid}", make the response invalid:
        foreach (Response response in responses)
        {
            string text = response.formattedText.text;
            if (text.Contains("{invalid}"))
            {
                text = text.Replace("{invalid}", string.Empty); // Remove "{invalid}"
                // This next line applies the Em Tag For Invalid Responses formatting:
                text = string.Format("[em{0}]{1}[/em{0}]", (int)DialogueManager.displaySettings.inputSettings.emTagForInvalidResponses, text);
                response.formattedText.text = FormattedText.Parse(text).text;
                response.enabled = false; // This means it's invalid and not clickable.
            }
        }
    }
}
Unity 2019.4.9f1
Dialogue System 2.2.15
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to bypass menu if no choices are "available"?

Post by Tony Li »

Does your current solution work for you?

I think what complicates this is if your normally allow invalid responses (i.e., nodes whose Conditions are false), but you may be filtering them out. (I don't remember the exact details of how you're handling invalid responses.) If you end up filtering out all responses so there are none, the response menu will be empty. If your current solution doesn't work for you, we can look into writing a custom subclass of StandardDialogueUI here that overrides the ShowResponses to handle this case.
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

Re: How to bypass menu if no choices are "available"?

Post by Abelius »

Yep, unchecking that option works for me.

In my game, I usually want to show invalid responses so players know what they're missing out for not having the adequate requirements.

Thanks for replying, as always!
Unity 2019.4.9f1
Dialogue System 2.2.15
Post Reply