diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/editor/editor_node.cpp | 18 | ||||
-rw-r--r-- | tools/editor/editor_node.h | 3 | ||||
-rw-r--r-- | tools/editor/property_editor.cpp | 151 | ||||
-rw-r--r-- | tools/editor/property_editor.h | 7 | ||||
-rw-r--r-- | tools/editor/reparent_dialog.cpp | 1 | ||||
-rw-r--r-- | tools/editor/scene_tree_dock.cpp | 51 | ||||
-rw-r--r-- | tools/editor/scene_tree_editor.cpp | 95 | ||||
-rw-r--r-- | tools/editor/scene_tree_editor.h | 7 |
8 files changed, 256 insertions, 77 deletions
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index fb3c7d5d18..1b709df7d8 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -1107,6 +1107,11 @@ void EditorNode::_dialog_action(String p_file) { push_item(res.operator->() ); } break; + case FILE_NEW_INHERITED_SCENE: { + + + load_scene(p_file,false,true); + } break; case FILE_OPEN_SCENE: { @@ -1930,6 +1935,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } break; + case FILE_NEW_INHERITED_SCENE: case FILE_OPEN_SCENE: { @@ -1950,7 +1956,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { if (scene) { file->set_current_path(scene->get_filename()); }; - file->set_title("Open Scene"); + file->set_title(p_option==FILE_OPEN_SCENE?"Open Scene":"Open Base Scene"); file->popup_centered_ratio(); } break; @@ -3311,7 +3317,7 @@ void EditorNode::fix_dependencies(const String& p_for_file) { dependency_fixer->edit(p_for_file); } -Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps) { +Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bool p_set_inherited) { if (!is_inside_tree()) { defer_load_scene = p_scene; @@ -3441,6 +3447,13 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps) { } */ + if (p_set_inherited) { + Ref<SceneState> state = sdata->get_state(); + state->set_path(lpath); + new_scene->set_scene_inherited_state(state); + } + + set_edited_scene(new_scene); _get_scene_metadata(); /* @@ -4793,6 +4806,7 @@ EditorNode::EditorNode() { file_menu->set_tooltip("Operations with scene files."); p=file_menu->get_popup(); p->add_item("New Scene",FILE_NEW_SCENE); + p->add_item("New Inherited Scene..",FILE_NEW_INHERITED_SCENE); p->add_item("Open Scene..",FILE_OPEN_SCENE,KEY_MASK_CMD+KEY_O); p->add_separator(); p->add_item("Save Scene",FILE_SAVE_SCENE,KEY_MASK_CMD+KEY_S); diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 53e16d9c58..d52e08191d 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -107,6 +107,7 @@ class EditorNode : public Node { enum MenuOptions { FILE_NEW_SCENE, + FILE_NEW_INHERITED_SCENE, FILE_OPEN_SCENE, FILE_SAVE_SCENE, FILE_SAVE_AS_SCENE, @@ -565,7 +566,7 @@ public: void fix_dependencies(const String& p_for_file); void clear_scene() { _cleanup_scene(); } - Error load_scene(const String& p_scene,bool p_ignore_broken_deps=false); + Error load_scene(const String& p_scene, bool p_ignore_broken_deps=false, bool p_set_inherited=false); Error load_resource(const String& p_scene); bool is_scene_open(const String& p_path); diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index b513e32c13..1a07f30e4e 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -42,6 +42,8 @@ #include "multi_node_edit.h" #include "array_property_edit.h" #include "editor_help.h" +#include "scene/resources/packed_scene.h" + void CustomPropertyEditor::_notification(int p_what) { @@ -1655,25 +1657,101 @@ CustomPropertyEditor::CustomPropertyEditor() { menu->connect("item_pressed",this,"_menu_option"); } +bool PropertyEditor::_might_be_in_instance() { - -Node *PropertyEditor::get_instanced_node() { - - //this sucks badly if (!obj) return NULL; Node *node = obj->cast_to<Node>(); + + Node* edited_scene =EditorNode::get_singleton()->get_edited_scene(); + + bool might_be=false; + + while(node) { + + if (node->get_scene_instance_state().is_valid()) { + might_be=true; + break; + } + if (node==edited_scene) { + if (node->get_scene_inherited_state().is_valid()) { + might_be=true; + break; + } + might_be=false; + break; + } + node=node->get_owner(); + } + + return might_be; + +} + +bool PropertyEditor::_get_instanced_node_original_property(const StringName& p_prop,Variant& value) { + + Node *node = obj->cast_to<Node>(); + if (!node) - return NULL; + return false; - if (node->get_filename()=="") - return NULL; + Node *orig=node; + + Node* edited_scene =EditorNode::get_singleton()->get_edited_scene(); + + bool found=false; - if (!node->get_owner()) - return NULL; //scene root i guess +// print_line("for prop - "+String(p_prop)); - return node; + while(node) { + + Ref<SceneState> ss; + + if (node==edited_scene) { + ss=node->get_scene_inherited_state(); + } else { + ss=node->get_scene_instance_state(); + } +// print_line("at - "+String(edited_scene->get_path_to(node))); + + if (ss.is_valid()) { + NodePath np = node->get_path_to(orig); + int node_idx = ss->find_node_by_path(np); +// print_line("\t valid, nodeidx "+itos(node_idx)); + if (node_idx>=0) { + bool lfound=false; + Variant lvar; + lvar=ss->get_property_value(node_idx,p_prop,lfound); + if (lfound) { + found=true; + value=lvar; +// print_line("\t found value "+String(value)); + } + } + } + if (node==edited_scene) { + //just in case + break; + } + node=node->get_owner(); + + } + + return found; +} + +bool PropertyEditor::_is_property_different(const Variant& p_current, const Variant& p_orig,int p_usage) { + + if (p_orig.get_type()==Variant::NIL) { + //special cases + if (p_current.is_zero() && p_usage&PROPERTY_USAGE_STORE_IF_NONZERO) + return false; + if (p_current.is_one() && p_usage&PROPERTY_USAGE_STORE_IF_NONONE) + return false; + } + + return bool(Variant::evaluate(Variant::OP_NOT_EQUAL,p_current,p_orig)); } TreeItem *PropertyEditor::find_item(TreeItem *p_item,const String& p_name) { @@ -1910,6 +1988,8 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String& p } + + void PropertyEditor::_notification(int p_what) { if (p_what==NOTIFICATION_ENTER_TREE) { @@ -1950,12 +2030,16 @@ void PropertyEditor::_notification(int p_what) { if (!item) continue; - if (get_instanced_node()) { + if (_might_be_in_instance()) { + + + Variant vorig; + Dictionary d=item->get_metadata(0); + int usage = d.has("usage")?int(int(d["usage"])&(PROPERTY_USAGE_STORE_IF_NONONE|PROPERTY_USAGE_STORE_IF_NONZERO)):0; - Dictionary d = get_instanced_node()->get_instance_state(); - if (d.has(*k)) { + + if (_get_instanced_node_original_property(*k,vorig) || usage) { Variant v = obj->get(*k); - Variant vorig = d[*k]; int found=-1; for(int i=0;i<item->get_button_count(1);i++) { @@ -1966,7 +2050,7 @@ void PropertyEditor::_notification(int p_what) { } } - bool changed = ! (v==vorig); + bool changed = _is_property_different(v,vorig,usage); if ((found!=-1)!=changed) { @@ -2049,12 +2133,14 @@ void PropertyEditor::_refresh_item(TreeItem *p_item) { if (name!=String()) { - if (get_instanced_node()) { + if (_might_be_in_instance()) { + + Variant vorig; + Dictionary d=p_item->get_metadata(0); + int usage = d.has("usage")?int(int(d["usage"])&(PROPERTY_USAGE_STORE_IF_NONONE|PROPERTY_USAGE_STORE_IF_NONZERO)):0; - Dictionary d = get_instanced_node()->get_instance_state(); - if (d.has(name)) { + if (_get_instanced_node_original_property(name,vorig) || usage) { Variant v = obj->get(name); - Variant vorig = d[name]; int found=-1; for(int i=0;i<p_item->get_button_count(1);i++) { @@ -2065,7 +2151,7 @@ void PropertyEditor::_refresh_item(TreeItem *p_item) { } } - bool changed = ! (v==vorig); + bool changed = _is_property_different(v,vorig,usage); if ((found!=-1)!=changed) { @@ -2326,7 +2412,8 @@ void PropertyEditor::update_tree() { d["type"]=(int)p.type; d["hint"]=(int)p.hint; d["hint_text"]=p.hint_string; - + d["usage"]=(int)p.usage; + item->set_metadata( 0, d ); item->set_metadata( 1, p.name ); @@ -2777,14 +2864,17 @@ void PropertyEditor::update_tree() { } } - if (get_instanced_node()) { + if (_might_be_in_instance()) { - Dictionary d = get_instanced_node()->get_instance_state(); - if (d.has(p.name)) { + Variant vorig; + Dictionary d=item->get_metadata(0); + int usage = d.has("usage")?int(int(d["usage"])&(PROPERTY_USAGE_STORE_IF_NONONE|PROPERTY_USAGE_STORE_IF_NONZERO)):0; + if (_get_instanced_node_original_property(p.name,vorig) || usage) { Variant v = obj->get(p.name); - Variant vorig = d[p.name]; - if (! (v==vorig)) { + + if (_is_property_different(v,vorig,usage)) { + //print_line("FOR "+String(p.name)+" RELOAD WITH: "+String(v)+"("+Variant::get_type_name(v.get_type())+")=="+String(vorig)+"("+Variant::get_type_name(vorig.get_type())+")"); item->add_button(1,get_icon("Reload","EditorIcons"),3); } } @@ -3081,17 +3171,18 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) { call_deferred("_set_range_def",ti,prop,ti->get_range(p_column)+1.0); } else if (p_button==3) { - if (!get_instanced_node()) + if (!_might_be_in_instance()) return; if (!d.has("name")) return; String prop=d["name"]; - Dictionary d2 = get_instanced_node()->get_instance_state(); - if (d2.has(prop)) { + Variant vorig; + + if (_get_instanced_node_original_property(prop,vorig)) { - _edit_set(prop,d2[prop]); + _edit_set(prop,vorig); } } else { diff --git a/tools/editor/property_editor.h b/tools/editor/property_editor.h index 36ecc794ed..9686bf0bd7 100644 --- a/tools/editor/property_editor.h +++ b/tools/editor/property_editor.h @@ -121,6 +121,7 @@ class CustomPropertyEditor : public Popup { void show_value_editors(int p_amount); void config_value_editors(int p_amount, int p_columns,int p_label_w,const List<String>& p_strings); void config_action_buttons(const List<String>& p_strings); + protected: void _notification(int p_what); @@ -184,13 +185,17 @@ class PropertyEditor : public Control { virtual void _changed_callback(Object *p_changed,const char * p_what); virtual void _changed_callbacks(Object *p_changed,const String& p_callback); + void _edit_button(Object *p_item, int p_column, int p_button); void _node_removed(Node *p_node); void _edit_set(const String& p_name, const Variant& p_value); void _draw_flags(Object *ti,const Rect2& p_rect); - Node *get_instanced_node(); + bool _might_be_in_instance(); + bool _get_instanced_node_original_property(const StringName& p_prop,Variant& value); + bool _is_property_different(const Variant& p_current, const Variant& p_orig,int p_usage=0); + void _refresh_item(TreeItem *p_item); void _set_range_def(Object *p_item, String prop, float p_frame); diff --git a/tools/editor/reparent_dialog.cpp b/tools/editor/reparent_dialog.cpp index 6d0c5b867e..78ba47d54b 100644 --- a/tools/editor/reparent_dialog.cpp +++ b/tools/editor/reparent_dialog.cpp @@ -103,6 +103,7 @@ ReparentDialog::ReparentDialog() { add_child(node_only); node_only->hide(); + tree->set_show_enabled_subscene(true); //vbc->add_margin_child("Options:",node_only);; diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 276f2dea33..920ab599e9 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -36,8 +36,8 @@ #include "script_editor_debugger.h" #include "tools/editor/plugins/script_editor_plugin.h" #include "multi_node_edit.h" -void SceneTreeDock::_unhandled_key_input(InputEvent p_event) { +void SceneTreeDock::_unhandled_key_input(InputEvent p_event) { uint32_t sc = p_event.key.get_scancode_with_modifiers(); if (!p_event.key.pressed || p_event.key.echo) @@ -71,7 +71,7 @@ Node* SceneTreeDock::instance(const String& p_file) { Node*instanced_scene=NULL; Ref<PackedScene> sdata = ResourceLoader::load(p_file); if (sdata.is_valid()) - instanced_scene=sdata->instance(); + instanced_scene=sdata->instance(true); if (!instanced_scene) { @@ -96,7 +96,7 @@ Node* SceneTreeDock::instance(const String& p_file) { } } - instanced_scene->generate_instance_state(); + //instanced_scene->generate_instance_state(); instanced_scene->set_filename( Globals::get_singleton()->localize_path(p_file) ); editor_data->get_undo_redo().create_action("Instance Scene"); @@ -158,8 +158,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { case TOOL_NEW: { - if (!_validate_no_foreign()) - break; + //if (!_validate_no_foreign()) + // break; create_dialog->popup_centered_ratio(); } break; case TOOL_INSTANCE: { @@ -176,8 +176,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; } - if (!_validate_no_foreign()) - break; + //if (!_validate_no_foreign()) + // break; file->set_mode(EditorFileDialog::MODE_OPEN_FILE); List<String> extensions; @@ -202,8 +202,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (!current) break; - if (!_validate_no_foreign()) - break; + //if (!_validate_no_foreign()) + // break; connect_dialog->popup_centered_ratio(); connect_dialog->set_node(current); @@ -213,8 +213,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { Node *current = scene_tree->get_selected(); if (!current) break; - if (!_validate_no_foreign()) - break; + //if (!_validate_no_foreign()) + // break; groups_editor->set_current(current); groups_editor->popup_centered_ratio(); } break; @@ -224,8 +224,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (!selected) break; - if (!_validate_no_foreign()) - break; + //if (!_validate_no_foreign()) + // break; Ref<Script> existing = selected->get_script(); if (existing.is_valid()) @@ -573,9 +573,9 @@ Node *SceneTreeDock::_duplicate(Node *p_node, Map<Node*,Node*> &duplimap) { Ref<PackedScene> sd = ResourceLoader::load( p_node->get_filename() ); ERR_FAIL_COND_V(!sd.is_valid(),NULL); - node = sd->instance(); + node = sd->instance(true); ERR_FAIL_COND_V(!node,NULL); - node->generate_instance_state(); + //node->generate_instance_state(); } else { Object *obj = ObjectTypeDB::instance(p_node->get_type()); ERR_FAIL_COND_V(!obj,NULL); @@ -874,6 +874,16 @@ bool SceneTreeDock::_validate_no_foreign() { return false; } + + if (edited_scene->get_scene_instance_state().is_valid() && edited_scene->get_scene_instance_state()->find_node_by_path(edited_scene->get_path_to(E->get()))>=0) { + + accept->get_ok()->set_text("Makes Sense!"); + accept->set_text("Can't operate on nodes the current scene inherits from!"); + accept->popup_centered_minsize(); + return false; + + } + } return true; @@ -1078,14 +1088,15 @@ void SceneTreeDock::_delete_confirm() { void SceneTreeDock::_update_tool_buttons() { Node *sel = scene_tree->get_selected(); - bool disable = !sel || (sel!=edited_scene && sel->get_owner()!=edited_scene); + bool disable = !sel || (sel!=edited_scene && sel->get_owner()!=edited_scene) || (edited_scene->get_scene_instance_state().is_valid() && edited_scene->get_scene_instance_state()->find_node_by_path(edited_scene->get_path_to(sel))>=0); bool disable_root = disable || sel->get_parent()==scene_root; + bool disable_edit = !sel; - tool_buttons[TOOL_INSTANCE]->set_disabled(disable); + tool_buttons[TOOL_INSTANCE]->set_disabled(disable_edit); tool_buttons[TOOL_REPLACE]->set_disabled(disable); - tool_buttons[TOOL_CONNECT]->set_disabled(disable); - tool_buttons[TOOL_GROUP]->set_disabled(disable); - tool_buttons[TOOL_SCRIPT]->set_disabled(disable); + tool_buttons[TOOL_CONNECT]->set_disabled(disable_edit); + tool_buttons[TOOL_GROUP]->set_disabled(disable_edit); + tool_buttons[TOOL_SCRIPT]->set_disabled(disable_edit); tool_buttons[TOOL_MOVE_UP]->set_disabled(disable_root); tool_buttons[TOOL_MOVE_DOWN]->set_disabled(disable_root); tool_buttons[TOOL_DUPLICATE]->set_disabled(disable_root); diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp index fd841028a2..719e853fda 100644 --- a/tools/editor/scene_tree_editor.cpp +++ b/tools/editor/scene_tree_editor.cpp @@ -34,6 +34,8 @@ #include "scene/main/viewport.h" #include "tools/editor/plugins/canvas_item_editor_plugin.h" +#include "scene/resources/packed_scene.h" + Node *SceneTreeEditor::get_scene_node() { ERR_FAIL_COND_V(!is_inside_tree(),NULL); @@ -57,22 +59,38 @@ void SceneTreeEditor::_subscene_option(int p_idx) { switch(p_idx) { - case SCENE_MENU_SHOW_CHILDREN: { + case SCENE_MENU_EDITABLE_CHILDREN: { - if (node->has_meta("__editor_show_subtree")) { - instance_menu->set_item_checked(0,true); - node->set_meta("__editor_show_subtree",Variant()); - _update_tree(); - } else { - node->set_meta("__editor_show_subtree",true); - _update_tree(); - } + bool editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(node); + editable = !editable; + + //node->set_instance_children_editable(editable); + EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node,editable); + instance_menu->set_item_checked(0,editable); + + _update_tree(); } break; case SCENE_MENU_OPEN: { emit_signal("open",node->get_filename()); } break; + case SCENE_MENU_CLEAR_INHERITANCE: { + clear_inherit_confirm->popup_centered_minsize(); + } break; + case SCENE_MENU_OPEN_INHERITED: { + if (node && node->get_scene_inherited_state().is_valid()) { + emit_signal("open",node->get_scene_inherited_state()->get_path()); + } + } break; + case SCENE_MENU_CLEAR_INHERITANCE_CONFIRM: { + if (node && node->get_scene_inherited_state().is_valid()) { + node->set_scene_inherited_state(Ref<SceneState>()); + update_tree(); + EditorNode::get_singleton()->get_property_editor()->update_tree(); + } + + } break; } @@ -94,15 +112,24 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id) Rect2 item_rect = tree->get_item_rect(item,0); item_rect.pos.y-=tree->get_scroll().y; item_rect.pos+=tree->get_global_pos(); - instance_menu->set_pos(item_rect.pos+Vector2(0,item_rect.size.y)); - instance_menu->set_size(Vector2(item_rect.size.x,0)); - if (n->has_meta("__editor_show_subtree")) - instance_menu->set_item_checked(0,true); - else - instance_menu->set_item_checked(0,false); - - instance_menu->popup(); - instance_node=n->get_instance_ID(); + + if (n==get_scene_node()) { + inheritance_menu->set_pos(item_rect.pos+Vector2(0,item_rect.size.y)); + inheritance_menu->set_size(Vector2(item_rect.size.x,0)); + inheritance_menu->popup(); + instance_node=n->get_instance_ID(); + + } else { + instance_menu->set_pos(item_rect.pos+Vector2(0,item_rect.size.y)); + instance_menu->set_size(Vector2(item_rect.size.x,0)); + if (EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(n)) + instance_menu->set_item_checked(0,true); + else + instance_menu->set_item_checked(0,false); + + instance_menu->popup(); + instance_node=n->get_instance_ID(); + } //emit_signal("open",n->get_filename()); } else if (p_id==BUTTON_SCRIPT) { RefPtr script=n->get_script(); @@ -168,15 +195,17 @@ void SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) { bool part_of_subscene=false; - if (!display_foreign && p_node->get_owner()!=get_scene_node() && p_node!=get_scene_node()) { + if (!display_foreign && p_node->get_owner()!=get_scene_node() && p_node!=get_scene_node()) { - if ((show_enabled_subscene || can_open_instance) && p_node->get_owner() && p_node->get_owner()->get_owner()==get_scene_node() && p_node->get_owner()->has_meta("__editor_show_subtree")) { + if ((show_enabled_subscene || can_open_instance) && p_node->get_owner() && (get_scene_node()->is_editable_instance(p_node->get_owner()))) { part_of_subscene=true; //allow } else { return; } + } else { + part_of_subscene = get_scene_node()->get_scene_inherited_state().is_valid() && get_scene_node()->get_scene_inherited_state()->find_node_by_path(get_scene_node()->get_path_to(p_node))>=0; } TreeItem *item = tree->create_item(p_parent); @@ -199,6 +228,7 @@ void SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) { icon=get_icon( (has_icon(p_node->get_type(),"EditorIcons")?p_node->get_type():String("Object")),"EditorIcons"); item->set_icon(0, icon ); item->set_metadata( 0,p_node->get_path() ); + if (part_of_subscene) { //item->set_selectable(0,marked_selectable); @@ -221,7 +251,10 @@ void SceneTreeEditor::_add_nodes(Node *p_node,TreeItem *p_parent) { } } - if (p_node!=get_scene_node() && p_node->get_filename()!="" && can_open_instance) { + if (p_node==get_scene_node() && p_node->get_scene_inherited_state().is_valid()) { + item->add_button(0,get_icon("InstanceOptions","EditorIcons"),BUTTON_SUBSCENE); + item->set_tooltip(0,"Inherits: "+p_node->get_scene_inherited_state()->get_path()+"\nType: "+p_node->get_type()); + } else if (p_node!=get_scene_node() && p_node->get_filename()!="" && can_open_instance) { item->add_button(0,get_icon("InstanceOptions","EditorIcons"),BUTTON_SUBSCENE); item->set_tooltip(0,"Instance: "+p_node->get_filename()+"\nType: "+p_node->get_type()); @@ -489,6 +522,9 @@ void SceneTreeEditor::_notification(int p_what) { get_tree()->connect("node_removed",this,"_node_removed"); instance_menu->set_item_icon(2,get_icon("Load","EditorIcons")); tree->connect("item_collapsed",this,"_cell_collapsed"); + inheritance_menu->set_item_icon(2,get_icon("Load","EditorIcons")); + clear_inherit_confirm->connect("confirmed",this,"_subscene_option",varray(SCENE_MENU_CLEAR_INHERITANCE_CONFIRM)); + // get_scene()->connect("tree_changed",this,"_tree_changed",Vector<Variant>(),CONNECT_DEFERRED); // get_scene()->connect("node_removed",this,"_node_removed",Vector<Variant>(),CONNECT_DEFERRED); @@ -499,6 +535,7 @@ void SceneTreeEditor::_notification(int p_what) { get_tree()->disconnect("tree_changed",this,"_tree_changed"); get_tree()->disconnect("node_removed",this,"_node_removed"); tree->disconnect("item_collapsed",this,"_cell_collapsed"); + clear_inherit_confirm->disconnect("confirmed",this,"_subscene_option"); _update_tree(); } @@ -788,12 +825,26 @@ SceneTreeEditor::SceneTreeEditor(bool p_label,bool p_can_rename, bool p_can_open blocked=0; instance_menu = memnew( PopupMenu ); - instance_menu->add_check_item("Show Children",SCENE_MENU_SHOW_CHILDREN); + instance_menu->add_check_item("Editable Children",SCENE_MENU_EDITABLE_CHILDREN); instance_menu->add_separator(); instance_menu->add_item("Open in Editor",SCENE_MENU_OPEN); instance_menu->connect("item_pressed",this,"_subscene_option"); add_child(instance_menu); + inheritance_menu = memnew( PopupMenu ); + inheritance_menu->add_item("Clear Inheritance",SCENE_MENU_CLEAR_INHERITANCE); + inheritance_menu->add_separator(); + inheritance_menu->add_item("Open in Editor",SCENE_MENU_OPEN_INHERITED); + inheritance_menu->connect("item_pressed",this,"_subscene_option"); + + add_child(inheritance_menu); + + clear_inherit_confirm = memnew( ConfirmationDialog ); + clear_inherit_confirm->set_text("Clear Inheritance? (No Undo!)"); + clear_inherit_confirm->get_ok()->set_text("Clear!"); + add_child(clear_inherit_confirm); + + } diff --git a/tools/editor/scene_tree_editor.h b/tools/editor/scene_tree_editor.h index b05a52a2da..b80ac30d87 100644 --- a/tools/editor/scene_tree_editor.h +++ b/tools/editor/scene_tree_editor.h @@ -52,16 +52,21 @@ class SceneTreeEditor : public Control { }; enum { - SCENE_MENU_SHOW_CHILDREN, + SCENE_MENU_EDITABLE_CHILDREN, SCENE_MENU_OPEN, + SCENE_MENU_CLEAR_INHERITANCE, + SCENE_MENU_OPEN_INHERITED, + SCENE_MENU_CLEAR_INHERITANCE_CONFIRM, }; Tree *tree; Node *selected; PopupMenu *instance_menu; + PopupMenu *inheritance_menu; ObjectID instance_node; AcceptDialog *error; + ConfirmationDialog *clear_inherit_confirm; int blocked; |