Arcweave Synchronisation

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
MeishinTale
Posts: 6
Joined: Tue Mar 23, 2021 9:37 am

Arcweave Synchronisation

Post by MeishinTale »

Hi,
First and foremost, thanks a looot for the updates and Arcweave 3rd party import support to Dialogue System !

I had 2 questions regarding this import ;
1- I can't seem to export boards correctly from the get go from Arcweave. Import gives me a ;
Dialogue System: Can't find root board in Arcweave Project.
unless i manually add

Code: Select all

"root": true,
to the exported board (even with a single board with 2 elements connected by a single connection).
Am i missing something ? (some hidden arcweave export options maybe?)

2- If i understand correctly, Merging dialogue databases at import overwrites single elements from old database also present in new import database. As such any modification made inside a conversation within a dialogue database is lost when re-importing corresponding board from arcweave (in particular Conditions, Scripts and events).

Conditions and scripts (even lua functions not recognized in Arcweave such as SetQuestEntryState) can both be imported from Arcweave (which is amazing btw!), so i can defined them directly in Arcweave and overwrite the whole board on import, but would there be a way to handle events imports? (quid references)

Edited :
Implemented import rules on conversation (as "keep old Conditions / Scripts / events" if none are found on the same new node), works great, but i guess i understand why you didnt do it in the first place :D No ID to use from Arcweave export so it's either based on import generated ID (which will change when adding elements in the source) or the Title (which i guess is OK as long as you're well aware you shouldn't change titles in Arcweave past 1st import).

Lastly, Do you have any plan to update current behavior in a near future ?

Thanks in advance, and thanks again for your awesome work !
MeishinTale
Posts: 6
Joined: Tue Mar 23, 2021 9:37 am

Re: Arcweave Synchronisation

Post by MeishinTale »

For anyone interested in keeping dialogue entries values set up directly in the Dialogue System when re-importing boards from Arcweave (dialogue entrie match based on "Title");
In AddConversations() ArcweaveImporter.cs, line 605 :

Code: Select all

	// Create conversation:
	var conversationTitle = GetConversationTitle(board);
	Conversation backupConversation = default;
	if (merge) 
	{
		backupConversation = database.conversations.Where(x => x.Title == conversationTitle).FirstOrDefault();   // Assuming each conversation has a unique title
		database.conversations.RemoveAll(x => x.Title == conversationTitle);
	}

In AddConversations() ArcweaveImporter.cs, line 605 (at the end of if (arcweaveProject.boards.TryGetValue(boardGuid, out board))):

Code: Select all

	// --- MERGE -----
	if (merge && backupConversation != default) MergeConversations(conversation, backupConversation);
Then define MergeConversations (within ArcweaveImporter.cs) :

Code: Select all

	/// <summary>
        /// Keeps old Sequences / Conditions / Scripts / events if none are found on the new dialogue entry
        /// Matches Old entries to new Entries using Title
        /// </summary>
        /// <param name="conversation"> The New conversation </param>
        /// <param name="oldConversation"> The Old conversation </param>
        private void MergeConversations(Conversation conversation, Conversation oldConversation)
        {
            foreach (DialogueEntry newDialogueEntrie in conversation.dialogueEntries)
            {
                // Get corresponding entry in old conversation based on Title
                // We need to use TouchUpRichText since it has not been yet applied on the new board
                // So newDialogueEntrie.Title looks like "<p style=\"margin-left: 0px\">Title_Example<\/p>" where we expect Title_Example
                string newTitle = TouchUpRichText(newDialogueEntrie.Title);     
                DialogueEntry oldDialogueEntrie = oldConversation.GetDialogueEntry(newTitle);
                // Skip if there's not old entry associated to title
                if (oldDialogueEntrie == null) continue;
                // For each dialogue entry content, fetch old value only if there is no value defined in the new entry
                // For Sequence
                if (!string.IsNullOrEmpty(oldDialogueEntrie.Sequence) && string.IsNullOrEmpty(newDialogueEntrie.Sequence))
                    newDialogueEntrie.Sequence = oldDialogueEntrie.Sequence;
                // For Conditions
                if (!string.IsNullOrEmpty(oldDialogueEntrie.conditionsString) && string.IsNullOrEmpty(newDialogueEntrie.conditionsString))
                    newDialogueEntrie.conditionsString = oldDialogueEntrie.conditionsString;
                // For Script
                if (!string.IsNullOrEmpty(oldDialogueEntrie.userScript) && string.IsNullOrEmpty(newDialogueEntrie.userScript))
                    newDialogueEntrie.userScript = oldDialogueEntrie.userScript;
                // For Events
                if (oldDialogueEntrie.onExecute.GetPersistentEventCount() > 0 && (newDialogueEntrie.onExecute.GetPersistentEventCount() == 0))
                    newDialogueEntrie.onExecute = oldDialogueEntrie.onExecute;
            }
	}
User avatar
Tony Li
Posts: 22131
Joined: Thu Jul 18, 2013 1:27 pm

Re: Arcweave Synchronisation

Post by Tony Li »

Hi,

For (1), Make sure your conversations are inside a Board (as in the "Dialogues" board below) and start with a Dialogue that then has dialogue elements inside it:


Image


The Dialogue should be a direct child of a Board.


For (2), thank you for sharing your code. If you want to continue with this workflow, I suggest adding a searchable comment such as "//[MeishinTale]" or otherwise documenting the changes so you can reapply then after updating the Dialogue System in the future.

