Rebirth saves flatten animation layers; missing animations show red; pivot paths follow libraries

A Rebirth document's game copy turns each animation layer into plain layers,
one per layer its child draws, baked a frame at a time (runs of identical
frames merged; skew dropped), adding library spritesheets at paths relative to
the document; the editor's copy is unchanged and the Isaac warning says so.
Layers whose animation isn't in its file are drawn red in the Layers window
(nothing is said while a library hasn't loaded). Onionskin pivot paths are
redrawn when a library loads or reloads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-10-08 18:16:35 -04:00
1 parent 76c2186c81
commit 8807096170
16 files changed
+278 -21

No files matched your search

+31
View File
@@ -5,6 +5,7 @@
#include <cstdlib>
#include <format>
#include <fstream>
#include "canvas.hpp"
#include "document.hpp"
@@ -227,3 +228,33 @@ TEST_CASE("converting SVG spritesheets writes PNGs beside them")
CHECK(document.texture_get(0)->is_vector());
std::filesystem::remove_all(directory);
}
TEST_CASE("a Rebirth save flattens animation layers for the game")
{
auto directory = std::filesystem::temp_directory_path() / "anm2ed_flatten";
std::filesystem::remove_all(directory);
std::filesystem::create_directories(directory / "library");
std::filesystem::copy_file(RENDER_TEST_DIR / "nested.anm2", directory / "nested.anm2");
for (auto name : {"spin.anm2", "sheet.png"})
std::filesystem::copy_file(RENDER_TEST_DIR / name, directory / "library" / name);
auto text = std::string{};
{
std::ifstream file(directory / "nested.anm2");
text.assign(std::istreambuf_iterator<char>(file), {});
}
text.replace(text.find("Path=\"spin.anm2\""), std::string("Path=\"spin.anm2\"").size(), "Path=\"library/spin.anm2\"");
std::ofstream(directory / "nested.anm2") << text;
Document document(directory / "nested.anm2", false);
REQUIRE(document.is_valid());
document.model.isExtendedFormat = false;
REQUIRE(document.save(directory / "rebirth.anm2"));
std::ifstream file(directory / "rebirth.anm2");
std::string saved(std::istreambuf_iterator<char>(file), {});
auto game = saved.substr(0, saved.find("<SourceDocument"));
CHECK(game.find("Name=\"spin/red\"") != std::string::npos);
CHECK(game.find("Path=\"library/sheet.png\"") != std::string::npos);
CHECK(game.find(" Animation=\"") == std::string::npos);
CHECK(saved.find(" Animation=\"Spin\"") != std::string::npos);
std::filesystem::remove_all(directory);
}