From 33e0ee3439b0d3963a17d44bcfe43565edc970b7 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Mon, 13 Jan 2025 04:58:43 +0100 Subject: [PATCH] anim editor usability fixes --- Aquaria/AnimationEditor.cpp | 22 ++++++++++++++-------- Aquaria/AnimationEditor.h | 3 ++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Aquaria/AnimationEditor.cpp b/Aquaria/AnimationEditor.cpp index b09f42a..9025069 100644 --- a/Aquaria/AnimationEditor.cpp +++ b/Aquaria/AnimationEditor.cpp @@ -421,7 +421,7 @@ void AnimationEditor::resetScaleOrSave() notify("Scale copied to clipboard"); } else - getCurrentPageSprite()->scale = Vector(1,1); + getSelectedPageSprite()->scale = Vector(1,1); } void AnimationEditor::applyState() @@ -510,10 +510,10 @@ void AnimationEditor::applyState() addAction(MakeFunctionEvent(AnimationEditor, showAllBones), KEY_A, 0); addAction(MakeFunctionEvent(AnimationEditor, toggleGradient), KEY_G, 0); - addAction(MakeFunctionEvent(AnimationEditor, decrTimelineUnit), KEY_U, 0); + /*addAction(MakeFunctionEvent(AnimationEditor, decrTimelineUnit), KEY_U, 0); addAction(MakeFunctionEvent(AnimationEditor, incrTimelineUnit), KEY_I, 0); addAction(MakeFunctionEvent(AnimationEditor, decrTimelineGrid), KEY_O, 0); - addAction(MakeFunctionEvent(AnimationEditor, incrTimelineGrid), KEY_P, 0); + addAction(MakeFunctionEvent(AnimationEditor, incrTimelineGrid), KEY_P, 0);*/ addAction(MakeFunctionEvent(AnimationEditor, toggleSplineMode), KEY_W, 0); addAction(MakeFunctionEvent(AnimationEditor, flipH), KEY_F, 0); @@ -913,8 +913,6 @@ void AnimationEditor::update(float dt) { StateObject::update(dt); - SkeletalSprite *editSprite = getCurrentPageSprite(); - const float tltime = getMouseTimelineTime(); { @@ -1001,7 +999,7 @@ void AnimationEditor::update(float dt) if(splinegrid) ctrlSprite = splinegrid; else - ctrlSprite = ctrlPressed ? (RenderObject*)getCurrentPageSprite() : (RenderObject*)spriteRoot; + ctrlSprite = ctrlPressed ? (RenderObject*)getSelectedPageSprite() : (RenderObject*)spriteRoot; if (core->mouse.buttons.middle) { @@ -1097,6 +1095,7 @@ void AnimationEditor::update(float dt) } if (!hastime && !isAnimating()) { + SkeletalSprite *editSprite = getCurrentPageSprite(); if(Animation *a = editSprite->getCurrentAnimationOrNull()) { SkeletalKeyframe *k = a->getKeyframe(currentKey); @@ -1826,7 +1825,7 @@ void AnimationEditor::flipH() { if (dsq->isNested()) return; - RenderObject *ro = core->getCtrlState() ? (RenderObject*)getCurrentPageSprite() : (RenderObject*)spriteRoot; + RenderObject *ro = core->getCtrlState() ? (RenderObject*)getSelectedPageSprite() : (RenderObject*)spriteRoot; ro->flipHorizontal(); const Vector red(1,0,0), white(1,1,1); @@ -1989,7 +1988,7 @@ void AnimationEditor::showAllBones() { if (dsq->isNested()) return; - SkeletalSprite *spr = getCurrentPageSprite(); + SkeletalSprite *spr = getSelectedPageSprite(); for (size_t i = 0; i < spr->bones.size(); ++i) spr->bones[i]->renderQuad = true; } @@ -2039,6 +2038,8 @@ void AnimationEditor::decrTimelineGrid() void AnimationEditor::toggleSplineMode() { + if (dsq->isNested()) return; + assistedSplineEdit = !assistedSplineEdit; updateButtonLabels(); if(splinegrid) @@ -2094,6 +2095,11 @@ SkeletalSprite* AnimationEditor::getCurrentPageSprite() const return getPageSprite(curPage); } +SkeletalSprite * AnimationEditor::getSelectedPageSprite() const +{ + return editingBoneSprite ? editingBoneSprite : getCurrentPageSprite(); +} + bool AnimationEditor::isAnimating() const { for(size_t i = 0; i < NumPages; ++i) diff --git a/Aquaria/AnimationEditor.h b/Aquaria/AnimationEditor.h index 9d38f04..45fbb28 100644 --- a/Aquaria/AnimationEditor.h +++ b/Aquaria/AnimationEditor.h @@ -168,7 +168,8 @@ public: Animation *getPageAnimation(size_t page) const; Animation *getCurrentPageAnimation() const; SkeletalSprite *getPageSprite(size_t page) const; - SkeletalSprite *getCurrentPageSprite() const; + SkeletalSprite *getCurrentPageSprite() const; // sprite on active page + SkeletalSprite *getSelectedPageSprite() const; //sprite that belong to selected bone, alternatively sprite on active page bool isAnimating() const; float getAnimTime() const;