diff options
Diffstat (limited to 'editor')
| -rw-r--r-- | editor/SCsub | 31 | ||||
| -rw-r--r-- | editor/editor_name_dialog.cpp | 1 | ||||
| -rw-r--r-- | editor/editor_node.cpp | 115 | ||||
| -rw-r--r-- | editor/import/editor_import_collada.cpp | 8 | ||||
| -rw-r--r-- | editor/plugins/animation_player_editor_plugin.cpp | 4 | ||||
| -rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 16 | ||||
| -rw-r--r-- | editor/plugins/script_editor_plugin.h | 3 | ||||
| -rw-r--r-- | editor/plugins/script_text_editor.cpp | 4 | ||||
| -rw-r--r-- | editor/plugins/script_text_editor.h | 2 | ||||
| -rw-r--r-- | editor/property_selector.cpp | 2 | ||||
| -rw-r--r-- | editor/scene_tree_dock.cpp | 132 | ||||
| -rw-r--r-- | editor/scene_tree_dock.h | 11 | ||||
| -rw-r--r-- | editor/scene_tree_editor.cpp | 167 | ||||
| -rw-r--r-- | editor/scene_tree_editor.h | 14 | ||||
| -rw-r--r-- | editor/script_create_dialog.cpp | 6 |
15 files changed, 272 insertions, 244 deletions
diff --git a/editor/SCsub b/editor/SCsub index ffdeed1523..a26f6bba77 100644 --- a/editor/SCsub +++ b/editor/SCsub @@ -143,6 +143,9 @@ def make_translations_header(target, source, env): def make_authors_header(target, source, env): + sections = ["Project Founders", "Lead Developer", "Project Manager", "Developers"] + sections_id = ["dev_founders", "dev_lead", "dev_manager", "dev_names"] + src = source[0].srcnode().abspath dst = target[0].srcnode().abspath f = open(src, "rb") @@ -151,19 +154,35 @@ def make_authors_header(target, source, env): g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") g.write("#ifndef _EDITOR_AUTHORS_H\n") g.write("#define _EDITOR_AUTHORS_H\n") - g.write("static const char *dev_names[] = {\n") + current_section = "" name_count = -1 + + def close_section(): + g.write("\t0\n") + g.write("};\n") + g.write("#define " + current_section.upper() + "_COUNT " + str(name_count) + "\n") + for line in f: if name_count >= 0: if line.startswith(" "): g.write("\t\"" + line.strip() + "\",\n") name_count += 1 - elif line.strip() == "## Developers": - name_count = 0 - g.write("\t0\n") - g.write("};\n") - g.write("#define AUTHORS_COUNT " + str(name_count) + "\n") + continue + if line.startswith("## "): + if name_count >= 0: + close_section() + name_count = -1 + for i in range(len(sections)): + if line.strip().endswith(sections[i]): + current_section = sections_id[i] + name_count = 0 + g.write("static const char *" + current_section + "[] = {\n") + break + + if name_count >= 0: + close_section() + g.write("#endif\n") if (env["tools"] == "yes"): diff --git a/editor/editor_name_dialog.cpp b/editor/editor_name_dialog.cpp index d4c418bfc9..7435e9a9f7 100644 --- a/editor/editor_name_dialog.cpp +++ b/editor/editor_name_dialog.cpp @@ -85,7 +85,6 @@ EditorNameDialog::EditorNameDialog() { add_child(makevb); name = memnew(LineEdit); makevb->add_child(name); - makevb->move_child(name, get_label()->get_index() + 1); name->set_margin(MARGIN_TOP, 5); name->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 5); name->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 5); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 77050acd7c..2274690569 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2646,7 +2646,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { OS::get_singleton()->shell_open("https://godotengine.org/community"); } break; case HELP_ABOUT: { - about->popup_centered_minsize(Size2(500, 130) * EDSCALE); + about->popup_centered_minsize(Size2(780, 500) * EDSCALE); } break; case SOURCES_REIMPORT: { @@ -6042,52 +6042,73 @@ EditorNode::EditorNode() { export_template_manager = memnew(ExportTemplateManager); gui_base->add_child(export_template_manager); - about = memnew(AcceptDialog); - about->set_title(TTR("Thanks from the Godot community!")); - about->get_ok()->set_text(TTR("Thanks!")); - about->set_hide_on_ok(true); - gui_base->add_child(about); - VBoxContainer *vbc = memnew(VBoxContainer); - HBoxContainer *hbc = memnew(HBoxContainer); - hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); - hbc->set_alignment(BoxContainer::ALIGN_CENTER); - about->add_child(vbc); - vbc->add_child(hbc); - Label *about_text = memnew(Label); - about_text->set_text(VERSION_FULL_NAME + String::utf8("\n\u00A9 2007-2017 Juan Linietsky, Ariel Manzur.\n\u00A9 2014-2017 ") + TTR("Godot Engine contributors") + "\n"); - TextureRect *logo = memnew(TextureRect); - logo->set_texture(gui_base->get_icon("Logo", "EditorIcons")); - hbc->add_child(logo); - hbc->add_child(about_text); - TabContainer *tc = memnew(TabContainer); - tc->set_custom_minimum_size(Vector2(740, 300)); - vbc->add_child(tc); - ScrollContainer *dev_base = memnew(ScrollContainer); - dev_base->set_name(TTR("Developers")); - tc->add_child(dev_base); - HBoxContainer *dev_hbc = memnew(HBoxContainer); - dev_hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); - dev_base->add_child(dev_hbc); - for (int i = 0; i < 3; i++) { - Label *dev_label = memnew(Label); - dev_label->set_h_size_flags(Control::SIZE_EXPAND); - dev_label->set_v_size_flags(Control::SIZE_FILL); - dev_hbc->add_child(dev_label); - } - int dev_name_index = 0; - int dev_name_column = 0; - const int dev_index_max = AUTHORS_COUNT / 3 + (AUTHORS_COUNT % 3 == 0 ? 0 : 1); - String dev_name = ""; - const char **dev_names_ptr = dev_names; - while (*dev_names_ptr) { - dev_name += String::utf8(*dev_names_ptr++); - if (++dev_name_index == dev_index_max || !*dev_names_ptr) { - dev_hbc->get_child(dev_name_column)->cast_to<Label>()->set_text(dev_name); - dev_name_column++; - dev_name = ""; - dev_name_index = 0; - } else { - dev_name += "\n"; + { + + about = memnew(AcceptDialog); + about->set_title(TTR("Thanks from the Godot community!")); + about->get_ok()->set_text(TTR("Thanks!")); + about->set_hide_on_ok(true); + about->set_resizable(true); + gui_base->add_child(about); + + VBoxContainer *vbc = memnew(VBoxContainer); + HBoxContainer *hbc = memnew(HBoxContainer); + hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); + hbc->set_alignment(BoxContainer::ALIGN_CENTER); + hbc->add_constant_override("separation", 30 * EDSCALE); + about->add_child(vbc); + vbc->add_child(hbc); + + TextureRect *logo = memnew(TextureRect); + logo->set_texture(gui_base->get_icon("Logo", "EditorIcons")); + hbc->add_child(logo); + + Label *about_text = memnew(Label); + about_text->set_text(VERSION_FULL_NAME + String::utf8("\n\u00A9 2007-2017 Juan Linietsky, Ariel Manzur.\n\u00A9 2014-2017 ") + + TTR("Godot Engine contributors") + "\n"); + hbc->add_child(about_text); + + TabContainer *tc = memnew(TabContainer); + tc->set_custom_minimum_size(Size2(600, 240) * EDSCALE); + tc->set_v_size_flags(Control::SIZE_EXPAND_FILL); + vbc->add_child(tc); + + ScrollContainer *dev_base = memnew(ScrollContainer); + dev_base->set_name(TTR("Authors")); + dev_base->set_v_size_flags(Control::SIZE_EXPAND); + tc->add_child(dev_base); + + VBoxContainer *dev_vbc = memnew(VBoxContainer); + dev_vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); + dev_base->add_child(dev_vbc); + + List<String> dev_sections; + dev_sections.push_back(TTR("Project Founders")); + dev_sections.push_back(TTR("Lead Developer")); + dev_sections.push_back(TTR("Project Manager")); + dev_sections.push_back(TTR("Developers")); + + const char **dev_src[] = { dev_founders, dev_lead, dev_manager, dev_names }; + + for (int i = 0; i < dev_sections.size(); i++) { + + Label *lbl = memnew(Label); + lbl->set_text(dev_sections[i]); + dev_vbc->add_child(lbl); + + ItemList *il = memnew(ItemList); + il->set_max_columns(32); + il->set_h_size_flags(Control::SIZE_EXPAND_FILL); + il->set_custom_minimum_size(Size2(0, i == 3 ? DEV_NAMES_COUNT * 7.6 : 30) * EDSCALE); + const char **dev_names_ptr = dev_src[i]; + while (*dev_names_ptr) + il->add_item(String::utf8(*dev_names_ptr++), NULL, false); + dev_vbc->add_child(il); + il->set_fixed_column_width(240 * EDSCALE); + + HSeparator *hs = memnew(HSeparator); + hs->set_modulate(Color(0, 0, 0, 0)); + dev_vbc->add_child(hs); } } diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index e0a2ea624e..7948db3797 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -908,12 +908,20 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me #ifndef NO_UP_AXIS_SWAP if (collada.state.up_axis == Vector3::AXIS_Z) { + Vector3 bn = vertex.normal.cross(vertex.tangent.normal) * vertex.tangent.d; + SWAP(vertex.vertex.z, vertex.vertex.y); vertex.vertex.z = -vertex.vertex.z; SWAP(vertex.normal.z, vertex.normal.y); vertex.normal.z = -vertex.normal.z; SWAP(vertex.tangent.normal.z, vertex.tangent.normal.y); vertex.tangent.normal.z = -vertex.tangent.normal.z; + SWAP(bn.z, bn.y); + bn.z = -bn.z; + + vertex.tangent.d = vertex.normal.cross(vertex.tangent.normal).dot(bn) > 0 ? 1 : -1; + + print_line("Tangent " + itos(p_i) + ": " + vertex.tangent); } #endif diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 28c5b89741..c3e1f60ccc 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -254,6 +254,10 @@ void AnimationPlayerEditor::_play_bw_from_pressed() { } void AnimationPlayerEditor::_stop_pressed() { + if (!player) { + return; + } + player->stop(false); play->set_pressed(false); stop->set_pressed(true); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 0024870665..aedc96d20e 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -509,9 +509,8 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) { if (p_save) { apply_scripts(); } - if (current->get_edit_menu()) { - memdelete(current->get_edit_menu()); - } + current->clear_edit_menu(); + } else { EditorHelp *help = tab_container->get_child(selected)->cast_to<EditorHelp>(); _add_recent_script(help->get_class()); @@ -1885,6 +1884,9 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { for (int i = 0; i < helps.size(); i++) { String path = helps[i]; + if (path == "") { // invalid, skip + continue; + } _help_class_open(path); } @@ -2180,13 +2182,15 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { script_list = memnew(ItemList); list_split->add_child(script_list); - script_list->set_custom_minimum_size(Size2(0, 0)); + script_list->set_custom_minimum_size(Size2(150 * EDSCALE, 100)); //need to give a bit of limit to avoid it from disappearing + script_list->set_v_size_flags(SIZE_EXPAND_FILL); script_split->set_split_offset(140); - list_split->set_split_offset(500); + //list_split->set_split_offset(500); members_overview = memnew(ItemList); list_split->add_child(members_overview); - members_overview->set_custom_minimum_size(Size2(0, 0)); + members_overview->set_custom_minimum_size(Size2(0, 100)); //need to give a bit of limit to avoid it from disappearing + members_overview->set_v_size_flags(SIZE_EXPAND_FILL); tab_container = memnew(TabContainer); tab_container->add_style_override("panel", p_editor->get_gui_base()->get_stylebox("ScriptPanel", "EditorStyles")); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index 3b444c0883..da8248a1a7 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -106,6 +106,7 @@ public: virtual void set_tooltip_request_func(String p_method, Object *p_obj) = 0; virtual Control *get_edit_menu() = 0; + virtual void clear_edit_menu() = 0; ScriptEditorBase() {} }; @@ -363,6 +364,8 @@ public: bool can_take_away_focus() const; + VSplitContainer *get_left_list_split() { return list_split; } + ScriptEditorDebugger *get_debugger() { return debugger; } void set_live_auto_reload_running_scripts(bool p_enabled); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 60fd9d8e30..83741c7fb8 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1093,6 +1093,10 @@ Control *ScriptTextEditor::get_edit_menu() { return edit_hb; } +void ScriptTextEditor::clear_edit_menu() { + memdelete(edit_hb); +} + void ScriptTextEditor::reload(bool p_soft) { TextEdit *te = code_editor->get_text_edit(); diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index ba40645161..e55847832f 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -156,7 +156,7 @@ public: virtual void set_debugger_active(bool p_active); Control *get_edit_menu(); - + virtual void clear_edit_menu(); static void register_editor(); ScriptTextEditor(); diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 47e5994e3f..c6af993676 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -167,7 +167,7 @@ void PropertySelector::_update_search() { continue; } - if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) + if (!(E->get().usage & PROPERTY_USAGE_EDITOR) && !(E->get().usage & PROPERTY_USAGE_SCRIPT_VARIABLE)) continue; if (search_box->get_text() != String() && E->get().name.find(search_box->get_text()) == -1) diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index da2d22b900..e8fa3f78cc 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -658,7 +658,91 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } } } break; - + case TOOL_SCENE_EDITABLE_CHILDREN: { + List<Node *> selection = editor_selection->get_selected_node_list(); + if (List<Node *>::Element *e = selection.front()) { + if (Node *node = e->get()) { + bool editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(node); + editable = !editable; + + EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node, editable); + menu->set_item_checked(18, editable); + if (editable) { + node->set_scene_instance_load_placeholder(false); + menu->set_item_checked(19, false); + } + scene_tree->update_tree(); + } + } + } break; + case TOOL_SCENE_USE_PLACEHOLDER: { + List<Node *> selection = editor_selection->get_selected_node_list(); + if (List<Node *>::Element *e = selection.front()) { + if (Node *node = e->get()) { + bool placeholder = node->get_scene_instance_load_placeholder(); + placeholder = !placeholder; + if (placeholder) + EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node, false); + + node->set_scene_instance_load_placeholder(placeholder); + menu->set_item_checked(18, false); + menu->set_item_checked(19, placeholder); + scene_tree->update_tree(); + } + } + } break; + case TOOL_SCENE_CLEAR_INSTANCING: { + List<Node *> selection = editor_selection->get_selected_node_list(); + if (List<Node *>::Element *e = selection.front()) { + if (Node *node = e->get()) { + Node *root = EditorNode::get_singleton()->get_edited_scene(); + UndoRedo *undo_redo = &editor_data->get_undo_redo(); + if (!root) + break; + + ERR_FAIL_COND(node->get_filename() == String()); + + undo_redo->create_action("Discard Instancing"); + undo_redo->add_do_method(node, "set_filename", ""); + undo_redo->add_undo_method(node, "set_filename", node->get_filename()); + _node_replace_owner(node, node, root); + undo_redo->add_do_method(scene_tree, "update_tree"); + undo_redo->add_undo_method(scene_tree, "update_tree"); + undo_redo->commit_action(); + } + } + } break; + case TOOL_SCENE_OPEN: { + List<Node *> selection = editor_selection->get_selected_node_list(); + if (List<Node *>::Element *e = selection.front()) { + if (Node *node = e->get()) { + scene_tree->emit_signal("open", node->get_filename()); + } + } + } break; + case TOOL_SCENE_CLEAR_INHERITANCE: { + clear_inherit_confirm->popup_centered_minsize(); + } break; + case TOOL_SCENE_CLEAR_INHERITANCE_CONFIRM: { + List<Node *> selection = editor_selection->get_selected_node_list(); + if (List<Node *>::Element *e = selection.front()) { + if (Node *node = e->get()) { + node->set_scene_inherited_state(Ref<SceneState>()); + scene_tree->update_tree(); + EditorNode::get_singleton()->get_property_editor()->update_tree(); + } + } + } break; + case TOOL_SCENE_OPEN_INHERITED: { + List<Node *> selection = editor_selection->get_selected_node_list(); + if (List<Node *>::Element *e = selection.front()) { + if (Node *node = e->get()) { + if (node && node->get_scene_inherited_state().is_valid()) { + scene_tree->emit_signal("open", node->get_scene_inherited_state()->get_path()); + } + } + } + } break; default: { if (p_tool >= EDIT_SUBRESOURCE_BASE) { @@ -702,6 +786,29 @@ void SceneTreeDock::_notification(int p_what) { EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", this, "_selection_changed"); } break; + + case NOTIFICATION_ENTER_TREE: { + clear_inherit_confirm->connect("confirmed", this, "_tool_selected", varray(TOOL_SCENE_CLEAR_INHERITANCE_CONFIRM)); + } break; + + case NOTIFICATION_EXIT_TREE: { + clear_inherit_confirm->disconnect("confirmed", this, "_tool_selected"); + } break; + } +} + +void SceneTreeDock::_node_replace_owner(Node *p_base, Node *p_node, Node *p_root) { + + if (p_base != p_node) { + if (p_node->get_owner() == p_base) { + UndoRedo *undo_redo = &editor_data->get_undo_redo(); + undo_redo->add_do_method(p_node, "set_owner", p_root); + undo_redo->add_undo_method(p_node, "set_owner", p_base); + } + } + + for (int i = 0; i < p_node->get_child_count(); i++) { + _node_replace_owner(p_base, p_node->get_child(i), p_root); } } @@ -1769,6 +1876,24 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_icon_shortcut(get_icon("CreateNewSceneFrom", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM); menu->add_separator(); menu->add_icon_shortcut(get_icon("CopyNodePath", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH); + bool is_external = (selection[0]->get_filename() != "") && (selection[0]->get_owner() != selection[0]); + if (is_external) { + bool is_inherited = selection[0]->get_scene_inherited_state() != NULL; + menu->add_separator(); + if (is_inherited) { + menu->add_item(TTR("Clear Inheritance"), TOOL_SCENE_CLEAR_INHERITANCE); + menu->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN_INHERITED); + } else { + bool editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(selection[0]); + bool placeholder = selection[0]->get_scene_instance_load_placeholder(); + menu->add_check_item(TTR("Editable Children"), TOOL_SCENE_EDITABLE_CHILDREN); + menu->add_check_item(TTR("Load As Placeholder"), TOOL_SCENE_USE_PLACEHOLDER); + menu->add_item(TTR("Discard Instancing"), TOOL_SCENE_CLEAR_INSTANCING); + menu->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN); + menu->set_item_checked(18, editable); + menu->set_item_checked(19, placeholder); + } + } } menu->add_separator(); menu->add_icon_shortcut(get_icon("Remove", "EditorIcons"), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE); @@ -1978,6 +2103,11 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel first_enter = true; restore_script_editor_on_drag = false; + clear_inherit_confirm = memnew(ConfirmationDialog); + clear_inherit_confirm->set_text(TTR("Clear Inheritance? (No Undo!)")); + clear_inherit_confirm->get_ok()->set_text(TTR("Clear!")); + add_child(clear_inherit_confirm); + vbc->add_constant_override("separation", 4); set_process_input(true); } diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 79e01e7571..5872c5a25d 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -70,7 +70,14 @@ class SceneTreeDock : public VBoxContainer { TOOL_MULTI_EDIT, TOOL_ERASE, TOOL_COPY_NODE_PATH, - TOOL_BUTTON_MAX + TOOL_BUTTON_MAX, + TOOL_SCENE_EDITABLE_CHILDREN, + TOOL_SCENE_USE_PLACEHOLDER, + TOOL_SCENE_CLEAR_INSTANCING, + TOOL_SCENE_OPEN, + TOOL_SCENE_CLEAR_INHERITANCE, + TOOL_SCENE_CLEAR_INHERITANCE_CONFIRM, + TOOL_SCENE_OPEN_INHERITED }; enum { @@ -112,6 +119,7 @@ class SceneTreeDock : public VBoxContainer { TextureRect *filter_icon; PopupMenu *menu; + ConfirmationDialog *clear_inherit_confirm; bool first_enter; @@ -127,6 +135,7 @@ class SceneTreeDock : public VBoxContainer { void _do_reparent(Node *p_new_parent, int p_position_in_parent, Vector<Node *> p_nodes, bool p_keep_global_xform); void _set_owners(Node *p_owner, const Array &p_nodes); + void _node_replace_owner(Node *p_base, Node *p_node, Node *p_root); void _load_request(const String &p_path); void _script_open_request(const Ref<Script> &p_script); diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index d4e5714c0d..d12d8b5528 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -44,110 +44,6 @@ Node *SceneTreeEditor::get_scene_node() { return get_tree()->get_edited_scene_root(); } -void SceneTreeEditor::_subscene_option(int p_idx) { - - Object *obj = ObjectDB::get_instance(instance_node); - if (!obj) - return; - Node *node = obj->cast_to<Node>(); - if (!node) - return; - - switch (p_idx) { - - case SCENE_MENU_EDITABLE_CHILDREN: { - - 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); - if (editable) { - node->set_scene_instance_load_placeholder(false); - instance_menu->set_item_checked(1, false); - } - - _update_tree(); - - } break; - case SCENE_MENU_USE_PLACEHOLDER: { - - bool placeholder = node->get_scene_instance_load_placeholder(); - placeholder = !placeholder; - - //node->set_instance_children_editable(editable); - if (placeholder) { - EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node, false); - } - node->set_scene_instance_load_placeholder(placeholder); - instance_menu->set_item_checked(0, false); - instance_menu->set_item_checked(1, placeholder); - - _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_CLEAR_INSTANCING: { - - Node *root = EditorNode::get_singleton()->get_edited_scene(); - if (!root) - break; - - ERR_FAIL_COND(node->get_filename() == String()); - - undo_redo->create_action("Discard Instancing"); - - undo_redo->add_do_method(node, "set_filename", ""); - undo_redo->add_undo_method(node, "set_filename", node->get_filename()); - - _node_replace_owner(node, node, root); - - undo_redo->add_do_method(this, "update_tree"); - undo_redo->add_undo_method(this, "update_tree"); - - undo_redo->commit_action(); - - } 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; - } -} - -void SceneTreeEditor::_node_replace_owner(Node *p_base, Node *p_node, Node *p_root) { - - if (p_base != p_node) { - - if (p_node->get_owner() == p_base) { - - undo_redo->add_do_method(p_node, "set_owner", p_root); - undo_redo->add_undo_method(p_node, "set_owner", p_base); - } - } - - for (int i = 0; i < p_node->get_child_count(); i++) { - - _node_replace_owner(p_base, p_node->get_child(i), p_root); - } -} - void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_id) { TreeItem *item = p_item->cast_to<TreeItem>(); @@ -159,38 +55,13 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i ERR_FAIL_COND(!n); if (p_id == BUTTON_SUBSCENE) { - //open scene request - Rect2 item_rect = tree->get_item_rect(item, 0); - item_rect.position.y -= tree->get_scroll().y; - item_rect.position += tree->get_global_position(); - if (n == get_scene_node()) { - inheritance_menu->set_position(item_rect.position + 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_position(item_rect.position + 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); - - if (n->get_owner() == get_scene_node()) { - instance_menu->set_item_checked(1, n->get_scene_instance_load_placeholder()); - instance_menu->set_item_disabled(1, false); - } else { - - instance_menu->set_item_checked(1, false); - instance_menu->set_item_disabled(1, true); + if (n && n->get_scene_inherited_state().is_valid()) { + emit_signal("open", n->get_scene_inherited_state()->get_path()); } - - instance_menu->popup(); - instance_node = n->get_instance_ID(); + } else { + emit_signal("open", n->get_filename()); } - //emit_signal("open",n->get_filename()); } else if (p_id == BUTTON_SCRIPT) { RefPtr script = n->get_script(); if (!script.is_null()) @@ -472,7 +343,7 @@ void SceneTreeEditor::_node_visibility_changed(Node *p_node) { void SceneTreeEditor::_update_visibility_color(Node *p_node, TreeItem *p_item) { if (p_node->is_class("CanvasItem") || p_node->is_class("Spatial")) { Color color(1, 1, 1, 1); - bool visible_on_screen = p_node->call("is_visible"); + bool visible_on_screen = p_node->call("is_visible_in_tree"); if (!visible_on_screen) { color = Color(0.6, 0.6, 0.6, 1); } @@ -633,10 +504,7 @@ void SceneTreeEditor::_notification(int p_what) { get_tree()->connect("node_removed", this, "_node_removed"); get_tree()->connect("node_configuration_warning_changed", this, "_warning_changed"); - instance_menu->set_item_icon(5, 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)); EditorSettings::get_singleton()->connect("settings_changed", this, "_editor_settings_changed"); @@ -649,7 +517,6 @@ 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"); get_tree()->disconnect("node_configuration_warning_changed", this, "_warning_changed"); EditorSettings::get_singleton()->disconnect("settings_changed", this, "_editor_settings_changed"); } @@ -1059,7 +926,6 @@ void SceneTreeEditor::_bind_methods() { ClassDB::bind_method("_selection_changed", &SceneTreeEditor::_selection_changed); ClassDB::bind_method("_cell_button_pressed", &SceneTreeEditor::_cell_button_pressed); ClassDB::bind_method("_cell_collapsed", &SceneTreeEditor::_cell_collapsed); - ClassDB::bind_method("_subscene_option", &SceneTreeEditor::_subscene_option); ClassDB::bind_method("_rmb_select", &SceneTreeEditor::_rmb_select); ClassDB::bind_method("_warning_changed", &SceneTreeEditor::_warning_changed); @@ -1145,29 +1011,6 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope updating_tree = false; blocked = 0; - instance_menu = memnew(PopupMenu); - instance_menu->add_check_item(TTR("Editable Children"), SCENE_MENU_EDITABLE_CHILDREN); - instance_menu->add_check_item(TTR("Load As Placeholder"), SCENE_MENU_USE_PLACEHOLDER); - instance_menu->add_separator(); - instance_menu->add_item(TTR("Discard Instancing"), SCENE_MENU_CLEAR_INSTANCING); - instance_menu->add_separator(); - instance_menu->add_item(TTR("Open in Editor"), SCENE_MENU_OPEN); - instance_menu->connect("id_pressed", this, "_subscene_option"); - add_child(instance_menu); - - inheritance_menu = memnew(PopupMenu); - inheritance_menu->add_item(TTR("Clear Inheritance"), SCENE_MENU_CLEAR_INHERITANCE); - inheritance_menu->add_separator(); - inheritance_menu->add_item(TTR("Open in Editor"), SCENE_MENU_OPEN_INHERITED); - inheritance_menu->connect("id_pressed", this, "_subscene_option"); - - add_child(inheritance_menu); - - clear_inherit_confirm = memnew(ConfirmationDialog); - clear_inherit_confirm->set_text(TTR("Clear Inheritance? (No Undo!)")); - clear_inherit_confirm->get_ok()->set_text(TTR("Clear!")); - add_child(clear_inherit_confirm); - update_timer = memnew(Timer); update_timer->connect("timeout", this, "_update_tree"); update_timer->set_one_shot(true); diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h index ec7115afed..c6283af7b5 100644 --- a/editor/scene_tree_editor.h +++ b/editor/scene_tree_editor.h @@ -56,27 +56,14 @@ class SceneTreeEditor : public Control { BUTTON_GROUPS = 7, }; - enum { - SCENE_MENU_EDITABLE_CHILDREN, - SCENE_MENU_USE_PLACEHOLDER, - SCENE_MENU_OPEN, - SCENE_MENU_CLEAR_INHERITANCE, - SCENE_MENU_OPEN_INHERITED, - SCENE_MENU_CLEAR_INHERITANCE_CONFIRM, - SCENE_MENU_CLEAR_INSTANCING, - }; - Tree *tree; Node *selected; - PopupMenu *instance_menu; - PopupMenu *inheritance_menu; ObjectID instance_node; String filter; AcceptDialog *error; AcceptDialog *warning; - ConfirmationDialog *clear_inherit_confirm; int blocked; @@ -119,7 +106,6 @@ class SceneTreeEditor : public Control { void _node_script_changed(Node *p_node); void _node_visibility_changed(Node *p_node); void _update_visibility_color(Node *p_node, TreeItem *p_item); - void _subscene_option(int p_idx); void _node_replace_owner(Node *p_base, Node *p_node, Node *p_root); diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 0f3f5500a8..00fdcb676b 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -271,10 +271,8 @@ void ScriptCreateDialog::_browse_path(bool browse_parent) { file_browse->clear_filters(); List<String> extensions; - // get all possible extensions for script - for (int l = 0; l < language_menu->get_item_count(); l++) { - ScriptServer::get_language(l)->get_recognized_extensions(&extensions); - } + int lang = language_menu->get_selected(); + ScriptServer::get_language(lang)->get_recognized_extensions(&extensions); for (List<String>::Element *E = extensions.front(); E; E = E->next()) { file_browse->add_filter("*." + E->get()); |