De-bloat anm2 core: templates, tables, unified emitter

- Collapse const/non-const pairs into templates; Anm2::element_get uses deducing this
- Drive container/track/item mappings from ANM2_ELEMENT_TYPES, ANM2_ITEM_TYPES and TRACK_CONTAINERS
- One sink-based emitter feeds both XML writing and hashing
- frame_mix and frame_bake_split replace five copies of the bake/lerp loop
- item_add replaces layer_animation_add/null_animation_add
- Fix timeline split ignoring shear

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-10-03 12:54:24 -04:00
1 parent 41ed347925
commit a9f48bc3a0
23 files changed
+1087 -1978

No files matched your search

+12 -15
View File
@@ -20,10 +20,8 @@ namespace anm2ed::imgui::popup
std::set<int> ItemProperties::unused_items_get(Anm2& anm2, const Element* animation, int type)
{
if (!animation) return {};
if (type == LAYER) return anm2.element_unused(ElementType::LAYER_ELEMENT, *animation);
if (type == NULL_) return anm2.element_unused(ElementType::NULL_ELEMENT, *animation);
return {};
auto row = track_container_get((ItemType)type);
return animation && row ? anm2.element_unused(row->element, animation) : std::set<int>{};
}
void ItemProperties::open()
@@ -162,7 +160,7 @@ namespace anm2ed::imgui::popup
else if (type == NULL_)
{
auto nulls = anm2.element_get(ElementType::NULLS);
auto null = nulls ? element_child_id_get(*nulls, ElementType::NULL_ELEMENT, id) : nullptr;
auto null = nulls ? child_id_get(*nulls, ElementType::NULL_ELEMENT, id) : nullptr;
if (null)
{
auto label = std::vformat(localize.get(FORMAT_NULL), std::make_format_args(id, null->name));
@@ -191,7 +189,7 @@ namespace anm2ed::imgui::popup
auto queuedType = type;
auto queuedDestination = destination;
auto queuedAnimationIndex = reference.animationIndex;
auto queuedInsertBeforeID = reference.itemType == LAYER ? reference.itemID : -1;
auto queuedInsertBeforeID = reference.itemType == LAYER && type == LAYER ? reference.itemID : -1;
auto queuedAddItemID = addItemID;
auto queuedAddItemName = addItemName;
auto queuedAddItemSpritesheetID = addItemSpritesheetID;
@@ -200,17 +198,16 @@ namespace anm2ed::imgui::popup
manager.command_push({manager.selected,
[=](Manager&, Document& document)
{
int addId{-1};
Element item{};
item.id = queuedAddItemID;
item.name = queuedAddItemName;
item.spritesheetId = queuedAddItemSpritesheetID;
item.isShowRect = queuedAddItemIsShowRect;
document.anm2_snapshot(localize.get(EDIT_ADD_ITEM));
if (queuedType == LAYER)
addId = document.anm2.layer_animation_add(
queuedAnimationIndex, queuedAddItemID, queuedInsertBeforeID, queuedAddItemName,
queuedAddItemSpritesheetID, (destination::Type)queuedDestination);
else if (queuedType == NULL_)
addId = document.anm2.null_animation_add(queuedAnimationIndex, queuedAddItemID,
queuedAddItemName, queuedAddItemIsShowRect,
(destination::Type)queuedDestination);
auto addId = document.anm2.item_add((ItemType)queuedType, queuedAnimationIndex, item,
queuedInsertBeforeID,
(destination::Type)queuedDestination);
document.anm2_change(Document::ITEMS);
+10 -10
View File
@@ -944,8 +944,8 @@ namespace anm2ed::imgui
float t) -> std::optional<Element>
{
if (track.groupId == -1) return std::nullopt;
auto group = element_child_id_get(container, ElementType::GROUP, track.groupId);
auto root = group ? element_child_first_get(*group, ElementType::ROOT_ANIMATION) : nullptr;
auto group = child_id_get(container, ElementType::GROUP, track.groupId);
auto root = group ? child_first_get(*group, ElementType::ROOT_ANIMATION) : nullptr;
if (!root) return std::nullopt;
return frame_generate(*root, t);
};
@@ -995,7 +995,7 @@ namespace anm2ed::imgui
auto draw_group_root = [&](Element& group, int groupType, float sampleTime, const glm::mat4& sampleTransform,
vec3 sampleColor, float sampleAlpha, bool isOnion)
{
auto groupRoot = element_child_first_get(group, ElementType::ROOT_ANIMATION);
auto groupRoot = child_first_get(group, ElementType::ROOT_ANIMATION);
if (!groupRoot) return;
auto rootFrame = frame_generate(*groupRoot, sampleTime);
if (isOnlyShowLayers || !rootFrame.isVisible || !groupRoot->isVisible) return;
@@ -1019,7 +1019,7 @@ namespace anm2ed::imgui
texture_render(shaderTexture, resources.icons[icon].id, rootTransform, color);
};
if (auto layerAnimations = element_child_first_get(*animation, ElementType::LAYER_ANIMATIONS))
if (auto layerAnimations = child_first_get(*animation, ElementType::LAYER_ANIMATIONS))
{
auto layer_animation_draw = [&](auto&& self, Element& layerAnimation, bool isParentVisible = true) -> void
{
@@ -1027,7 +1027,7 @@ namespace anm2ed::imgui
{
if (isParentVisible && layerAnimation.isVisible)
{
auto groupRoot = element_child_first_get(layerAnimation, ElementType::ROOT_ANIMATION);
auto groupRoot = child_first_get(layerAnimation, ElementType::ROOT_ANIMATION);
if (layeredOnions && groupRoot)
for (auto& sample : *layeredOnions)
if (auto sampleTime = sample_time_for_item(*groupRoot, sample))
@@ -1134,7 +1134,7 @@ namespace anm2ed::imgui
layer_animation_draw(layer_animation_draw, layerAnimation);
}
if (auto nullAnimations = element_child_first_get(*animation, ElementType::NULL_ANIMATIONS))
if (auto nullAnimations = child_first_get(*animation, ElementType::NULL_ANIMATIONS))
{
auto null_animation_draw = [&](auto&& self, Element& nullAnimation, bool isParentVisible = true) -> void
{
@@ -1142,7 +1142,7 @@ namespace anm2ed::imgui
{
if (isParentVisible && nullAnimation.isVisible)
{
auto groupRoot = element_child_first_get(nullAnimation, ElementType::ROOT_ANIMATION);
auto groupRoot = child_first_get(nullAnimation, ElementType::ROOT_ANIMATION);
if (layeredOnions && groupRoot)
for (auto& sample : *layeredOnions)
if (auto sampleTime = sample_time_for_item(*groupRoot, sample))
@@ -1163,7 +1163,7 @@ namespace anm2ed::imgui
auto id = nullAnimation.nullId;
auto nulls = sampleAnm2.element_get(ElementType::NULLS);
auto nullInfo = nulls ? element_child_id_get(*nulls, ElementType::NULL_ELEMENT, id) : nullptr;
auto nullInfo = nulls ? child_id_get(*nulls, ElementType::NULL_ELEMENT, id) : nullptr;
if (!nullInfo) return;
auto isShowRect = nullInfo->isShowRect;
@@ -1314,7 +1314,7 @@ namespace anm2ed::imgui
ImGui::PushFont(resources.fonts[font::BOLD].get(), font::SIZE_LARGE);
auto triggerTextColor = isLightTheme ? TRIGGER_TEXT_COLOR_LIGHT : TRIGGER_TEXT_COLOR_DARK;
auto events = anm2.element_get(ElementType::EVENTS);
auto event = events ? element_child_id_get(*events, ElementType::EVENT_ELEMENT, trigger.eventId) : nullptr;
auto event = events ? child_id_get(*events, ElementType::EVENT_ELEMENT, trigger.eventId) : nullptr;
if (event) drawList->AddText(textPos, ImGui::GetColorU32(triggerTextColor), event->name.c_str());
ImGui::PopFont();
drawList->PopClipRect();
@@ -1379,7 +1379,7 @@ namespace anm2ed::imgui
auto item = anm2.element_get(editItemReference);
auto nulls = anm2.element_get(ElementType::NULLS);
auto selectedNull = editItemType == ItemType::NULL_ && nulls
? element_child_id_get(*nulls, ElementType::NULL_ELEMENT, editReference.itemID)
? child_id_get(*nulls, ElementType::NULL_ELEMENT, editReference.itemID)
: nullptr;
bool isSelectedNullRect = selectedNull && selectedNull->isShowRect;
auto null_rect_top_left = [](const Element& frame) { return frame.position - (frame.scale * 0.5f); };
+15 -7
View File
@@ -55,7 +55,7 @@ namespace anm2ed::imgui
Element* shader_element_get(Document& document, int id)
{
auto shaders = document.anm2.element_get(ElementType::SHADERS);
return shaders ? element_child_id_get(*shaders, ElementType::SHADER, id) : nullptr;
return shaders ? child_id_get(*shaders, ElementType::SHADER, id) : nullptr;
}
std::filesystem::path shader_asset_path_get(Document& document, const std::filesystem::path& path)
@@ -124,8 +124,12 @@ namespace anm2ed::imgui
void shader_uniform_config_save(Document& document, Element& shaderElement, const resource::shader::Uniform& uniform)
{
auto config = shader_uniform_get(shaderElement, uniform.name, true);
if (!config) return;
auto config = shader_uniform_get(shaderElement, uniform.name);
if (!config)
{
config = &shaderElement.children.emplace_back(element_make(ElementType::UNIFORM));
config->name = uniform.name;
}
config->binding = std::string(resource::shader::uniform_binding_value_get(uniform.binding));
config->value = resource::shader::uniform_value_string_get(uniform);
@@ -133,8 +137,12 @@ namespace anm2ed::imgui
{
for (int index = 0; index < (int)uniform.components.size(); ++index)
{
auto component = shader_uniform_component_get(*config, index, true);
if (!component) continue;
auto component = shader_uniform_component_get(*config, index);
if (!component)
{
component = &config->children.emplace_back(element_make(ElementType::COMPONENT));
component->index = index;
}
component->binding =
std::string(resource::shader::uniform_binding_value_get(uniform.components[index].binding));
component->value = std::format("{:.6g}", uniform.components[index].value);
@@ -382,10 +390,10 @@ namespace anm2ed::imgui
for (auto& shader : shaders->children)
if (shader.type == ElementType::SHADER) ids.push_back(shader.id);
if (reference != -1 && !element_child_id_get(*shaders, ElementType::SHADER, reference)) reference = -1;
if (reference != -1 && !child_id_get(*shaders, ElementType::SHADER, reference)) reference = -1;
for (auto it = selection.begin(); it != selection.end();)
{
if (!element_child_id_get(*shaders, ElementType::SHADER, *it))
if (!child_id_get(*shaders, ElementType::SHADER, *it))
it = selection.erase(it);
else
++it;
+3 -3
View File
@@ -122,7 +122,7 @@ namespace anm2ed::imgui
auto zoom_out = [&]() { zoom_adjust(-ZOOM_LEVEL_STEP); };
auto region_get = [&](int id)
{ return spritesheet ? element_child_id_get(*spritesheet, ElementType::REGION, id) : nullptr; };
{ return spritesheet ? child_id_get(*spritesheet, ElementType::REGION, id) : nullptr; };
if (ImGui::Begin(localize.get(LABEL_SPRITESHEET_EDITOR_WINDOW), &settings.windowIsSpritesheetEditor))
{
@@ -553,7 +553,7 @@ namespace anm2ed::imgui
auto spritesheet =
document.anm2.element_get(ElementType::SPRITESHEET, queuedSpritesheet);
if (!spritesheet) return;
auto region = element_child_id_get(*spritesheet, ElementType::REGION, id);
auto region = child_id_get(*spritesheet, ElementType::REGION, id);
if (!region) return;
update(*region);
}});
@@ -569,7 +569,7 @@ namespace anm2ed::imgui
if (!spritesheet) return;
for (auto id : queuedSelection)
{
auto region = element_child_id_get(*spritesheet, ElementType::REGION, id);
auto region = child_id_get(*spritesheet, ElementType::REGION, id);
if (!region) continue;
update(*region);
}
+18 -42
View File
@@ -60,7 +60,7 @@ namespace anm2ed::imgui
null_get = [&](int id)
{
auto nulls = anm2.element_get(ElementType::NULLS);
return nulls ? element_child_id_get(*nulls, ElementType::NULL_ELEMENT, id) : nullptr;
return nulls ? child_id_get(*nulls, ElementType::NULL_ELEMENT, id) : nullptr;
};
spritesheet_get = [&](int id) { return anm2.element_get(ElementType::SPRITESHEET, id); };
info_get = [&]() { return element_first_get(anm2.root, ElementType::INFO); };
@@ -84,12 +84,12 @@ namespace anm2ed::imgui
};
track_container_get = [&](int type)
{
return animation ? element_child_first_get(*animation, container_type_get(type)) : nullptr;
return animation ? child_first_get(*animation, container_type_get(type)) : nullptr;
};
track_group_get = [&](int type, int groupId)
{
auto container = track_container_get(type);
return container ? element_child_id_get(*container, ElementType::GROUP, groupId) : nullptr;
return container ? child_id_get(*container, ElementType::GROUP, groupId) : nullptr;
};
is_track_group_visible = [&](int type, int groupId)
{
@@ -829,7 +829,7 @@ namespace anm2ed::imgui
auto add_items = [&](const Element& container, int itemType)
{
auto trackType = item_type_to_track_type_get(static_cast<ItemType>(itemType));
auto trackType = TYPE_TRACKS[itemType];
auto add_item = [&](auto&& self, const Element& item) -> void
{
if (item.type == ElementType::GROUP)
@@ -848,10 +848,10 @@ namespace anm2ed::imgui
};
if (isLayers)
if (auto layerAnimations = element_child_first_get(targetAnimation, ElementType::LAYER_ANIMATIONS))
if (auto layerAnimations = child_first_get(targetAnimation, ElementType::LAYER_ANIMATIONS))
add_items(*layerAnimations, LAYER);
if (isNulls)
if (auto nullAnimations = element_child_first_get(targetAnimation, ElementType::NULL_ANIMATIONS))
if (auto nullAnimations = child_first_get(targetAnimation, ElementType::NULL_ANIMATIONS))
add_items(*nullAnimations, NULL_);
return result;
};
@@ -1070,33 +1070,9 @@ namespace anm2ed::imgui
auto nextFrame = track_frame_get(*item, targetReference.frameIndex + 1);
if (frame->interpolation != Interpolation::NONE && nextFrame)
{
float interpolation = (float)firstDuration / (float)originalDuration;
switch (frame->interpolation)
{
case Interpolation::EASE_IN:
interpolation *= interpolation;
break;
case Interpolation::EASE_OUT:
interpolation = 1.0f - ((1.0f - interpolation) * (1.0f - interpolation));
break;
case Interpolation::EASE_IN_OUT:
interpolation = interpolation < 0.5f
? (2.0f * interpolation * interpolation)
: (1.0f - std::pow(-2.0f * interpolation + 2.0f, 2.0f) * 0.5f);
break;
case Interpolation::LINEAR:
case Interpolation::NONE:
default:
break;
}
splitFrame.rotation = glm::mix(frame->rotation, nextFrame->rotation, interpolation);
splitFrame.position = glm::mix(frame->position, nextFrame->position, interpolation);
splitFrame.scale = glm::mix(frame->scale, nextFrame->scale, interpolation);
splitFrame.colorOffset = glm::mix(frame->colorOffset, nextFrame->colorOffset, interpolation);
splitFrame.tint = glm::mix(frame->tint, nextFrame->tint, interpolation);
}
frame_mix(splitFrame, *nextFrame,
interpolation_factor(frame->interpolation,
(float)firstDuration / (float)originalDuration));
frame->duration = firstDuration;
auto insertIndex = item_frame_insert_index_get(*item, targetReference.frameIndex + 1);
@@ -1152,7 +1128,7 @@ namespace anm2ed::imgui
rows.push_back({.type = ROOT});
if (auto layerAnimations = element_child_first_get(*animation, ElementType::LAYER_ANIMATIONS))
if (auto layerAnimations = child_first_get(*animation, ElementType::LAYER_ANIMATIONS))
{
auto groupIds = group_ids_get(*layerAnimations);
auto layer_track_push = [&](int groupId, int depth)
@@ -1183,7 +1159,7 @@ namespace anm2ed::imgui
}
}
if (auto nullAnimations = element_child_first_get(*animation, ElementType::NULL_ANIMATIONS))
if (auto nullAnimations = child_first_get(*animation, ElementType::NULL_ANIMATIONS))
{
auto groupIds = group_ids_get(*nullAnimations);
auto null_track_push = [&](int groupId, int depth)
@@ -1418,7 +1394,7 @@ namespace anm2ed::imgui
{
auto containerType = container_type_get(targetType);
auto targetTrackType = track_type_get(targetType);
auto container = element_child_first_get(*animation, containerType);
auto container = child_first_get(*animation, containerType);
if (!container) continue;
auto ids = targetIds.contains(targetType) ? targetIds.at(targetType) : std::set<int>{};
auto groupIds =
@@ -1480,7 +1456,7 @@ namespace anm2ed::imgui
auto containerType = container_type_get(targetType);
auto targetTrackType = track_type_get(targetType);
auto container = element_child_first_get(*animation, containerType);
auto container = child_first_get(*animation, containerType);
if (!container) return;
std::set<int> targetIds{};
@@ -1538,7 +1514,7 @@ namespace anm2ed::imgui
{
auto animation = command_animation_get(document, animationIndex);
if (!animation) return;
auto container = element_child_first_get(*animation, container_type_get(targetType));
auto container = child_first_get(*animation, container_type_get(targetType));
if (!container) return;
auto targetTrackType = track_type_get(targetType);
@@ -1681,7 +1657,7 @@ namespace anm2ed::imgui
frameReference.groupId);
auto frame = item ? track_frame_get(*item, frameReference.frameIndex) : nullptr;
if (!frame) continue;
auto parentType = item_type_to_track_type_get(item_type_get(frameReference.itemType));
auto parentType = TYPE_TRACKS[frameReference.itemType];
clipboardString += element_to_string(*frame, parentType);
}
if (!clipboardString.empty()) clipboard.set(clipboardString);
@@ -1758,7 +1734,7 @@ namespace anm2ed::imgui
auto frame = track_frame_get(*item, i);
if (!frame || frame->regionId == -1) continue;
auto region =
spritesheet ? element_child_id_get(*spritesheet, ElementType::REGION, frame->regionId)
spritesheet ? child_id_get(*spritesheet, ElementType::REGION, frame->regionId)
: nullptr;
if (!region) frame->regionId = -1;
}
@@ -2001,9 +1977,9 @@ namespace anm2ed::imgui
{
auto animation = command_animation_get(document, targetAnimationIndex);
auto container =
animation ? element_child_first_get(*animation, container_type_get(targetType))
animation ? child_first_get(*animation, container_type_get(targetType))
: nullptr;
auto group = container ? element_child_id_get(*container, ElementType::GROUP, targetId)
auto group = container ? child_id_get(*container, ElementType::GROUP, targetId)
: nullptr;
if (!group) return;
group->name = targetName;
+5 -5
View File
@@ -51,9 +51,9 @@ namespace anm2ed::imgui
{
auto animation = command_animation_get(document, targetAnimationIndex);
auto container =
animation ? element_child_first_get(*animation, container_type_get(targetRow.type))
animation ? child_first_get(*animation, container_type_get(targetRow.type))
: nullptr;
auto group = container ? element_child_id_get(*container, ElementType::GROUP,
auto group = container ? child_id_get(*container, ElementType::GROUP,
targetRow.id)
: nullptr;
if (!group) return;
@@ -154,10 +154,10 @@ namespace anm2ed::imgui
{
auto animation = command_animation_get(document, targetAnimationIndex);
auto container =
animation ? element_child_first_get(*animation, container_type_get(targetType))
animation ? child_first_get(*animation, container_type_get(targetType))
: nullptr;
if (!container) return;
auto group = element_child_id_get(*container, ElementType::GROUP, targetGroupId);
auto group = child_id_get(*container, ElementType::GROUP, targetGroupId);
if (!group) return;
group->isVisible = targetVisible;
});
@@ -453,7 +453,7 @@ namespace anm2ed::imgui
[=, this](Manager&, Document& document)
{
auto nulls = document.anm2.element_get(ElementType::NULLS);
auto null = nulls ? element_child_id_get(*nulls, ElementType::NULL_ELEMENT, nullID)
auto null = nulls ? child_id_get(*nulls, ElementType::NULL_ELEMENT, nullID)
: nullptr;
if (!null) return;
null->isShowRect = !null->isShowRect;
+18 -18
View File
@@ -106,7 +106,7 @@ namespace anm2ed::imgui
{
if (window.element_get) return window.element_get(anm2, key);
auto container = window_container_get(window, anm2);
return container ? element_child_id_get(*container, window.elementType, key) : nullptr;
return container ? child_id_get(*container, window.elementType, key) : nullptr;
}
int region_insert_index_get(const Element& spritesheet, const Storage& storage)
@@ -208,7 +208,7 @@ namespace anm2ed::imgui
auto element = elementGet ? elementGet(document.anm2, key) : nullptr;
if (!element)
if (auto container = document.anm2.element_get(containerType))
element = element_child_id_get(*container, elementType, key);
element = child_id_get(*container, elementType, key);
if (!element || element->name == name) return;
document.anm2_snapshot(localize.get(renameEdit));
@@ -987,7 +987,7 @@ namespace anm2ed::imgui
}
auto spritesheet = document.anm2.element_get(ElementType::SPRITESHEET, options.spritesheetId);
auto region = spritesheet ? element_child_id_get(*spritesheet, ElementType::REGION, options.regionId) : nullptr;
auto region = spritesheet ? child_id_get(*spritesheet, ElementType::REGION, options.regionId) : nullptr;
auto texture = document.texture_get(options.spritesheetId);
if (!spritesheet || !region || !texture || !texture->is_valid())
{
@@ -1774,7 +1774,7 @@ namespace anm2ed::imgui
manager.command_push({manager.selected, [targetGroupId, targetName](Manager&, Document& document)
{
auto animations = document.anm2.element_get(ElementType::ANIMATIONS);
auto group = animations ? element_child_id_get(*animations, ElementType::GROUP,
auto group = animations ? child_id_get(*animations, ElementType::GROUP,
targetGroupId)
: nullptr;
if (!group || group->name == targetName) return;
@@ -1793,7 +1793,7 @@ namespace anm2ed::imgui
manager.command_push({manager.selected, [targetGroupId, isGroupOpen](Manager&, Document& document)
{
auto animations = document.anm2.element_get(ElementType::ANIMATIONS);
auto group = animations ? element_child_id_get(*animations, ElementType::GROUP,
auto group = animations ? child_id_get(*animations, ElementType::GROUP,
targetGroupId)
: nullptr;
if (!group || group->isExpanded == isGroupOpen) return;
@@ -1883,8 +1883,8 @@ namespace anm2ed::imgui
const Element* referenceNullAnimations{};
if (auto referenceAnimation = anm2.element_get(ElementType::ANIMATION, reference.animationIndex))
{
referenceLayerAnimations = element_child_first_get(*referenceAnimation, ElementType::LAYER_ANIMATIONS);
referenceNullAnimations = element_child_first_get(*referenceAnimation, ElementType::NULL_ANIMATIONS);
referenceLayerAnimations = child_first_get(*referenceAnimation, ElementType::LAYER_ANIMATIONS);
referenceNullAnimations = child_first_get(*referenceAnimation, ElementType::NULL_ANIMATIONS);
}
animation.children.push_back(window_track_container_shell_copy(referenceLayerAnimations,
@@ -2387,7 +2387,7 @@ namespace anm2ed::imgui
auto spritesheet = document.anm2.element_get(ElementType::SPRITESHEET, document.spritesheet.reference);
if (!spritesheet || selection.size() != 1) return;
auto id = *selection.begin();
if (!element_child_id_get(*spritesheet, ElementType::REGION, id)) return;
if (!child_id_get(*spritesheet, ElementType::REGION, id)) return;
reference = id;
window.popup.open();
};
@@ -2398,7 +2398,7 @@ namespace anm2ed::imgui
auto spritesheet = anm2.element_get(ElementType::SPRITESHEET, spritesheetReference);
if (!spritesheet) return;
auto unused = anm2.element_unused(ElementType::REGION, spritesheetReference);
auto unused = anm2.region_unused(spritesheetReference);
if (unused.empty()) return;
auto behavior = [&]()
@@ -2411,7 +2411,7 @@ namespace anm2ed::imgui
for (auto& animation : animations->children)
{
if (animation.type != ElementType::ANIMATION) continue;
auto layerAnimations = element_child_first_get(animation, ElementType::LAYER_ANIMATIONS);
auto layerAnimations = child_first_get(animation, ElementType::LAYER_ANIMATIONS);
if (!layerAnimations) continue;
auto region_clear = [&](auto&& self, Element& layerAnimation) -> void
{
@@ -2486,7 +2486,7 @@ namespace anm2ed::imgui
auto insertIndex = region_insert_index_get(*spritesheet, document.region);
auto pasted = anm2;
std::string errorString{};
if (pasted.regions_deserialize(spritesheetReference, clipboard.get(), true, &errorString))
if (pasted.deserialize(ElementType::REGION, clipboard.get(), true, &errorString, {}, spritesheetReference))
{
document.anm2_snapshot(localize.get(EDIT_PASTE_REGIONS));
anm2 = std::move(pasted);
@@ -2590,7 +2590,7 @@ namespace anm2ed::imgui
for (int i = 0; i < (int)window.order.size(); i++)
{
int id = window.order[i];
auto region = element_child_id_get(*spritesheet, ElementType::REGION, id);
auto region = child_id_get(*spritesheet, ElementType::REGION, id);
if (!region) continue;
auto isNewRegion = window.newElementId == id;
auto nameCStr = region->name.c_str();
@@ -2817,7 +2817,7 @@ namespace anm2ed::imgui
{
for (auto regionId : window.dragSelection)
{
auto drag = element_child_id_get(*spritesheet, ElementType::REGION, regionId);
auto drag = child_id_get(*spritesheet, ElementType::REGION, regionId);
if (drag) ImGui::TextUnformatted(drag->name.c_str());
}
ImGui::EndTooltip();
@@ -2925,7 +2925,7 @@ namespace anm2ed::imgui
auto region_get = [&](int id)
{
auto spritesheet = spritesheet_get();
return spritesheet ? element_child_id_get(*spritesheet, ElementType::REGION, id) : nullptr;
return spritesheet ? child_id_get(*spritesheet, ElementType::REGION, id) : nullptr;
};
window.popup.trigger();
@@ -3026,7 +3026,7 @@ namespace anm2ed::imgui
auto set = [&]()
{
auto target =
element_child_id_get(*spritesheet, ElementType::REGION, editedReference);
child_id_get(*spritesheet, ElementType::REGION, editedReference);
if (!target) return;
auto changed = editedRegion;
changed.type = ElementType::REGION;
@@ -3917,7 +3917,7 @@ namespace anm2ed::imgui
auto sounds = document.anm2.element_get(ElementType::SOUNDS);
if (!sounds) return;
for (auto& id : selection)
if (auto sound = element_child_id_get(*sounds, ElementType::SOUND_ELEMENT, id))
if (auto sound = child_id_get(*sounds, ElementType::SOUND_ELEMENT, id))
clipboardText += element_to_string(*sound);
clipboard.set(clipboardText);
};
@@ -4304,7 +4304,7 @@ namespace anm2ed::imgui
}
auto target =
element_child_id_get(*layers, ElementType::LAYER_ELEMENT, editedReference);
child_id_get(*layers, ElementType::LAYER_ELEMENT, editedReference);
if (!target) return;
changed.id = editedReference;
*target = changed;
@@ -4410,7 +4410,7 @@ namespace anm2ed::imgui
return;
}
auto target = element_child_id_get(*nulls, ElementType::NULL_ELEMENT, editedReference);
auto target = child_id_get(*nulls, ElementType::NULL_ELEMENT, editedReference);
if (!target) return;
changed.id = editedReference;
*target = changed;
+1 -1
View File
@@ -256,7 +256,7 @@ namespace anm2ed::imgui::wizard
rootFrame.rotation, math::percent_to_unit(rootFrame.shear));
}
if (auto layerAnimations = element_child_first_get(*animation, ElementType::LAYER_ANIMATIONS))
if (auto layerAnimations = child_first_get(*animation, ElementType::LAYER_ANIMATIONS))
for (auto& layerAnimation : layerAnimations->children)
friend_layer_draw(state, resources, transform, layerAnimation, rootFrame);
@@ -460,7 +460,7 @@ namespace anm2ed::imgui::wizard
if (queuedIsLayers)
{
auto layerAnimations =
element_child_first_get(*animation, ElementType::LAYER_ANIMATIONS);
child_first_get(*animation, ElementType::LAYER_ANIMATIONS);
if (layerAnimations)
{
auto item_change = [&](auto&& self, Element& item) -> void
@@ -485,7 +485,7 @@ namespace anm2ed::imgui::wizard
if (queuedIsNulls)
{
auto nullAnimations =
element_child_first_get(*animation, ElementType::NULL_ANIMATIONS);
child_first_get(*animation, ElementType::NULL_ANIMATIONS);
if (nullAnimations)
{
auto item_change = [&](auto&& self, Element& item) -> void