Slim Document: move data-model code out, unify edit plumbing
- Region generate/scan move to anm2/regions.cpp; both generators number from 1 - file_merge moves to anm2/merge.cpp and is table-driven - MaxRects packer moves to util/pack - Uniform config apply/trim/save move to resource/shader - Snapshots push from their owned state; Document snapshot wrappers removed - DocumentData base replaces the hand-written move constructor - toast_log replaces 55 duplicated toast + English log pairs - Apply repo .clang-format to touched files Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a9f48bc3a0
commit
3f31cedeed
32 files changed
+3405
-4428
No files matched your search
+3
-30
@@ -15,25 +15,6 @@ namespace anm2ed
|
||||
});
|
||||
}
|
||||
|
||||
template <class Callback> void layer_frames_each(Element& root, Callback&& callback)
|
||||
{
|
||||
auto layers = content_container_get(root, ElementType::LAYERS);
|
||||
auto spritesheets = content_container_get(root, ElementType::SPRITESHEETS);
|
||||
if (!layers || !spritesheets) return;
|
||||
|
||||
animations_tracks_each(root, ElementType::LAYER_ANIMATION,
|
||||
[&](Element& track)
|
||||
{
|
||||
auto layer = child_id_get(*layers, ElementType::LAYER_ELEMENT, track.layerId);
|
||||
auto spritesheet = layer ? child_id_get(*spritesheets, ElementType::SPRITESHEET,
|
||||
layer->spritesheetId)
|
||||
: nullptr;
|
||||
if (!spritesheet) return;
|
||||
for (auto& frame : track.children)
|
||||
if (frame.type == ElementType::FRAME) callback(frame, *spritesheet);
|
||||
});
|
||||
}
|
||||
|
||||
void shader_ids_repair(Element& root)
|
||||
{
|
||||
auto shaders = content_container_get(root, ElementType::SHADERS);
|
||||
@@ -69,21 +50,13 @@ namespace anm2ed
|
||||
void region_frame_ids_repair(Element& root)
|
||||
{
|
||||
layer_frames_each(root,
|
||||
[](Element& frame, const Element& spritesheet)
|
||||
[](Element& frame, Element& spritesheet)
|
||||
{
|
||||
auto is_region_match = [&](const Element& region)
|
||||
{
|
||||
return region.type == ElementType::REGION &&
|
||||
glm::ivec2(region.crop) == glm::ivec2(frame.crop) &&
|
||||
glm::ivec2(region.size) == glm::ivec2(frame.size) &&
|
||||
glm::ivec2(region.pivot) == glm::ivec2(frame.pivot);
|
||||
};
|
||||
|
||||
auto region = frame.regionId == -1
|
||||
? nullptr
|
||||
: child_id_get(spritesheet, ElementType::REGION, frame.regionId);
|
||||
if (region && is_region_match(*region)) return;
|
||||
if (auto candidate = child_find(spritesheet, is_region_match)) frame.regionId = candidate->id;
|
||||
if (region && is_region_matched(*region, frame)) return;
|
||||
if (auto match = region_match_get(spritesheet, frame)) frame.regionId = match->id;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user