diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/editor/editor_node.h | 1 | ||||
-rw-r--r-- | tools/editor/property_editor.cpp | 65 | ||||
-rw-r--r-- | tools/editor/property_editor.h | 4 | ||||
-rw-r--r-- | tools/editor/scene_tree_dock.cpp | 28 | ||||
-rw-r--r-- | tools/editor/scene_tree_dock.h | 3 | ||||
-rw-r--r-- | tools/editor/scene_tree_editor.cpp | 3 |
6 files changed, 96 insertions, 8 deletions
diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 793c148671..09c42c6cd0 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -586,6 +586,7 @@ public: EDITOR_SCRIPT }; + void set_visible_editor(EditorTable p_table) { _editor_select(p_table); } static EditorNode* get_singleton() { return singleton; } diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index ccce92523f..135eca6860 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -45,6 +45,7 @@ #include "scene/resources/packed_scene.h" #include "scene/main/viewport.h" #include "editor_file_system.h" +#include "create_dialog.h" void CustomPropertyEditor::_notification(int p_what) { @@ -431,6 +432,23 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty action_buttons[0]->set_text(TTR("Close")); action_buttons[0]->show(); + } else if (hint==PROPERTY_HINT_TYPE_STRING) { + + if (!create_dialog) { + create_dialog = memnew( CreateDialog ); + create_dialog->connect("create",this,"_create_dialog_callback"); + add_child(create_dialog); + } + + if (hint_text!=String()) { + create_dialog->set_base_type(hint_text); + } else { + create_dialog->set_base_type("Object"); + } + + create_dialog->popup(false); + hide(); + } else { List<String> names; names.push_back("string:"); @@ -1331,6 +1349,13 @@ void CustomPropertyEditor::_text_edit_changed() { } +void CustomPropertyEditor::_create_dialog_callback() { + + + v=create_dialog->get_selected_type(); + emit_signal("variant_changed"); +} + void CustomPropertyEditor::_modified(String p_string) { if (updating) @@ -1712,6 +1737,7 @@ void CustomPropertyEditor::_bind_methods() { ObjectTypeDB::bind_method("_drag_easing",&CustomPropertyEditor::_drag_easing); ObjectTypeDB::bind_method( "_text_edit_changed",&CustomPropertyEditor::_text_edit_changed); ObjectTypeDB::bind_method( "_menu_option",&CustomPropertyEditor::_menu_option); + ObjectTypeDB::bind_method( "_create_dialog_callback",&CustomPropertyEditor::_create_dialog_callback); @@ -1834,6 +1860,8 @@ CustomPropertyEditor::CustomPropertyEditor() { add_child(slider); slider->set_area_as_parent_rect(5); slider->connect("value_changed",this,"_range_modified"); + + create_dialog = NULL; } bool PropertyEditor::_might_be_in_instance() { @@ -2101,6 +2129,12 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String& p } break; case Variant::STRING: + + if (p_hint==PROPERTY_HINT_TYPE_STRING) { + + p_item->set_text(1,obj->get(p_name)); + } + if (p_hint==PROPERTY_HINT_ENUM) { Vector<String> strings = p_hint_text.split(","); @@ -2367,15 +2401,27 @@ Variant PropertyEditor::get_drag_data_fw(const Point2& p_point,Control* p_from) if (!item) return Variant(); - int col = tree->get_column_at_pos(p_point); - if (col!=1) - return Variant(); - - Dictionary d = item->get_metadata(0); if (!d.has("name")) return Variant(); + int col = tree->get_column_at_pos(p_point); + if (col==0) { + + Dictionary dp; + dp["type"]="obj_property"; + dp["object"]=obj; + dp["property"]=d["name"]; + dp["value"]=obj->get(d["name"]); + + Label *label =memnew( Label ); + label->set_text(d["name"]); + set_drag_preview(label); + return dp; + } + + + Variant val = obj->get(d["name"]); if (val.get_type()==Variant::OBJECT) { @@ -3111,6 +3157,15 @@ void PropertyEditor::update_tree() { } break; + case PROPERTY_HINT_TYPE_STRING: { + + item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM); + item->set_editable(1,!read_only); + if (show_type_icons) + item->set_icon( 0, get_icon("String","EditorIcons") ); + item->set_text(1,obj->get(p.name)); + + } break; default: { item->set_cell_mode( 1, TreeItem::CELL_MODE_STRING ); diff --git a/tools/editor/property_editor.h b/tools/editor/property_editor.h index a909b5ccd3..d911aae883 100644 --- a/tools/editor/property_editor.h +++ b/tools/editor/property_editor.h @@ -48,7 +48,7 @@ */ class PropertyValueEvaluator; - +class CreateDialog; class CustomPropertyEditor : public Popup { OBJ_TYPE( CustomPropertyEditor, Popup ); @@ -102,6 +102,7 @@ class CustomPropertyEditor : public Popup { Control *easing_draw; + CreateDialog *create_dialog; Object* owner; @@ -118,6 +119,7 @@ class CustomPropertyEditor : public Popup { void _focus_exit(); void _action_pressed(int p_which); void _type_create_selected(int p_idx); + void _create_dialog_callback(); void _color_changed(const Color& p_color); diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 9e2b2266a5..c4718a19a1 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -42,6 +42,22 @@ #include "scene/main/viewport.h" +void SceneTreeDock::_nodes_drag_begin() { + + + if (restore_script_editor_on_drag) { + EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); + restore_script_editor_on_drag=false; + } + +} + +void SceneTreeDock::_input(InputEvent p_event) { + + if (p_event.type==InputEvent::MOUSE_BUTTON && !p_event.mouse_button.pressed && p_event.mouse_button.button_index==BUTTON_LEFT) { + restore_script_editor_on_drag=false; //lost chance + } +} void SceneTreeDock::_unhandled_key_input(InputEvent p_event) { @@ -698,7 +714,13 @@ void SceneTreeDock::_node_selected() { return; } + if (ScriptEditor::get_singleton()->is_visible()) { + restore_script_editor_on_drag=true; + } + editor->push_item(node); + + } void SceneTreeDock::_node_renamed() { @@ -1807,6 +1829,8 @@ void SceneTreeDock::_bind_methods() { ObjectTypeDB::bind_method(_MD("_load_request"),&SceneTreeDock::_load_request); ObjectTypeDB::bind_method(_MD("_script_open_request"),&SceneTreeDock::_script_open_request); ObjectTypeDB::bind_method(_MD("_unhandled_key_input"),&SceneTreeDock::_unhandled_key_input); + ObjectTypeDB::bind_method(_MD("_input"),&SceneTreeDock::_input); + ObjectTypeDB::bind_method(_MD("_nodes_drag_begin"),&SceneTreeDock::_nodes_drag_begin); ObjectTypeDB::bind_method(_MD("_delete_confirm"),&SceneTreeDock::_delete_confirm); ObjectTypeDB::bind_method(_MD("_node_prerenamed"),&SceneTreeDock::_node_prerenamed); ObjectTypeDB::bind_method(_MD("_import_subscene"),&SceneTreeDock::_import_subscene); @@ -1889,6 +1913,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec scene_tree->connect("open_script",this,"_script_open_request"); scene_tree->connect("nodes_rearranged",this,"_nodes_dragged"); scene_tree->connect("files_dropped",this,"_files_dropped"); + scene_tree->connect("nodes_dragged",this,"_nodes_drag_begin"); scene_tree->set_undo_redo(&editor_data->get_undo_redo()); scene_tree->set_editor_selection(editor_selection); @@ -1941,7 +1966,8 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec add_child(menu); menu->connect("item_pressed",this,"_tool_selected"); first_enter=true; - + restore_script_editor_on_drag=false; vbc->add_constant_override("separation",4); + set_process_input(true); } diff --git a/tools/editor/scene_tree_dock.h b/tools/editor/scene_tree_dock.h index 04ed16967f..bcf7ff7173 100644 --- a/tools/editor/scene_tree_dock.h +++ b/tools/editor/scene_tree_dock.h @@ -71,6 +71,7 @@ class SceneTreeDock : public VBoxContainer { }; + bool restore_script_editor_on_drag; int current_option; CreateDialog *create_dialog; @@ -128,6 +129,8 @@ class SceneTreeDock : public VBoxContainer { void _node_prerenamed(Node* p_node, const String& p_new_name); + void _nodes_drag_begin(); + void _input(InputEvent p_event); void _unhandled_key_input(InputEvent p_event); void _import_subscene(); diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp index 73358e805d..e5a97fa26e 100644 --- a/tools/editor/scene_tree_editor.cpp +++ b/tools/editor/scene_tree_editor.cpp @@ -966,7 +966,7 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2& p_point,Control* p_from) drag_data["nodes"]=objs; tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN|Tree::DROP_MODE_ON_ITEM); - + emit_signal("nodes_dragged"); return drag_data; } @@ -1110,6 +1110,7 @@ void SceneTreeEditor::_bind_methods() { ADD_SIGNAL( MethodInfo("node_renamed") ); ADD_SIGNAL( MethodInfo("node_prerename") ); ADD_SIGNAL( MethodInfo("node_changed") ); + 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("rmb_pressed",PropertyInfo(Variant::VECTOR2,"pos")) ) ; |