However, I recommend maintaining a definitive source of your dialogue entirely in Arcweave. As your project grows, it will get messy to have some changes in Arcweave and other changes in your dialogue database that aren't in Arcweave. In other words, if you're using Arcweave, add all content to Arcweave, not to the dialogue database. Let the Arcweave importer create the dialogue database fresh with each import. This will also help avoid issues where you've intentionally removed code in an Arcweave element; otherwise, if you merge like in your code, your dialogue database will still have code that it shouldn't have.
MeishinTale
Posts: 6
Joined: Tue Mar 23, 2021 9:37 am

Re: Arcweave Synchronisation

Post by MeishinTale »

Hello, thanks for the reply !

For 1°) with a fresh board with 2 elements ;
Image

This is what is generated by arcweave from start to end of board section;
"startingElement": "101c0f3d-1fbf-4730-a2f1-50911af40626",
"boards": {
"7d51913d-90a0-4834-896e-5891b41314e6": {
"name": "Test",
"notes": [],
"jumpers": [],
"branches": [],
"elements": [
"101c0f3d-1fbf-4730-a2f1-50911af40626",
"e465db18-b6aa-4527-bd2f-7fcc43163e10"
],
"connections": [
"873966ae-1715-4d5f-9d57-31240bc927cd"
]
}
},
It's missing a
"root": true,
and will generate the error (Can't find root board) unless added manually.
(Tried different configurations, doesnt change anything if i had some text in the connection(s))

For 2°) ; Yeah i documented everything and would usually agree 100% with you on the "one source of truth" tho it would require adding things like If QuestEntryState and equivalent methods to my custom Quest system which are unrecognized by arcweave thus a writer with no access to Unity would have no way to test the logic (logic that is usually not expected from a writer in the first place)
User avatar
Tony Li
Posts: 22131
Joined: Thu Jul 18, 2013 1:27 pm

Re: Arcweave Synchronisation

Post by Tony Li »

Hi,

For (1), can you create your dialogue inside a folder?

folderDialogue.png
folderDialogue.png (22.55 KiB) Viewed 1802 times
MeishinTale
Posts: 6
Joined: Tue Mar 23, 2021 9:37 am

Re: Arcweave Synchronisation

Post by MeishinTale »

Yeah it's the same ;
Image

Code: Select all

"startingElement": "0f505c44-fb8b-4018-8cd9-ad2f2bdbb277",
    "boards": {
        "e48ef3cc-3a1e-42b8-a3a6-f5eaf3f75b5a": {
            "name": "SimpleTest Dialogue",
            "notes": [],
            "jumpers": [],
            "branches": [],
            "elements": [
                "80d7acc1-bbdb-4a40-aa07-d23132ff7057",
                "0f505c44-fb8b-4018-8cd9-ad2f2bdbb277",
                "95254588-412d-48a8-b730-c88d74f3b026"
            ],
            "connections": [
                "4966fb54-4265-4a6f-bd29-d84cf21ceca8",
                "4639b68a-5735-473f-9623-984f34fcbf74"
            ]
        }
    },
Changing name to SimpleTest, or exporting 2 boards instead of one yield the same results :o
User avatar
Tony Li
Posts: 22131
Joined: Thu Jul 18, 2013 1:27 pm

Re: Arcweave Synchronisation

Post by Tony Li »

Hi,

Does your JSON file contain any board with the property "root":true?

For example, if you create a new Arcweave project using the "Sample interactive walkthrough" option, the JSON will start like this:

Code: Select all

{
    "startingElement": "38375689-9e4d-430e-954c-65205eb622fe",
    "boards": {
        "2ad15ff6-f2ba-4f1d-9d9d-68938c683d7e": {
            "name": "Root",
            "root": true,
            "children": [
                "630fdb8a-48d6-473e-9974-2460f7eb2b41",
                "733b1cc4-6d51-4ad6-9fba-444b4f2d98f3",
                "b924f43d-3c3c-4769-b9c2-34a7a5c8da49"
            ]
        },
        "630fdb8a-48d6-473e-9974-2460f7eb2b41": {
            "name": "Main Board",
            "notes": [
Notice that there's a Root node with the property "root":true.
MeishinTale
Posts: 6
Joined: Tue Mar 23, 2021 9:37 am

Re: Arcweave Synchronisation

Post by MeishinTale »

Hi back,

Did some testing and this is what i found;
-> Exporting a new "Sample interactive walkthrough" using "all boards" option does generate a "root": true,
-> Exporting a new "Sample interactive walkthrough" using "Select boards" option does NOT generate "root": true,, even if all boards are selected
-> Exporting my project does NOT generate any "root": true,, whatever the option selected

At this point it seems Arcweave did not test thoroughly their export or did not bother explaining their export rules (saw nothing on the world wide web apart from their walkthrough project example), i'll just remove that root condition in the import on my end, i've no use for it anyway and have already modified some files anyway :)

Thanks for your time !
User avatar
Tony Li
Posts: 22131
Joined: Thu Jul 18, 2013 1:27 pm

Re: Arcweave Synchronisation

Post by Tony Li »

Hi,

I just had an email exchange with the Arcweave devs.

The Dialogue System importer requires that the Arcweave export contains the "root" board. This is so it can consistently determine the hierarchy of folders and boards and include the full hierarchy in conversation titles.

As you've seen, if you export all boards, it will include the root board.

If you do a selective export, it will not include the root board.

I'll update our documentation to make it clear that the Dialogue System importer requires that you export all boards. (Your customized version being an exception to the rule of course.)

The Arcweave devs have also offered to change the export so that it always includes the folder hierarchy even if you export select boards. So, with select board exports, the hierarchy will be the same as an "all boards" export, but it will only contain the dialogues you've selected for export.
User avatar
Tony Li
Posts: 22131
Joined: Thu Jul 18, 2013 1:27 pm

Re: Arcweave Synchronisation

Post by Tony Li »

The devs just updated Arcweave. Even if you export only selected boards, not the entire project, it will now properly include the root board.
Post Reply