Skip to content

Add JSON import/export support for dialogues#21

Open
pixeru wants to merge 10 commits into
NotYetGames:masterfrom
pixeru:master
Open

Add JSON import/export support for dialogues#21
pixeru wants to merge 10 commits into
NotYetGames:masterfrom
pixeru:master

Conversation

@pixeru
Copy link
Copy Markdown

@pixeru pixeru commented May 19, 2026

Added json support so it's easier to import/export! :)

Added

  • FDlgJsonDialogueHelper — static utility class with 5 methods:
    • ExportDialogueToJson — serializes a dialogue to a JSON string
    • ImportDialogueFromJson — updates existing nodes from JSON
    • ImportDialogueFromJsonFile — file-based wrapper for the above
    • ImportDialogueFromJsonDestructive — full destructive overwrite from JSON
    • ImportDialogueFromJsonFileDestructive — file-based wrapper for the above
  • Toolbar buttons in the Dialogue Editor: Import JSON... and Export JSON...
  • File picker dialogs for .dlg_human.json files
  • Non-destructive import with fallback to destructive overwrite (with confirmation warning)

Design notes

  • Reuses existing FDlgJsonWriter / FDlgJsonParser and FDlgDialogue_FormatHumanReadable
  • No changes to the runtime DlgSystem module
  • Adds DesktopPlatform dependency to DlgSystemEditor.Build.cs for file dialogs

pixeru added 2 commits May 18, 2026 23:54
Adds FDlgJsonDialogueHelper with non-destructive and destructive JSON
import/export for UDlgDialogue assets. Uses existing DlgJsonWriter/
DlgJsonParser and FDlgDialogue_FormatHumanReadable infrastructure.

- ExportDialogueToJson: serializes dialogue to JSON string
- ImportDialogueFromJson: updates existing dialogue text/speakers/edges
- ImportDialogueFromJsonDestructive: rebuilds dialogue from JSON
- Add ImportDialogueJSON and ExportDialogueJSON UI commands
- Add DesktopPlatform module dependency for file dialogs
- Wire Import JSON... and Export JSON... buttons into the Dialogue Editor toolbar
- Add OnCommandImportDialogueJSON and OnCommandExportDialogueJSON handlers
  with file picker dialogs and success/failure message boxes
@pixeru
Copy link
Copy Markdown
Author

pixeru commented May 22, 2026

Still waiting for approval! :)

Comment thread Source/DlgSystemEditor/IO/DlgJsonDialogueHelper.h Outdated
else
{
// Create speech node
UDlgNode_Speech* SpeechNode = Dialogue->ConstructDialogueNode<UDlgNode_Speech>();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The destructive import is not a faithful full overwrite. SpeechSequenceNodes are recreated separately, but SpeechNodes also contains fallback exports for unsupported node types from ExportDialogueToHumanReadableFormat (End/Proxy/Selector/Custom/etc.).

This branch recreates every non-root SpeechNodes entry as UDlgNode_Speech, so those node types are changed into speech nodes and their original data is lost. Please either serialize enough type-specific data to reconstruct the original nodes, or avoid offering this as a destructive full-dialogue import.

Comment thread Source/DlgSystemEditor/IO/DlgJsonDialogueHelper.cpp Outdated
Comment thread Source/DlgSystemEditor/IO/DlgJsonDialogueHelper.cpp Outdated
Comment thread Source/DlgSystemEditor/IO/DlgJsonDialogueHelper.cpp
@pixeru pixeru requested a review from vampy May 25, 2026 17:07
pixeru added 8 commits May 25, 2026 10:45
Rename the node-update JSON import helpers so callers can tell they only update matching existing nodes. Rename the destructive helpers as replacement imports and document the public JSON helper behavior in the header.
Record the rebuilt dialogue node index returned by AddNode for each imported JSON node and use that remapped index when recreating FDlgEdge targets. This keeps edges valid when replacement import reorders speech and speech sequence nodes.
Keep node-update imports successful when matching JSON produces no changes, while preserving failure reporting for imports that process no nodes due to structure mismatches.
@pixeru
Copy link
Copy Markdown
Author

pixeru commented May 26, 2026

Alright, the adjustments are applied! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants