JSON documents; remove the extended format
Documents can be saved as the editor's own JSON (Save as JSON, in Configure's
Serialization row, off by default) and any .anm2 starting with '{' opens as
one. The schema is new, not an XML mirror: content items in arrays (an item's
index is its id), animations keyed by unique name (a repeat saves as "Name 2"),
groups nested, paired values as arrays, a frame on a region storing only the
region, ISO 8601 dates, every default left out, and one line per frame and
content item, with anything else that fits in 100 columns on one line. Unknown
XML isn't kept. Each part is described once (frame_io, track_io, model_io...)
and run by a JsonWriter or a JsonReader; simdjson parses (new submodule). A
JSON file that opens but has unknown keys, wrong types, unknown values or bad
indices lists them by location in a warning toast; libraries toast their load
problems too. With Save as JSON on, saving always shows the Isaac warning.
The extended format is gone: no setting, File menu toggle, ExtendedVersion or
isExtendedFormat. XML saves are always the game's copy with SourceDocument;
old extended files still open. Document saves take Options instead of loose
bools, and model_load reads through model_load_string. docs/json_format.md
replaces docs/extended_format.md; goldens lose ExtendedVersion and the
.extended variants.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d77b2bae71
commit
b69b0eaa1b
121 files changed
+1248
-913
No files matched your search
+8
-10
@@ -133,10 +133,10 @@ namespace anm2ed
|
||||
if (command.runManager) command.runManager(*this);
|
||||
}
|
||||
|
||||
Document* Manager::open(const std::filesystem::path& path, bool isNew, bool isRecent, bool isExtendedFormat)
|
||||
Document* Manager::open(const std::filesystem::path& path, bool isNew, bool isRecent)
|
||||
{
|
||||
std::string errorString{};
|
||||
documents.emplace_back(path, isNew, &errorString, isExtendedFormat);
|
||||
documents.emplace_back(path, isNew, &errorString);
|
||||
auto pathString = path::to_utf8(path);
|
||||
|
||||
auto& document = documents.back();
|
||||
@@ -153,15 +153,13 @@ namespace anm2ed
|
||||
pendingSelected = selected;
|
||||
selection_history_push(selected);
|
||||
toast_log(Level::INFO, TOAST_OPEN_DOCUMENT, pathString);
|
||||
// A JSON document that opened lists what it couldn't read.
|
||||
if (!errorString.empty()) toast_log(Level::WARNING, TOAST_OPEN_DOCUMENT_ISSUES, pathString, errorString);
|
||||
|
||||
return &document;
|
||||
}
|
||||
|
||||
// A new document targets the extended format or Rebirth's, as the settings default.
|
||||
void Manager::new_(const std::filesystem::path& path, bool isExtendedFormat)
|
||||
{
|
||||
open(path, true, true, isExtendedFormat);
|
||||
}
|
||||
void Manager::new_(const std::filesystem::path& path) { open(path, true, true); }
|
||||
|
||||
bool Manager::save(int index, const std::filesystem::path& path)
|
||||
{
|
||||
@@ -173,7 +171,7 @@ namespace anm2ed
|
||||
savePath.replace_extension(".anm2");
|
||||
ensure_parent_directory_exists(savePath);
|
||||
|
||||
if (!document->save(savePath, &errorString, isPurgeDefaultColors)) return false;
|
||||
if (!document->save(savePath, &errorString, saveOptions)) return false;
|
||||
|
||||
const auto autosavePath = document->autosave_path_get();
|
||||
autosaveFiles.erase(std::remove(autosaveFiles.begin(), autosaveFiles.end(), previousAutosavePath),
|
||||
@@ -196,7 +194,7 @@ namespace anm2ed
|
||||
{
|
||||
std::string errorString{};
|
||||
auto autosavePath = document.autosave_path_get();
|
||||
if (!document.autosave(&errorString, isPurgeDefaultColors)) return;
|
||||
if (!document.autosave(&errorString, saveOptions)) return;
|
||||
|
||||
autosaveFiles.erase(std::remove(autosaveFiles.begin(), autosaveFiles.end(), autosavePath), autosaveFiles.end());
|
||||
autosaveFiles.insert(autosaveFiles.begin(), autosavePath);
|
||||
@@ -472,7 +470,7 @@ namespace anm2ed
|
||||
// What the manager keeps from the settings: shortcuts, and how documents save.
|
||||
void Manager::settings_apply(Settings& settings)
|
||||
{
|
||||
isPurgeDefaultColors = settings.fileIsPurgeDefaultColors;
|
||||
saveOptions = {.isPurgeDefaultColors = settings.fileIsPurgeDefaultColors, .isJson = settings.fileIsJson};
|
||||
for (int i = 0; i < SHORTCUT_COUNT; i++)
|
||||
chords[i] = imgui::string_to_chord(settings.*SHORTCUT_MEMBERS[i]);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user