Good method to save and load previous subtitles?

Announcements, support questions, and discussion for the Dialogue System.
CuickQat
Posts: 6
Joined: Sun Sep 08, 2024 1:34 pm

Good method to save and load previous subtitles?

Post by CuickQat »

Hello, thank you for creating this cool asset. Really helps me alot.
I'm currently making a game using SMS-like dialogue window(like Discord app), and this SMS-like window should contain all of the previous dialogues and load them at loading a savefile in a new game session.

Also I had to consider minimizing my game savefile, I am finding a method to save all of the dialogue data as simple as possible and load it at once.
What methods can I use?

this is what I was trying btw...

I tried to make a list of the shown dialogues using method like this:

Code: Select all

public void OnConverSationLine(Subtitle subtitle)
    {
        conversationLog.Add(SubtitleToDialogueInt(subtitle));
    }
    public int SubtitleToDialogueInt(Subtitle subtitle)
    {
        int conversationID = subtitle.dialogueEntry.conversationID;
        int entryID = subtitle.dialogueEntry.id;

        return conversationID * 10000 + entryID;
    }
    
and load by finding a dialogueEntry via masterDatabase like this:

Code: Select all

    public static DialogueEntry DialogueIntToDialogueEntry(int dialogueInt)
    {
        int conversationID = dialogueInt / 10000;
        int entryID = dialogueInt % 10000;

        return DialogueManager.masterDatabase.GetDialogueEntry(conversationID, entryID);
    }
but eventually got lost, where I needed the subtitle class to use panel.ShowSubtitle() function to mimic the dialogue entry at game load.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Good method to save and load previous subtitles?

Post by Tony Li »

Hi,

If you're using the SMSDialogueUI component, you can call its SaveConversation() method to save its data to a Dialogue System variable. To resume that conversation, call ResumeConversation("title").

If you've set up the save system, the DialogueSystemSaver component will save the Dialogue System variables, including the variable(s) that contain SMSDialogueUI conversation histories.

Tip: If you want to override or add to some behavior in SMSDialogueUI, make a subclass instead of directly modifying the script file. This way you won't lose your customizations when you update the Dialogue System.
CuickQat
Posts: 6
Joined: Sun Sep 08, 2024 1:34 pm

Re: Good method to save and load previous subtitles?

Post by CuickQat »

Thank you for the quick reply.
Yes, I am using SMSDialogueUI Component and using save system.(with ES3 data storer)
But it didn't gave me the desired effect I wanted.

I'll explain more details:

My game uses only 2 actors, PC and NPC.
The game has multiple Dialogue triggers with multiple conversations, can be used in an undetermined order.
The game's SMS screen will show every past dialogue lines in a shown order, save system will save these properties and order, and while loading a save in a new session, populate past dialogue lines.
(It's just like Discord desktop app)

SMSDialogueUI component only shows the dialogues of the very conversation, and can't be used if I use condition to call same conversation multiple times.

This is why I wanted to create a new system for save&loading.
Will there be any good method to make a function like this?

PS. Thank you for the Tips, I will create a subclass if I modify the files from the package.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Good method to save and load previous subtitles?

Post by Tony Li »

Hi,
CuickQat wrote: Tue Sep 10, 2024 10:02 pmSMSDialogueUI component only shows the dialogues of the very conversation, and can't be used if I use condition to call same conversation multiple times.
Can you explain what you mean by this?

Using the SMSDialogueUI, you can exit a conversation (SaveConversation() + DialogueManager.StopConversation()) and return to it later (ResumeConversation()). It will show the dialogue entries that were previously shown and then continue from there.

In-between, you can also do the same for other conversations. It works similarly to Discord DMs or SMS apps.
CuickQat
Posts: 6
Joined: Sun Sep 08, 2024 1:34 pm

Re: Good method to save and load previous subtitles?

Post by CuickQat »

You know, SaveConversation() or OnRecordPersistentData() saves previous dialogue entries with each conversation name. And also ResumeConversation() will use the conversation name parameter and mimic the DialogueManager.StartConversation() function with it.

I am using multiple conversations for same actor-conversant group, since conversations of my game is based on indetermined conversation order.
So I decided to create which is not tied into a single Conversation, and save & reload every shown Dialogue Entry regardless of it's conversation name.

So it's basically a backlog function for an SMS, which can easily handed over between gameplay sessions by save system.
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Good method to save and load previous subtitles?

Post by Tony Li »

Hi,

Got it. That sounds fine, too. You might find this example helpful for some of the code.
CuickQat
Posts: 6
Joined: Sun Sep 08, 2024 1:34 pm

Re: Good method to save and load previous subtitles?

Post by CuickQat »

Thanks, I will take a deep look inside and try making one for my own.
btw, is there any function I can find a Conversation from a DialogueEntry?
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Good method to save and load previous subtitles?

Post by Tony Li »

Hi,

Each DialogueEntry has a conversationID value. Example:

Code: Select all

DialogueEntry entry = DialogueManager.currentConversationState.subtitle.dialogueEntry;
Conversation conversation = DialogueManager.masterDatabase.GetConversation(entry.conversationID);
Debug.Log("Conversation: " + conversation.Title);
CuickQat
Posts: 6
Joined: Sun Sep 08, 2024 1:34 pm

Re: Good method to save and load previous subtitles?

Post by CuickQat »

Sorry, mb, not a conversation, A Subtitle.
Can I get a subtitle class from a DialogueEntry?
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Good method to save and load previous subtitles?

Post by Tony Li »

If it's the current dialogue entry in the active conversation, you can get it from DialogueManager.currentConversationState.subtitle.

If you only have an arbitrary DialogueEntry, you can create a Subtitle object from it using new Subtitle().
Post Reply