summaryrefslogtreecommitdiff
path: root/tools/editor
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-01-31 20:06:37 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-01-31 20:06:37 -0300
commit373268823182416de3e4f7231e6c4a68b1253a87 (patch)
tree827f80f403eb46ffb3eeba6457ba2a8bec9c2348 /tools/editor
parent0364d6b076cfc4e75985731b67f8155bf173dd06 (diff)
-Make sure to properly use node path from animation track as base path, fixes #3448
Diffstat (limited to 'tools/editor')
-rw-r--r--tools/editor/animation_editor.cpp69
-rw-r--r--tools/editor/animation_editor.h2
2 files changed, 60 insertions, 11 deletions
diff --git a/tools/editor/animation_editor.cpp b/tools/editor/animation_editor.cpp
index a247543830..79a9677edd 100644
--- a/tools/editor/animation_editor.cpp
+++ b/tools/editor/animation_editor.cpp
@@ -35,6 +35,7 @@
#include "scene/gui/separator.h"
#include "editor_node.h"
#include "tools/editor/plugins/animation_player_editor_plugin.h"
+#include "scene/main/viewport.h"
/* Missing to fix:
*Set
@@ -256,6 +257,25 @@ public:
//PopupDialog *ke_dialog;
+ void _fix_node_path(Variant &value) {
+
+
+ NodePath np=value;
+
+ Node* root = EditorNode::get_singleton()->get_tree()->get_root();
+
+ Node* np_node = root->get_node(np);
+ ERR_FAIL_COND(!np_node);
+
+ Node* edited_node = root->get_node(base);
+ ERR_FAIL_COND(!edited_node);
+
+
+
+ value = edited_node->get_path_to(np_node);
+ }
+
+
void _update_obj(const Ref<Animation> &p_anim) {
if (setting)
return;
@@ -356,10 +376,18 @@ public:
case Animation::TYPE_VALUE: {
if (name=="value") {
+
+ Variant value = p_value;
+
+ if (value.get_type()==Variant::NODE_PATH) {
+
+ _fix_node_path(value);
+ }
+
setting=true;
undo_redo->create_action("Anim Change Value",true);
Variant prev = animation->track_get_key_value(track,key);
- undo_redo->add_do_method(animation.ptr(),"track_set_key_value",track,key,p_value);
+ undo_redo->add_do_method(animation.ptr(),"track_set_key_value",track,key,value);
undo_redo->add_undo_method(animation.ptr(),"track_set_key_value",track,key,prev);
undo_redo->add_do_method(this,"_update_obj",animation);
undo_redo->add_undo_method(this,"_update_obj",animation);
@@ -420,7 +448,14 @@ public:
}
if (what=="value") {
- args[idx]=p_value;
+
+ Variant value=p_value;
+ if (value.get_type()==Variant::NODE_PATH) {
+
+ _fix_node_path(value);
+ }
+
+ args[idx]=value;
d_new["args"]=args;
mergeable=true;
}
@@ -441,7 +476,7 @@ public:
} break;
}
- return false;
+
return false;
@@ -616,6 +651,7 @@ public:
float key_ofs;
PropertyInfo hint;
+ NodePath base;
void notify_change() {
@@ -1630,8 +1666,9 @@ void AnimationKeyEditor::_select_at_anim(const Ref<Animation>& p_anim,int p_trac
}
-PropertyInfo AnimationKeyEditor::_find_hint_for_track(int p_idx) {
+PropertyInfo AnimationKeyEditor::_find_hint_for_track(int p_idx,NodePath& r_base_path) {
+ r_base_path=NodePath();
ERR_FAIL_COND_V(!animation.is_valid(),PropertyInfo());
ERR_FAIL_INDEX_V(p_idx,animation->get_track_count(),PropertyInfo());
@@ -1640,9 +1677,6 @@ PropertyInfo AnimationKeyEditor::_find_hint_for_track(int p_idx) {
NodePath path = animation->track_get_path(p_idx);
- String property = path.get_property();
- if (property=="")
- return PropertyInfo();
if (!root->has_node_and_resource(path))
return PropertyInfo();
@@ -1650,6 +1684,15 @@ PropertyInfo AnimationKeyEditor::_find_hint_for_track(int p_idx) {
RES res;
Node *node = root->get_node_and_resource(path,res);
+
+ if (node) {
+ r_base_path=node->get_path();
+ }
+
+ String property = path.get_property();
+ if (property=="")
+ return PropertyInfo();
+
List<PropertyInfo> pinfo;
if (res.is_valid())
res->get_property_list(&pinfo);
@@ -1729,7 +1772,7 @@ bool AnimationKeyEditor::_edit_if_single_selection() {
key_edit->animation=animation;
key_edit->track=idx;
key_edit->key_ofs=animation->track_get_key_time(idx,key);
- key_edit->hint=_find_hint_for_track(idx);
+ key_edit->hint=_find_hint_for_track(idx,key_edit->base);
key_edit->notify_change();
curve_edit->set_transition(animation->track_get_key_transition(idx,key));
@@ -2187,7 +2230,8 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) {
newval=d;
} else if (tt==Animation::TYPE_VALUE) {
- PropertyInfo inf = _find_hint_for_track(idx);
+ NodePath np;
+ PropertyInfo inf = _find_hint_for_track(idx,np);
if (inf.type!=Variant::NIL) {
Variant::CallError err;
@@ -2975,6 +3019,7 @@ void AnimationKeyEditor::_clear_selection() {
key_edit->track=0;
key_edit->key_ofs=0;
key_edit->hint=PropertyInfo();
+ key_edit->base=NodePath();
key_edit->notify_change();
}
@@ -3269,9 +3314,10 @@ int AnimationKeyEditor::_confirm_insert(InsertData p_id,int p_last_track) {
{
//shitty hack
+ NodePath np;
animation->add_track(p_id.type);
animation->track_set_path(animation->get_track_count()-1,p_id.path);
- PropertyInfo h = _find_hint_for_track(animation->get_track_count()-1);
+ PropertyInfo h = _find_hint_for_track(animation->get_track_count()-1,np);
animation->remove_track(animation->get_track_count()-1); //hack
@@ -3645,6 +3691,9 @@ void AnimationKeyEditor::_add_call_track(const NodePath& p_base) {
NodePath path = root->get_path_to(from);
+ //print_line("root: "+String(root->get_path()));
+ //print_line("path: "+String(path));
+
undo_redo->create_action("Anim Add Call Track");
undo_redo->add_do_method(animation.ptr(),"add_track",Animation::TYPE_METHOD);
undo_redo->add_do_method(animation.ptr(),"track_set_path",animation->get_track_count(),path);
diff --git a/tools/editor/animation_editor.h b/tools/editor/animation_editor.h
index 5e81439fe6..cd22dc3106 100644
--- a/tools/editor/animation_editor.h
+++ b/tools/editor/animation_editor.h
@@ -302,7 +302,7 @@ class AnimationKeyEditor : public VBoxContainer {
void _select_at_anim(const Ref<Animation>& p_anim,int p_track,float p_pos);
void _curve_transition_changed(float p_what);
- PropertyInfo _find_hint_for_track(int p_idx);
+ PropertyInfo _find_hint_for_track(int p_idx, NodePath &r_base_path);
void _create_value_item(int p_type);
void _pane_drag(const Point2& p_delta);