change all frame properties adjustments
This commit is contained in:
@@ -71,6 +71,8 @@ namespace anm2ed::anm2
|
|||||||
std::optional<float> tintG{};
|
std::optional<float> tintG{};
|
||||||
std::optional<float> tintB{};
|
std::optional<float> tintB{};
|
||||||
std::optional<float> tintA{};
|
std::optional<float> tintA{};
|
||||||
|
std::optional<bool> isFlipX{};
|
||||||
|
std::optional<bool> isFlipY{};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,16 +126,14 @@ 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, std::set<int>& selection)
|
||||||
{
|
{
|
||||||
auto useStart = numberFrames > -1 ? start : 0;
|
|
||||||
auto end = numberFrames > -1 ? start + numberFrames : (int)frames.size();
|
|
||||||
end = glm::clamp(end, start, (int)frames.size());
|
|
||||||
|
|
||||||
const auto clamp_identity = [](auto value) { return value; };
|
const auto clamp_identity = [](auto value) { return value; };
|
||||||
const auto clamp01 = [](auto value) { return glm::clamp(value, 0.0f, 1.0f); };
|
const auto clamp01 = [](auto value) { return glm::clamp(value, 0.0f, 1.0f); };
|
||||||
const auto clamp_duration = [](int value) { return std::max(FRAME_DURATION_MIN, value); };
|
const auto clamp_duration = [](int value) { return std::max(FRAME_DURATION_MIN, value); };
|
||||||
|
|
||||||
|
if (selection.empty()) return;
|
||||||
|
|
||||||
auto apply_scalar_with_clamp = [&](auto& target, const auto& optionalValue, auto clampFunc)
|
auto apply_scalar_with_clamp = [&](auto& target, const auto& optionalValue, auto clampFunc)
|
||||||
{
|
{
|
||||||
if (!optionalValue) return;
|
if (!optionalValue) return;
|
||||||
@@ -165,12 +163,15 @@ namespace anm2ed::anm2
|
|||||||
auto apply_scalar = [&](auto& target, const auto& optionalValue)
|
auto apply_scalar = [&](auto& target, const auto& optionalValue)
|
||||||
{ apply_scalar_with_clamp(target, optionalValue, clamp_identity); };
|
{ apply_scalar_with_clamp(target, optionalValue, clamp_identity); };
|
||||||
|
|
||||||
for (int i = useStart; i < end; i++)
|
for (auto i : selection)
|
||||||
{
|
{
|
||||||
|
if (!vector::in_bounds(frames, i)) continue;
|
||||||
Frame& frame = frames[i];
|
Frame& frame = frames[i];
|
||||||
|
|
||||||
if (change.isVisible) frame.isVisible = *change.isVisible;
|
if (change.isVisible) frame.isVisible = *change.isVisible;
|
||||||
if (change.isInterpolated) frame.isInterpolated = *change.isInterpolated;
|
if (change.isInterpolated) frame.isInterpolated = *change.isInterpolated;
|
||||||
|
if (change.isFlipX) frame.scale.x = -frame.scale.y;
|
||||||
|
if (change.isFlipY) frame.scale.y = -frame.scale.y;
|
||||||
|
|
||||||
apply_scalar(frame.rotation, change.rotation);
|
apply_scalar(frame.rotation, change.rotation);
|
||||||
apply_scalar_with_clamp(frame.duration, change.duration, clamp_duration);
|
apply_scalar_with_clamp(frame.duration, change.duration, clamp_duration);
|
||||||
|
|||||||
@@ -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, std::set<int>&);
|
||||||
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);
|
||||||
|
|||||||
@@ -746,7 +746,7 @@ namespace anm2ed::imgui
|
|||||||
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)
|
auto frame_change_apply = [&](anm2::FrameChange frameChange, anm2::ChangeType changeType = anm2::ADJUST)
|
||||||
{ item->frames_change(frameChange, changeType, *frames.begin(), frames.size()); };
|
{ item->frames_change(frameChange, changeType, frames); };
|
||||||
|
|
||||||
auto& toolInfo = tool::INFO[useTool];
|
auto& toolInfo = tool::INFO[useTool];
|
||||||
auto& areaType = toolInfo.areaType;
|
auto& areaType = toolInfo.areaType;
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ namespace anm2ed::imgui
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto frame_change_apply = [&](anm2::FrameChange frameChange, anm2::ChangeType changeType = anm2::ADJUST)
|
auto frame_change_apply = [&](anm2::FrameChange frameChange, anm2::ChangeType changeType = anm2::ADJUST)
|
||||||
{ item->frames_change(frameChange, changeType, *frames.begin(), frames.size()); };
|
{ item->frames_change(frameChange, changeType, frames); };
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ namespace anm2ed::imgui::wizard
|
|||||||
auto& isColorOffsetB = settings.changeIsColorOffsetB;
|
auto& isColorOffsetB = settings.changeIsColorOffsetB;
|
||||||
auto& isVisibleSet = settings.changeIsVisibleSet;
|
auto& isVisibleSet = settings.changeIsVisibleSet;
|
||||||
auto& isInterpolatedSet = settings.changeIsInterpolatedSet;
|
auto& isInterpolatedSet = settings.changeIsInterpolatedSet;
|
||||||
|
auto& isFlipXSet = settings.changeIsFlipXSet;
|
||||||
|
auto& isFlipYSet = settings.changeIsFlipYSet;
|
||||||
auto& crop = settings.changeCrop;
|
auto& crop = settings.changeCrop;
|
||||||
auto& size = settings.changeSize;
|
auto& size = settings.changeSize;
|
||||||
auto& position = settings.changePosition;
|
auto& position = settings.changePosition;
|
||||||
@@ -46,6 +48,8 @@ namespace anm2ed::imgui::wizard
|
|||||||
auto& colorOffset = settings.changeColorOffset;
|
auto& colorOffset = settings.changeColorOffset;
|
||||||
auto& isVisible = settings.changeIsVisible;
|
auto& isVisible = settings.changeIsVisible;
|
||||||
auto& isInterpolated = settings.changeIsInterpolated;
|
auto& isInterpolated = settings.changeIsInterpolated;
|
||||||
|
auto& isFlipX = settings.changeIsFlipX;
|
||||||
|
auto& isFlipY = settings.changeIsFlipY;
|
||||||
|
|
||||||
#define PROPERTIES_WIDGET(body, checkboxLabel, isEnabled) \
|
#define PROPERTIES_WIDGET(body, checkboxLabel, isEnabled) \
|
||||||
ImGui::Checkbox(checkboxLabel, &isEnabled); \
|
ImGui::Checkbox(checkboxLabel, &isEnabled); \
|
||||||
@@ -196,6 +200,10 @@ namespace anm2ed::imgui::wizard
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
bool_value("##Is Interpolated", localize.get(BASIC_INTERPOLATED), isInterpolatedSet, isInterpolated);
|
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();
|
ImGui::PopStyleVar();
|
||||||
|
|
||||||
auto frame_change = [&](anm2::ChangeType type)
|
auto frame_change = [&](anm2::ChangeType type)
|
||||||
@@ -222,9 +230,11 @@ namespace anm2ed::imgui::wizard
|
|||||||
if (isColorOffsetB) frameChange.colorOffsetB = colorOffset.b;
|
if (isColorOffsetB) frameChange.colorOffsetB = colorOffset.b;
|
||||||
if (isVisibleSet) frameChange.isVisible = std::make_optional(isVisible);
|
if (isVisibleSet) frameChange.isVisible = std::make_optional(isVisible);
|
||||||
if (isInterpolatedSet) frameChange.isInterpolated = std::make_optional(isInterpolated);
|
if (isInterpolatedSet) frameChange.isInterpolated = std::make_optional(isInterpolated);
|
||||||
|
if (isFlipXSet) frameChange.isFlipX = std::make_optional(isFlipX);
|
||||||
|
if (isFlipYSet) frameChange.isFlipY = std::make_optional(isFlipY);
|
||||||
|
|
||||||
DOCUMENT_EDIT(document, localize.get(EDIT_CHANGE_FRAME_PROPERTIES), Document::FRAMES,
|
DOCUMENT_EDIT(document, localize.get(EDIT_CHANGE_FRAME_PROPERTIES), Document::FRAMES,
|
||||||
document.item_get()->frames_change(frameChange, type, *frames.begin(), (int)frames.size()));
|
document.item_get()->frames_change(frameChange, type, frames));
|
||||||
|
|
||||||
isChanged = true;
|
isChanged = true;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ namespace anm2ed
|
|||||||
X(CHANGE_IS_COLOR_OFFSET_A, changeIsColorOffsetA, STRING_UNDEFINED, BOOL, false) \
|
X(CHANGE_IS_COLOR_OFFSET_A, changeIsColorOffsetA, STRING_UNDEFINED, BOOL, false) \
|
||||||
X(CHANGE_IS_VISIBLE_SET, changeIsVisibleSet, STRING_UNDEFINED, BOOL, false) \
|
X(CHANGE_IS_VISIBLE_SET, changeIsVisibleSet, STRING_UNDEFINED, BOOL, false) \
|
||||||
X(CHANGE_IS_INTERPOLATED_SET, changeIsInterpolatedSet, STRING_UNDEFINED, BOOL, false) \
|
X(CHANGE_IS_INTERPOLATED_SET, changeIsInterpolatedSet, STRING_UNDEFINED, BOOL, false) \
|
||||||
|
X(CHANGE_IS_FLIP_X_SET, changeIsFlipXSet, STRING_UNDEFINED, BOOL, false) \
|
||||||
|
X(CHANGE_IS_FLIP_Y_SET, changeIsFlipYSet, STRING_UNDEFINED, BOOL, false) \
|
||||||
X(CHANGE_CROP, changeCrop, STRING_UNDEFINED, VEC2, {}) \
|
X(CHANGE_CROP, changeCrop, STRING_UNDEFINED, VEC2, {}) \
|
||||||
X(CHANGE_SIZE, changeSize, STRING_UNDEFINED, VEC2, {}) \
|
X(CHANGE_SIZE, changeSize, STRING_UNDEFINED, VEC2, {}) \
|
||||||
X(CHANGE_POSITION, changePosition, STRING_UNDEFINED, VEC2, {}) \
|
X(CHANGE_POSITION, changePosition, STRING_UNDEFINED, VEC2, {}) \
|
||||||
@@ -104,6 +106,8 @@ namespace anm2ed
|
|||||||
X(CHANGE_COLOR_OFFSET, changeColorOffset, STRING_UNDEFINED, VEC3, {}) \
|
X(CHANGE_COLOR_OFFSET, changeColorOffset, STRING_UNDEFINED, VEC3, {}) \
|
||||||
X(CHANGE_IS_VISIBLE, changeIsVisible, STRING_UNDEFINED, BOOL, false) \
|
X(CHANGE_IS_VISIBLE, changeIsVisible, STRING_UNDEFINED, BOOL, false) \
|
||||||
X(CHANGE_IS_INTERPOLATED, changeIsInterpolated, STRING_UNDEFINED, BOOL, false) \
|
X(CHANGE_IS_INTERPOLATED, changeIsInterpolated, STRING_UNDEFINED, BOOL, false) \
|
||||||
|
X(CHANGE_IS_FLIP_X, changeIsFlipX, STRING_UNDEFINED, BOOL, false) \
|
||||||
|
X(CHANGE_IS_FLIP_Y, changeIsFlipY, STRING_UNDEFINED, BOOL, false) \
|
||||||
\
|
\
|
||||||
X(SCALE_VALUE, scaleValue, STRING_UNDEFINED, FLOAT, 1.0f) \
|
X(SCALE_VALUE, scaleValue, STRING_UNDEFINED, FLOAT, 1.0f) \
|
||||||
\
|
\
|
||||||
|
|||||||
Reference in New Issue
Block a user