SVG sheets: draw tool hint, convert to PNG for Rebirth; game copy skips built-in events

Drawing or erasing on an SVG spritesheet shows why it can't be edited (and
no longer leaves an empty undo step). Saving a Rebirth document whose layers
show SVG spritesheets first offers to convert them into PNGs beside them
(one undoable edit); keeping them counts them in the Isaac warning. The
game's copy of a trigger keeps its first event that isn't stop or done, and
only further custom events count as dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-10-08 17:56:06 -04:00
1 parent 5d274e547a
commit 280adaa189
14 files changed
+154 -10

No files matched your search

+16
View File
@@ -3,6 +3,11 @@
#include <algorithm>
#include <unordered_set>
#include "image.hpp"
#include "path.hpp"
using namespace anm2ed::util;
namespace anm2ed::model
{
// The slot holding the animation at a flat index (animations inside groups count in order), or nullptr.
@@ -369,6 +374,17 @@ namespace anm2ed::model
repair(library.uid);
}
// SVG spritesheets that layers show.
std::set<int> spritesheets_vector_used_get(const Model& model)
{
std::set<int> ids{};
for (const auto& layer : model.content.layers)
if (auto spritesheet = item_get(model.content.spritesheets, layer.spritesheetId);
spritesheet && !layer.is_animation() && path::is_extension(spritesheet->path, resource::image::SVG_EXTENSION))
ids.insert(spritesheet->id);
return ids;
}
int track_frames_count_get(const Track& track) { return (int)track.frames.size(); }
int track_length_get(const Track& track)
+1
View File
@@ -416,6 +416,7 @@ namespace anm2ed::model
};
bool is_model_equal(const Model&, const Model&);
std::set<int> spritesheets_vector_used_get(const Model&);
int track_frames_count_get(const Track&);
int track_length_get(const Track&);
int animation_length_get(const Animation&);
+20 -7
View File
@@ -13,7 +13,6 @@
#include "file.hpp"
#include "frames.hpp"
#include "image.hpp"
#include "math.hpp"
#include "path.hpp"
#include "time.hpp"
@@ -1125,12 +1124,21 @@ namespace anm2ed::model
if (type == ItemType::TRIGGER)
{
sink.open(tag_get(ElementType::TRIGGER));
if (!frame.eventIds.empty()) sink.attribute("EventId", frame.eventIds.front());
// The game's copy (one event per trigger) keeps the first event that isn't built in.
auto eventIds = frame.eventIds;
if (!writer.is(SERIALIZE_EXTENSIONS) && writer.model)
std::erase_if(eventIds,
[&](int id)
{
auto event = item_get(writer.model->content.events, id);
return event && is_event_built_in(event->name);
});
if (!eventIds.empty()) sink.attribute("EventId", eventIds.front());
sink.attribute("AtFrame", frame.atFrame);
extras_write(sink, frame.extras);
Children children{sink, frame.extras};
if (writer.is(SERIALIZE_EXTENSIONS))
for (auto eventId : frame.eventIds | std::views::drop(1))
for (auto eventId : eventIds | std::views::drop(1))
{
children.add();
sink.open(tag_get(ElementType::EVENT_ELEMENT));
@@ -1374,9 +1382,7 @@ namespace anm2ed::model
{
IsaacIssues issues{};
issues.animationLayers = (int)std::ranges::count_if(model.content.layers, &Layer::is_animation);
issues.vectorSpritesheets =
(int)std::ranges::count_if(model.content.spritesheets, [](const Spritesheet& spritesheet)
{ return path::is_extension(spritesheet.path, resource::image::SVG_EXTENSION); });
issues.vectorSpritesheets = (int)spritesheets_vector_used_get(model).size();
for (auto [index, animation] : model.animations_get())
{
for (const auto* entries : {&animation->layers, &animation->nulls})
@@ -1394,7 +1400,14 @@ namespace anm2ed::model
issues.depthFrames += track.type == ItemType::LAYER && frame.depth != 0;
issues.alphaOffsetFrames += math::float_to_uint8(frame.colorOffset.a) != 0;
issues.blurFrames += track.type == ItemType::LAYER && frame.blur != 0.0f;
issues.extraEvents += track.type == ItemType::TRIGGER ? std::max((int)frame.eventIds.size() - 1, 0) : 0;
// Built-in events are left out of the game's copy on purpose; only further custom ones are lost.
auto customEvents = std::ranges::count_if(frame.eventIds,
[&](int id)
{
auto event = item_get(model.content.events, id);
return !event || !is_event_built_in(event->name);
});
issues.extraEvents += track.type == ItemType::TRIGGER ? std::max((int)customEvents - 1, 0) : 0;
issues.triggerSounds += track.type == ItemType::TRIGGER &&
std::ranges::any_of(frame.soundIds, [](int id) { return id != -1; });
}