[Solved] Replaying a Node

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
samcsss
Posts: 9
Joined: Thu Sep 17, 2015 6:06 am

[Solved] Replaying a Node

Post by samcsss »

Hello,
My game has 2 languages, with the option to change between them from a settings menu - which calls DialogueSystemController.SetLanguage

When a user changes to a different language mid-conversation, I would like the currently displayed text to be re-shown in the selected language.

What happens at the moment is that the currently displayed text remains in the old language and the new language is used for any subsequent text.

I've been searching for some sort of command or function that will replay or repeat the current node, but so far I've come up empty.

Any guidance is appreciated.

Edit: I just realized what I probably want is to refresh the current subtitle using the localized subtitle, and not replay the whole node (which would likely introduce a bunch of bugs depending on which node was active when the user switched languages)
Last edited by samcsss on Tue Dec 04, 2018 5:01 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Replaying a Node

Post by Tony Li »

Hi,

This will require a little bit of scripting. You can call the dialogue UI's ShowSubtitle() method, passing it an updated subtitle object that contains the new localized text.

Code: Select all

DialogueManager.SetLanguage(newLanguage);
if (DialogueManager.isConversationActive) {
    var subtitle = DialogueManager.currentConversationState.subtitle;
    subtitle.formattedText = FormattedText.Parse(subtitle.dialogueEntry.currentDialogueText);
    DialogueManager.dialogueUI.ShowSubtitle(subtitle);
}
samcsss
Posts: 9
Joined: Thu Sep 17, 2015 6:06 am

Re: Replaying a Node

Post by samcsss »

Thanks Tony,

Actually came up with something very similar by modifying the Backtracker script before looking at your reply:

Code: Select all

    
    public class Backtracker : MonoBehaviour
    {
        private ConversationState lastState = null;

        public void OnConversationLine(Subtitle subtitle)
        {
            lastState = DialogueManager.CurrentConversationState;
        }

        // Call this method to go back:
        public void Backtrack(bool toPreviousNPCLine)
        {
            if (lastState == null)// || lastState.subtitle.speakerInfo.IsNPC == false)
                return;

            lastState.subtitle.formattedText = FormattedText.Parse(lastState.subtitle.dialogueEntry.currentDialogueText, 
                DialogueManager.masterDatabase.emphasisSettings);
            DialogueManager.ConversationController.GotoState(lastState);

        }
    }
I guess there's no need to track the current conversation state in a variable if I can pull it form the DialogueManager though.
I'll fool around with whether GotoState is the better option - we might want to replay play the localized audio when changing languages
Thanks for your help!
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: [Solved] Replaying a Node

Post by Tony Li »

Happy to help!
Post Reply