From f7109c24d0cb026b2cdeb4ff42e5fadfb7f6481b Mon Sep 17 00:00:00 2001 From: shweet Date: Sun, 28 Dec 2025 18:41:37 -0500 Subject: [PATCH] change all frame properties disallows root/nulls in some cases --- src/anm2/item.cpp | 21 +++++++++++-------- src/anm2/item.h | 2 +- src/imgui/window/animation_preview.cpp | 2 +- src/imgui/window/spritesheet_editor.cpp | 2 +- .../wizard/change_all_frame_properties.cpp | 21 +++++++++++++++++-- 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/anm2/item.cpp b/src/anm2/item.cpp index 64ca43e..e7adb99 100644 --- a/src/anm2/item.cpp +++ b/src/anm2/item.cpp @@ -126,7 +126,7 @@ namespace anm2ed::anm2 return frame; } - void Item::frames_change(FrameChange change, ChangeType type, std::set& selection) + void Item::frames_change(FrameChange change, anm2::Type itemType, ChangeType changeType, std::set& selection) { const auto clamp_identity = [](auto value) { return value; }; const auto clamp01 = [](auto value) { return glm::clamp(value, 0.0f, 1.0f); }; @@ -139,7 +139,7 @@ namespace anm2ed::anm2 if (!optionalValue) return; auto value = *optionalValue; - switch (type) + switch (changeType) { case ADJUST: target = clampFunc(value); @@ -176,18 +176,21 @@ namespace anm2ed::anm2 apply_scalar(frame.rotation, change.rotation); apply_scalar_with_clamp(frame.duration, change.duration, clamp_duration); - apply_scalar(frame.crop.x, change.cropX); - apply_scalar(frame.crop.y, change.cropY); + if (itemType == LAYER) + { + apply_scalar(frame.crop.x, change.cropX); + apply_scalar(frame.crop.y, change.cropY); - apply_scalar(frame.pivot.x, change.pivotX); - apply_scalar(frame.pivot.y, change.pivotY); + apply_scalar(frame.pivot.x, change.pivotX); + apply_scalar(frame.pivot.y, change.pivotY); + + apply_scalar(frame.size.x, change.sizeX); + apply_scalar(frame.size.y, change.sizeY); + } apply_scalar(frame.position.x, change.positionX); apply_scalar(frame.position.y, change.positionY); - apply_scalar(frame.size.x, change.sizeX); - apply_scalar(frame.size.y, change.sizeY); - apply_scalar(frame.scale.x, change.scaleX); apply_scalar(frame.scale.y, change.scaleY); diff --git a/src/anm2/item.h b/src/anm2/item.h index 6fc4c13..4d9f97d 100644 --- a/src/anm2/item.h +++ b/src/anm2/item.h @@ -20,7 +20,7 @@ namespace anm2ed::anm2 std::string to_string(Type, int = -1); int length(Type); Frame frame_generate(float, Type); - void frames_change(FrameChange, ChangeType, std::set&); + void frames_change(FrameChange, anm2::Type, ChangeType, std::set&); bool frames_deserialize(const std::string&, Type, int, std::set&, std::string*); void frames_bake(int, int, bool, bool); void frames_generate_from_grid(glm::ivec2, glm::ivec2, glm::ivec2, int, int, int); diff --git a/src/imgui/window/animation_preview.cpp b/src/imgui/window/animation_preview.cpp index 538b161..6f28636 100644 --- a/src/imgui/window/animation_preview.cpp +++ b/src/imgui/window/animation_preview.cpp @@ -746,7 +746,7 @@ namespace anm2ed::imgui if (tool == tool::SCALE && isMouseRightDown) useTool = tool::MOVE; auto frame_change_apply = [&](anm2::FrameChange frameChange, anm2::ChangeType changeType = anm2::ADJUST) - { item->frames_change(frameChange, changeType, frames); }; + { item->frames_change(frameChange, reference.itemType, changeType, frames); }; auto& toolInfo = tool::INFO[useTool]; auto& areaType = toolInfo.areaType; diff --git a/src/imgui/window/spritesheet_editor.cpp b/src/imgui/window/spritesheet_editor.cpp index 5d16903..b19b19d 100644 --- a/src/imgui/window/spritesheet_editor.cpp +++ b/src/imgui/window/spritesheet_editor.cpp @@ -302,7 +302,7 @@ namespace anm2ed::imgui }; auto frame_change_apply = [&](anm2::FrameChange frameChange, anm2::ChangeType changeType = anm2::ADJUST) - { item->frames_change(frameChange, changeType, frames); }; + { item->frames_change(frameChange, reference.itemType, changeType, frames); }; if (isMouseMiddleDown) useTool = tool::PAN; if (tool == tool::MOVE && isMouseRightDown) useTool = tool::CROP; diff --git a/src/imgui/wizard/change_all_frame_properties.cpp b/src/imgui/wizard/change_all_frame_properties.cpp index 26672d8..d7effdd 100644 --- a/src/imgui/wizard/change_all_frame_properties.cpp +++ b/src/imgui/wizard/change_all_frame_properties.cpp @@ -50,6 +50,7 @@ namespace anm2ed::imgui::wizard auto& isInterpolated = settings.changeIsInterpolated; auto& isFlipX = settings.changeIsFlipX; auto& isFlipY = settings.changeIsFlipY; + auto& itemType = document.reference.itemType; #define PROPERTIES_WIDGET(body, checkboxLabel, isEnabled) \ ImGui::Checkbox(checkboxLabel, &isEnabled); \ @@ -183,30 +184,46 @@ namespace anm2ed::imgui::wizard ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImGui::GetStyle().ItemInnerSpacing); + ImGui::BeginDisabled(itemType != anm2::LAYER); float2_value("##Is Crop X", "##Is Crop Y", "##Crop X", localize.get(BASIC_CROP), isCropX, isCropY, crop); float2_value("##Is Size X", "##Is Size Y", "##Size X", localize.get(BASIC_SIZE), isSizeX, isSizeY, size); + ImGui::EndDisabled(); + float2_value("##Is Position X", "##Is Position Y", "##Position X", localize.get(BASIC_POSITION), isPositionX, isPositionY, position); + + ImGui::BeginDisabled(itemType != anm2::LAYER); float2_value("##Is Pivot X", "##Is Pivot Y", "##Pivot X", localize.get(BASIC_PIVOT), isPivotX, isPivotY, pivot); + ImGui::EndDisabled(); + float2_value("##Is Scale X", "##Is Scale Y", "##Scale X", localize.get(BASIC_SCALE), isScaleX, isScaleY, scale); + float_value("##Is Rotation", localize.get(BASIC_ROTATION), isRotation, rotation); + duration_value("##Is Duration", localize.get(BASIC_DURATION), isDuration, duration); + color4_value("##Is Tint R", "##Is Tint G", "##Is Tint B", "##Is Tint A", "##Tint R", "##Tint G", "##Tint B", "##Tint A", localize.get(BASIC_TINT), isTintR, isTintG, isTintB, isTintA, tint); + color3_value("##Is Color Offset R", "##Is Color Offset G", "##Is Color Offset B", "##Color Offset R", "##Color Offset B", "##Color Offset G", localize.get(BASIC_COLOR_OFFSET), isColorOffsetR, isColorOffsetG, isColorOffsetB, colorOffset); + bool_value("##Is Visible", localize.get(BASIC_VISIBLE), isVisibleSet, isVisible); + ImGui::SameLine(); + bool_value("##Is Interpolated", localize.get(BASIC_INTERPOLATED), isInterpolatedSet, isInterpolated); bool_value("##Is Flip X", localize.get(LABEL_FLIP_X), isFlipXSet, isFlipX); + ImGui::SameLine(); + bool_value("##Is Flip Y", localize.get(LABEL_FLIP_Y), isFlipYSet, isFlipY); ImGui::PopStyleVar(); - auto frame_change = [&](anm2::ChangeType type) + auto frame_change = [&](anm2::ChangeType changeType) { anm2::FrameChange frameChange; if (isCropX) frameChange.cropX = crop.x; @@ -234,7 +251,7 @@ namespace anm2ed::imgui::wizard if (isFlipYSet) frameChange.isFlipY = std::make_optional(isFlipY); DOCUMENT_EDIT(document, localize.get(EDIT_CHANGE_FRAME_PROPERTIES), Document::FRAMES, - document.item_get()->frames_change(frameChange, type, frames)); + document.item_get()->frames_change(frameChange, itemType, changeType, frames)); isChanged = true; };