瀏覽代碼

-fix compile issue (pow)
-ask user for track to call nodes when adding call track

Juan Linietsky 10 年之前
父節點
當前提交
947b283248
共有 4 個文件被更改,包括 40 次插入6 次删除
  1. 1 1
      scene/gui/spin_box.cpp
  2. 1 1
      scene/gui/tree.cpp
  3. 33 3
      tools/editor/animation_editor.cpp
  4. 5 1
      tools/editor/animation_editor.h

+ 1 - 1
scene/gui/spin_box.cpp

@@ -125,7 +125,7 @@ void SpinBox::_input_event(const InputEvent& p_event) {
 		if (drag.enabled) {
 		if (drag.enabled) {
 
 
 			float diff_y = drag.mouse_pos.y - cpos.y;
 			float diff_y = drag.mouse_pos.y - cpos.y;
-			diff_y=pow(ABS(diff_y),1.8)*SGN(diff_y);
+			diff_y=Math::pow(ABS(diff_y),1.8)*SGN(diff_y);
 			diff_y*=0.1;
 			diff_y*=0.1;
 
 
 			drag.mouse_pos=cpos;
 			drag.mouse_pos=cpos;

+ 1 - 1
scene/gui/tree.cpp

@@ -2070,7 +2070,7 @@ void Tree::_input_event(InputEvent p_event) {
 
 
 					TreeItem::Cell &c=popup_edited_item->cells[popup_edited_item_col];
 					TreeItem::Cell &c=popup_edited_item->cells[popup_edited_item_col];
 					float diff_y = -b.relative_y;
 					float diff_y = -b.relative_y;
-					diff_y=pow(ABS(diff_y),1.8)*SGN(diff_y);
+					diff_y=Math::pow(ABS(diff_y),1.8)*SGN(diff_y);
 					diff_y*=0.1;
 					diff_y*=0.1;
 					range_drag_base=CLAMP(range_drag_base + c.step * diff_y, c.min, c.max);
 					range_drag_base=CLAMP(range_drag_base + c.step * diff_y, c.min, c.max);
 
 

+ 33 - 3
tools/editor/animation_editor.cpp

@@ -33,6 +33,7 @@
 #include "io/resource_saver.h"
 #include "io/resource_saver.h"
 #include "pair.h"
 #include "pair.h"
 #include "scene/gui/separator.h"
 #include "scene/gui/separator.h"
+#include "editor_node.h"
 /* Missing to fix:
 /* Missing to fix:
 
 
   *Set
   *Set
@@ -634,9 +635,14 @@ void AnimationKeyEditor::_menu_track(int p_type) {
 	last_menu_track_opt=p_type;
 	last_menu_track_opt=p_type;
 	switch(p_type) {
 	switch(p_type) {
 
 
-		case TRACK_MENU_ADD_VALUE_TRACK:
-		case TRACK_MENU_ADD_TRANSFORM_TRACK:
 		case TRACK_MENU_ADD_CALL_TRACK: {
 		case TRACK_MENU_ADD_CALL_TRACK: {
+			if (root) {
+				call_select->popup_centered_ratio();
+				break;
+			}
+		} break;
+		case TRACK_MENU_ADD_VALUE_TRACK:
+		case TRACK_MENU_ADD_TRANSFORM_TRACK: {
 
 
 			undo_redo->create_action("Anim Add Track");
 			undo_redo->create_action("Anim Add Track");
 			undo_redo->add_do_method(animation.ptr(),"add_track",p_type);			
 			undo_redo->add_do_method(animation.ptr(),"add_track",p_type);			
@@ -2735,6 +2741,7 @@ void AnimationKeyEditor::_notification(int p_what) {
 
 
 
 
 				}
 				}
+				call_select->connect("selected",this,"_add_call_track");
 //				rename_anim->set_icon( get_icon("Rename","EditorIcons") );
 //				rename_anim->set_icon( get_icon("Rename","EditorIcons") );
 /*
 /*
 				edit_anim->set_icon( get_icon("Edit","EditorIcons") );
 				edit_anim->set_icon( get_icon("Edit","EditorIcons") );
@@ -3456,6 +3463,26 @@ void AnimationKeyEditor::_scale() {
 }
 }
 
 
 
 
+void AnimationKeyEditor::_add_call_track(const NodePath& p_base) {
+
+	print_line("BASE IS "+String(p_base));
+	Node* base = EditorNode::get_singleton()->get_edited_scene();
+	if (!base)
+		return;
+	Node* from=base->get_node(p_base);
+	if (!from || !root)
+		return;
+
+	NodePath path = root->get_path_to(from);
+
+	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);
+	undo_redo->add_undo_method(animation.ptr(),"remove_track",animation->get_track_count());
+	undo_redo->commit_action();
+
+}
+
 void AnimationKeyEditor::cleanup() {
 void AnimationKeyEditor::cleanup() {
 
 
 	set_animation(Ref<Animation>());
 	set_animation(Ref<Animation>());
@@ -3503,6 +3530,7 @@ void AnimationKeyEditor::_bind_methods() {
 	ObjectTypeDB::bind_method(_MD("_animation_optimize"),&AnimationKeyEditor::_animation_optimize);
 	ObjectTypeDB::bind_method(_MD("_animation_optimize"),&AnimationKeyEditor::_animation_optimize);
 	ObjectTypeDB::bind_method(_MD("_curve_transition_changed"),&AnimationKeyEditor::_curve_transition_changed);
 	ObjectTypeDB::bind_method(_MD("_curve_transition_changed"),&AnimationKeyEditor::_curve_transition_changed);
 	ObjectTypeDB::bind_method(_MD("_toggle_edit_curves"),&AnimationKeyEditor::_toggle_edit_curves);
 	ObjectTypeDB::bind_method(_MD("_toggle_edit_curves"),&AnimationKeyEditor::_toggle_edit_curves);
+	ObjectTypeDB::bind_method(_MD("_add_call_track"),&AnimationKeyEditor::_add_call_track);
 
 
 
 
 	ADD_SIGNAL( MethodInfo("resource_selected", PropertyInfo( Variant::OBJECT, "res"),PropertyInfo( Variant::STRING, "prop") ) );
 	ADD_SIGNAL( MethodInfo("resource_selected", PropertyInfo( Variant::OBJECT, "res"),PropertyInfo( Variant::STRING, "prop") ) );
@@ -3815,7 +3843,9 @@ AnimationKeyEditor::AnimationKeyEditor(UndoRedo *p_undo_redo, EditorHistory *p_h
 	scale_dialog->connect("confirmed",this,"_scale");
 	scale_dialog->connect("confirmed",this,"_scale");
 	add_child(scale_dialog);
 	add_child(scale_dialog);
 
 
-
+	call_select = memnew( SceneTreeDialog );
+	add_child(call_select);
+	call_select->set_title("Call Functions in Which Node?");
 
 
 }
 }
 
 

+ 5 - 1
tools/editor/animation_editor.h

@@ -44,7 +44,7 @@
 #include "scene_tree_editor.h"
 #include "scene_tree_editor.h"
 #include "editor_data.h"
 #include "editor_data.h"
 #include "property_editor.h"
 #include "property_editor.h"
-
+#include "scene_tree_editor.h"
 
 
 class AnimationKeyEdit;
 class AnimationKeyEdit;
 class AnimationCurveEdit;
 class AnimationCurveEdit;
@@ -206,6 +206,8 @@ class AnimationKeyEditor : public VBoxContainer  {
 
 
 	PropertyEditor *key_editor;	
 	PropertyEditor *key_editor;	
 
 
+	SceneTreeDialog *call_select;
+
 	Ref<Animation> animation;
 	Ref<Animation> animation;
 	void _update_paths();
 	void _update_paths();
 
 
@@ -299,6 +301,8 @@ class AnimationKeyEditor : public VBoxContainer  {
 	void _toggle_edit_curves();
 	void _toggle_edit_curves();
 	void _animation_len_update();
 	void _animation_len_update();
 
 
+	void _add_call_track(const NodePath& p_base);
+
 	void _root_removed();
 	void _root_removed();
 protected:
 protected: