diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_export.cpp | 18 | ||||
-rw-r--r-- | editor/editor_export.h | 8 | ||||
-rw-r--r-- | editor/editor_sub_scene.cpp | 95 | ||||
-rw-r--r-- | editor/editor_sub_scene.h | 5 | ||||
-rw-r--r-- | editor/plugins/mesh_instance_editor_plugin.h | 4 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 14 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.h | 1 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 45 | ||||
-rw-r--r-- | editor/plugins/shader_editor_plugin.cpp | 36 | ||||
-rw-r--r-- | editor/project_export.cpp | 4 | ||||
-rw-r--r-- | editor/property_editor.cpp | 1 | ||||
-rw-r--r-- | editor/scene_tree_dock.cpp | 113 | ||||
-rw-r--r-- | editor/scene_tree_editor.cpp | 8 | ||||
-rw-r--r-- | editor/script_create_dialog.cpp | 14 | ||||
-rw-r--r-- | editor/script_create_dialog.h | 1 |
15 files changed, 196 insertions, 171 deletions
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index b330f5d177..3585417d13 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -1288,8 +1288,18 @@ bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset> &p_preset, return valid; } -String EditorExportPlatformPC::get_binary_extension() const { - return extension; +String EditorExportPlatformPC::get_binary_extension(const Ref<EditorExportPreset> &p_preset) const { + for (Map<String, String>::Element *E = extensions.front(); E; E = E->next()) { + if (p_preset->get(E->key())) { + return extensions[E->key()]; + } + } + + if (extensions.has("default")) { + return extensions["default"]; + } + + return ""; } Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { @@ -1337,8 +1347,8 @@ Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_pr return save_pack(p_preset, pck_path); } -void EditorExportPlatformPC::set_extension(const String &p_extension) { - extension = p_extension; +void EditorExportPlatformPC::set_extension(const String &p_extension, const String &p_feature_key) { + extensions[p_feature_key] = p_extension; } void EditorExportPlatformPC::set_name(const String &p_name) { diff --git a/editor/editor_export.h b/editor/editor_export.h index 8b1cf4bcff..02b15aff10 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -240,7 +240,7 @@ public: virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const = 0; - virtual String get_binary_extension() const = 0; + virtual String get_binary_extension(const Ref<EditorExportPreset> &p_preset) const = 0; virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) = 0; virtual void get_platform_features(List<String> *r_features) = 0; @@ -363,7 +363,7 @@ class EditorExportPlatformPC : public EditorExportPlatform { Ref<ImageTexture> logo; String name; String os_name; - String extension; + Map<String, String> extensions; String release_file_32; String release_file_64; @@ -385,10 +385,10 @@ public: virtual Ref<Texture> get_logo() const; virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const; - virtual String get_binary_extension() const; + virtual String get_binary_extension(const Ref<EditorExportPreset> &p_preset) const; virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0); - void set_extension(const String &p_extension); + void set_extension(const String &p_extension, const String &p_feature_key = "default"); void set_name(const String &p_name); void set_os_name(const String &p_name); diff --git a/editor/editor_sub_scene.cpp b/editor/editor_sub_scene.cpp index b81dfd3f46..fad9346b38 100644 --- a/editor/editor_sub_scene.cpp +++ b/editor/editor_sub_scene.cpp @@ -96,14 +96,54 @@ void EditorSubScene::_fill_tree(Node *p_node, TreeItem *p_parent) { } } -void EditorSubScene::ok_pressed() { +void EditorSubScene::_selected_changed() { + selection.clear(); + is_root = false; +} - TreeItem *s = tree->get_selected(); - if (!s) - return; - Node *selnode = s->get_metadata(0); - if (!selnode) +void EditorSubScene::_item_multi_selected(Object *p_object, int p_cell, bool p_selected) { + if (!is_root) { + TreeItem *item = Object::cast_to<TreeItem>(p_object); + ERR_FAIL_COND(!item); + + Node *n = item->get_metadata(0); + + if (!n) + return; + if (p_selected) { + if (n == scene) { + is_root = true; + selection.clear(); + } + selection.push_back(n); + } + } +} + +void EditorSubScene::_remove_selection_child(Node *n) { + if (n->get_child_count() > 0) { + for (int i = 0; i < n->get_child_count(); i++) { + Node *c = n->get_child(i); + List<Node *>::Element *E = selection.find(c); + if (E) { + selection.move_to_back(E); + selection.pop_back(); + } + if (c->get_child_count() > 0) { + _remove_selection_child(c); + } + } + } +} + +void EditorSubScene::ok_pressed() { + if (selection.size() <= 0) { return; + } + for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { + Node *c = E->get(); + _remove_selection_child(c); + } emit_signal("subscene_selected"); hide(); clear(); @@ -127,37 +167,34 @@ void EditorSubScene::_reown(Node *p_node, List<Node *> *p_to_reown) { } void EditorSubScene::move(Node *p_new_parent, Node *p_new_owner) { - if (!scene) { return; } - TreeItem *s = tree->get_selected(); - if (!s) { - return; - } - Node *selnode = s->get_metadata(0); - if (!selnode) { + if (selection.size() <= 0) { return; } - List<Node *> to_reown; - _reown(selnode, &to_reown); - - if (selnode != scene) { - selnode->get_parent()->remove_child(selnode); - } + for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { + Node *selnode = E->get(); + if (!selnode) { + return; + } + List<Node *> to_reown; + _reown(selnode, &to_reown); + if (selnode != scene) { + selnode->get_parent()->remove_child(selnode); + } - p_new_parent->add_child(selnode); - for (List<Node *>::Element *E = to_reown.front(); E; E = E->next()) { - E->get()->set_owner(p_new_owner); + p_new_parent->add_child(selnode); + for (List<Node *>::Element *E = to_reown.front(); E; E = E->next()) { + E->get()->set_owner(p_new_owner); + } } - - if (selnode != scene) { + if (!is_root) { memdelete(scene); } scene = NULL; - //return selnode; } @@ -172,12 +209,15 @@ void EditorSubScene::_bind_methods() { ClassDB::bind_method(D_METHOD("_path_selected"), &EditorSubScene::_path_selected); ClassDB::bind_method(D_METHOD("_path_changed"), &EditorSubScene::_path_changed); ClassDB::bind_method(D_METHOD("_path_browse"), &EditorSubScene::_path_browse); + ClassDB::bind_method(D_METHOD("_item_multi_selected"), &EditorSubScene::_item_multi_selected); + ClassDB::bind_method(D_METHOD("_selected_changed"), &EditorSubScene::_selected_changed); ADD_SIGNAL(MethodInfo("subscene_selected")); } EditorSubScene::EditorSubScene() { scene = NULL; + is_root = false; set_title(TTR("Select Node(s) to Import")); set_hide_on_ok(false); @@ -200,6 +240,11 @@ EditorSubScene::EditorSubScene() { tree = memnew(Tree); tree->set_v_size_flags(SIZE_EXPAND_FILL); vb->add_margin_child(TTR("Import From Node:"), tree, true); + tree->set_select_mode(Tree::SELECT_MULTI); + tree->connect("multi_selected", this, "_item_multi_selected"); + //tree->connect("nothing_selected", this, "_deselect_items"); + tree->connect("cell_selected", this, "_selected_changed"); + tree->connect("item_activated", this, "_ok", make_binds(), CONNECT_DEFERRED); file_dialog = memnew(EditorFileDialog); diff --git a/editor/editor_sub_scene.h b/editor/editor_sub_scene.h index 13ce19bbb2..db9d91018a 100644 --- a/editor/editor_sub_scene.h +++ b/editor/editor_sub_scene.h @@ -38,13 +38,18 @@ class EditorSubScene : public ConfirmationDialog { GDCLASS(EditorSubScene, ConfirmationDialog); + List<Node *> selection; LineEdit *path; Tree *tree; Node *scene; + bool is_root; EditorFileDialog *file_dialog; void _fill_tree(Node *p_node, TreeItem *p_parent); + void _selected_changed(); + void _item_multi_selected(Object *p_object, int p_cell, bool p_selected); + void _remove_selection_child(Node *c); void _reown(Node *p_node, List<Node *> *p_to_reown); void ok_pressed(); diff --git a/editor/plugins/mesh_instance_editor_plugin.h b/editor/plugins/mesh_instance_editor_plugin.h index 68c149f98a..32c779509a 100644 --- a/editor/plugins/mesh_instance_editor_plugin.h +++ b/editor/plugins/mesh_instance_editor_plugin.h @@ -35,9 +35,9 @@ #include "scene/3d/mesh_instance.h" #include "scene/gui/spin_box.h" -class MeshInstanceEditor : public Node { +class MeshInstanceEditor : public Control { - GDCLASS(MeshInstanceEditor, Node); + GDCLASS(MeshInstanceEditor, Control); enum Menu { diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index c02b3458e5..591e6dac56 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1329,12 +1329,12 @@ void ScriptEditor::_members_overview_selected(int p_idx) { if (!se) { return; } - Dictionary state; - state["scroll_position"] = members_overview->get_item_metadata(p_idx); + // Go to the member's line and reset the cursor column. We can't just change scroll_position + // directly, since code might be folded. + se->goto_line(members_overview->get_item_metadata(p_idx)); + Dictionary state = se->get_edit_state(); state["column"] = 0; - state["row"] = members_overview->get_item_metadata(p_idx); se->set_edit_state(state); - se->ensure_focus(); } void ScriptEditor::_help_overview_selected(int p_idx) { @@ -1845,6 +1845,11 @@ void ScriptEditor::apply_scripts() const { } } +void ScriptEditor::open_script_create_dialog(const String &p_base_name, const String &p_base_path) { + _menu_option(FILE_NEW); + script_create_dialog->config(p_base_name, p_base_path); +} + void ScriptEditor::_editor_play() { debugger->start(); @@ -2548,6 +2553,7 @@ void ScriptEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("get_current_script"), &ScriptEditor::_get_current_script); ClassDB::bind_method(D_METHOD("get_open_scripts"), &ScriptEditor::_get_open_scripts); + ClassDB::bind_method(D_METHOD("open_script_create_dialog", "base_name", "base_path"), &ScriptEditor::open_script_create_dialog); ADD_SIGNAL(MethodInfo("editor_script_changed", PropertyInfo(Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script"))); ADD_SIGNAL(MethodInfo("script_close", PropertyInfo(Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script"))); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index ffd42d18ca..9d5c110dec 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -360,6 +360,7 @@ public: void ensure_focus_current(); void apply_scripts() const; + void open_script_create_dialog(const String &p_base_name, const String &p_base_path); void ensure_select_current(); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 95f2739927..0610f55b3f 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -537,10 +537,6 @@ void ScriptTextEditor::set_edit_state(const Variant &p_state) { code_editor->get_text_edit()->cursor_set_line(state["row"]); code_editor->get_text_edit()->set_v_scroll(state["scroll_position"]); code_editor->get_text_edit()->grab_focus(); - - //int scroll_pos; - //int cursor_column; - //int cursor_row; } String ScriptTextEditor::get_name() { @@ -924,26 +920,7 @@ void ScriptTextEditor::_edit_option(int p_op) { if (scr.is_null()) return; - tx->begin_complex_operation(); - if (tx->is_selection_active()) { - tx->indent_selection_left(); - } else { - int begin = tx->cursor_get_line(); - String line_text = tx->get_line(begin); - // begins with tab - if (line_text.begins_with("\t")) { - line_text = line_text.substr(1, line_text.length()); - tx->set_line(begin, line_text); - } - // begins with 4 spaces - else if (line_text.begins_with(" ")) { - line_text = line_text.substr(4, line_text.length()); - tx->set_line(begin, line_text); - } - } - tx->end_complex_operation(); - tx->update(); - //tx->deselect(); + tx->indent_left(); } break; case EDIT_INDENT_RIGHT: { @@ -951,18 +928,7 @@ void ScriptTextEditor::_edit_option(int p_op) { if (scr.is_null()) return; - tx->begin_complex_operation(); - if (tx->is_selection_active()) { - tx->indent_selection_right(); - } else { - int begin = tx->cursor_get_line(); - String line_text = tx->get_line(begin); - line_text = '\t' + line_text; - tx->set_line(begin, line_text); - } - tx->end_complex_operation(); - tx->update(); - //tx->deselect(); + tx->indent_right(); } break; case EDIT_DELETE_LINE: { @@ -1503,14 +1469,15 @@ void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color, bool p context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/select_all"), EDIT_SELECT_ALL); context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo"), EDIT_UNDO); context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/redo"), EDIT_REDO); + context_menu->add_separator(); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_left"), EDIT_INDENT_LEFT); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_right"), EDIT_INDENT_RIGHT); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_comment"), EDIT_TOGGLE_COMMENT); if (p_selection) { context_menu->add_separator(); context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_to_uppercase"), EDIT_TO_UPPERCASE); context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_to_lowercase"), EDIT_TO_LOWERCASE); - context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_left"), EDIT_INDENT_LEFT); - context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_right"), EDIT_INDENT_RIGHT); - context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_comment"), EDIT_TOGGLE_COMMENT); } if (p_can_fold || p_is_folded) context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_fold_line"), EDIT_TOGGLE_FOLD_LINE); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index b390070b4a..3e00776dfd 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -161,7 +161,7 @@ void ShaderTextEditor::_load_theme_settings() { for (const Map<StringName, ShaderLanguage::FunctionInfo>::Element *E = ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())).front(); E; E = E->next()) { - for (const Map<StringName, ShaderLanguage::DataType>::Element *F = E->get().built_ins.front(); F; F = F->next()) { + for (const Map<StringName, ShaderLanguage::BuiltInInfo>::Element *F = E->get().built_ins.front(); F; F = F->next()) { keywords.push_back(F->key()); } } @@ -379,26 +379,7 @@ void ShaderEditor::_menu_option(int p_option) { if (shader.is_null()) return; - tx->begin_complex_operation(); - if (tx->is_selection_active()) { - tx->indent_selection_left(); - } else { - int begin = tx->cursor_get_line(); - String line_text = tx->get_line(begin); - // begins with tab - if (line_text.begins_with("\t")) { - line_text = line_text.substr(1, line_text.length()); - tx->set_line(begin, line_text); - } - // begins with 4 spaces - else if (line_text.begins_with(" ")) { - line_text = line_text.substr(4, line_text.length()); - tx->set_line(begin, line_text); - } - } - tx->end_complex_operation(); - tx->update(); - //tx->deselect(); + tx->indent_left(); } break; case EDIT_INDENT_RIGHT: { @@ -407,18 +388,7 @@ void ShaderEditor::_menu_option(int p_option) { if (shader.is_null()) return; - tx->begin_complex_operation(); - if (tx->is_selection_active()) { - tx->indent_selection_right(); - } else { - int begin = tx->cursor_get_line(); - String line_text = tx->get_line(begin); - line_text = '\t' + line_text; - tx->set_line(begin, line_text); - } - tx->end_complex_operation(); - tx->update(); - //tx->deselect(); + tx->indent_right(); } break; case EDIT_DELETE_LINE: { diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 767dbcc27b..3c31b70564 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -718,7 +718,9 @@ void ProjectExportDialog::_export_project() { export_project->set_access(FileDialog::ACCESS_FILESYSTEM); export_project->clear_filters(); export_project->set_current_file(default_filename); - String extension = platform->get_binary_extension(); + + String extension = platform->get_binary_extension(current); + if (extension != String()) { export_project->add_filter("*." + extension + " ; " + platform->get_name() + " Export"); } diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 3369ad67c6..623b0e15ab 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -551,6 +551,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: text_edit->show(); text_edit->set_text(v); + text_edit->deselect(); int button_margin = get_constant("button_margin", "Dialogs"); int margin = get_constant("margin", "Dialogs"); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 4d86030e7d..4d5d467857 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1373,77 +1373,81 @@ void SceneTreeDock::_create() { } } else if (current_option == TOOL_REPLACE) { - Node *n = scene_tree->get_selected(); - ERR_FAIL_COND(!n); + List<Node *> selection = editor_selection->get_selected_node_list(); + ERR_FAIL_COND(selection.size() <= 0); + for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { + Node *n = E->get(); + ERR_FAIL_COND(!n); - Object *c = create_dialog->instance_selected(); + Object *c = create_dialog->instance_selected(); - ERR_FAIL_COND(!c); - Node *newnode = Object::cast_to<Node>(c); - ERR_FAIL_COND(!newnode); + ERR_FAIL_COND(!c); + Node *newnode = Object::cast_to<Node>(c); + ERR_FAIL_COND(!newnode); - List<PropertyInfo> pinfo; - n->get_property_list(&pinfo); + List<PropertyInfo> pinfo; + n->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) - continue; - if (E->get().name == "__meta__") - continue; - newnode->set(E->get().name, n->get(E->get().name)); - } + for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { + if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) + continue; + if (E->get().name == "__meta__") + continue; + newnode->set(E->get().name, n->get(E->get().name)); + } - editor->push_item(NULL); + editor->push_item(NULL); - //reconnect signals - List<MethodInfo> sl; + //reconnect signals + List<MethodInfo> sl; - n->get_signal_list(&sl); - for (List<MethodInfo>::Element *E = sl.front(); E; E = E->next()) { + n->get_signal_list(&sl); + for (List<MethodInfo>::Element *E = sl.front(); E; E = E->next()) { - List<Object::Connection> cl; - n->get_signal_connection_list(E->get().name, &cl); + List<Object::Connection> cl; + n->get_signal_connection_list(E->get().name, &cl); - for (List<Object::Connection>::Element *F = cl.front(); F; F = F->next()) { + for (List<Object::Connection>::Element *F = cl.front(); F; F = F->next()) { - Object::Connection &c = F->get(); - if (!(c.flags & Object::CONNECT_PERSIST)) - continue; - newnode->connect(c.signal, c.target, c.method, varray(), Object::CONNECT_PERSIST); + Object::Connection &c = F->get(); + if (!(c.flags & Object::CONNECT_PERSIST)) + continue; + newnode->connect(c.signal, c.target, c.method, varray(), Object::CONNECT_PERSIST); + } } - } - String newname = n->get_name(); + String newname = n->get_name(); - List<Node *> to_erase; - for (int i = 0; i < n->get_child_count(); i++) { - if (n->get_child(i)->get_owner() == NULL && n->is_owned_by_parent()) { - to_erase.push_back(n->get_child(i)); + List<Node *> to_erase; + for (int i = 0; i < n->get_child_count(); i++) { + if (n->get_child(i)->get_owner() == NULL && n->is_owned_by_parent()) { + to_erase.push_back(n->get_child(i)); + } } - } - n->replace_by(newnode, true); + n->replace_by(newnode, true); - if (n == edited_scene) { - edited_scene = newnode; - editor->set_edited_scene(newnode); - newnode->set_editable_instances(n->get_editable_instances()); - } + if (n == edited_scene) { + edited_scene = newnode; + editor->set_edited_scene(newnode); + newnode->set_editable_instances(n->get_editable_instances()); + } - //small hack to make collisionshapes and other kind of nodes to work - for (int i = 0; i < newnode->get_child_count(); i++) { - Node *c = newnode->get_child(i); - c->call("set_transform", c->call("get_transform")); - } - editor_data->get_undo_redo().clear_history(); - newnode->set_name(newname); + //small hack to make collisionshapes and other kind of nodes to work + for (int i = 0; i < newnode->get_child_count(); i++) { + Node *c = newnode->get_child(i); + c->call("set_transform", c->call("get_transform")); + } + editor_data->get_undo_redo().clear_history(); + newnode->set_name(newname); - editor->push_item(newnode); + editor->push_item(newnode); - memdelete(n); + memdelete(n); - while (to_erase.front()) { - memdelete(to_erase.front()->get()); - to_erase.pop_front(); + while (to_erase.front()) { + memdelete(to_erase.front()->get()); + to_erase.pop_front(); + } } } } @@ -1737,13 +1741,12 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_icon_shortcut(get_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); menu->add_icon_shortcut(get_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE); menu->add_separator(); - menu->add_icon_shortcut(get_icon("Reload", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE); - menu->add_separator(); menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT); menu->add_icon_shortcut(get_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT); menu->add_separator(); } - + menu->add_icon_shortcut(get_icon("Reload", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE); + menu->add_separator(); menu->add_icon_shortcut(get_icon("MoveUp", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/move_up"), TOOL_MOVE_UP); menu->add_icon_shortcut(get_icon("MoveDown", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/move_down"), TOOL_MOVE_DOWN); menu->add_icon_shortcut(get_icon("Duplicate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/duplicate"), TOOL_DUPLICATE); diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 3e503c45a5..827e8d9ee4 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -774,9 +774,11 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from Node *n = get_node(np); if (n) { - - selected.push_back(n); - icons.push_back(next->get_icon(0)); + // Only allow selection if not part of an instanced scene. + if (!n->get_owner() || n->get_owner() == get_scene_node() || n->get_owner()->get_filename() == String()) { + selected.push_back(n); + icons.push_back(next->get_icon(0)); + } } next = tree->get_next_selected(next); } diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 3cab14b0c4..97f442b0ec 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -331,6 +331,12 @@ void ScriptCreateDialog::_file_selected(const String &p_file) { } else { file_path->set_text(p); _path_changed(p); + + String filename = p.get_file().get_basename(); + int select_start = p.find_last(filename); + file_path->select(select_start, select_start + filename.length()); + file_path->set_cursor_position(select_start + filename.length()); + file_path->grab_focus(); } } @@ -425,6 +431,10 @@ void ScriptCreateDialog::_path_changed(const String &p_path) { _update_dialog(); } +void ScriptCreateDialog::_path_entered(const String &p_path) { + ok_pressed(); +} + void ScriptCreateDialog::_msg_script_valid(bool valid, const String &p_msg) { error_label->set_text(TTR(p_msg)); @@ -459,7 +469,7 @@ void ScriptCreateDialog::_update_dialog() { script_ok = false; } } - if (has_named_classes && (!is_class_name_valid)) { + if (has_named_classes && (is_new_script_created && !is_class_name_valid)) { _msg_script_valid(false, TTR("Invalid class name")); script_ok = false; } @@ -550,6 +560,7 @@ void ScriptCreateDialog::_bind_methods() { ClassDB::bind_method("_browse_path", &ScriptCreateDialog::_browse_path); ClassDB::bind_method("_file_selected", &ScriptCreateDialog::_file_selected); ClassDB::bind_method("_path_changed", &ScriptCreateDialog::_path_changed); + ClassDB::bind_method("_path_entered", &ScriptCreateDialog::_path_entered); ClassDB::bind_method("_template_changed", &ScriptCreateDialog::_template_changed); ADD_SIGNAL(MethodInfo("script_created", PropertyInfo(Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script"))); } @@ -715,6 +726,7 @@ ScriptCreateDialog::ScriptCreateDialog() { hb = memnew(HBoxContainer); file_path = memnew(LineEdit); file_path->connect("text_changed", this, "_path_changed"); + file_path->connect("text_entered", this, "_path_entered"); file_path->set_h_size_flags(SIZE_EXPAND_FILL); hb->add_child(file_path); path_button = memnew(Button); diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h index c7bbc82d47..1cff9871d8 100644 --- a/editor/script_create_dialog.h +++ b/editor/script_create_dialog.h @@ -73,6 +73,7 @@ class ScriptCreateDialog : public ConfirmationDialog { Vector<String> template_list; void _path_changed(const String &p_path = String()); + void _path_entered(const String &p_path = String()); void _lang_changed(int l = 0); void _built_in_pressed(); bool _validate(const String &p_string); |