Project, scene and prefab files as JSON #42

Open
UnflavoredMeson/Primal_Plus_Plus
opened 2026-11-24 20:16:01 +00:00 by UnflavoredMeson · 0 comments
Owner

Why

The editor needs files for projects, scenes and prefabs. Nothing has to read the WPF editor's XML, so the format can be chosen fresh.

Decided

  • JSON text for project, scene and prefab files: readable in diffs, merge-friendly. Imported asset data and game.bin stay binary.
  • nlohmann/json (MIT, one header), downloaded and pinned like doctest.
  • Every file has a "format" version from v1; a newer version is refused with a clear message.
  • Fields are written by their reflected names; 64-bit integers are written as strings.
  • Asset references are GUIDs.

Read first

  • Actors, section 10 (what the fork's files held).
  • PrimalEditor/GameProject/Project.cs on master (what a project knows).

Steps

  • 1. Write round-trip tests: a project with two scenes, a scene with entities and fields of every reflected type, a u64 above 2^53.
  • 2. Write the readers and writers until they pass.
  • 3. Refuse a file with a future format version; test it.

Done when

  • Round-trip tests pass; a saved scene diffs cleanly after one field change; 0 warnings; tidy 0.

Claude can help with

  • Test fixtures for every field type.

Learn

  • Why JSON numbers can't hold every u64.
## Why The editor needs files for projects, scenes and prefabs. Nothing has to read the WPF editor's XML, so the format can be chosen fresh. ## Decided - JSON text for project, scene and prefab files: readable in diffs, merge-friendly. Imported asset data and game.bin stay binary. - nlohmann/json (MIT, one header), downloaded and pinned like doctest. - Every file has a `"format"` version from v1; a newer version is refused with a clear message. - Fields are written by their reflected names; 64-bit integers are written as strings. - Asset references are GUIDs. ## Read first - [Actors](https://forgejo.unflavoredmeson.com/UnflavoredMeson/Primal_Plus_Plus/wiki/Actors), section 10 (what the fork's files held). - `PrimalEditor/GameProject/Project.cs` on `master` (what a project knows). ## Steps - [ ] 1. Write round-trip tests: a project with two scenes, a scene with entities and fields of every reflected type, a `u64` above 2^53. - [ ] 2. Write the readers and writers until they pass. - [ ] 3. Refuse a file with a future format version; test it. ## Done when - [ ] Round-trip tests pass; a saved scene diffs cleanly after one field change; 0 warnings; tidy 0. ## Claude can help with - Test fixtures for every field type. ## Learn - Why JSON numbers can't hold every `u64`.
Sign in to join this conversation.
No assignees
No project
No milestone
Blocks
#46 Outliner, details, gizmos, undo and redo
UnflavoredMeson/Primal_Plus_Plus
Depends on
#21 Reflection generator PrimalReflectGen
UnflavoredMeson/Primal_Plus_Plus
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
UnflavoredMeson/Primal_Plus_Plus#42
No description provided.