summaryrefslogtreecommitdiff
path: root/tools/editor/scene_tree_editor.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-10-30 09:00:45 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-10-30 09:00:45 -0300
commitab4126f51061277e87b41c48b40e7b54942d4eca (patch)
treec58168b60323c4d43b58743b099e562a89e60a56 /tools/editor/scene_tree_editor.cpp
parent8b15b26eedad4fdd33d50f5f9aa0fcc1875d503f (diff)
parent914015f3b63dd956e72ea937d46ea4b2db005ada (diff)
Merge branch 'master' of https://github.com/godotengine/godot
Diffstat (limited to 'tools/editor/scene_tree_editor.cpp')
-rw-r--r--tools/editor/scene_tree_editor.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp
index e5a97fa26e..f5628d0c8f 100644
--- a/tools/editor/scene_tree_editor.cpp
+++ b/tools/editor/scene_tree_editor.cpp
@@ -254,7 +254,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id)
String config_err = n->get_configuration_warning();
if (config_err==String())
return;
- config_err=config_err.world_wrap(80);
+ config_err=config_err.word_wrap(80);
warning->set_text(config_err);
warning->popup_centered_minsize();
@@ -971,6 +971,10 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2& p_point,Control* p_from)
return drag_data;
}
+bool SceneTreeEditor::_is_script_type(const StringName &p_type) const {
+ return (script_types->find(p_type));
+}
+
bool SceneTreeEditor::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from) const {
if (!can_rename)
@@ -998,9 +1002,13 @@ bool SceneTreeEditor::can_drop_data_fw(const Point2& p_point,const Variant& p_da
if (files.size()==0)
return false; //weird
+ if (_is_script_type(EditorFileSystem::get_singleton()->get_file_type(files[0]))) {
+ tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM);
+ return true;
+ }
for(int i=0;i<files.size();i++) {
- String file = files[0];
+ String file = files[i];
String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
if (ftype!="PackedScene")
return false;
@@ -1044,7 +1052,15 @@ void SceneTreeEditor::drop_data_fw(const Point2& p_point,const Variant& p_data,C
if (String(d["type"])=="files") {
- emit_signal("files_dropped",d["files"],np,section);
+ Vector<String> files = d["files"];
+
+
+ String ftype = EditorFileSystem::get_singleton()->get_file_type(files[0]);
+ if (_is_script_type(ftype)) {
+ emit_signal("script_dropped", files[0],np);
+ } else {
+ emit_signal("files_dropped",files,np,section);
+ }
}
}
@@ -1113,6 +1129,7 @@ void SceneTreeEditor::_bind_methods() {
ADD_SIGNAL( MethodInfo("nodes_dragged") );
ADD_SIGNAL( MethodInfo("nodes_rearranged",PropertyInfo(Variant::ARRAY,"paths"),PropertyInfo(Variant::NODE_PATH,"to_path"),PropertyInfo(Variant::INT,"type") ) );
ADD_SIGNAL( MethodInfo("files_dropped",PropertyInfo(Variant::STRING_ARRAY,"files"),PropertyInfo(Variant::NODE_PATH,"to_path"),PropertyInfo(Variant::INT,"type") ) );
+ ADD_SIGNAL( MethodInfo("script_dropped",PropertyInfo(Variant::STRING,"file"),PropertyInfo(Variant::NODE_PATH,"to_path")));
ADD_SIGNAL( MethodInfo("rmb_pressed",PropertyInfo(Variant::VECTOR2,"pos")) ) ;
ADD_SIGNAL( MethodInfo("open") );
@@ -1209,12 +1226,16 @@ SceneTreeEditor::SceneTreeEditor(bool p_label,bool p_can_rename, bool p_can_open
update_timer->set_wait_time(0.5);
add_child(update_timer);
+ script_types = memnew(List<StringName>);
+ ObjectTypeDB::get_inheriters_from("Script", script_types);
+
}
SceneTreeEditor::~SceneTreeEditor() {
+ memdelete(script_types);
}