diff options
Diffstat (limited to 'editor')
36 files changed, 358 insertions, 147 deletions
diff --git a/editor/animation_editor.cpp b/editor/animation_editor.cpp index 91aa189c8f..cd8233e460 100644 --- a/editor/animation_editor.cpp +++ b/editor/animation_editor.cpp @@ -1359,7 +1359,7 @@ void AnimationKeyEditor::_track_editor_draw() { Color ncol = color; if (n && editor_selection->is_selected(n)) ncol = track_select_color; - te->draw_string(font, Point2(ofs + Point2(left_check_ofs + sep + type_icon[0]->get_width() + sep, y + font->get_ascent() + (sep / 2))).floor(), np, ncol, name_limit - (type_icon[0]->get_width() + sep) - 5); + te->draw_string(font, Point2(ofs + Point2(left_check_ofs + sep + type_icon[0]->get_width() + sep, y + font->get_ascent() + (sep / 2))).floor(), np, ncol, name_limit - (left_check_ofs + sep) - (type_icon[0]->get_width() + sep) - 5); // Draw separator line below track area if (!obj) diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index 58eaab78ed..3a418e5f33 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -611,6 +611,14 @@ void DocData::generate(bool p_basic_types) { ArgumentDoc ad; argument_doc_from_arginfo(ad, mi.arguments[i]); + + int darg_idx = i - (mi.arguments.size() - mi.default_arguments.size()); + + if (darg_idx >= 0) { + Variant default_arg = E->get().default_arguments[darg_idx]; + ad.default_value = default_arg.get_construct_string(); + } + md.arguments.push_back(ad); } diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index f356c16827..22b33cc98f 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -458,6 +458,23 @@ void EditorFileDialog::_item_selected(int p_item) { get_ok()->set_disabled(_is_open_should_be_disabled()); } +void EditorFileDialog::_multi_selected(int p_item, bool p_selected) { + + int current = p_item; + if (current < 0 || current >= item_list->get_item_count()) + return; + + Dictionary d = item_list->get_item_metadata(current); + + if (!d["dir"] && p_selected) { + + file->set_text(d["name"]); + _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); + } + + get_ok()->set_disabled(_is_open_should_be_disabled()); +} + void EditorFileDialog::_items_clear_selection() { item_list->unselect_all(); @@ -1290,6 +1307,7 @@ void EditorFileDialog::_bind_methods() { ClassDB::bind_method(D_METHOD("_unhandled_input"), &EditorFileDialog::_unhandled_input); ClassDB::bind_method(D_METHOD("_item_selected"), &EditorFileDialog::_item_selected); + ClassDB::bind_method(D_METHOD("_multi_selected"), &EditorFileDialog::_multi_selected); ClassDB::bind_method(D_METHOD("_items_clear_selection"), &EditorFileDialog::_items_clear_selection); ClassDB::bind_method(D_METHOD("_item_list_item_rmb_selected"), &EditorFileDialog::_item_list_item_rmb_selected); ClassDB::bind_method(D_METHOD("_item_list_rmb_clicked"), &EditorFileDialog::_item_list_rmb_clicked); @@ -1598,6 +1616,7 @@ EditorFileDialog::EditorFileDialog() { connect("confirmed", this, "_action_pressed"); item_list->connect("item_selected", this, "_item_selected", varray(), CONNECT_DEFERRED); + item_list->connect("multi_selected", this, "_multi_selected", varray(), CONNECT_DEFERRED); item_list->connect("item_activated", this, "_item_db_selected", varray()); item_list->connect("nothing_selected", this, "_items_clear_selection"); dir->connect("text_entered", this, "_dir_entered"); diff --git a/editor/editor_file_dialog.h b/editor/editor_file_dialog.h index 05f66eadbf..b1f8f1108c 100644 --- a/editor/editor_file_dialog.h +++ b/editor/editor_file_dialog.h @@ -159,6 +159,7 @@ private: void _recent_selected(int p_idx); void _item_selected(int p_item); + void _multi_selected(int p_item, bool p_selected); void _items_clear_selection(); void _item_dc_selected(int p_item); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 2f0c41c6e1..bec6d581f8 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -339,7 +339,7 @@ void EditorNode::_notification(int p_what) { if (ScriptEditor::get_singleton()->get_debugger()->is_visible()) bottom_panel->add_style_override("panel", gui_base->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")); - //_update_icons + // update_icons for (int i = 0; i < singleton->main_editor_buttons.size(); i++) { Ref<Texture> icon = singleton->main_editor_buttons[i]->get_icon(); @@ -709,7 +709,7 @@ void EditorNode::_dialog_display_load_error(String p_file, Error p_error) { case ERR_CANT_OPEN: { - accept->set_text(vformat(TTR("Can't open '%s'."), p_file.get_file())); + accept->set_text(vformat(TTR("Can't open '%s'. The file could have been moved or deleted."), p_file.get_file())); } break; case ERR_PARSE_ERROR: { @@ -1110,7 +1110,7 @@ void EditorNode::_dialog_action(String p_file) { if (res.is_null()) { current_option = -1; - accept->get_ok()->set_text("ok :("); + accept->get_ok()->set_text("Ugh"); accept->set_text(TTR("Failed to load resource.")); return; }; @@ -1145,6 +1145,7 @@ void EditorNode::_dialog_action(String p_file) { _save_default_environment(); _save_scene_with_preview(p_file, scene_idx); + _add_to_recent_scenes(p_file); if (scene_idx != -1) _discard_changes(); @@ -1919,7 +1920,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { if (!scene) { current_option = -1; - //confirmation->get_cancel()->hide(); accept->get_ok()->set_text(TTR("I see..")); accept->set_text(TTR("This operation can't be done without a tree root.")); accept->popup_centered_minsize(); @@ -1937,7 +1937,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); } - //file->set_current_path(current_path); if (scene->get_filename() != "") { file->set_current_path(scene->get_filename()); if (extensions.size()) { @@ -1987,7 +1986,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { if (!editor_data.get_edited_scene_root()) { current_option = -1; - //confirmation->get_cancel()->hide(); accept->get_ok()->set_text(TTR("I see..")); accept->set_text(TTR("This operation can't be done without a scene.")); accept->popup_centered_minsize(); @@ -2036,8 +2034,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case FILE_IMPORT_SUBSCENE: { - //import_subscene->popup_centered_ratio(); - if (!editor_data.get_edited_scene_root()) { current_option = -1; @@ -2056,7 +2052,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { if (unsaved_cache && !p_confirmed) { confirmation->get_ok()->set_text(TTR("Open")); - //confirmation->get_cancel()->show(); confirmation->set_text(TTR("Current scene not saved. Open anyway?")); confirmation->popup_centered_minsize(); break; @@ -2843,7 +2838,7 @@ void EditorNode::_remove_scene(int index) { //Scene to remove is current scene _remove_edited_scene(); } else { - // Scene to remove is not active scene + //Scene to remove is not active scene editor_data.remove_scene(index); } } @@ -3240,48 +3235,47 @@ void EditorNode::_show_messages() { void EditorNode::_add_to_recent_scenes(const String &p_scene) { - String base = "_" + ProjectSettings::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::"); - Vector<String> rc = EDITOR_DEF(base + "/_recent_scenes", Array()); - String name = p_scene; - name = name.replace("res://", ""); - if (rc.find(name) != -1) - rc.erase(name); - rc.insert(0, name); + Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scenes", Array()); + if (rc.find(p_scene) != -1) + rc.erase(p_scene); + rc.push_front(p_scene); if (rc.size() > 10) rc.resize(10); - EditorSettings::get_singleton()->set(base + "/_recent_scenes", rc); - EditorSettings::get_singleton()->save(); + EditorSettings::get_singleton()->set_project_metadata("recent_files", "scenes", rc); _update_recent_scenes(); } void EditorNode::_open_recent_scene(int p_idx) { - String base = "_" + ProjectSettings::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::"); - if (p_idx == recent_scenes->get_item_count() - 1) { - EditorSettings::get_singleton()->erase(base + "/_recent_scenes"); + EditorSettings::get_singleton()->set_project_metadata("recent_files", "scenes", Array()); call_deferred("_update_recent_scenes"); } else { - Vector<String> rc = EDITOR_DEF(base + "/_recent_scenes", Array()); + Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scenes", Array()); ERR_FAIL_INDEX(p_idx, rc.size()); - String path = "res://" + rc[p_idx]; - load_scene(path); + if (load_scene(rc[p_idx]) != OK) { + + rc.remove(p_idx); + EditorSettings::get_singleton()->set_project_metadata("recent_files", "scenes", rc); + _update_recent_scenes(); + } } } void EditorNode::_update_recent_scenes() { - String base = "_" + ProjectSettings::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::"); - Vector<String> rc = EDITOR_DEF(base + "/_recent_scenes", Array()); + Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scenes", Array()); recent_scenes->clear(); + String path; for (int i = 0; i < rc.size(); i++) { - recent_scenes->add_item(rc[i], i); + path = rc[i]; + recent_scenes->add_item(path.replace("res://", ""), i); } recent_scenes->add_separator(); @@ -4815,6 +4809,10 @@ EditorNode::EditorNode() { Ref<EditorSceneImporterGLTF> import_gltf; import_gltf.instance(); import_scene->add_importer(import_gltf); + + Ref<EditorSceneImporterESCN> import_escn; + import_escn.instance(); + import_scene->add_importer(import_escn); } Ref<ResourceImporterBitMap> import_bitmap; @@ -5114,7 +5112,6 @@ EditorNode::EditorNode() { gui_base->add_child(dependency_fixer); settings_config_dialog = memnew(EditorSettingsDialog); - // settings_config_dialog->add_style_override("panel", gui_base->get_stylebox("EditorSettingsDialog", "EditorStyles")); gui_base->add_child(settings_config_dialog); project_settings = memnew(ProjectSettingsEditor(&editor_data)); @@ -5188,7 +5185,6 @@ EditorNode::EditorNode() { p->add_item(TTR("Project Settings"), RUN_SETTINGS); p->add_separator(); p->connect("id_pressed", this, "_menu_option"); - //p->add_item(TTR("Run Script"), FILE_RUN_SCRIPT, KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_R); p->add_item(TTR("Export"), FILE_EXPORT_PROJECT); PopupMenu *tool_menu = memnew(PopupMenu); @@ -5279,7 +5275,6 @@ EditorNode::EditorNode() { menu_hb->add_child(play_cc); play_button_panel = memnew(PanelContainer); - // play_button_panel->add_style_override("panel", gui_base->get_stylebox("PlayButtonPanel", "EditorStyles")); play_cc->add_child(play_button_panel); HBoxContainer *play_hb = memnew(HBoxContainer); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 9dd8a7232f..733680645f 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -235,6 +235,14 @@ Control *EditorInterface::get_base_control() { return EditorNode::get_singleton()->get_gui_base(); } +void EditorInterface::set_plugin_enabled(const String &p_plugin, bool p_enabled) { + EditorNode::get_singleton()->set_addon_plugin_enabled(p_plugin, p_enabled); +} + +bool EditorInterface::is_plugin_enabled(const String &p_plugin) const { + return EditorNode::get_singleton()->is_addon_plugin_enabled(p_plugin); +} + Error EditorInterface::save_scene() { if (!get_edited_scene_root()) return ERR_CANT_CREATE; @@ -271,6 +279,9 @@ void EditorInterface::_bind_methods() { ClassDB::bind_method(D_METHOD("select_file", "p_file"), &EditorInterface::select_file); ClassDB::bind_method(D_METHOD("get_selected_path"), &EditorInterface::get_selected_path); + ClassDB::bind_method(D_METHOD("set_plugin_enabled", "plugin", "enabled"), &EditorInterface::set_plugin_enabled); + ClassDB::bind_method(D_METHOD("is_plugin_enabled", "plugin"), &EditorInterface::is_plugin_enabled); + ClassDB::bind_method(D_METHOD("save_scene"), &EditorInterface::save_scene); ClassDB::bind_method(D_METHOD("save_scene_as", "path", "with_preview"), &EditorInterface::save_scene_as, DEFVAL(true)); } @@ -362,6 +373,53 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location, C } } +void EditorPlugin::remove_control_from_container(CustomControlContainer p_location, Control *p_control) { + + switch (p_location) { + + case CONTAINER_TOOLBAR: { + + EditorNode::get_menu_hb()->remove_child(p_control); + } break; + + case CONTAINER_SPATIAL_EDITOR_MENU: { + + SpatialEditor::get_singleton()->remove_control_from_menu_panel(p_control); + + } break; + case CONTAINER_SPATIAL_EDITOR_SIDE: { + + SpatialEditor::get_singleton()->get_palette_split()->remove_child(p_control); + + } break; + case CONTAINER_SPATIAL_EDITOR_BOTTOM: { + + SpatialEditor::get_singleton()->get_shader_split()->remove_child(p_control); + + } break; + case CONTAINER_CANVAS_EDITOR_MENU: { + + CanvasItemEditor::get_singleton()->remove_control_from_menu_panel(p_control); + + } break; + case CONTAINER_CANVAS_EDITOR_SIDE: { + + CanvasItemEditor::get_singleton()->get_palette_split()->remove_child(p_control); + + } break; + case CONTAINER_CANVAS_EDITOR_BOTTOM: { + + CanvasItemEditor::get_singleton()->get_bottom_split()->remove_child(p_control); + + } break; + case CONTAINER_PROPERTY_EDITOR_BOTTOM: { + + EditorNode::get_singleton()->get_property_editor_vb()->remove_child(p_control); + + } break; + } +} + void EditorPlugin::add_tool_menu_item(const String &p_name, Object *p_handler, const String &p_callback, const Variant &p_ud) { //EditorNode::get_singleton()->add_tool_menu_item(p_name, p_handler, p_callback, p_ud); @@ -640,6 +698,7 @@ void EditorPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("add_control_to_dock", "slot", "control"), &EditorPlugin::add_control_to_dock); ClassDB::bind_method(D_METHOD("remove_control_from_docks", "control"), &EditorPlugin::remove_control_from_docks); ClassDB::bind_method(D_METHOD("remove_control_from_bottom_panel", "control"), &EditorPlugin::remove_control_from_bottom_panel); + ClassDB::bind_method(D_METHOD("remove_control_from_container", "container", "control"), &EditorPlugin::remove_control_from_container); //ClassDB::bind_method(D_METHOD("add_tool_menu_item", "name", "handler", "callback", "ud"),&EditorPlugin::add_tool_menu_item,DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("add_tool_submenu_item", "name", "submenu"), &EditorPlugin::add_tool_submenu_item); //ClassDB::bind_method(D_METHOD("remove_tool_menu_item", "name"),&EditorPlugin::remove_tool_menu_item); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 145dccc2d5..e3e405479c 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -90,6 +90,9 @@ public: Control *get_base_control(); + void set_plugin_enabled(const String &p_plugin, bool p_enabled); + bool is_plugin_enabled(const String &p_plugin) const; + Error save_scene(); void save_scene_as(const String &p_scene, bool p_with_preview = true); @@ -145,6 +148,7 @@ public: //TODO: send a resource for editing to the editor node? void add_control_to_container(CustomControlContainer p_location, Control *p_control); + void remove_control_from_container(CustomControlContainer p_location, Control *p_control); ToolButton *add_control_to_bottom_panel(Control *p_control, const String &p_title); void add_control_to_dock(DockSlot p_slot, Control *p_control); void remove_control_from_docks(Control *p_control); diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp index 8803a03f2d..ea1e0fe99e 100644 --- a/editor/editor_plugin_settings.cpp +++ b/editor/editor_plugin_settings.cpp @@ -83,8 +83,6 @@ void EditorPluginSettings::update_plugins() { plugins.sort(); - Vector<String> active_plugins = ProjectSettings::get_singleton()->get("editor_plugins/enabled"); - for (int i = 0; i < plugins.size(); i++) { Ref<ConfigFile> cf; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 433f501fc8..c6676a1f0f 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -382,8 +382,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("text_editor/completion/callhint_tooltip_offset", Vector2()); _initial_set("text_editor/files/restore_scripts_on_load", true); _initial_set("text_editor/completion/complete_file_paths", true); - _initial_set("text_editor/files/maximum_recent_files", 20); - hints["text_editor/files/maximum_recent_files"] = PropertyInfo(Variant::INT, "text_editor/files/maximum_recent_files", PROPERTY_HINT_RANGE, "1, 200, 1"); _initial_set("docks/scene_tree/start_create_dialog_fully_expanded", false); _initial_set("docks/scene_tree/draw_relationship_lines", false); diff --git a/editor/editor_settings.h b/editor/editor_settings.h index 914316ee61..8bcb599a67 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -145,7 +145,7 @@ public: bool has_setting(const String &p_setting) const; void erase(const String &p_setting); void raise_order(const String &p_setting); - void set_initial_value(const StringName &p_setting, const Variant &p_value, bool update_current = false); + void set_initial_value(const StringName &p_setting, const Variant &p_value, bool p_update_current = false); void set_manually(const StringName &p_setting, const Variant &p_value, bool p_emit_signal = false) { if (p_emit_signal) _set(p_setting, p_value); diff --git a/editor/editor_sub_scene.cpp b/editor/editor_sub_scene.cpp index 7527b198b8..056ee59860 100644 --- a/editor/editor_sub_scene.cpp +++ b/editor/editor_sub_scene.cpp @@ -121,10 +121,10 @@ void EditorSubScene::_item_multi_selected(Object *p_object, int p_cell, bool p_s } } -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); +void EditorSubScene::_remove_selection_child(Node *p_node) { + if (p_node->get_child_count() > 0) { + for (int i = 0; i < p_node->get_child_count(); i++) { + Node *c = p_node->get_child(i); List<Node *>::Element *E = selection.find(c); if (E) { selection.move_to_back(E); diff --git a/editor/editor_sub_scene.h b/editor/editor_sub_scene.h index cf4d6fd5b9..202ba03cea 100644 --- a/editor/editor_sub_scene.h +++ b/editor/editor_sub_scene.h @@ -50,7 +50,7 @@ class EditorSubScene : public ConfirmationDialog { 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 _remove_selection_child(Node *p_node); void _reown(Node *p_node, List<Node *> *p_to_reown); void ok_pressed(); diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index 6cbca3f733..c4ecf3c098 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -30,6 +30,8 @@ #include "export_template_manager.h" +#include "core/os/input.h" +#include "core/os/keyboard.h" #include "editor_node.h" #include "editor_scale.h" #include "io/json.h" @@ -422,6 +424,11 @@ void ExportTemplateManager::_http_download_templates_completed(int p_status, int void ExportTemplateManager::_begin_template_download(const String &p_url) { + if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { + OS::get_singleton()->shell_open(p_url); + return; + } + for (int i = 0; i < template_list->get_child_count(); i++) { BaseButton *b = Object::cast_to<BaseButton>(template_list->get_child(0)); if (b) { @@ -576,7 +583,7 @@ ExportTemplateManager::ExportTemplateManager() { template_downloader->add_child(vbc); ScrollContainer *sc = memnew(ScrollContainer); sc->set_custom_minimum_size(Size2(400, 200) * EDSCALE); - vbc->add_margin_child(TTR("Select mirror from list: "), sc); + vbc->add_margin_child(TTR("Select mirror from list: (Shift+Click: Open in Browser)"), sc); template_list = memnew(VBoxContainer); sc->add_child(template_list); sc->set_enable_v_scroll(true); diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp index 56fb7633e7..a218070933 100644 --- a/editor/fileserver/editor_file_server.cpp +++ b/editor/fileserver/editor_file_server.cpp @@ -55,7 +55,7 @@ void EditorFileServer::_subthread_start(void *s) { ClientData *cd = (ClientData *)s; - cd->connection->set_nodelay(true); + cd->connection->set_no_delay(true); uint8_t buf4[8]; Error err = cd->connection->get_data(buf4, 4); if (err != OK) { diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index cc9c9a11d7..9804d1d9a3 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -77,7 +77,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory return true; } -void FileSystemDock::_update_tree(bool keep_collapse_state) { +void FileSystemDock::_update_tree(bool keep_collapse_state, bool p_uncollapse_root) { Vector<String> uncollapsed_paths; if (keep_collapse_state) { @@ -129,6 +129,10 @@ void FileSystemDock::_update_tree(bool keep_collapse_state) { ti->set_metadata(0, fave); } + if (p_uncollapse_root) { + uncollapsed_paths.push_back("res://"); + } + _create_tree(root, EditorFileSystem::get_singleton()->get_filesystem(), uncollapsed_paths); tree->ensure_cursor_is_visible(); updating_tree = false; @@ -154,6 +158,7 @@ void FileSystemDock::_notification(int p_what) { } else { tree->set_v_size_flags(SIZE_FILL); + button_tree->hide(); if (!tree->is_visible()) { tree->show(); button_favorite->show(); @@ -163,7 +168,6 @@ void FileSystemDock::_notification(int p_what) { if (!file_list_vb->is_visible()) { file_list_vb->show(); - button_tree->hide(); _update_files(true); } } @@ -204,7 +208,7 @@ void FileSystemDock::_notification(int p_what) { if (EditorFileSystem::get_singleton()->is_scanning()) { _set_scanning_mode(); } else { - _update_tree(false); + _update_tree(false, true); } } break; @@ -488,7 +492,7 @@ void FileSystemDock::_update_files(bool p_keep_selection) { Ref<Texture> folderIcon = (use_thumbnails) ? folder_thumbnail : get_icon("folder", "FileDialog"); if (path != "res://") { - files->add_item("..", folderIcon, false); + files->add_item("..", folderIcon, true); String bd = path.get_base_dir(); if (bd != "res://" && !bd.ends_with("/")) diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index af80557465..2e86b83efc 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -157,7 +157,7 @@ private: bool import_dock_needs_update; bool _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths); - void _update_tree(bool keep_collapse_state); + void _update_tree(bool keep_collapse_state, bool p_uncollapse_root = false); void _update_files(bool p_keep_selection); void _update_file_display_toggle_button(); diff --git a/editor/import/editor_import_plugin.cpp b/editor/import/editor_import_plugin.cpp index 07c77a9df0..3f5dc7c9f4 100644 --- a/editor/import/editor_import_plugin.cpp +++ b/editor/import/editor_import_plugin.cpp @@ -72,6 +72,20 @@ String EditorImportPlugin::get_resource_type() const { return get_script_instance()->call("get_resource_type"); } +float EditorImportPlugin::get_priority() const { + if (!(get_script_instance() && get_script_instance()->has_method("get_priority"))) { + return EditorImportPlugin::get_priority(); + } + return get_script_instance()->call("get_priority"); +} + +int EditorImportPlugin::get_import_order() const { + if (!(get_script_instance() && get_script_instance()->has_method("get_import_order"))) { + return EditorImportPlugin::get_import_order(); + } + return get_script_instance()->call("get_import_order"); +} + void EditorImportPlugin::get_import_options(List<ResourceImporter::ImportOption> *r_options, int p_preset) const { ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("get_import_options"))); @@ -148,6 +162,8 @@ void EditorImportPlugin::_bind_methods() { ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::ARRAY, "get_import_options", PropertyInfo(Variant::INT, "preset"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_save_extension")); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_resource_type")); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::REAL, "get_priority")); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "get_import_order")); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "get_option_visibility", PropertyInfo(Variant::STRING, "option"), PropertyInfo(Variant::DICTIONARY, "options"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "import", PropertyInfo(Variant::STRING, "source_file"), PropertyInfo(Variant::STRING, "save_path"), PropertyInfo(Variant::DICTIONARY, "options"), PropertyInfo(Variant::ARRAY, "r_platform_variants"), PropertyInfo(Variant::ARRAY, "r_gen_files"))); } diff --git a/editor/import/editor_import_plugin.h b/editor/import/editor_import_plugin.h index 61a0a944f5..92d83158ef 100644 --- a/editor/import/editor_import_plugin.h +++ b/editor/import/editor_import_plugin.h @@ -47,6 +47,8 @@ public: virtual int get_preset_count() const; virtual String get_save_extension() const; virtual String get_resource_type() const; + virtual float get_priority() const; + virtual int get_import_order() const; virtual void get_import_options(List<ImportOption> *r_options, int p_preset) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files); diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 060953d36a..44948b8209 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -46,6 +46,7 @@ #include "scene/resources/box_shape.h" #include "scene/resources/plane_shape.h" #include "scene/resources/ray_shape.h" +#include "scene/resources/scene_format_text.h" #include "scene/resources/sphere_shape.h" uint32_t EditorSceneImporter::get_import_flags() const { @@ -1395,3 +1396,25 @@ ResourceImporterScene *ResourceImporterScene::singleton = NULL; ResourceImporterScene::ResourceImporterScene() { singleton = this; } +/////////////////////////////////////// + +uint32_t EditorSceneImporterESCN::get_import_flags() const { + return IMPORT_SCENE; +} +void EditorSceneImporterESCN::get_extensions(List<String> *r_extensions) const { + r_extensions->push_back("escn"); +} +Node *EditorSceneImporterESCN::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { + + Error error; + Ref<PackedScene> ps = ResourceFormatLoaderText::singleton->load(p_path, p_path, &error); + ERR_FAIL_COND_V(!ps.is_valid(), NULL); + + Node *scene = ps->instance(); + ERR_FAIL_COND_V(!scene, NULL); + + return scene; +} +Ref<Animation> EditorSceneImporterESCN::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) { + ERR_FAIL_V(Ref<Animation>()); +} diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index d5f9d53e91..9c3ec7a29b 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -155,4 +155,14 @@ public: ResourceImporterScene(); }; +class EditorSceneImporterESCN : public EditorSceneImporter { + GDCLASS(EditorSceneImporterESCN, EditorSceneImporter); + +public: + virtual uint32_t get_import_flags() const; + virtual void get_extensions(List<String> *r_extensions) const; + virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = NULL); + virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps); +}; + #endif // RESOURCEIMPORTERSCENE_H diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 915132c75c..b8bf2b97f6 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -316,7 +316,6 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() { void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data) { String error_text; - print_line("COMPLETED: " + itos(p_status) + " code: " + itos(p_code) + " data size: " + itos(p_data.size())); switch (p_status) { @@ -371,7 +370,6 @@ void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int progress->set_max(download->get_body_size()); progress->set_value(download->get_downloaded_bytes()); - print_line("max: " + itos(download->get_body_size()) + " bytes: " + itos(download->get_downloaded_bytes())); install->set_disabled(false); progress->set_value(download->get_downloaded_bytes()); @@ -747,8 +745,6 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons if (p_status == HTTPRequest::RESULT_SUCCESS) { - print_line("GOT IMAGE YAY!"); - if (p_code != HTTPClient::RESPONSE_NOT_MODIFIED) { for (int i = 0; i < headers.size(); i++) { if (headers[i].findn("ETag:") == 0) { // Save etag @@ -811,7 +807,6 @@ void EditorAssetLibrary::_update_image_queue() { } } - print_line("REQUEST ICON FOR: " + itos(E->get().asset_id)); Error err = E->get().request->request(E->get().image_url, headers); if (err != OK) { to_delete.push_back(E->key()); @@ -855,7 +850,6 @@ void EditorAssetLibrary::_request_image(ObjectID p_for, String p_image_url, Imag void EditorAssetLibrary::_repository_changed(int p_repository_id) { host = repository->get_item_metadata(p_repository_id); - print_line(".." + host); if (templates_only) { _api_request("configure", REQUESTING_CONFIG, "?type=project"); } else { @@ -1066,8 +1060,6 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const return; } - print_line("response: " + itos(p_status) + " code: " + itos(p_code)); - Dictionary d; { Variant js; @@ -1077,8 +1069,6 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const d = js; } - print_line(Variant(d).get_construct_string()); - RequestType requested = requesting; requesting = REQUESTING_NONE; diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 7d6025cb03..4a05d401cb 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -4002,6 +4002,11 @@ void CanvasItemEditor::add_control_to_menu_panel(Control *p_control) { hb->add_child(p_control); } +void CanvasItemEditor::remove_control_from_menu_panel(Control *p_control) { + + hb->remove_child(p_control); +} + HSplitContainer *CanvasItemEditor::get_palette_split() { return palette_split; @@ -4225,9 +4230,9 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { p = view_menu->get_popup(); p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_grid", TTR("Show Grid"), KEY_G), SHOW_GRID); - p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_helpers", TTR("Show helpers"), KEY_H), SHOW_HELPERS); - p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_rulers", TTR("Show rulers"), KEY_R), SHOW_RULERS); - p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_guides", TTR("Show guides"), KEY_Y), SHOW_GUIDES); + p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_helpers", TTR("Show Helpers"), KEY_H), SHOW_HELPERS); + p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_rulers", TTR("Show Rulers"), KEY_R), SHOW_RULERS); + p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_guides", TTR("Show Guides"), KEY_Y), SHOW_GUIDES); p->add_separator(); p->add_shortcut(ED_SHORTCUT("canvas_item_editor/center_selection", TTR("Center Selection"), KEY_F), VIEW_CENTER_TO_SELECTION); p->add_shortcut(ED_SHORTCUT("canvas_item_editor/frame_selection", TTR("Frame Selection"), KEY_MASK_SHIFT | KEY_F), VIEW_FRAME_TO_SELECTION); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index ace87f9fe2..ee9be86cce 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -509,6 +509,7 @@ public: void set_state(const Dictionary &p_state); void add_control_to_menu_panel(Control *p_control); + void remove_control_from_menu_panel(Control *p_control); HSplitContainer *get_palette_split(); VSplitContainer *get_bottom_split(); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index d18422c0c0..bd8c502a80 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -148,8 +148,6 @@ public: } }; -#define SORT_SCRIPT_LIST - void ScriptEditorQuickOpen::popup(const Vector<String> &p_functions, bool p_dontclear) { popup_centered_ratio(0.6); @@ -429,36 +427,32 @@ void ScriptEditor::_add_recent_script(String p_path) { return; } - // remove if already stored - int already_recent = previous_scripts.find(p_path); - if (already_recent >= 0) { - previous_scripts.remove(already_recent); + Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scripts", Array()); + if (rc.find(p_path) != -1) { + rc.erase(p_path); + } + rc.push_front(p_path); + if (rc.size() > 10) { + rc.resize(10); } - // add to list - previous_scripts.insert(0, p_path); - + EditorSettings::get_singleton()->set_project_metadata("recent_files", "scripts", rc); _update_recent_scripts(); } void ScriptEditor::_update_recent_scripts() { - // make sure we don't exceed max size - const int max_history = EDITOR_DEF("text_editor/files/maximum_recent_files", 20); - if (previous_scripts.size() > max_history) { - previous_scripts.resize(max_history); - } - + Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scripts", Array()); recent_scripts->clear(); recent_scripts->add_shortcut(ED_SHORTCUT("script_editor/open_recent", TTR("Open Recent"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_T)); recent_scripts->add_separator(); - const int max_shown = 8; - for (int i = 0; i < previous_scripts.size() && i <= max_shown; i++) { - String path = previous_scripts.get(i); - // just show script name and last dir - recent_scripts->add_item(path.get_slice("/", path.get_slice_count("/") - 2) + "/" + path.get_file()); + String path; + for (int i = 0; i < rc.size(); i++) { + + path = rc[i]; + recent_scripts->add_item(path.replace("res://", "")); } recent_scripts->add_separator(); @@ -471,7 +465,7 @@ void ScriptEditor::_open_recent_script(int p_idx) { // clear button if (p_idx == recent_scripts->get_item_count() - 1) { - previous_scripts.clear(); + EditorSettings::get_singleton()->set_project_metadata("recent_files", "scripts", Array()); call_deferred("_update_recent_scripts"); return; } @@ -481,22 +475,34 @@ void ScriptEditor::_open_recent_script(int p_idx) { p_idx -= 2; } - if (p_idx < previous_scripts.size() && p_idx >= 0) { + Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scripts", Array()); + ERR_FAIL_INDEX(p_idx, rc.size()); - String path = previous_scripts.get(p_idx); - // if its not on disk its a help file or deleted - if (FileAccess::exists(path)) { - Ref<Script> script = ResourceLoader::load(path); - if (script.is_valid()) { - edit(script, true); - } - // if it's a path then its most likely a delted file not help - } else if (!path.is_resource_file()) { - _help_class_open(path); + String path = rc[p_idx]; + // if its not on disk its a help file or deleted + if (FileAccess::exists(path)) { + Ref<Script> script = ResourceLoader::load(path); + if (script.is_valid()) { + edit(script, true); + return; } - previous_scripts.remove(p_idx); - _update_recent_scripts(); + + // if it's a path then its most likely a deleted file not help + } else if (!path.is_resource_file()) { + _help_class_open(path); + return; } + + rc.remove(p_idx); + EditorSettings::get_singleton()->set_project_metadata("recent_files", "scripts", rc); + _update_recent_scripts(); + _show_error_dialog(path); +} + +void ScriptEditor::_show_error_dialog(String p_path) { + + error_dialog->set_text(vformat(TTR("Can't open '%s'. The file could have been moved or deleted."), p_path)); + error_dialog->popup_centered_minsize(); } void ScriptEditor::_close_tab(int p_idx, bool p_save) { @@ -508,14 +514,10 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) { Node *tselected = tab_container->get_child(selected); ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected)); if (current) { - _add_recent_script(current->get_edited_script()->get_path()); if (p_save) { apply_scripts(); } notify_script_close(current->get_edited_script()); - } else { - EditorHelp *help = Object::cast_to<EditorHelp>(tab_container->get_child(selected)); - _add_recent_script(help->get_class()); } // roll back to previous tab @@ -1328,11 +1330,12 @@ void ScriptEditor::_members_overview_selected(int p_idx) { if (!se) { return; } - // Go to the member's line and reset the cursor column. We can't just change scroll_position - // directly, since code might be folded. + // Go to the member's line and reset the cursor column. We can't change scroll_position + // directly until we have gone to the line first, 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["scroll_position"] = members_overview->get_item_metadata(p_idx); se->set_edit_state(state); } @@ -1690,28 +1693,42 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool String path = EditorSettings::get_singleton()->get("text_editor/external/exec_path"); String flags = EditorSettings::get_singleton()->get("text_editor/external/exec_flags"); - Dictionary keys; - keys["project"] = ProjectSettings::get_singleton()->get_resource_path(); - keys["file"] = ProjectSettings::get_singleton()->globalize_path(p_script->get_path()); - keys["line"] = p_line >= 0 ? p_line : 0; - keys["col"] = p_col; - - flags = flags.format(keys).strip_edges().replace("\\\\", "\\"); - List<String> args; if (flags.size()) { - int from = 0, to = 0; + String project_path = ProjectSettings::get_singleton()->get_resource_path(); + String script_path = ProjectSettings::get_singleton()->globalize_path(p_script->get_path()); + + flags = flags.replacen("{line}", itos(p_line > 0 ? p_line : 0)); + flags = flags.replacen("{col}", itos(p_col)); + flags = flags.strip_edges().replace("\\\\", "\\"); + + int from = 0; + int num_chars = 0; bool inside_quotes = false; + for (int i = 0; i < flags.size(); i++) { + if (flags[i] == '"' && (!i || flags[i - 1] != '\\')) { + + if (!inside_quotes) { + from++; + } inside_quotes = !inside_quotes; + } else if (flags[i] == '\0' || (!inside_quotes && flags[i] == ' ')) { - args.push_back(flags.substr(from, to)); + + String arg = flags.substr(from, num_chars); + + // do path replacement here, else there will be issues with spaces and quotes + arg = arg.replacen("{project}", project_path); + arg = arg.replacen("{file}", script_path); + args.push_back(arg); + from = i + 1; - to = 0; + num_chars = 0; } else { - to++; + num_chars++; } } } @@ -1787,6 +1804,7 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool se->goto_line(p_line - 1); notify_script_changed(p_script); + _add_recent_script(p_script->get_path()); return true; } @@ -2304,6 +2322,7 @@ void ScriptEditor::_help_class_open(const String &p_class) { _go_to_tab(tab_container->get_tab_count() - 1); eh->go_to_class(p_class, 0); eh->connect("go_to_help", this, "_help_class_goto"); + _add_recent_script(p_class); _update_script_names(); _save_layout(); } @@ -2332,6 +2351,7 @@ void ScriptEditor::_help_class_goto(const String &p_desc) { _go_to_tab(tab_container->get_tab_count() - 1); eh->go_to_help(p_desc); eh->connect("go_to_help", this, "_help_class_goto"); + _add_recent_script(eh->get_class()); _update_script_names(); _save_layout(); } @@ -2586,11 +2606,13 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { members_overview = memnew(ItemList); list_split->add_child(members_overview); + members_overview->set_allow_reselect(true); members_overview->set_custom_minimum_size(Size2(0, 90)); //need to give a bit of limit to avoid it from disappearing members_overview->set_v_size_flags(SIZE_EXPAND_FILL); help_overview = memnew(ItemList); list_split->add_child(help_overview); + help_overview->set_allow_reselect(true); help_overview->set_custom_minimum_size(Size2(0, 90)); //need to give a bit of limit to avoid it from disappearing help_overview->set_v_size_flags(SIZE_EXPAND_FILL); @@ -2738,6 +2760,10 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { add_child(file_dialog); file_dialog->connect("file_selected", this, "_file_dialog_action"); + error_dialog = memnew(AcceptDialog); + add_child(error_dialog); + error_dialog->get_ok()->set_text(TTR("I see..")); + debugger = memnew(ScriptEditorDebugger(editor)); debugger->connect("goto_script_line", this, "_goto_script_line"); debugger->connect("show_debugger", this, "_show_debugger"); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index e60e4cf8c0..e98a4c97a6 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -198,6 +198,7 @@ class ScriptEditor : public PanelContainer { VSplitContainer *list_split; TabContainer *tab_container; EditorFileDialog *file_dialog; + AcceptDialog *error_dialog; ConfirmationDialog *erase_tab_confirm; ScriptCreateDialog *script_create_dialog; ScriptEditorDebugger *debugger; @@ -227,8 +228,6 @@ class ScriptEditor : public PanelContainer { Vector<ScriptHistory> history; int history_pos; - Vector<String> previous_scripts; - EditorHelpIndex *help_index; void _tab_changed(int p_which); @@ -250,6 +249,8 @@ class ScriptEditor : public PanelContainer { void _update_recent_scripts(); void _open_recent_script(int p_idx); + void _show_error_dialog(String p_path); + void _close_tab(int p_idx, bool p_save = true); void _close_current_tab(); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index a3728a1d46..87e92f0807 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -519,6 +519,7 @@ void ScriptTextEditor::tag_saved_version() { void ScriptTextEditor::goto_line(int p_line, bool p_with_error) { TextEdit *tx = code_editor->get_text_edit(); + tx->deselect(); tx->unfold_line(p_line); tx->call_deferred("cursor_set_line", p_line); } @@ -1283,12 +1284,9 @@ Variant ScriptTextEditor::get_drag_data_fw(const Point2 &p_point, Control *p_fro bool ScriptTextEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { Dictionary d = p_data; - if (d.has("type") && - ( - - String(d["type"]) == "resource" || - String(d["type"]) == "files" || - String(d["type"]) == "nodes")) { + if (d.has("type") && (String(d["type"]) == "resource" || + String(d["type"]) == "files" || + String(d["type"]) == "nodes")) { return true; } @@ -1329,6 +1327,10 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data Dictionary d = p_data; + TextEdit *te = code_editor->get_text_edit(); + int row, col; + te->_get_mouse_pos(p_point, row, col); + if (d.has("type") && String(d["type"]) == "resource") { Ref<Resource> res = d["resource"]; @@ -1341,7 +1343,9 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data return; } - code_editor->get_text_edit()->insert_text_at_cursor(res->get_path()); + te->cursor_set_line(row); + te->cursor_set_column(col); + te->insert_text_at_cursor(res->get_path()); } if (d.has("type") && String(d["type"]) == "files") { @@ -1356,7 +1360,9 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data text_to_drop += "\"" + String(files[i]).c_escape() + "\""; } - code_editor->get_text_edit()->insert_text_at_cursor(text_to_drop); + te->cursor_set_line(row); + te->cursor_set_column(col); + te->insert_text_at_cursor(text_to_drop); } if (d.has("type") && String(d["type"]) == "nodes") { @@ -1385,7 +1391,9 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data text_to_drop += "\"" + path.c_escape() + "\""; } - code_editor->get_text_edit()->insert_text_at_cursor(text_to_drop); + te->cursor_set_line(row); + te->cursor_set_column(col); + te->insert_text_at_cursor(text_to_drop); } } diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 5e8eb06556..63762651d7 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -318,6 +318,9 @@ void SpatialEditorViewport::_select(Spatial *p_node, bool p_append, bool p_singl editor_selection->clear(); editor_selection->add_node(p_node); + if (Engine::get_singleton()->is_editor_hint()) + editor->call("edit_node", p_node); + } else { if (editor_selection->is_selected(p_node) && p_single) { @@ -3827,9 +3830,6 @@ Object *SpatialEditor::_get_editor_data(Object *p_what) { si->sbox_instance = VisualServer::get_singleton()->instance_create2(selection_box->get_rid(), sp->get_world()->get_scenario()); VS::get_singleton()->instance_geometry_set_cast_shadows_setting(si->sbox_instance, VS::SHADOW_CASTING_SETTING_OFF); - if (Engine::get_singleton()->is_editor_hint()) - editor->call("edit_node", sp); - return si; } @@ -4778,6 +4778,11 @@ void SpatialEditor::add_control_to_menu_panel(Control *p_control) { hbc_menu->add_child(p_control); } +void SpatialEditor::remove_control_from_menu_panel(Control *p_control) { + + hbc_menu->remove_child(p_control); +} + void SpatialEditor::set_can_preview(Camera *p_preview) { for (int i = 0; i < 4; i++) { diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index e12f7affb7..55866cac99 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -605,6 +605,7 @@ public: UndoRedo *get_undo_redo() { return undo_redo; } void add_control_to_menu_panel(Control *p_control); + void remove_control_from_menu_panel(Control *p_control); VSplitContainer *get_shader_split(); HSplitContainer *get_palette_split(); diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index 36a578037e..e891850870 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -75,6 +75,9 @@ void TextureEditor::_notification(int p_what) { // In the case of CurveTextures we know they are 1 in height, so fill the preview to see the gradient ofs_y = 0; tex_height = size.height; + } else if (Object::cast_to<GradientTexture>(*texture)) { + ofs_y = size.height / 4.0; + tex_height = size.height / 2.0; } draw_texture_rect(texture, Rect2(ofs_x, ofs_y, tex_width, tex_height)); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 704ec40e4c..9625bc19c0 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -750,7 +750,16 @@ void ProjectSettingsEditor::_item_add() { String catname = category->get_text().strip_edges(); String propname = property->get_text().strip_edges(); - String name = catname != "" ? catname + "/" + propname : propname; + + if (propname.empty()) { + return; + } + + if (catname.empty()) { + catname = "global"; + } + + String name = catname + "/" + propname; undo_redo->create_action(TTR("Add Global Property")); @@ -1586,7 +1595,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); props_base->add_child(hbc); - search_button = memnew(ToolButton); + search_button = memnew(Button); search_button->set_toggle_mode(true); search_button->set_pressed(false); search_button->set_text(TTR("Search")); diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h index d6c2c0f5a8..452cf5b060 100644 --- a/editor/project_settings_editor.h +++ b/editor/project_settings_editor.h @@ -67,7 +67,7 @@ class ProjectSettingsEditor : public AcceptDialog { SectionedPropertyEditor *globals_editor; HBoxContainer *search_bar; - ToolButton *search_button; + Button *search_button; LineEdit *search_box; ToolButton *clear_button; diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 41ee5ab286..8506c75a68 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -67,6 +67,9 @@ void SceneTreeDock::_unhandled_key_input(Ref<InputEvent> p_event) { if (get_viewport()->get_modal_stack_top()) return; //ignore because of modal window + if (get_focus_owner() && get_focus_owner()->is_text_field()) + return; + if (!p_event->is_pressed() || p_event->is_echo()) return; diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index d0527a13ea..86ab84909e 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -193,6 +193,12 @@ public: } }; +void ScriptEditorDebugger::debug_copy() { + String msg = reason->get_text(); + if (msg == "") return; + OS::get_singleton()->set_clipboard(msg); +} + void ScriptEditorDebugger::debug_next() { ERR_FAIL_COND(!breaked); @@ -338,6 +344,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da step->set_disabled(!can_continue); next->set_disabled(!can_continue); _set_reason_text(error, MESSAGE_ERROR); + copy->set_disabled(false); breaked = true; dobreak->set_disabled(true); docontinue->set_disabled(false); @@ -354,6 +361,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da } else if (p_msg == "debug_exit") { breaked = false; + copy->set_disabled(true); step->set_disabled(true); next->set_disabled(true); reason->set_text(""); @@ -940,6 +948,8 @@ void ScriptEditorDebugger::_notification(int p_what) { inspector->edit(variables); + copy->set_icon(get_icon("Duplicate", "EditorIcons")); + step->set_icon(get_icon("DebugStep", "EditorIcons")); next->set_icon(get_icon("DebugNext", "EditorIcons")); back->set_icon(get_icon("Back", "EditorIcons")); @@ -1741,6 +1751,9 @@ void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) { void ScriptEditorDebugger::_bind_methods() { ClassDB::bind_method(D_METHOD("_stack_dump_frame_selected"), &ScriptEditorDebugger::_stack_dump_frame_selected); + + ClassDB::bind_method(D_METHOD("debug_copy"), &ScriptEditorDebugger::debug_copy); + ClassDB::bind_method(D_METHOD("debug_next"), &ScriptEditorDebugger::debug_next); ClassDB::bind_method(D_METHOD("debug_step"), &ScriptEditorDebugger::debug_step); ClassDB::bind_method(D_METHOD("debug_break"), &ScriptEditorDebugger::debug_break); @@ -1816,6 +1829,13 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { hbc->add_child(memnew(VSeparator)); + copy = memnew(ToolButton); + hbc->add_child(copy); + copy->set_tooltip(TTR("Copy Error")); + copy->connect("pressed", this, "debug_copy"); + + hbc->add_child(memnew(VSeparator)); + step = memnew(ToolButton); hbc->add_child(step); step->set_tooltip(TTR("Step Into")); diff --git a/editor/script_editor_debugger.h b/editor/script_editor_debugger.h index e86add940a..669d8737fe 100644 --- a/editor/script_editor_debugger.h +++ b/editor/script_editor_debugger.h @@ -104,6 +104,7 @@ class ScriptEditorDebugger : public Control { Label *reason; + Button *copy; Button *step; Button *next; Button *back; @@ -197,6 +198,8 @@ public: void unpause(); void stop(); + void debug_copy(); + void debug_next(); void debug_step(); void debug_break(); diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 72c0f050d2..8c90d86b9e 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -308,15 +308,6 @@ void EditorSpatialGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size m->add_surface_from_arrays(cubem.surface_get_primitive_type(0), cubem.surface_get_arrays(0)); m->surface_set_material(0, p_material); add_mesh(m); - - Instance ins; - ins.mesh = m; - if (valid) { - ins.create_instance(spatial_node); - VS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); - } - - instances.push_back(ins); } void EditorSpatialGizmo::set_spatial_node(Spatial *p_node) { @@ -1130,7 +1121,7 @@ void CameraSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) { Transform gt = camera->get_global_transform(); float a = _find_closest_angle_to_half_pi_arc(s[0], s[1], 1.0, gt); - camera->set("fov", a); + camera->set("fov", a * 2.0); } else { Vector3 ra, rb; @@ -1187,7 +1178,8 @@ void CameraSpatialGizmo::redraw() { case Camera::PROJECTION_PERSPECTIVE: { - float fov = camera->get_fov(); + // The real FOV is halved for accurate representation + float fov = camera->get_fov() / 2.0; Vector3 side = Vector3(Math::sin(Math::deg2rad(fov)), 0, -Math::cos(Math::deg2rad(fov))); Vector3 nside = side; diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h index cb483ed653..eedab7fdef 100644 --- a/editor/spatial_editor_gizmos.h +++ b/editor/spatial_editor_gizmos.h @@ -105,7 +105,7 @@ protected: void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh, const AABB &p_bounds = AABB()); void add_unscaled_billboard(const Ref<Material> &p_material, float p_scale = 1); void add_handles(const Vector<Vector3> &p_handles, bool p_billboard = false, bool p_secondary = false); - void add_solid_box(Ref<Material> &p_material, Vector3 size); + void add_solid_box(Ref<Material> &p_material, Vector3 p_size); void set_spatial_node(Spatial *p_node); const Spatial *get_spatial_node() const { return spatial_node; } @@ -376,13 +376,13 @@ public: class JointGizmosDrawer { public: - static Basis look_body(const Transform &joint_transform, const Transform &body_transform); + static Basis look_body(const Transform &p_joint_transform, const Transform &p_body_transform); static Basis look_body_toward(Vector3::Axis p_axis, const Transform &joint_transform, const Transform &body_transform); - static Basis look_body_toward_x(const Transform &joint_transform, const Transform &body_transform); - static Basis look_body_toward_y(const Transform &joint_transform, const Transform &body_transform); + static Basis look_body_toward_x(const Transform &p_joint_transform, const Transform &p_body_transform); + static Basis look_body_toward_y(const Transform &p_joint_transform, const Transform &p_body_transform); /// Special function just used for physics joints, it that returns a basis constrained toward Joint Z axis /// with axis X and Y that are looking toward the body and oriented toward up - static Basis look_body_toward_z(const Transform &joint_transform, const Transform &body_transform); + static Basis look_body_toward_z(const Transform &p_joint_transform, const Transform &p_body_transform); // Draw circle around p_axis static void draw_circle(Vector3::Axis p_axis, real_t p_radius, const Transform &p_offset, const Basis &p_base, real_t p_limit_lower, real_t p_limit_upper, Vector<Vector3> &r_points, bool p_inverse = false); |