Page 1 of 1

Single Continue Button

Posted: Wed Nov 08, 2023 12:44 pm
by RPGKeith
Hi!

What would be the best way to set up a single continue button that can handle 3 or more subtitle panels? I have a narrator/player/npc panel. My continue button has a lot going on and would like to only have one in my hierarchy. Like a central continue button rather than one on each panel. Thanks!

also how would I add the Continue sequence logic to my default sequence for this following if(currentSpeaker == "LOGIC")?

Code: Select all

        
        private DialogueCutsceneManager dialogueCutsceneManager;

        public void Awake()
        {
            dialogueCutsceneManager = DialogueCutsceneManager.Instance;
            MySubtitlePanel.TypewriterDelay = GetParameterAsFloat(0); 
            currentSpeaker = ParseSpeakerFromEntryTag(GetParameter(2));

            if (dialogueCutsceneManager != null)
            {
                dialogueCutsceneManager.SetCurrentActor(currentSpeaker);
                dialogueCutsceneManager.HandleCurrentActorDialogue();
            }
            else
            {
                Debug.LogError("DialogueCutsceneManager not found in the scene.");
            }

            if(currentSpeaker == "LOGIC")
            {
                //add same logic as sequencer command "Continue();"
            }

            if (DialogueDebug.logInfo) Debug.Log(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}: Sequencer: Delay({1})", new System.Object[] { DialogueDebug.Prefix, GetParameterAsFloat(1) }));
        }
        

Re: Single Continue Button

Posted: Wed Nov 08, 2023 3:29 pm
by Tony Li
Hi,

You can point all 3 subtitle panels' Continue Button fields to the same continue button. Make sure the continue button is not a child of any of the subtitle panels.

A few notes on your custom sequencer command:
  • Always end your sequencer command with "Stop();"
  • You can get the current speaker from the "speaker" property. Also from DialogueManager.currentConversationState.speakerInfo.
However, since you're changing the typewriter speed, it's probably better to do this in an OnConversationLine(Subtitle) method. This method runs before the subtitle is displayed -- unlike the sequencer command which runs after the typewriter has just started. Example:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    float typewriterSpeed = 50; // Default typewriter speed.
    if (subtitle.speakerInfo.Name == "LOGIC")
    {
        DialogueActor dialogueActor;
        var panel = DialogueManager.standardDialogueUI.conversationUIElements.standardSubtitleControls.GetPanel(subtitle, out dialogueActor);
        typewriterSpeed = 25; // Cut speed in half for LOGIC speaker.
    }
    panel.SetTypewriterSpeed(typewriterSpeed);
}
If you need to use a sequencer command, see "Speed up dialogue text" and "How To: Adjust Typewriter To Audio Length" for example code.

Re: Single Continue Button

Posted: Wed Nov 08, 2023 3:43 pm
by RPGKeith
Thanks! There's one part I was asking about though that wasn't addressed. I'd like to know how to simulate a continue button push in the event the actors name is "Logic"

Since I plan on always requiring a continue button except before player response I need a way to skip this actor's entry.
This actor is used for putting in logic commands for skill checks and the sort. So After the variable is generated in the dialogue conversation lua environment I just want to simulate the continue button. Otherwise the player gets stuck unable to continue the dialogue conversation. just for reference this is the whole command, before was a snippet.

Also I tried to implement this advice, but the continue button only seems to be working for one panel, for the other two panels it shows up for an instant and but is deactivated shortly after before any input is made.

Code: Select all

namespace PixelCrushers.DialogueSystem.SequencerCommands
{
    public class SequencerCommandDefaultTK : SequencerCommand
    {
        private GameEvent OnPlayerDialogue; // Reference to your GameEvent ScriptableObject
        private GameEvent OnNPCDialogue; // Reference to your GameEvent ScriptableObject
        private string currentSpeaker;
        private DialogueCutsceneManager dialogueCutsceneManager; // Reference to your DialogueCutsceneManager.

        public void Awake()
        {
            dialogueCutsceneManager = DialogueCutsceneManager.Instance;
            MySubtitlePanel.TypewriterDelay = GetParameterAsFloat(0);
            currentSpeaker = ParseSpeakerFromEntryTag(GetParameter(2));

            if (dialogueCutsceneManager != null)
            {
                dialogueCutsceneManager.SetCurrentActor(currentSpeaker);
                dialogueCutsceneManager.HandleCurrentActorDialogue();
            }
            else
            {
                Debug.LogError("DialogueCutsceneManager not found in the scene.");
            }

            if (currentSpeaker == "LOGIC")
            {
                // simulate continue button push

            }

            if (DialogueDebug.logInfo) Debug.Log(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}: Sequencer: Delay({1})", new System.Object[] { DialogueDebug.Prefix, GetParameterAsFloat(1) }));
        }

        public void OnSequencerMessage(string message)
        {
            //Debug.Log("sequencer message  = " + message);
            if (message == "Typed")
            {
                dialogueCutsceneManager.SubtitleTypingCompleted(currentSpeaker);
                StartCoroutine(MyCoroutine());
            }
        }

        private IEnumerator MyCoroutine()
        {
            yield return new WaitForSeconds(2.0f);
            Stop();
        }

        private string ParseSpeakerFromEntryTag(string entryTag)
        {
            // Split the entry tag by underscores to get the parts.
            string[] parts = entryTag.Split('_');

            if (parts.Length > 0)
            {
                // The first part should be the speaker name.
                return parts[0].ToLower();
            }

            // If the entry tag doesn't match the expected format, return a default value.
            return "UnknownSpeaker";
        }

        private string SetCurrentSpeaker(string actor)
        {
            List<string> specialSpeakers = new List<string> { "player", "narrator", "logic", "organizer" };
            return specialSpeakers.Contains(actor.ToLower()) ? actor : "npc";
        }
    }
}

Re: Single Continue Button

Posted: Wed Nov 08, 2023 4:29 pm
by Tony Li
Hi,

To simulate a continue button click, you can put "Continue()" in the logic dialogue entry's Sequence field, or in C#:

Code: Select all

DialogueManager.standardDialogueUI.OnContinueConversation();
You can also set the Dialogue Manager GameObject's Display Settings > Subtitle Settings > Continue Button mode to Not Before Response Menu. This will bypass the continue button if the next step in the conversation is a response menu.