multiselect changing on animation preview/spritesheet editor
This commit is contained in:
@@ -25,6 +25,7 @@ A reimplementation of *The Binding of Isaac: Rebirth*'s proprietary animation ed
|
|||||||
- Pусский (Russian)
|
- Pусский (Russian)
|
||||||
- 中文 (Chinese)
|
- 中文 (Chinese)
|
||||||
- 한국어 (Korean)
|
- 한국어 (Korean)
|
||||||
|
|
||||||
**If you want to help localize for your language, feel free to get in touch to contribute!**
|
**If you want to help localize for your language, feel free to get in touch to contribute!**
|
||||||
|
|
||||||
### Note: Rendering Animations
|
### Note: Rendering Animations
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ namespace anm2ed::anm2
|
|||||||
return frame;
|
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 useStart = numberFrames > -1 ? start : 0;
|
||||||
auto end = numberFrames > -1 ? start + numberFrames : (int)frames.size();
|
auto end = numberFrames > -1 ? start + numberFrames : (int)frames.size();
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace anm2ed::anm2
|
|||||||
std::string to_string(Type, int = -1);
|
std::string to_string(Type, int = -1);
|
||||||
int length(Type);
|
int length(Type);
|
||||||
Frame frame_generate(float, 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<int>&, std::string*);
|
bool frames_deserialize(const std::string&, Type, int, std::set<int>&, std::string*);
|
||||||
void frames_bake(int, int, bool, bool);
|
void frames_bake(int, int, bool, bool);
|
||||||
void frames_generate_from_grid(glm::ivec2, glm::ivec2, glm::ivec2, int, int, int);
|
void frames_generate_from_grid(glm::ivec2, glm::ivec2, glm::ivec2, int, int, int);
|
||||||
|
|||||||
@@ -246,6 +246,7 @@ namespace anm2ed::imgui
|
|||||||
auto& shaderAxes = resources.shaders[shader::AXIS];
|
auto& shaderAxes = resources.shaders[shader::AXIS];
|
||||||
auto& shaderGrid = resources.shaders[shader::GRID];
|
auto& shaderGrid = resources.shaders[shader::GRID];
|
||||||
auto& shaderTexture = resources.shaders[shader::TEXTURE];
|
auto& shaderTexture = resources.shaders[shader::TEXTURE];
|
||||||
|
auto& frames = document.frames.selection;
|
||||||
|
|
||||||
auto reset_checker_pan = [&]()
|
auto reset_checker_pan = [&]()
|
||||||
{
|
{
|
||||||
@@ -735,6 +736,7 @@ namespace anm2ed::imgui
|
|||||||
auto isMod = ImGui::IsKeyDown(ImGuiMod_Shift);
|
auto isMod = ImGui::IsKeyDown(ImGuiMod_Shift);
|
||||||
|
|
||||||
auto frame = document.frame_get();
|
auto frame = document.frame_get();
|
||||||
|
auto item = document.item_get();
|
||||||
auto useTool = tool;
|
auto useTool = tool;
|
||||||
auto step = isMod ? STEP_FAST : STEP;
|
auto step = isMod ? STEP_FAST : STEP;
|
||||||
mousePos = position_translate(zoom, pan, to_vec2(ImGui::GetMousePos()) - to_vec2(cursorScreenPos));
|
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::MOVE && isMouseRightDown) useTool = tool::SCALE;
|
||||||
if (tool == tool::SCALE && isMouseRightDown) useTool = tool::MOVE;
|
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& toolInfo = tool::INFO[useTool];
|
||||||
auto& areaType = toolInfo.areaType;
|
auto& areaType = toolInfo.areaType;
|
||||||
bool isAreaAllowed = areaType == tool::ALL || areaType == tool::ANIMATION_PREVIEW;
|
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);
|
if (isMouseDown || isMouseMiddleDown) pan += vec2(mouseDelta.x, mouseDelta.y);
|
||||||
break;
|
break;
|
||||||
case tool::MOVE:
|
case tool::MOVE:
|
||||||
if (!frame) break;
|
if (!item || frames.empty()) break;
|
||||||
if (isBegin)
|
if (isBegin)
|
||||||
{
|
{
|
||||||
document.snapshot(localize.get(EDIT_FRAME_POSITION));
|
document.snapshot(localize.get(EDIT_FRAME_POSITION));
|
||||||
@@ -769,11 +774,15 @@ namespace anm2ed::imgui
|
|||||||
isMoveDragging = true;
|
isMoveDragging = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isMouseDown && isMoveDragging) frame->position = ivec2(mousePos - moveOffset);
|
if (isMouseDown && isMoveDragging)
|
||||||
if (isLeftPressed) frame->position.x -= step;
|
frame_change_apply(
|
||||||
if (isRightPressed) frame->position.x += step;
|
{.positionX = (int)mousePos.x - moveOffset.x, .positionY = (int)mousePos.y - moveOffset.y});
|
||||||
if (isUpPressed) frame->position.y -= step;
|
|
||||||
if (isDownPressed) frame->position.y += step;
|
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 (isMouseReleased) isMoveDragging = false;
|
||||||
if (isEnd) document.change(Document::FRAMES);
|
if (isEnd) document.change(Document::FRAMES);
|
||||||
if (isDuring)
|
if (isDuring)
|
||||||
@@ -788,17 +797,20 @@ namespace anm2ed::imgui
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case tool::SCALE:
|
case tool::SCALE:
|
||||||
if (!frame) break;
|
if (!item || frames.empty()) break;
|
||||||
if (isBegin) document.snapshot(localize.get(EDIT_FRAME_SCALE));
|
if (isBegin) document.snapshot(localize.get(EDIT_FRAME_SCALE));
|
||||||
if (isMouseDown)
|
if (isMouseDown)
|
||||||
{
|
{
|
||||||
frame->scale += vec2(mouseDelta.x, mouseDelta.y);
|
frame->scale += vec2(mouseDelta.x, mouseDelta.y);
|
||||||
if (isMod) frame->scale = {frame->scale.x, frame->scale.x};
|
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 (isLeftPressed) frame_change_apply({.scaleX = step}, anm2::SUBTRACT);
|
||||||
if (isUpPressed) frame->scale.y -= step;
|
if (isRightPressed) frame_change_apply({.scaleX = step}, anm2::ADD);
|
||||||
if (isDownPressed) frame->scale.y += step;
|
if (isUpPressed) frame_change_apply({.scaleY = step}, anm2::SUBTRACT);
|
||||||
|
if (isDownPressed) frame_change_apply({.scaleY = step}, anm2::ADD);
|
||||||
|
|
||||||
if (isDuring)
|
if (isDuring)
|
||||||
{
|
{
|
||||||
@@ -814,11 +826,11 @@ namespace anm2ed::imgui
|
|||||||
if (isEnd) document.change(Document::FRAMES);
|
if (isEnd) document.change(Document::FRAMES);
|
||||||
break;
|
break;
|
||||||
case tool::ROTATE:
|
case tool::ROTATE:
|
||||||
if (!frame) break;
|
if (!item || frames.empty()) break;
|
||||||
if (isBegin) document.snapshot(localize.get(EDIT_FRAME_ROTATION));
|
if (isBegin) document.snapshot(localize.get(EDIT_FRAME_ROTATION));
|
||||||
if (isMouseDown) frame->rotation += mouseDelta.y;
|
if (isMouseDown) frame_change_apply({.rotation = mouseDelta.x}, anm2::ADD);
|
||||||
if (isLeftPressed || isDownPressed) frame->rotation -= step;
|
if (isLeftPressed || isDownPressed) frame_change_apply({.rotation = step}, anm2::SUBTRACT);
|
||||||
if (isUpPressed || isRightPressed) frame->rotation += step;
|
if (isUpPressed || isRightPressed) frame_change_apply({.rotation = step}, anm2::ADD);
|
||||||
|
|
||||||
if (isDuring)
|
if (isDuring)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ namespace anm2ed::imgui
|
|||||||
auto& shaderGrid = resources.shaders[shader::GRID];
|
auto& shaderGrid = resources.shaders[shader::GRID];
|
||||||
auto& shaderTexture = resources.shaders[shader::TEXTURE];
|
auto& shaderTexture = resources.shaders[shader::TEXTURE];
|
||||||
auto& dashedShader = resources.shaders[shader::DASHED];
|
auto& dashedShader = resources.shaders[shader::DASHED];
|
||||||
|
auto& frames = document.frames.selection;
|
||||||
|
|
||||||
auto reset_checker_pan = [&]()
|
auto reset_checker_pan = [&]()
|
||||||
{
|
{
|
||||||
@@ -186,6 +187,7 @@ namespace anm2ed::imgui
|
|||||||
clear(isTransparent ? vec4(0) : vec4(backgroundColor, 1.0f));
|
clear(isTransparent ? vec4(0) : vec4(backgroundColor, 1.0f));
|
||||||
|
|
||||||
auto frame = document.frame_get();
|
auto frame = document.frame_get();
|
||||||
|
auto item = document.item_get();
|
||||||
|
|
||||||
if (spritesheet && spritesheet->texture.is_valid())
|
if (spritesheet && spritesheet->texture.is_valid())
|
||||||
{
|
{
|
||||||
@@ -299,6 +301,9 @@ namespace anm2ed::imgui
|
|||||||
return std::pair{minPoint, maxPoint};
|
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 (isMouseMiddleDown) useTool = tool::PAN;
|
||||||
if (tool == tool::MOVE && isMouseRightDown) useTool = tool::CROP;
|
if (tool == tool::MOVE && isMouseRightDown) useTool = tool::CROP;
|
||||||
if (tool == tool::CROP && isMouseRightDown) useTool = tool::MOVE;
|
if (tool == tool::CROP && isMouseRightDown) useTool = tool::MOVE;
|
||||||
@@ -324,14 +329,17 @@ namespace anm2ed::imgui
|
|||||||
if (isMouseDown || isMouseMiddleDown) pan += mouseDelta;
|
if (isMouseDown || isMouseMiddleDown) pan += mouseDelta;
|
||||||
break;
|
break;
|
||||||
case tool::MOVE:
|
case tool::MOVE:
|
||||||
if (!frame) break;
|
if (!item || frames.empty()) break;
|
||||||
if (isBegin) document.snapshot(localize.get(EDIT_FRAME_PIVOT));
|
if (isBegin) document.snapshot(localize.get(EDIT_FRAME_PIVOT));
|
||||||
if (isMouseDown) frame->pivot = vec2(ivec2(mousePos - frame->crop));
|
if (isMouseDown)
|
||||||
if (isLeftPressed) frame->pivot.x -= step;
|
frame_change_apply({.pivotX = mousePos.x - frame->crop.x, .pivotY = mousePos.y - frame->crop.y});
|
||||||
if (isRightPressed) frame->pivot.x += step;
|
if (isLeftPressed) frame_change_apply({.pivotX = step}, anm2::SUBTRACT);
|
||||||
if (isUpPressed) frame->pivot.y -= step;
|
if (isRightPressed) frame_change_apply({.pivotX = step}, anm2::ADD);
|
||||||
if (isDownPressed) frame->pivot.y += step;
|
if (isUpPressed) frame_change_apply({.pivotY = step}, anm2::SUBTRACT);
|
||||||
frame->pivot = vec2(ivec2(frame->pivot));
|
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 (isDuring)
|
||||||
{
|
{
|
||||||
if (ImGui::BeginTooltip())
|
if (ImGui::BeginTooltip())
|
||||||
@@ -346,40 +354,52 @@ namespace anm2ed::imgui
|
|||||||
if (isEnd) document.change(Document::FRAMES);
|
if (isEnd) document.change(Document::FRAMES);
|
||||||
break;
|
break;
|
||||||
case tool::CROP:
|
case tool::CROP:
|
||||||
if (!frame) break;
|
if (!item || frames.empty()) break;
|
||||||
if (isBegin) document.snapshot(localize.get(EDIT_FRAME_CROP));
|
if (isBegin) document.snapshot(localize.get(EDIT_FRAME_CROP));
|
||||||
|
|
||||||
if (isMouseClicked)
|
if (isMouseClicked)
|
||||||
{
|
{
|
||||||
cropAnchor = mousePos;
|
cropAnchor = mousePos;
|
||||||
frame->crop = vec2(ivec2(cropAnchor));
|
frame_change_apply({.cropX = cropAnchor.x, .cropY = cropAnchor.y, .sizeX = {}, .sizeY = {}});
|
||||||
frame->size = vec2();
|
|
||||||
}
|
}
|
||||||
if (isMouseDown)
|
if (isMouseDown)
|
||||||
{
|
{
|
||||||
auto [minPoint, maxPoint] = snap_rect(glm::min(cropAnchor, mousePos), glm::max(cropAnchor, mousePos));
|
auto [minPoint, maxPoint] = snap_rect(glm::min(cropAnchor, mousePos), glm::max(cropAnchor, mousePos));
|
||||||
frame->crop = vec2(ivec2(minPoint));
|
frame_change_apply({.cropX = (int)minPoint.x,
|
||||||
frame->size = vec2(ivec2(maxPoint - minPoint));
|
.cropY = (int)minPoint.y,
|
||||||
|
.sizeX = (int)maxPoint.x - minPoint.x,
|
||||||
|
.sizeY = (int)maxPoint.y - minPoint.y});
|
||||||
}
|
}
|
||||||
if (isLeftPressed) frame->crop.x -= stepX;
|
if (isLeftPressed) frame_change_apply({.cropX = stepX}, anm2::SUBTRACT);
|
||||||
if (isRightPressed) frame->crop.x += stepX;
|
if (isRightPressed) frame_change_apply({.cropX = stepX}, anm2::ADD);
|
||||||
if (isUpPressed) frame->crop.y -= stepY;
|
if (isUpPressed) frame_change_apply({.cropY = stepY}, anm2::SUBTRACT);
|
||||||
if (isDownPressed) frame->crop.y += stepY;
|
if (isDownPressed) frame_change_apply({.cropY = stepY}, anm2::ADD);
|
||||||
frame->crop = vec2(ivec2(frame->crop));
|
|
||||||
frame->size = vec2(ivec2(frame->size));
|
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 (isDuring)
|
||||||
{
|
{
|
||||||
if (!isMouseDown)
|
if (!isMouseDown)
|
||||||
{
|
{
|
||||||
auto minPoint = glm::min(frame->crop, frame->crop + frame->size);
|
auto minPoint = glm::min(frame->crop, frame->crop + frame->size);
|
||||||
auto maxPoint = glm::max(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)
|
if (isGridSnap)
|
||||||
{
|
{
|
||||||
auto [snapMin, snapMax] = snap_rect(frame->crop, frame->crop + frame->size);
|
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())
|
if (ImGui::BeginTooltip())
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#include "change_all_frame_properties.h"
|
#include "change_all_frame_properties.h"
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cmath>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "math_.h"
|
#include "math_.h"
|
||||||
|
|||||||
@@ -49,6 +49,6 @@ Alternatively, if you have subscribed to the mod, you can find the latest releas
|
|||||||
[h3]Happy animating![/h3]
|
[h3]Happy animating![/h3]
|
||||||
[img]https://files.catbox.moe/4auc1c.gif[/img]
|
[img]https://files.catbox.moe/4auc1c.gif[/img]
|
||||||
</description>
|
</description>
|
||||||
<version>2.9</version>
|
<version>2.10</version>
|
||||||
<visibility>Public</visibility>
|
<visibility>Public</visibility>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
|||||||
Reference in New Issue
Block a user