diff options
32 files changed, 127 insertions, 183 deletions
diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index 54c20bc2ff..6aa81803b7 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -393,9 +393,6 @@ <member name="editors/3d_gizmos/gizmo_colors/joint" type="Color" setter="" getter=""> The 3D editor gizmo color for [Joint3D]s and [PhysicalBone3D]s. </member> - <member name="editors/3d_gizmos/gizmo_colors/shape" type="Color" setter="" getter=""> - The 3D editor gizmo color for [CollisionShape3D]s, [VehicleWheel3D]s, [RayCast3D]s and [SpringArm3D]s. - </member> <member name="editors/animation/autorename_animation_tracks" type="bool" setter="" getter=""> If [code]true[/code], automatically updates animation tracks' target paths when renaming or reparenting nodes in the Scene tree dock. </member> diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index b7719f6c97..3ee8a33e70 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -324,6 +324,7 @@ void EditorDebuggerNode::_notification(int p_what) { case NOTIFICATION_READY: { _update_debug_options(); + initializing = false; } break; case NOTIFICATION_PROCESS: { @@ -535,7 +536,9 @@ void EditorDebuggerNode::_menu_option(int p_id) { bool ischecked = script_menu->get_popup()->is_item_checked(script_menu->get_popup()->get_item_index(DEBUG_WITH_EXTERNAL_EDITOR)); debug_with_external_editor = !ischecked; script_menu->get_popup()->set_item_checked(script_menu->get_popup()->get_item_index(DEBUG_WITH_EXTERNAL_EDITOR), !ischecked); - EditorSettings::get_singleton()->set_project_metadata("debug_options", "debug_with_external_editor", !ischecked); + if (!initializing) { + EditorSettings::get_singleton()->set_project_metadata("debug_options", "debug_with_external_editor", !ischecked); + } } break; } } diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h index 01aa522f40..aef1d84758 100644 --- a/editor/debugger/editor_debugger_node.h +++ b/editor/debugger/editor_debugger_node.h @@ -102,6 +102,7 @@ private: Ref<Script> stack_script; // Why?!? + bool initializing = true; int last_error_count = 0; int last_warning_count = 0; diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index dd9805085b..d9dcf949c7 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -4039,25 +4039,16 @@ void EditorInspector::_notification(int p_what) { EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &EditorInspector::_feature_profile_changed)); set_process(is_visible_in_tree()); add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); - } break; - - case NOTIFICATION_ENTER_TREE: { if (!sub_inspector) { get_tree()->connect("node_removed", callable_mp(this, &EditorInspector::_node_removed)); } } break; case NOTIFICATION_PREDELETE: { - if (EditorNode::get_singleton() && !EditorNode::get_singleton()->is_exiting()) { - // Don't need to clean up if exiting, and object may already be freed. - edit(nullptr); - } - } break; - - case NOTIFICATION_EXIT_TREE: { - if (!sub_inspector) { + if (!sub_inspector && is_inside_tree()) { get_tree()->disconnect("node_removed", callable_mp(this, &EditorInspector::_node_removed)); } + edit(nullptr); } break; case NOTIFICATION_VISIBILITY_CHANGED: { diff --git a/editor/editor_properties_vector.cpp b/editor/editor_properties_vector.cpp index 453675bebe..46bfb69e29 100644 --- a/editor/editor_properties_vector.cpp +++ b/editor/editor_properties_vector.cpp @@ -129,7 +129,8 @@ void EditorPropertyVectorN::_notification(int p_what) { case NOTIFICATION_READY: { if (linked->is_visible()) { const String key = vformat("%s:%s", get_edited_object()->get_class(), get_edited_property()); - linked->set_pressed(EditorSettings::get_singleton()->get_project_metadata("linked_properties", key, true)); + linked->set_pressed_no_signal(EditorSettings::get_singleton()->get_project_metadata("linked_properties", key, true)); + _update_ratio(); } } break; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index cec50ac30f..41d328c6de 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -691,7 +691,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { EDITOR_SETTING_USAGE(Variant::COLOR, PROPERTY_HINT_NONE, "editors/3d/selection_box_color", Color(1.0, 0.5, 0), "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED) EDITOR_SETTING_USAGE(Variant::COLOR, PROPERTY_HINT_NONE, "editors/3d_gizmos/gizmo_colors/instantiated", Color(0.7, 0.7, 0.7, 0.6), "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED) EDITOR_SETTING_USAGE(Variant::COLOR, PROPERTY_HINT_NONE, "editors/3d_gizmos/gizmo_colors/joint", Color(0.5, 0.8, 1), "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED) - EDITOR_SETTING_USAGE(Variant::COLOR, PROPERTY_HINT_NONE, "editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1), "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED) EDITOR_SETTING_USAGE(Variant::COLOR, PROPERTY_HINT_NONE, "editors/3d_gizmos/gizmo_colors/aabb", Color(0.28, 0.8, 0.82), "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED) // If a line is a multiple of this, it uses the primary grid color. diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index ea76c20a0f..ef77e5340b 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -138,9 +138,7 @@ String FileSystemList::get_edit_text() { } void FileSystemList::_text_editor_popup_modal_close() { - if (Input::get_singleton()->is_key_pressed(Key::ESCAPE) || - Input::get_singleton()->is_key_pressed(Key::KP_ENTER) || - Input::get_singleton()->is_key_pressed(Key::ENTER)) { + if (popup_editor->get_hide_reason() == Popup::HIDE_REASON_CANCELED) { return; } diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index 3bddc91b81..dff7ee5bb8 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -222,7 +222,9 @@ void FindInFiles::_scan_dir(const String &path, PackedStringArray &out_folders, dir->list_dir_begin(); - for (int i = 0; i < 1000; ++i) { + // Limit to 100,000 iterations to avoid an infinite loop just in case + // (this technically limits results to 100,000 files per folder). + for (int i = 0; i < 100'000; ++i) { String file = dir->get_next(); if (file.is_empty()) { diff --git a/editor/plugins/debugger_editor_plugin.cpp b/editor/plugins/debugger_editor_plugin.cpp index edd0ddbdad..53cb76f133 100644 --- a/editor/plugins/debugger_editor_plugin.cpp +++ b/editor/plugins/debugger_editor_plugin.cpp @@ -124,7 +124,9 @@ void DebuggerEditorPlugin::_menu_option(int p_option) { } debug_menu->set_item_checked(debug_menu->get_item_index(RUN_FILE_SERVER), !ischecked); - EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_file_server", !ischecked); + if (!initializing) { + EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_file_server", !ischecked); + } } break; case RUN_LIVE_DEBUG: { @@ -132,43 +134,57 @@ void DebuggerEditorPlugin::_menu_option(int p_option) { debug_menu->set_item_checked(debug_menu->get_item_index(RUN_LIVE_DEBUG), !ischecked); EditorDebuggerNode::get_singleton()->set_live_debugging(!ischecked); - EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_live_debug", !ischecked); + if (!initializing) { + EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_live_debug", !ischecked); + } } break; case RUN_DEPLOY_REMOTE_DEBUG: { bool ischecked = debug_menu->is_item_checked(debug_menu->get_item_index(RUN_DEPLOY_REMOTE_DEBUG)); debug_menu->set_item_checked(debug_menu->get_item_index(RUN_DEPLOY_REMOTE_DEBUG), !ischecked); - EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_deploy_remote_debug", !ischecked); + if (!initializing) { + EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_deploy_remote_debug", !ischecked); + } } break; case RUN_DEBUG_COLLISIONS: { bool ischecked = debug_menu->is_item_checked(debug_menu->get_item_index(RUN_DEBUG_COLLISIONS)); debug_menu->set_item_checked(debug_menu->get_item_index(RUN_DEBUG_COLLISIONS), !ischecked); - EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_collisions", !ischecked); + if (!initializing) { + EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_collisions", !ischecked); + } } break; case RUN_DEBUG_PATHS: { bool ischecked = debug_menu->is_item_checked(debug_menu->get_item_index(RUN_DEBUG_PATHS)); debug_menu->set_item_checked(debug_menu->get_item_index(RUN_DEBUG_PATHS), !ischecked); - EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_paths", !ischecked); + if (!initializing) { + EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_paths", !ischecked); + } } break; case RUN_DEBUG_NAVIGATION: { bool ischecked = debug_menu->is_item_checked(debug_menu->get_item_index(RUN_DEBUG_NAVIGATION)); debug_menu->set_item_checked(debug_menu->get_item_index(RUN_DEBUG_NAVIGATION), !ischecked); - EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_navigation", !ischecked); + if (!initializing) { + EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_navigation", !ischecked); + } } break; case RUN_DEBUG_AVOIDANCE: { bool ischecked = debug_menu->is_item_checked(debug_menu->get_item_index(RUN_DEBUG_AVOIDANCE)); debug_menu->set_item_checked(debug_menu->get_item_index(RUN_DEBUG_AVOIDANCE), !ischecked); - EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_avoidance", !ischecked); + if (!initializing) { + EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_avoidance", !ischecked); + } } break; case RUN_DEBUG_CANVAS_REDRAW: { bool ischecked = debug_menu->is_item_checked(debug_menu->get_item_index(RUN_DEBUG_CANVAS_REDRAW)); debug_menu->set_item_checked(debug_menu->get_item_index(RUN_DEBUG_CANVAS_REDRAW), !ischecked); - EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_canvas_redraw", !ischecked); + if (!initializing) { + EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_canvas_redraw", !ischecked); + } } break; case RUN_RELOAD_SCRIPTS: { @@ -176,7 +192,9 @@ void DebuggerEditorPlugin::_menu_option(int p_option) { debug_menu->set_item_checked(debug_menu->get_item_index(RUN_RELOAD_SCRIPTS), !ischecked); ScriptEditor::get_singleton()->set_live_auto_reload_running_scripts(!ischecked); - EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_reload_scripts", !ischecked); + if (!initializing) { + EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_reload_scripts", !ischecked); + } } break; case SERVER_KEEP_OPEN: { @@ -184,7 +202,9 @@ void DebuggerEditorPlugin::_menu_option(int p_option) { debug_menu->set_item_checked(debug_menu->get_item_index(SERVER_KEEP_OPEN), !ischecked); EditorDebuggerNode::get_singleton()->set_keep_open(!ischecked); - EditorSettings::get_singleton()->set_project_metadata("debug_options", "server_keep_open", !ischecked); + if (!initializing) { + EditorSettings::get_singleton()->set_project_metadata("debug_options", "server_keep_open", !ischecked); + } } break; case RUN_MULTIPLE_INSTANCES: { @@ -198,6 +218,7 @@ void DebuggerEditorPlugin::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { _update_debug_options(); + initializing = false; } break; case NOTIFICATION_PROCESS: { diff --git a/editor/plugins/debugger_editor_plugin.h b/editor/plugins/debugger_editor_plugin.h index a6df83496e..c7ad31ebad 100644 --- a/editor/plugins/debugger_editor_plugin.h +++ b/editor/plugins/debugger_editor_plugin.h @@ -60,6 +60,8 @@ private: RUN_MULTIPLE_INSTANCES, }; + bool initializing = true; + void _update_debug_options(); void _notification(int p_what); void _menu_option(int p_option); diff --git a/editor/plugins/gizmos/collision_object_3d_gizmo_plugin.cpp b/editor/plugins/gizmos/collision_object_3d_gizmo_plugin.cpp index caac143f23..9a0cf36c4c 100644 --- a/editor/plugins/gizmos/collision_object_3d_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/collision_object_3d_gizmo_plugin.cpp @@ -38,7 +38,7 @@ #include "scene/resources/surface_tool.h" CollisionObject3DGizmoPlugin::CollisionObject3DGizmoPlugin() { - const Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape"); + const Color gizmo_color = SceneTree::get_singleton()->get_debug_collisions_color(); create_material("shape_material", gizmo_color); const float gizmo_value = gizmo_color.get_v(); const Color gizmo_color_disabled = Color(gizmo_value, gizmo_value, gizmo_value, 0.65); diff --git a/editor/plugins/gizmos/collision_polygon_3d_gizmo_plugin.cpp b/editor/plugins/gizmos/collision_polygon_3d_gizmo_plugin.cpp index 7d19e8f677..44814fd2ba 100644 --- a/editor/plugins/gizmos/collision_polygon_3d_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/collision_polygon_3d_gizmo_plugin.cpp @@ -35,7 +35,7 @@ #include "scene/3d/physics/collision_polygon_3d.h" CollisionPolygon3DGizmoPlugin::CollisionPolygon3DGizmoPlugin() { - const Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape"); + const Color gizmo_color = SceneTree::get_singleton()->get_debug_collisions_color(); create_material("shape_material", gizmo_color); const float gizmo_value = gizmo_color.get_v(); const Color gizmo_color_disabled = Color(gizmo_value, gizmo_value, gizmo_value, 0.65); diff --git a/editor/plugins/gizmos/collision_shape_3d_gizmo_plugin.cpp b/editor/plugins/gizmos/collision_shape_3d_gizmo_plugin.cpp index 9d4c08ed57..01492c1dd0 100644 --- a/editor/plugins/gizmos/collision_shape_3d_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/collision_shape_3d_gizmo_plugin.cpp @@ -49,7 +49,7 @@ CollisionShape3DGizmoPlugin::CollisionShape3DGizmoPlugin() { helper.instantiate(); - const Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape"); + const Color gizmo_color = SceneTree::get_singleton()->get_debug_collisions_color(); create_material("shape_material", gizmo_color); const float gizmo_value = gizmo_color.get_v(); const Color gizmo_color_disabled = Color(gizmo_value, gizmo_value, gizmo_value, 0.65); diff --git a/editor/plugins/gizmos/gpu_particles_3d_gizmo_plugin.cpp b/editor/plugins/gizmos/gpu_particles_3d_gizmo_plugin.cpp index bef6971eba..39bfed93b0 100644 --- a/editor/plugins/gizmos/gpu_particles_3d_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/gpu_particles_3d_gizmo_plugin.cpp @@ -41,9 +41,7 @@ GPUParticles3DGizmoPlugin::GPUParticles3DGizmoPlugin() { Color gizmo_color = EDITOR_DEF_RST("editors/3d_gizmos/gizmo_colors/particles", Color(0.8, 0.7, 0.4)); create_material("particles_material", gizmo_color); gizmo_color.a = MAX((gizmo_color.a - 0.2) * 0.02, 0.0); - create_material("particles_solid_material", gizmo_color); create_icon_material("particles_icon", EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("GizmoGPUParticles3D"), EditorStringName(EditorIcons))); - create_handle_material("handles"); } bool GPUParticles3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { @@ -62,96 +60,6 @@ bool GPUParticles3DGizmoPlugin::is_selectable_when_hidden() const { return true; } -String GPUParticles3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const { - switch (p_id) { - case 0: - return "Size X"; - case 1: - return "Size Y"; - case 2: - return "Size Z"; - case 3: - return "Pos X"; - case 4: - return "Pos Y"; - case 5: - return "Pos Z"; - } - - return ""; -} - -Variant GPUParticles3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const { - GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_node_3d()); - return particles->get_visibility_aabb(); -} - -void GPUParticles3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) { - GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_node_3d()); - - Transform3D gt = particles->get_global_transform(); - Transform3D gi = gt.affine_inverse(); - - bool move = p_id >= 3; - p_id = p_id % 3; - - AABB aabb = particles->get_visibility_aabb(); - Vector3 ray_from = p_camera->project_ray_origin(p_point); - Vector3 ray_dir = p_camera->project_ray_normal(p_point); - - Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) }; - - Vector3 ofs = aabb.get_center(); - - Vector3 axis; - axis[p_id] = 1.0; - - if (move) { - Vector3 ra, rb; - Geometry3D::get_closest_points_between_segments(ofs - axis * 4096, ofs + axis * 4096, sg[0], sg[1], ra, rb); - - float d = ra[p_id]; - if (Node3DEditor::get_singleton()->is_snap_enabled()) { - d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); - } - - aabb.position[p_id] = d - 1.0 - aabb.size[p_id] * 0.5; - particles->set_visibility_aabb(aabb); - - } else { - Vector3 ra, rb; - Geometry3D::get_closest_points_between_segments(ofs, ofs + axis * 4096, sg[0], sg[1], ra, rb); - - float d = ra[p_id] - ofs[p_id]; - if (Node3DEditor::get_singleton()->is_snap_enabled()) { - d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); - } - - if (d < 0.001) { - d = 0.001; - } - //resize - aabb.position[p_id] = (aabb.position[p_id] + aabb.size[p_id] * 0.5) - d; - aabb.size[p_id] = d * 2; - particles->set_visibility_aabb(aabb); - } -} - -void GPUParticles3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) { - GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_node_3d()); - - if (p_cancel) { - particles->set_visibility_aabb(p_restore); - return; - } - - EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton(); - ur->create_action(TTR("Change Particles AABB")); - ur->add_do_method(particles, "set_visibility_aabb", particles->get_visibility_aabb()); - ur->add_undo_method(particles, "set_visibility_aabb", p_restore); - ur->commit_action(); -} - void GPUParticles3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { p_gizmo->clear(); @@ -168,33 +76,9 @@ void GPUParticles3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { lines.push_back(b); } - Vector<Vector3> handles; - - for (int i = 0; i < 3; i++) { - Vector3 ax; - ax[i] = aabb.position[i] + aabb.size[i]; - ax[(i + 1) % 3] = aabb.position[(i + 1) % 3] + aabb.size[(i + 1) % 3] * 0.5; - ax[(i + 2) % 3] = aabb.position[(i + 2) % 3] + aabb.size[(i + 2) % 3] * 0.5; - handles.push_back(ax); - } - - Vector3 center = aabb.get_center(); - for (int i = 0; i < 3; i++) { - Vector3 ax; - ax[i] = 1.0; - handles.push_back(center + ax); - lines.push_back(center); - lines.push_back(center + ax); - } - Ref<Material> material = get_material("particles_material", p_gizmo); p_gizmo->add_lines(lines, material); - - Ref<Material> solid_material = get_material("particles_solid_material", p_gizmo); - p_gizmo->add_solid_box(solid_material, aabb.get_size(), aabb.get_center()); - - p_gizmo->add_handles(handles, get_material("handles")); } Ref<Material> icon = get_material("particles_icon", p_gizmo); diff --git a/editor/plugins/gizmos/gpu_particles_3d_gizmo_plugin.h b/editor/plugins/gizmos/gpu_particles_3d_gizmo_plugin.h index 530e3fcc5d..b463e60a5f 100644 --- a/editor/plugins/gizmos/gpu_particles_3d_gizmo_plugin.h +++ b/editor/plugins/gizmos/gpu_particles_3d_gizmo_plugin.h @@ -43,11 +43,6 @@ public: bool is_selectable_when_hidden() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const override; - Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const override; - void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false) override; - GPUParticles3DGizmoPlugin(); }; diff --git a/editor/plugins/gizmos/ray_cast_3d_gizmo_plugin.cpp b/editor/plugins/gizmos/ray_cast_3d_gizmo_plugin.cpp index d783c4e4a7..2731a76f52 100644 --- a/editor/plugins/gizmos/ray_cast_3d_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/ray_cast_3d_gizmo_plugin.cpp @@ -35,7 +35,7 @@ #include "scene/3d/physics/ray_cast_3d.h" RayCast3DGizmoPlugin::RayCast3DGizmoPlugin() { - const Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape"); + const Color gizmo_color = SceneTree::get_singleton()->get_debug_collisions_color(); create_material("shape_material", gizmo_color); const float gizmo_value = gizmo_color.get_v(); const Color gizmo_color_disabled = Color(gizmo_value, gizmo_value, gizmo_value, 0.65); diff --git a/editor/plugins/gizmos/shape_cast_3d_gizmo_plugin.cpp b/editor/plugins/gizmos/shape_cast_3d_gizmo_plugin.cpp index 909f5b5f9a..3bf8adb80a 100644 --- a/editor/plugins/gizmos/shape_cast_3d_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/shape_cast_3d_gizmo_plugin.cpp @@ -35,7 +35,7 @@ #include "scene/3d/physics/shape_cast_3d.h" ShapeCast3DGizmoPlugin::ShapeCast3DGizmoPlugin() { - const Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape"); + const Color gizmo_color = SceneTree::get_singleton()->get_debug_collisions_color(); create_material("shape_material", gizmo_color); const float gizmo_value = gizmo_color.get_v(); const Color gizmo_color_disabled = Color(gizmo_value, gizmo_value, gizmo_value, 0.65); diff --git a/editor/plugins/gizmos/soft_body_3d_gizmo_plugin.cpp b/editor/plugins/gizmos/soft_body_3d_gizmo_plugin.cpp index be48e3764a..f5c8858a9c 100644 --- a/editor/plugins/gizmos/soft_body_3d_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/soft_body_3d_gizmo_plugin.cpp @@ -35,7 +35,7 @@ #include "scene/3d/soft_body_3d.h" SoftBody3DGizmoPlugin::SoftBody3DGizmoPlugin() { - Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape"); + Color gizmo_color = SceneTree::get_singleton()->get_debug_collisions_color(); create_material("shape_material", gizmo_color); create_handle_material("handles"); } diff --git a/editor/plugins/gizmos/spring_arm_3d_gizmo_plugin.cpp b/editor/plugins/gizmos/spring_arm_3d_gizmo_plugin.cpp index 85e2c86947..74c55bf3dd 100644 --- a/editor/plugins/gizmos/spring_arm_3d_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/spring_arm_3d_gizmo_plugin.cpp @@ -52,7 +52,7 @@ void SpringArm3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } SpringArm3DGizmoPlugin::SpringArm3DGizmoPlugin() { - Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape"); + Color gizmo_color = SceneTree::get_singleton()->get_debug_collisions_color(); create_material("shape_material", gizmo_color); } diff --git a/editor/plugins/gizmos/vehicle_body_3d_gizmo_plugin.cpp b/editor/plugins/gizmos/vehicle_body_3d_gizmo_plugin.cpp index 69e87a55c0..1015e46965 100644 --- a/editor/plugins/gizmos/vehicle_body_3d_gizmo_plugin.cpp +++ b/editor/plugins/gizmos/vehicle_body_3d_gizmo_plugin.cpp @@ -35,7 +35,7 @@ #include "scene/3d/physics/vehicle_body_3d.h" VehicleWheel3DGizmoPlugin::VehicleWheel3DGizmoPlugin() { - Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape"); + Color gizmo_color = SceneTree::get_singleton()->get_debug_collisions_color(); create_material("shape_material", gizmo_color); } diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp index f09318277a..f81ba07398 100644 --- a/editor/plugins/path_3d_editor_plugin.cpp +++ b/editor/plugins/path_3d_editor_plugin.cpp @@ -1050,7 +1050,7 @@ int Path3DGizmoPlugin::get_priority() const { } Path3DGizmoPlugin::Path3DGizmoPlugin(float p_disk_size) { - Color path_color = EDITOR_DEF_RST("editors/3d_gizmos/gizmo_colors/path", Color(0.5, 0.5, 1.0, 0.9)); + Color path_color = SceneTree::get_singleton()->get_debug_paths_color(); Color path_tilt_color = EDITOR_DEF_RST("editors/3d_gizmos/gizmo_colors/path_tilt", Color(1.0, 1.0, 0.4, 0.9)); disk_size = p_disk_size; diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index e901f38944..2f479527f3 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -4479,7 +4479,7 @@ ScriptEditorPlugin::ScriptEditorPlugin() { EDITOR_GET("text_editor/behavior/files/auto_reload_scripts_on_external_change"); ScriptServer::set_reload_scripts_on_save(EDITOR_DEF("text_editor/behavior/files/auto_reload_and_parse_scripts_on_save", true)); - EDITOR_DEF("text_editor/behavior/files/open_dominant_script_on_scene_change", true); + EDITOR_DEF("text_editor/behavior/files/open_dominant_script_on_scene_change", false); EDITOR_DEF("text_editor/external/use_external_editor", false); EDITOR_DEF("text_editor/external/exec_path", ""); EDITOR_DEF("text_editor/script_list/script_temperature_enabled", true); diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index 86a291db0e..a617a39fa2 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -674,6 +674,11 @@ void GenericTilePolygonEditor::_set_snap_option(int p_index) { current_snap_option = p_index; button_pixel_snap->set_icon(button_pixel_snap->get_popup()->get_item_icon(p_index)); snap_subdivision->set_visible(p_index == SNAP_GRID); + + if (initializing) { + return; + } + base_control->queue_redraw(); _store_snap_options(); } @@ -955,6 +960,7 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() { snap_subdivision->set_value_no_signal(EditorSettings::get_singleton()->get_project_metadata("editor_metadata", "tile_snap_subdiv", 4)); _set_snap_option(EditorSettings::get_singleton()->get_project_metadata("editor_metadata", "tile_snap_option", SNAP_NONE)); + initializing = false; } void TileDataDefaultEditor::_property_value_changed(const StringName &p_property, const Variant &p_value, const StringName &p_field) { diff --git a/editor/plugins/tiles/tile_data_editors.h b/editor/plugins/tiles/tile_data_editors.h index 40c049f70c..f9d8f7d077 100644 --- a/editor/plugins/tiles/tile_data_editors.h +++ b/editor/plugins/tiles/tile_data_editors.h @@ -140,6 +140,7 @@ private: EditorZoomWidget *editor_zoom_widget = nullptr; Button *button_center_view = nullptr; Vector2 panning; + bool initializing = true; Ref<Texture2D> background_texture; Rect2 background_region; diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp index 8c41858d62..7706842965 100644 --- a/editor/plugins/tiles/tile_set_editor.cpp +++ b/editor/plugins/tiles/tile_set_editor.cpp @@ -357,7 +357,10 @@ void TileSetEditor::_set_source_sort(int p_sort) { } } _update_sources_list(old_selected); - EditorSettings::get_singleton()->set_project_metadata("editor_metadata", "tile_source_sort", p_sort); + + if (!first_edit) { + EditorSettings::get_singleton()->set_project_metadata("editor_metadata", "tile_source_sort", p_sort); + } } void TileSetEditor::_notification(int p_what) { @@ -738,8 +741,8 @@ void TileSetEditor::edit(Ref<TileSet> p_tile_set) { tile_set->connect_changed(callable_mp(this, &TileSetEditor::_tile_set_changed)); if (first_edit) { - first_edit = false; _set_source_sort(EditorSettings::get_singleton()->get_project_metadata("editor_metadata", "tile_source_sort", 0)); + first_edit = false; } else { _update_sources_list(); } diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 634d4fc867..9be9307b8a 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -3199,6 +3199,9 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_call(ExpressionNode *p_pre } GDScriptParser::ExpressionNode *GDScriptParser::parse_get_node(ExpressionNode *p_previous_operand, bool p_can_assign) { + // We want code completion after a DOLLAR even if the current code is invalid. + make_completion_context(COMPLETION_GET_NODE, nullptr, -1, true); + if (!current.is_node_name() && !check(GDScriptTokenizer::Token::LITERAL) && !check(GDScriptTokenizer::Token::SLASH) && !check(GDScriptTokenizer::Token::PERCENT)) { push_error(vformat(R"(Expected node path as string or identifier after "%s".)", previous.get_name())); return nullptr; @@ -3254,7 +3257,7 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_get_node(ExpressionNode *p path_state = PATH_STATE_SLASH; } - make_completion_context(COMPLETION_GET_NODE, get_node, context_argument++); + make_completion_context(COMPLETION_GET_NODE, get_node, context_argument++, true); if (match(GDScriptTokenizer::Token::LITERAL)) { if (previous.literal.get_type() != Variant::STRING) { diff --git a/scene/2d/physics/collision_polygon_2d.cpp b/scene/2d/physics/collision_polygon_2d.cpp index 72ee4d52c5..a9b47ef4d4 100644 --- a/scene/2d/physics/collision_polygon_2d.cpp +++ b/scene/2d/physics/collision_polygon_2d.cpp @@ -144,7 +144,7 @@ void CollisionPolygon2D::_notification(int p_what) { } #endif - const Color stroke_color = Color(0.9, 0.2, 0.0); + const Color stroke_color = get_tree()->get_debug_collisions_color(); draw_polyline(polygon, stroke_color); // Draw the last segment. draw_line(polygon[polygon.size() - 1], polygon[0], stroke_color); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index d78077316a..2dd12b92f3 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -208,28 +208,42 @@ void Control::set_root_layout_direction(int p_root_dir) { #ifdef TOOLS_ENABLED void Control::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const { ERR_READ_THREAD_GUARD; - CanvasItem::get_argument_options(p_function, p_idx, r_options); - if (p_idx == 0) { - List<StringName> sn; const String pf = p_function; + Theme::DataType type = Theme::DATA_TYPE_MAX; + if (pf == "add_theme_color_override" || pf == "has_theme_color" || pf == "has_theme_color_override" || pf == "get_theme_color") { - ThemeDB::get_singleton()->get_default_theme()->get_color_list(get_class(), &sn); - } else if (pf == "add_theme_style_override" || pf == "has_theme_style" || pf == "has_theme_style_override" || pf == "get_theme_style") { - ThemeDB::get_singleton()->get_default_theme()->get_stylebox_list(get_class(), &sn); + type = Theme::DATA_TYPE_COLOR; + } else if (pf == "add_theme_constant_override" || pf == "has_theme_constant" || pf == "has_theme_constant_override" || pf == "get_theme_constant") { + type = Theme::DATA_TYPE_CONSTANT; } else if (pf == "add_theme_font_override" || pf == "has_theme_font" || pf == "has_theme_font_override" || pf == "get_theme_font") { - ThemeDB::get_singleton()->get_default_theme()->get_font_list(get_class(), &sn); + type = Theme::DATA_TYPE_FONT; } else if (pf == "add_theme_font_size_override" || pf == "has_theme_font_size" || pf == "has_theme_font_size_override" || pf == "get_theme_font_size") { - ThemeDB::get_singleton()->get_default_theme()->get_font_size_list(get_class(), &sn); - } else if (pf == "add_theme_constant_override" || pf == "has_theme_constant" || pf == "has_theme_constant_override" || pf == "get_theme_constant") { - ThemeDB::get_singleton()->get_default_theme()->get_constant_list(get_class(), &sn); + type = Theme::DATA_TYPE_FONT_SIZE; + } else if (pf == "add_theme_icon_override" || pf == "has_theme_icon" || pf == "has_theme_icon_override" || pf == "get_theme_icon") { + type = Theme::DATA_TYPE_ICON; + } else if (pf == "add_theme_style_override" || pf == "has_theme_style" || pf == "has_theme_style_override" || pf == "get_theme_style") { + type = Theme::DATA_TYPE_STYLEBOX; } - sn.sort_custom<StringName::AlphCompare>(); - for (const StringName &name : sn) { - r_options->push_back(String(name).quote()); + if (type != Theme::DATA_TYPE_MAX) { + List<ThemeDB::ThemeItemBind> theme_items; + ThemeDB::get_singleton()->get_class_items(get_class_name(), &theme_items, true, type); + + List<StringName> sn; + for (const ThemeDB::ThemeItemBind &E : theme_items) { + if (E.data_type == type) { + sn.push_back(E.item_name); + } + } + + sn.sort_custom<StringName::AlphCompare>(); + for (const StringName &name : sn) { + r_options->push_back(String(name).quote()); + } } } + CanvasItem::get_argument_options(p_function, p_idx, r_options); } #endif diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp index 87383283fd..97b33c4f74 100644 --- a/scene/gui/popup.cpp +++ b/scene/gui/popup.cpp @@ -77,6 +77,9 @@ void Popup::_notification(int p_what) { _initialize_visible_parents(); } else { _deinitialize_visible_parents(); + if (hide_reason == HIDE_REASON_NONE) { + hide_reason = HIDE_REASON_CANCELED; + } emit_signal(SNAME("popup_hide")); popped_up = false; } @@ -87,6 +90,7 @@ void Popup::_notification(int p_what) { if (!is_in_edited_scene_root()) { if (has_focus()) { popped_up = true; + hide_reason = HIDE_REASON_NONE; } } } break; @@ -100,6 +104,7 @@ void Popup::_notification(int p_what) { case NOTIFICATION_WM_CLOSE_REQUEST: { if (!is_in_edited_scene_root()) { + hide_reason = HIDE_REASON_UNFOCUSED; _close_pressed(); } } break; @@ -114,6 +119,7 @@ void Popup::_notification(int p_what) { void Popup::_parent_focused() { if (popped_up && get_flag(FLAG_POPUP)) { + hide_reason = HIDE_REASON_UNFOCUSED; _close_pressed(); } } diff --git a/scene/gui/popup.h b/scene/gui/popup.h index 48818686f7..69a81ad98c 100644 --- a/scene/gui/popup.h +++ b/scene/gui/popup.h @@ -43,6 +43,16 @@ class Popup : public Window { LocalVector<Window *> visible_parents; bool popped_up = false; +public: + enum HideReason { + HIDE_REASON_NONE, + HIDE_REASON_CANCELED, // E.g., because of rupture of UI flow (app unfocused). Includes closed programmatically. + HIDE_REASON_UNFOCUSED, // E.g., user clicked outside. + }; + +private: + HideReason hide_reason = HIDE_REASON_NONE; + void _initialize_visible_parents(); void _deinitialize_visible_parents(); @@ -60,6 +70,8 @@ protected: virtual void _post_popup() override; public: + HideReason get_hide_reason() const { return hide_reason; } + Popup(); ~Popup(); }; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 376ace2fe2..df0bb365e5 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -3152,9 +3152,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int } void Tree::_text_editor_popup_modal_close() { - if (Input::get_singleton()->is_key_pressed(Key::ESCAPE) || - Input::get_singleton()->is_key_pressed(Key::KP_ENTER) || - Input::get_singleton()->is_key_pressed(Key::ENTER)) { + if (popup_editor->get_hide_reason() == Popup::HIDE_REASON_CANCELED) { return; } diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 94a031947a..407b12d72f 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -191,6 +191,7 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const { Node *node = nullptr; MissingNode *missing_node = nullptr; + bool is_inherited_scene = false; if (i == 0 && base_scene_idx >= 0) { // Scene inheritance on root node. @@ -201,7 +202,7 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const { if (p_edit_state != GEN_EDIT_STATE_DISABLED) { node->set_scene_inherited_state(sdata->get_state()); } - + is_inherited_scene = true; } else if (n.instance >= 0) { // Instance a scene into this node. if (n.instance & FLAG_INSTANCE_IS_PLACEHOLDER) { @@ -346,6 +347,12 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const { } else { Variant value = props[nprops[j].value]; + // Making sure that instances of inherited scenes don't share the same + // reference between them. + if (is_inherited_scene) { + value = value.duplicate(true); + } + if (value.get_type() == Variant::OBJECT) { //handle resources that are local to scene by duplicating them if needed Ref<Resource> res = value; |