diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_export.cpp | 58 | ||||
-rw-r--r-- | editor/editor_file_dialog.cpp | 4 | ||||
-rw-r--r-- | editor/editor_node.cpp | 13 | ||||
-rw-r--r-- | editor/editor_properties.cpp | 2 | ||||
-rw-r--r-- | editor/editor_spin_slider.cpp | 8 | ||||
-rw-r--r-- | editor/editor_themes.cpp | 2 | ||||
-rw-r--r-- | editor/node_3d_editor_gizmos.cpp | 8 | ||||
-rw-r--r-- | editor/plugin_config_dialog.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/abstract_polygon_2d_editor.cpp | 4 | ||||
-rw-r--r-- | editor/plugins/asset_library_editor_plugin.cpp | 31 | ||||
-rw-r--r-- | editor/plugins/asset_library_editor_plugin.h | 1 | ||||
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.cpp | 5 | ||||
-rw-r--r-- | editor/plugins/sprite_frames_editor_plugin.cpp | 20 | ||||
-rw-r--r-- | editor/scene_tree_dock.cpp | 10 | ||||
-rw-r--r-- | editor/scene_tree_editor.cpp | 3 |
15 files changed, 108 insertions, 63 deletions
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 4f60258d95..7f5f51cf70 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -301,6 +301,8 @@ void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags) } Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key) { + ERR_FAIL_COND_V_MSG(p_total < 1, ERR_PARAMETER_RANGE_ERROR, "Must select at least one file to export."); + PackData *pd = (PackData *)p_userdata; SavedData sd; @@ -368,6 +370,8 @@ Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_pa } Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key) { + ERR_FAIL_COND_V_MSG(p_total < 1, ERR_PARAMETER_RANGE_ERROR, "Must select at least one file to export."); + String path = p_path.replace_first("res://", ""); ZipData *zd = (ZipData *)p_userdata; @@ -824,17 +828,25 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & } } + Error err = OK; Vector<Ref<EditorExportPlugin>> export_plugins = EditorExport::get_singleton()->get_export_plugins(); + for (int i = 0; i < export_plugins.size(); i++) { export_plugins.write[i]->set_export_preset(p_preset); if (p_so_func) { for (int j = 0; j < export_plugins[i]->shared_objects.size(); j++) { - p_so_func(p_udata, export_plugins[i]->shared_objects[j]); + err = p_so_func(p_udata, export_plugins[i]->shared_objects[j]); + if (err != OK) { + return err; + } } } for (int j = 0; j < export_plugins[i]->extra_files.size(); j++) { - p_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, 0, paths.size(), enc_in_filters, enc_ex_filters, key); + err = p_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, 0, paths.size(), enc_in_filters, enc_ex_filters, key); + if (err != OK) { + return err; + } } export_plugins.write[i]->_clear(); @@ -856,7 +868,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & //file is imported, replace by what it imports Ref<ConfigFile> config; config.instance(); - Error err = config->load(path + ".import"); + err = config->load(path + ".import"); if (err != OK) { ERR_PRINT("Could not parse: '" + path + "', not exported."); continue; @@ -920,12 +932,18 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & } if (p_so_func) { for (int j = 0; j < export_plugins[i]->shared_objects.size(); j++) { - p_so_func(p_udata, export_plugins[i]->shared_objects[j]); + err = p_so_func(p_udata, export_plugins[i]->shared_objects[j]); + if (err != OK) { + return err; + } } } for (int j = 0; j < export_plugins[i]->extra_files.size(); j++) { - p_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, idx, total, enc_in_filters, enc_ex_filters, key); + err = p_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, idx, total, enc_in_filters, enc_ex_filters, key); + if (err != OK) { + return err; + } if (export_plugins[i]->extra_files[j].remap) { do_export = false; //if remap, do not path_remaps.push_back(path); @@ -945,7 +963,10 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & //just store it as it comes if (do_export) { Vector<uint8_t> array = FileAccess::get_file_as_array(path); - p_func(p_udata, path, array, idx, total, enc_in_filters, enc_ex_filters, key); + err = p_func(p_udata, path, array, idx, total, enc_in_filters, enc_ex_filters, key); + if (err != OK) { + return err; + } } } @@ -981,7 +1002,10 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & new_file.write[j] = utf8[j]; } - p_func(p_udata, from + ".remap", new_file, idx, total, enc_in_filters, enc_ex_filters, key); + err = p_func(p_udata, from + ".remap", new_file, idx, total, enc_in_filters, enc_ex_filters, key); + if (err != OK) { + return err; + } } } else { //old remap mode, will still work, but it's unused because it's not multiple pck export friendly @@ -994,11 +1018,17 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & String splash = ProjectSettings::get_singleton()->get("application/boot_splash/image"); if (icon != String() && FileAccess::exists(icon)) { Vector<uint8_t> array = FileAccess::get_file_as_array(icon); - p_func(p_udata, icon, array, idx, total, enc_in_filters, enc_ex_filters, key); + err = p_func(p_udata, icon, array, idx, total, enc_in_filters, enc_ex_filters, key); + if (err != OK) { + return err; + } } if (splash != String() && FileAccess::exists(splash) && icon != splash) { Vector<uint8_t> array = FileAccess::get_file_as_array(splash); - p_func(p_udata, splash, array, idx, total, enc_in_filters, enc_ex_filters, key); + err = p_func(p_udata, splash, array, idx, total, enc_in_filters, enc_ex_filters, key); + if (err != OK) { + return err; + } } // Store text server data if exists. @@ -1006,7 +1036,10 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & String ts_data = "res://" + TS->get_support_data_filename(); if (FileAccess::exists(ts_data)) { Vector<uint8_t> array = FileAccess::get_file_as_array(ts_data); - p_func(p_udata, ts_data, array, idx, total, enc_in_filters, enc_ex_filters, key); + err = p_func(p_udata, ts_data, array, idx, total, enc_in_filters, enc_ex_filters, key); + if (err != OK) { + return err; + } } } @@ -1016,9 +1049,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & Vector<uint8_t> data = FileAccess::get_file_as_array(engine_cfb); DirAccess::remove_file_or_error(engine_cfb); - p_func(p_udata, "res://" + config_file, data, idx, total, enc_in_filters, enc_ex_filters, key); - - return OK; + return p_func(p_udata, "res://" + config_file, data, idx, total, enc_in_filters, enc_ex_filters, key); } Error EditorExportPlatform::_add_shared_object(void *p_userdata, const SharedObject &p_so) { @@ -1052,6 +1083,7 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, c if (err != OK) { DirAccess::remove_file_or_error(tmppath); + ERR_PRINT("Failed to export project files"); return err; } diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 6d694358bf..f78da9569f 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -1076,9 +1076,9 @@ EditorFileDialog::Access EditorFileDialog::get_access() const { } void EditorFileDialog::_make_dir_confirm() { - Error err = dir_access->make_dir(makedirname->get_text()); + Error err = dir_access->make_dir(makedirname->get_text().strip_edges()); if (err == OK) { - dir_access->change_dir(makedirname->get_text()); + dir_access->change_dir(makedirname->get_text().strip_edges()); invalidate(); update_filters(); update_dir(); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index f0e53e7ef5..4c23ada5e9 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2387,11 +2387,14 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { _scene_tab_changed(tab_closing); if (unsaved_cache || p_option == FILE_CLOSE_ALL_AND_QUIT || p_option == FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER) { - String scene_filename = editor_data.get_edited_scene_root(tab_closing)->get_filename(); - save_confirmation->get_ok_button()->set_text(TTR("Save & Close")); - save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), scene_filename != "" ? scene_filename : "unsaved scene")); - save_confirmation->popup_centered(); - break; + Node *scene_root = editor_data.get_edited_scene_root(tab_closing); + if (scene_root) { + String scene_filename = scene_root->get_filename(); + save_confirmation->get_ok_button()->set_text(TTR("Save & Close")); + save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), scene_filename != "" ? scene_filename : "unsaved scene")); + save_confirmation->popup_centered(); + break; + } } } else if (p_option == FILE_CLOSE) { tab_closing = editor_data.get_edited_scene(); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index dbe4aa55fa..2d7235038a 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2915,7 +2915,7 @@ void EditorPropertyResource::update_property() { sub_inspector->set_use_doc_hints(true); sub_inspector->set_sub_inspector(true); - sub_inspector->set_enable_capitalize_paths(true); + sub_inspector->set_enable_capitalize_paths(bool(EDITOR_GET("interface/inspector/capitalize_properties"))); sub_inspector->connect("property_keyed", callable_mp(this, &EditorPropertyResource::_sub_inspector_property_keyed)); sub_inspector->connect("resource_selected", callable_mp(this, &EditorPropertyResource::_sub_inspector_resource_selected)); diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index 618d953c56..bbabc08ea4 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -175,7 +175,9 @@ void EditorSpinSlider::_grabber_gui_input(const Ref<InputEvent> &p_event) { return; } - float grabbing_ofs = (grabber->get_transform().xform(mm->get_position()).x - grabbing_from) / float(grabber_range); + float scale_x = get_global_transform_with_canvas().get_scale().x; + ERR_FAIL_COND(Math::is_zero_approx(scale_x)); + float grabbing_ofs = (grabber->get_transform().xform(mm->get_position()).x - grabbing_from) / float(grabber_range) / scale_x; set_as_ratio(grabbing_ratio + grabbing_ofs); update(); } @@ -300,8 +302,10 @@ void EditorSpinSlider::_notification(int p_what) { grabber->set_texture(grabber_tex); } + Vector2 scale = get_global_transform_with_canvas().get_scale(); + grabber->set_scale(scale); grabber->set_size(Size2(0, 0)); - grabber->set_position(get_global_position() + grabber_rect.position + grabber_rect.size * 0.5 - grabber->get_size() * 0.5); + grabber->set_position(get_global_position() + (grabber_rect.position + grabber_rect.size * 0.5 - grabber->get_size() * 0.5) * scale); if (mousewheel_over_grabber) { Input::get_singleton()->warp_mouse_position(grabber->get_position() + grabber_rect.size); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index fe748b81c3..030d36ff78 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -852,7 +852,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { Ref<StyleBoxFlat> style_tree_cursor = style_default->duplicate(); style_tree_cursor->set_draw_center(false); - style_tree_cursor->set_border_width_all(border_width); + style_tree_cursor->set_border_width_all(MAX(1, border_width)); style_tree_cursor->set_border_color(contrast_color_1); Ref<StyleBoxFlat> style_tree_title = style_default->duplicate(); diff --git a/editor/node_3d_editor_gizmos.cpp b/editor/node_3d_editor_gizmos.cpp index 16eefb1ad3..64cf9a7bb7 100644 --- a/editor/node_3d_editor_gizmos.cpp +++ b/editor/node_3d_editor_gizmos.cpp @@ -2073,7 +2073,13 @@ void SoftBody3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Ref<TriangleMesh> tm = soft_body->get_mesh()->generate_triangle_mesh(); Vector<Vector3> points; - soft_body->get_mesh()->generate_debug_mesh_indices(points); + for (int i = 0; i < soft_body->get_mesh()->get_surface_count(); i++) { + Array arrays = soft_body->get_mesh()->surface_get_arrays(i); + ERR_CONTINUE(arrays.is_empty()); + + const Vector<Vector3> &vertices = arrays[Mesh::ARRAY_VERTEX]; + points.append_array(vertices); + } Ref<Material> material = get_material("shape_material", p_gizmo); diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index 2a0e7d0732..f496811e0a 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -86,7 +86,7 @@ void PluginConfigDialog::_on_confirmed() { // Hard-coded GDScript template to keep usability until we use script templates. Ref<Script> gdscript = memnew(GDScript); gdscript->set_source_code( - "tool\n" + "@tool\n" "extends EditorPlugin\n" "\n" "\n" diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index 876b67fa77..c90f87de56 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -585,11 +585,11 @@ void AbstractPolygon2DEditor::edit(Node *p_polygon) { edited_point = PosVertex(); hover_point = Vertex(); selected_point = Vertex(); - - canvas_item_editor->update_viewport(); } else { _set_node(nullptr); } + + canvas_item_editor->update_viewport(); } void AbstractPolygon2DEditor::_bind_methods() { diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 030ce4655d..b7484aa748 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -584,6 +584,24 @@ void EditorAssetLibrary::_notification(int p_what) { filter->set_right_icon(get_theme_icon("Search", "EditorIcons")); filter->set_clear_button_enabled(true); } break; + + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { + _update_repository_options(); + } break; + } +} + +void EditorAssetLibrary::_update_repository_options() { + Dictionary default_urls; + default_urls["godotengine.org"] = "https://godotengine.org/asset-library/api"; + default_urls["localhost"] = "http://127.0.0.1/asset-library/api"; + Dictionary available_urls = _EDITOR_DEF("asset_library/available_urls", default_urls, true); + repository->clear(); + Array keys = available_urls.keys(); + for (int i = 0; i < available_urls.size(); i++) { + String key = keys[i]; + repository->add_item(key); + repository->set_item_metadata(i, available_urls[key]); } } @@ -1373,18 +1391,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { search_hb2->add_child(memnew(Label(TTR("Site:") + " "))); repository = memnew(OptionButton); - { - Dictionary default_urls; - default_urls["godotengine.org"] = "https://godotengine.org/asset-library/api"; - default_urls["localhost"] = "http://127.0.0.1/asset-library/api"; - Dictionary available_urls = _EDITOR_DEF("asset_library/available_urls", default_urls, true); - Array keys = available_urls.keys(); - for (int i = 0; i < available_urls.size(); i++) { - String key = keys[i]; - repository->add_item(key); - repository->set_item_metadata(i, available_urls[key]); - } - } + _update_repository_options(); repository->connect("item_selected", callable_mp(this, &EditorAssetLibrary::_repository_changed)); diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h index 0509145673..11eae9e041 100644 --- a/editor/plugins/asset_library_editor_plugin.h +++ b/editor/plugins/asset_library_editor_plugin.h @@ -176,6 +176,7 @@ class EditorAssetLibrary : public PanelContainer { void _asset_open(); void _asset_file_selected(const String &p_file); + void _update_repository_options(); PanelContainer *library_scroll_bg; ScrollContainer *library_scroll; diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 9643881f96..1d08a7821d 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -1841,9 +1841,8 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } } else if (m->get_button_mask() & BUTTON_MASK_MIDDLE) { + const int mod = _get_key_modifier(m); if (nav_scheme == NAVIGATION_GODOT) { - const int mod = _get_key_modifier(m); - if (mod == _get_key_modifier_setting("editors/3d/navigation/pan_modifier")) { nav_mode = NAVIGATION_PAN; } else if (mod == _get_key_modifier_setting("editors/3d/navigation/zoom_modifier")) { @@ -1854,7 +1853,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } } else if (nav_scheme == NAVIGATION_MAYA) { - if (m->get_alt()) { + if (mod == _get_key_modifier_setting("editors/3d/navigation/pan_modifier")) { nav_mode = NAVIGATION_PAN; } } diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 0547f99079..a6949c873e 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -219,7 +219,8 @@ void SpriteFramesEditor::_sheet_zoom_out() { } void SpriteFramesEditor::_sheet_zoom_reset() { - sheet_zoom = 1.f; + // Default the zoom to match the editor scale, but don't dezoom on editor scales below 100% to prevent pixel art from looking bad. + sheet_zoom = MAX(1.0, EDSCALE); Size2 texture_size = split_sheet_preview->get_texture()->get_size(); split_sheet_preview->set_custom_minimum_size(texture_size * sheet_zoom); } @@ -732,7 +733,7 @@ void SpriteFramesEditor::_zoom_out() { } void SpriteFramesEditor::_zoom_reset() { - thumbnail_zoom = 1.0f; + thumbnail_zoom = MAX(1.0, EDSCALE); tree->set_fixed_column_width(thumbnail_default_size * 3 / 2); tree->set_fixed_icon_size(Size2(thumbnail_default_size, thumbnail_default_size)); } @@ -1229,13 +1230,14 @@ SpriteFramesEditor::SpriteFramesEditor() { // Config scale. scale_ratio = 1.2f; - thumbnail_default_size = 96; - thumbnail_zoom = 1.0f; - max_thumbnail_zoom = 8.0f; - min_thumbnail_zoom = 0.1f; - sheet_zoom = 1.0f; - max_sheet_zoom = 16.0f; - min_sheet_zoom = 0.01f; + thumbnail_default_size = 96 * MAX(1.0, EDSCALE); + thumbnail_zoom = MAX(1.0, EDSCALE); + max_thumbnail_zoom = 8.0f * MAX(1.0, EDSCALE); + min_thumbnail_zoom = 0.1f * MAX(1.0, EDSCALE); + // Default the zoom to match the editor scale, but don't dezoom on editor scales below 100% to prevent pixel art from looking bad. + sheet_zoom = MAX(1.0, EDSCALE); + max_sheet_zoom = 16.0f * MAX(1.0, EDSCALE); + min_sheet_zoom = 0.01f * MAX(1.0, EDSCALE); _zoom_reset(); } diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 16a0576af4..2cdab83d90 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -685,7 +685,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_do_method(editor_selection, "clear"); Node *dupsingle = nullptr; - List<Node *> editable_children; selection.sort_custom<Node::Comparator>(); @@ -701,10 +700,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { Map<const Node *, Node *> duplimap; Node *dup = node->duplicate_from_editor(duplimap); - if (EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(node)) { - editable_children.push_back(dup); - } - ERR_CONTINUE(!dup); if (selection.size() == 1) { @@ -739,11 +734,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (dupsingle) { editor->push_item(dupsingle); } - - for (List<Node *>::Element *E = editable_children.back(); E; E = E->prev()) { - _toggle_editable_children(E->get()); - } - } break; case TOOL_REPARENT: { if (!profile_allow_editing) { diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 2d739202fb..e9de91f851 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -626,7 +626,7 @@ void SceneTreeEditor::_selected_changed() { } void SceneTreeEditor::_deselect_items() { - // Clear currently elected items in scene tree dock. + // Clear currently selected items in scene tree dock. if (editor_selection) { editor_selection->clear(); emit_signal("node_changed"); @@ -1172,6 +1172,7 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope tree->set_anchor(SIDE_BOTTOM, ANCHOR_END); tree->set_begin(Point2(0, p_label ? 18 : 0)); tree->set_end(Point2(0, 0)); + tree->set_allow_reselect(true); tree->add_theme_constant_override("button_margin", 0); add_child(tree); |