diff --git a/README.md b/README.md index ebddf1a..4d3b9b8 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ A reimplementation of *The Binding of Isaac: Rebirth*'s proprietary animation ed - Pусский (Russian) - 中文 (Chinese) - 한국어 (Korean) + **If you want to help localize for your language, feel free to get in touch to contribute!** ### Note: Rendering Animations diff --git a/src/anm2/item.cpp b/src/anm2/item.cpp index 17667e8..ba651d3 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, int start, int numberFrames) + void Item::frames_change(FrameChange change, ChangeType type, int start, int numberFrames) { auto useStart = numberFrames > -1 ? start : 0; auto end = numberFrames > -1 ? start + numberFrames : (int)frames.size(); diff --git a/src/anm2/item.h b/src/anm2/item.h index abbf131..82b1cfd 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, int, int = 0); + void frames_change(FrameChange, ChangeType, int, int = 0); 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 0996a54..79e6924 100644 --- a/src/imgui/window/animation_preview.cpp +++ b/src/imgui/window/animation_preview.cpp @@ -246,6 +246,7 @@ namespace anm2ed::imgui auto& shaderAxes = resources.shaders[shader::AXIS]; auto& shaderGrid = resources.shaders[shader::GRID]; auto& shaderTexture = resources.shaders[shader::TEXTURE]; + auto& frames = document.frames.selection; auto reset_checker_pan = [&]() { @@ -735,6 +736,7 @@ namespace anm2ed::imgui auto isMod = ImGui::IsKeyDown(ImGuiMod_Shift); auto frame = document.frame_get(); + auto item = document.item_get(); auto useTool = tool; auto step = isMod ? STEP_FAST : STEP; mousePos = position_translate(zoom, pan, to_vec2(ImGui::GetMousePos()) - to_vec2(cursorScreenPos)); @@ -743,6 +745,9 @@ namespace anm2ed::imgui if (tool == tool::MOVE && isMouseRightDown) useTool = tool::SCALE; 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.begin(), frames.size()); }; + auto& toolInfo = tool::INFO[useTool]; auto& areaType = toolInfo.areaType; bool isAreaAllowed = areaType == tool::ALL || areaType == tool::ANIMATION_PREVIEW; @@ -759,7 +764,7 @@ namespace anm2ed::imgui if (isMouseDown || isMouseMiddleDown) pan += vec2(mouseDelta.x, mouseDelta.y); break; case tool::MOVE: - if (!frame) break; + if (!item || frames.empty()) break; if (isBegin) { document.snapshot(localize.get(EDIT_FRAME_POSITION)); @@ -769,11 +774,15 @@ namespace anm2ed::imgui isMoveDragging = true; } } - if (isMouseDown && isMoveDragging) frame->position = ivec2(mousePos - moveOffset); - if (isLeftPressed) frame->position.x -= step; - if (isRightPressed) frame->position.x += step; - if (isUpPressed) frame->position.y -= step; - if (isDownPressed) frame->position.y += step; + if (isMouseDown && isMoveDragging) + frame_change_apply( + {.positionX = (int)mousePos.x - moveOffset.x, .positionY = (int)mousePos.y - moveOffset.y}); + + if (isLeftPressed) frame_change_apply({.positionX = step}, anm2::SUBTRACT); + if (isRightPressed) frame_change_apply({.positionX = step}, anm2::ADD); + if (isUpPressed) frame_change_apply({.positionY = step}, anm2::SUBTRACT); + if (isDownPressed) frame_change_apply({.positionY = step}, anm2::ADD); + if (isMouseReleased) isMoveDragging = false; if (isEnd) document.change(Document::FRAMES); if (isDuring) @@ -788,17 +797,20 @@ namespace anm2ed::imgui } break; case tool::SCALE: - if (!frame) break; + if (!item || frames.empty()) break; if (isBegin) document.snapshot(localize.get(EDIT_FRAME_SCALE)); if (isMouseDown) { frame->scale += vec2(mouseDelta.x, mouseDelta.y); if (isMod) frame->scale = {frame->scale.x, frame->scale.x}; + + frame_change_apply({.scaleX = (int)frame->scale.x, .scaleY = (int)frame->scale.y}); } - if (isLeftPressed) frame->scale.x -= step; - if (isRightPressed) frame->scale.x += step; - if (isUpPressed) frame->scale.y -= step; - if (isDownPressed) frame->scale.y += step; + + if (isLeftPressed) frame_change_apply({.scaleX = step}, anm2::SUBTRACT); + if (isRightPressed) frame_change_apply({.scaleX = step}, anm2::ADD); + if (isUpPressed) frame_change_apply({.scaleY = step}, anm2::SUBTRACT); + if (isDownPressed) frame_change_apply({.scaleY = step}, anm2::ADD); if (isDuring) { @@ -814,11 +826,11 @@ namespace anm2ed::imgui if (isEnd) document.change(Document::FRAMES); break; case tool::ROTATE: - if (!frame) break; + if (!item || frames.empty()) break; if (isBegin) document.snapshot(localize.get(EDIT_FRAME_ROTATION)); - if (isMouseDown) frame->rotation += mouseDelta.y; - if (isLeftPressed || isDownPressed) frame->rotation -= step; - if (isUpPressed || isRightPressed) frame->rotation += step; + if (isMouseDown) frame_change_apply({.rotation = mouseDelta.x}, anm2::ADD); + if (isLeftPressed || isDownPressed) frame_change_apply({.rotation = step}, anm2::SUBTRACT); + if (isUpPressed || isRightPressed) frame_change_apply({.rotation = step}, anm2::ADD); if (isDuring) { diff --git a/src/imgui/window/spritesheet_editor.cpp b/src/imgui/window/spritesheet_editor.cpp index 5f786c9..f9b64b4 100644 --- a/src/imgui/window/spritesheet_editor.cpp +++ b/src/imgui/window/spritesheet_editor.cpp @@ -43,6 +43,7 @@ namespace anm2ed::imgui auto& shaderGrid = resources.shaders[shader::GRID]; auto& shaderTexture = resources.shaders[shader::TEXTURE]; auto& dashedShader = resources.shaders[shader::DASHED]; + auto& frames = document.frames.selection; auto reset_checker_pan = [&]() { @@ -186,6 +187,7 @@ namespace anm2ed::imgui clear(isTransparent ? vec4(0) : vec4(backgroundColor, 1.0f)); auto frame = document.frame_get(); + auto item = document.item_get(); if (spritesheet && spritesheet->texture.is_valid()) { @@ -299,6 +301,9 @@ namespace anm2ed::imgui return std::pair{minPoint, maxPoint}; }; + auto frame_change_apply = [&](anm2::FrameChange frameChange, anm2::ChangeType changeType = anm2::ADJUST) + { item->frames_change(frameChange, changeType, *frames.begin(), frames.size()); }; + if (isMouseMiddleDown) useTool = tool::PAN; if (tool == tool::MOVE && isMouseRightDown) useTool = tool::CROP; if (tool == tool::CROP && isMouseRightDown) useTool = tool::MOVE; @@ -324,14 +329,17 @@ namespace anm2ed::imgui if (isMouseDown || isMouseMiddleDown) pan += mouseDelta; break; case tool::MOVE: - if (!frame) break; + if (!item || frames.empty()) break; if (isBegin) document.snapshot(localize.get(EDIT_FRAME_PIVOT)); - if (isMouseDown) frame->pivot = vec2(ivec2(mousePos - frame->crop)); - if (isLeftPressed) frame->pivot.x -= step; - if (isRightPressed) frame->pivot.x += step; - if (isUpPressed) frame->pivot.y -= step; - if (isDownPressed) frame->pivot.y += step; - frame->pivot = vec2(ivec2(frame->pivot)); + if (isMouseDown) + frame_change_apply({.pivotX = mousePos.x - frame->crop.x, .pivotY = mousePos.y - frame->crop.y}); + if (isLeftPressed) frame_change_apply({.pivotX = step}, anm2::SUBTRACT); + if (isRightPressed) frame_change_apply({.pivotX = step}, anm2::ADD); + if (isUpPressed) frame_change_apply({.pivotY = step}, anm2::SUBTRACT); + if (isDownPressed) frame_change_apply({.pivotY = step}, anm2::ADD); + + frame_change_apply({.pivotX = (int)frame->pivot.x, .pivotY = (int)frame->pivot.y}); + if (isDuring) { if (ImGui::BeginTooltip()) @@ -346,40 +354,52 @@ namespace anm2ed::imgui if (isEnd) document.change(Document::FRAMES); break; case tool::CROP: - if (!frame) break; + if (!item || frames.empty()) break; if (isBegin) document.snapshot(localize.get(EDIT_FRAME_CROP)); if (isMouseClicked) { cropAnchor = mousePos; - frame->crop = vec2(ivec2(cropAnchor)); - frame->size = vec2(); + frame_change_apply({.cropX = cropAnchor.x, .cropY = cropAnchor.y, .sizeX = {}, .sizeY = {}}); } if (isMouseDown) { auto [minPoint, maxPoint] = snap_rect(glm::min(cropAnchor, mousePos), glm::max(cropAnchor, mousePos)); - frame->crop = vec2(ivec2(minPoint)); - frame->size = vec2(ivec2(maxPoint - minPoint)); + frame_change_apply({.cropX = (int)minPoint.x, + .cropY = (int)minPoint.y, + .sizeX = (int)maxPoint.x - minPoint.x, + .sizeY = (int)maxPoint.y - minPoint.y}); } - if (isLeftPressed) frame->crop.x -= stepX; - if (isRightPressed) frame->crop.x += stepX; - if (isUpPressed) frame->crop.y -= stepY; - if (isDownPressed) frame->crop.y += stepY; - frame->crop = vec2(ivec2(frame->crop)); - frame->size = vec2(ivec2(frame->size)); + if (isLeftPressed) frame_change_apply({.cropX = stepX}, anm2::SUBTRACT); + if (isRightPressed) frame_change_apply({.cropX = stepX}, anm2::ADD); + if (isUpPressed) frame_change_apply({.cropY = stepY}, anm2::SUBTRACT); + if (isDownPressed) frame_change_apply({.cropY = stepY}, anm2::ADD); + + frame_change_apply({.cropX = (int)frame->crop.x, + .cropY = (int)frame->crop.y, + .sizeX = (int)frame->size.x, + .sizeY = (int)frame->size.y}); + if (isDuring) { if (!isMouseDown) { auto minPoint = glm::min(frame->crop, frame->crop + frame->size); auto maxPoint = glm::max(frame->crop, frame->crop + frame->size); - frame->crop = vec2(ivec2(minPoint)); - frame->size = vec2(ivec2(maxPoint - minPoint)); + + frame_change_apply({.cropX = (int)minPoint.x, + .cropY = (int)minPoint.y, + .sizeX = (int)maxPoint.x - minPoint.x, + .sizeY = (int)maxPoint.y - minPoint.y}); + if (isGridSnap) { auto [snapMin, snapMax] = snap_rect(frame->crop, frame->crop + frame->size); - frame->crop = snapMin; - frame->size = snapMax - snapMin; + + frame_change_apply({.cropX = (int)snapMin.x, + .cropY = (int)snapMin.y, + .sizeX = (int)snapMax.x - snapMin.x, + .sizeY = (int)snapMax.y - snapMin.y}); } } if (ImGui::BeginTooltip()) diff --git a/src/imgui/wizard/change_all_frame_properties.cpp b/src/imgui/wizard/change_all_frame_properties.cpp index d85df38..fb2179f 100644 --- a/src/imgui/wizard/change_all_frame_properties.cpp +++ b/src/imgui/wizard/change_all_frame_properties.cpp @@ -1,7 +1,5 @@ #include "change_all_frame_properties.h" -#include -#include #include #include "math_.h" diff --git a/workshop/metadata.xml b/workshop/metadata.xml index 0e34f06..f4feb24 100644 --- a/workshop/metadata.xml +++ b/workshop/metadata.xml @@ -49,6 +49,6 @@ Alternatively, if you have subscribed to the mod, you can find the latest releas [h3]Happy animating![/h3] [img]https://files.catbox.moe/4auc1c.gif[/img] - 2.9 + 2.10 Public