diff options
Diffstat (limited to 'editor')
63 files changed, 343 insertions, 389 deletions
diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index 8e55f3a1c3..712b11d7d7 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -578,7 +578,7 @@ ActionMapEditor::ActionMapEditor() { action_tree->connect("button_clicked", callable_mp(this, &ActionMapEditor::_tree_button_pressed)); main_vbox->add_child(action_tree); - action_tree->set_drag_forwarding(this); + action_tree->set_drag_forwarding_compat(this); // Adding event dialog event_config_dialog = memnew(InputEventConfigurationDialog); diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 65bc7b2414..89bb1f5ae6 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1253,7 +1253,7 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) { editing = true; Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); - undo_redo->create_action(TTR("Change Animation Length")); + undo_redo->create_action(TTR("Change Animation Length"), UndoRedo::MERGE_ENDS); undo_redo->add_do_method(animation.ptr(), "set_length", p_new_len); undo_redo->add_undo_method(animation.ptr(), "set_length", animation->get_length()); undo_redo->commit_action(); @@ -2919,7 +2919,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { } } - if (mm.is_valid() && (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE && moving_selection_attempt) { + if (mm.is_valid() && mm->get_button_mask().has_flag(MouseButtonMask::LEFT) && moving_selection_attempt) { if (!moving_selection) { moving_selection = true; emit_signal(SNAME("move_selection_begin")); @@ -5309,7 +5309,7 @@ void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid() && box_selecting) { - if ((mm->get_button_mask() & MouseButton::MASK_LEFT) == MouseButton::NONE) { + if (!mm->get_button_mask().has_flag(MouseButtonMask::LEFT)) { // No longer. box_selection->hide(); box_selecting = false; diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 76d70b09e6..6e701cb6bd 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -754,7 +754,7 @@ CreateDialog::CreateDialog() { favorites->connect("cell_selected", callable_mp(this, &CreateDialog::_favorite_selected)); favorites->connect("item_activated", callable_mp(this, &CreateDialog::_favorite_activated)); favorites->add_theme_constant_override("draw_guides", 1); - favorites->set_drag_forwarding(this); + favorites->set_drag_forwarding_compat(this); fav_vb->add_margin_child(TTR("Favorites:"), favorites, true); VBoxContainer *rec_vb = memnew(VBoxContainer); diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index 2e68e91c8b..38934ae8a5 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -468,7 +468,7 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { x = frame_metrics.size() - 1; } - if (mb.is_valid() || (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) { + if (mb.is_valid() || (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) { updating_frame = true; if (x < total_metrics) { diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index 8fa77fd028..91d9204863 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -544,7 +544,7 @@ void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { hover_metric = -1; } - if (mb.is_valid() || (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) { + if (mb.is_valid() || mm->get_button_mask().has_flag(MouseButtonMask::LEFT)) { //cursor_metric=x; updating_frame = true; diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index 002599acdb..85adc312f2 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -845,6 +845,7 @@ void DocTools::generate(bool p_basic_types) { for (int i = 0; i < CoreConstants::get_global_constant_count(); i++) { DocData::ConstantDoc cd; cd.name = CoreConstants::get_global_constant_name(i); + cd.is_bitfield = CoreConstants::is_global_constant_bitfield(i); if (!CoreConstants::get_ignore_value_in_docs(i)) { cd.value = itos(CoreConstants::get_global_constant_value(i)); cd.is_value_valid = true; diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp index ae9abc638f..25bca2a099 100644 --- a/editor/editor_about.cpp +++ b/editor/editor_about.cpp @@ -153,8 +153,8 @@ EditorAbout::EditorAbout() { Label *about_text = memnew(Label); about_text->set_v_size_flags(Control::SIZE_SHRINK_CENTER); - about_text->set_text(String::utf8("\xc2\xa9 2014-present ") + TTR("Godot Engine contributors") + - "\n\xc2\xa9 2007-2014 Juan Linietsky, Ariel Manzur.\n"); + about_text->set_text(String::utf8("\xc2\xa9 2014-present ") + TTR("Godot Engine contributors") + "." + + String::utf8("\n\xc2\xa9 2007-2014 Juan Linietsky, Ariel Manzur.\n")); version_info_vbc->add_child(about_text); hbc->add_child(version_info_vbc); diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index 0258ac532f..a5bc90159a 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -120,7 +120,6 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { // Mark C# support as unavailable. extension_guess["cs"] = tree->get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons")); } - extension_guess["vs"] = tree->get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons")); extension_guess["res"] = tree->get_theme_icon(SNAME("Resource"), SNAME("EditorIcons")); extension_guess["tres"] = tree->get_theme_icon(SNAME("Resource"), SNAME("EditorIcons")); diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 5296749c18..7ef99d56ab 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -903,7 +903,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { effects->connect("item_edited", callable_mp(this, &EditorAudioBus::_effect_edited)); effects->connect("cell_selected", callable_mp(this, &EditorAudioBus::_effect_selected)); effects->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true); - effects->set_drag_forwarding(this); + effects->set_drag_forwarding_compat(this); effects->connect("item_mouse_selected", callable_mp(this, &EditorAudioBus::_effect_rmb)); effects->set_allow_rmb_select(true); effects->set_focus_mode(FOCUS_CLICK); diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index db251c857c..4001b849ff 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -935,7 +935,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() { tree->set_select_mode(Tree::SELECT_MULTI); tree->set_allow_reselect(true); - tree->set_drag_forwarding(this); + tree->set_drag_forwarding_compat(this); tree->set_columns(4); tree->set_column_titles_visible(true); diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 28424d53b1..4efc7c3055 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -433,7 +433,7 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo } if (!found_uid) { - return true; //UUID not found, old format, reimport. + return true; //UID not found, old format, reimport. } Ref<ResourceImporter> importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(importer_name); @@ -868,7 +868,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, Ref<DirAc } if (fc->uid == ResourceUID::INVALID_ID) { - // imported files should always have a UUID, so attempt to fetch it. + // imported files should always have a UID, so attempt to fetch it. fi->uid = ResourceLoader::get_resource_uid(path); } @@ -2319,14 +2319,14 @@ ResourceUID::ID EditorFileSystem::_resource_saver_get_resource_id_for_path(const } if (p_generate) { - return ResourceUID::get_singleton()->create_id(); // Just create a new one, we will be notified of save anyway and fetch the right UUID at that time, to keep things simple. + return ResourceUID::get_singleton()->create_id(); // Just create a new one, we will be notified of save anyway and fetch the right UID at that time, to keep things simple. } else { return ResourceUID::INVALID_ID; } } else if (fs->files[cpos]->uid != ResourceUID::INVALID_ID) { return fs->files[cpos]->uid; } else if (p_generate) { - return ResourceUID::get_singleton()->create_id(); // Just create a new one, we will be notified of save anyway and fetch the right UUID at that time, to keep things simple. + return ResourceUID::get_singleton()->create_id(); // Just create a new one, we will be notified of save anyway and fetch the right UID at that time, to keep things simple. } else { return ResourceUID::INVALID_ID; } diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index c24bab054f..12aa44891d 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -618,7 +618,7 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) { if (is_layout_rtl()) { mpos.x = get_size().x - mpos.x; } - bool button_left = (me->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE; + bool button_left = me->get_button_mask().has_flag(MouseButtonMask::LEFT); bool new_keying_hover = keying_rect.has_point(mpos) && !button_left; if (new_keying_hover != keying_hover) { @@ -2065,7 +2065,7 @@ void EditorInspectorArray::_setup() { ae.panel = memnew(PanelContainer); ae.panel->set_focus_mode(FOCUS_ALL); ae.panel->set_mouse_filter(MOUSE_FILTER_PASS); - ae.panel->set_drag_forwarding(this); + ae.panel->set_drag_forwarding_compat(this); ae.panel->set_meta("index", begin_array_index + i); ae.panel->set_tooltip_text(vformat(TTR("Element %d: %s%d*"), i, array_element_prefix, i)); ae.panel->connect("focus_entered", callable_mp((CanvasItem *)ae.panel, &PanelContainer::queue_redraw)); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 13dd03068f..ab79031ad2 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -493,16 +493,16 @@ void EditorNode::_update_from_settings() { tree->set_debug_collision_contact_color(GLOBAL_GET("debug/shapes/collision/contact_color")); #ifdef DEBUG_ENABLED - NavigationServer3D::get_singleton_mut()->set_debug_navigation_edge_connection_color(GLOBAL_GET("debug/shapes/navigation/edge_connection_color")); - NavigationServer3D::get_singleton_mut()->set_debug_navigation_geometry_edge_color(GLOBAL_GET("debug/shapes/navigation/geometry_edge_color")); - NavigationServer3D::get_singleton_mut()->set_debug_navigation_geometry_face_color(GLOBAL_GET("debug/shapes/navigation/geometry_face_color")); - NavigationServer3D::get_singleton_mut()->set_debug_navigation_geometry_edge_disabled_color(GLOBAL_GET("debug/shapes/navigation/geometry_edge_disabled_color")); - NavigationServer3D::get_singleton_mut()->set_debug_navigation_geometry_face_disabled_color(GLOBAL_GET("debug/shapes/navigation/geometry_face_disabled_color")); - NavigationServer3D::get_singleton_mut()->set_debug_navigation_enable_edge_connections(GLOBAL_GET("debug/shapes/navigation/enable_edge_connections")); - NavigationServer3D::get_singleton_mut()->set_debug_navigation_enable_edge_connections_xray(GLOBAL_GET("debug/shapes/navigation/enable_edge_connections_xray")); - NavigationServer3D::get_singleton_mut()->set_debug_navigation_enable_edge_lines(GLOBAL_GET("debug/shapes/navigation/enable_edge_lines")); - NavigationServer3D::get_singleton_mut()->set_debug_navigation_enable_edge_lines_xray(GLOBAL_GET("debug/shapes/navigation/enable_edge_lines_xray")); - NavigationServer3D::get_singleton_mut()->set_debug_navigation_enable_geometry_face_random_color(GLOBAL_GET("debug/shapes/navigation/enable_geometry_face_random_color")); + NavigationServer3D::get_singleton()->set_debug_navigation_edge_connection_color(GLOBAL_GET("debug/shapes/navigation/edge_connection_color")); + NavigationServer3D::get_singleton()->set_debug_navigation_geometry_edge_color(GLOBAL_GET("debug/shapes/navigation/geometry_edge_color")); + NavigationServer3D::get_singleton()->set_debug_navigation_geometry_face_color(GLOBAL_GET("debug/shapes/navigation/geometry_face_color")); + NavigationServer3D::get_singleton()->set_debug_navigation_geometry_edge_disabled_color(GLOBAL_GET("debug/shapes/navigation/geometry_edge_disabled_color")); + NavigationServer3D::get_singleton()->set_debug_navigation_geometry_face_disabled_color(GLOBAL_GET("debug/shapes/navigation/geometry_face_disabled_color")); + NavigationServer3D::get_singleton()->set_debug_navigation_enable_edge_connections(GLOBAL_GET("debug/shapes/navigation/enable_edge_connections")); + NavigationServer3D::get_singleton()->set_debug_navigation_enable_edge_connections_xray(GLOBAL_GET("debug/shapes/navigation/enable_edge_connections_xray")); + NavigationServer3D::get_singleton()->set_debug_navigation_enable_edge_lines(GLOBAL_GET("debug/shapes/navigation/enable_edge_lines")); + NavigationServer3D::get_singleton()->set_debug_navigation_enable_edge_lines_xray(GLOBAL_GET("debug/shapes/navigation/enable_edge_lines_xray")); + NavigationServer3D::get_singleton()->set_debug_navigation_enable_geometry_face_random_color(GLOBAL_GET("debug/shapes/navigation/enable_geometry_face_random_color")); #endif // DEBUG_ENABLED } @@ -1123,6 +1123,12 @@ void EditorNode::_version_button_pressed() { DisplayServer::get_singleton()->clipboard_set(version_btn->get_meta(META_TEXT_TO_COPY)); } +void EditorNode::_update_undo_redo_allowed() { + Ref<EditorUndoRedoManager> undo_redo = get_undo_redo(); + file_menu->set_item_disabled(file_menu->get_item_index(EDIT_UNDO), !undo_redo->has_undo()); + file_menu->set_item_disabled(file_menu->get_item_index(EDIT_REDO), !undo_redo->has_redo()); +} + void EditorNode::_node_renamed() { if (InspectorDock::get_inspector_singleton()) { InspectorDock::get_inspector_singleton()->update_tree(); @@ -2330,7 +2336,7 @@ void EditorNode::_edit_current(bool p_skip_foreign) { if (main_plugin && !skip_main_plugin) { // Special case if use of external editor is true. Resource *current_res = Object::cast_to<Resource>(current_obj); - if (main_plugin->get_name() == "Script" && !current_obj->is_class("VisualScript") && current_res && !current_res->is_built_in() && (bool(EDITOR_GET("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) { + if (main_plugin->get_name() == "Script" && current_res && !current_res->is_built_in() && (bool(EDITOR_GET("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) { if (!changing_scene) { main_plugin->edit(current_obj); } @@ -3245,16 +3251,8 @@ void EditorNode::_discard_changes(const String &p_str) { } void EditorNode::_update_file_menu_opened() { - Ref<Shortcut> close_scene_sc = ED_GET_SHORTCUT("editor/close_scene"); - close_scene_sc->set_name(TTR("Close Scene")); - Ref<Shortcut> reopen_closed_scene_sc = ED_GET_SHORTCUT("editor/reopen_closed_scene"); - reopen_closed_scene_sc->set_name(TTR("Reopen Closed Scene")); - file_menu->set_item_disabled(file_menu->get_item_index(FILE_OPEN_PREV), previous_scenes.is_empty()); - - Ref<EditorUndoRedoManager> undo_redo = editor_data.get_undo_redo(); - file_menu->set_item_disabled(file_menu->get_item_index(EDIT_UNDO), !undo_redo->has_undo()); - file_menu->set_item_disabled(file_menu->get_item_index(EDIT_REDO), !undo_redo->has_redo()); + _update_undo_redo_allowed(); } void EditorNode::_update_file_menu_closed() { @@ -5281,12 +5279,10 @@ void EditorNode::_scene_tab_input(const Ref<InputEvent> &p_input) { scene_tabs_context_menu->add_item(TTR("Play This Scene"), RUN_PLAY_SCENE); scene_tabs_context_menu->add_separator(); - Ref<Shortcut> close_tab_sc = ED_GET_SHORTCUT("editor/close_scene"); - close_tab_sc->set_name(TTR("Close Tab")); - scene_tabs_context_menu->add_shortcut(close_tab_sc, FILE_CLOSE); - Ref<Shortcut> undo_close_tab_sc = ED_GET_SHORTCUT("editor/reopen_closed_scene"); - undo_close_tab_sc->set_name(TTR("Undo Close Tab")); - scene_tabs_context_menu->add_shortcut(undo_close_tab_sc, FILE_OPEN_PREV); + scene_tabs_context_menu->add_shortcut(ED_GET_SHORTCUT("editor/close_scene"), FILE_CLOSE); + scene_tabs_context_menu->set_item_text(scene_tabs_context_menu->get_item_index(FILE_CLOSE), TTR("Close Tab")); + scene_tabs_context_menu->add_shortcut(ED_GET_SHORTCUT("editor/reopen_closed_scene"), FILE_OPEN_PREV); + scene_tabs_context_menu->set_item_text(scene_tabs_context_menu->get_item_index(FILE_OPEN_PREV), TTR("Undo Close Tab")); if (previous_scenes.is_empty()) { scene_tabs_context_menu->set_item_disabled(scene_tabs_context_menu->get_item_index(FILE_OPEN_PREV), true); } @@ -6053,6 +6049,9 @@ EditorNode::EditorNode() { singleton = this; + get_undo_redo()->connect("version_changed", callable_mp(this, &EditorNode::_update_undo_redo_allowed)); + get_undo_redo()->connect("history_changed", callable_mp(this, &EditorNode::_update_undo_redo_allowed)); + TranslationServer::get_singleton()->set_enabled(false); // Load settings. if (!EditorSettings::get_singleton()) { @@ -6094,7 +6093,10 @@ EditorNode::EditorNode() { } // Define a minimum window size to prevent UI elements from overlapping or being cut off. - DisplayServer::get_singleton()->window_set_min_size(Size2(1024, 600) * EDSCALE); + Window *w = Object::cast_to<Window>(SceneTree::get_singleton()->get_root()); + if (w) { + w->set_min_size(Size2(1024, 600) * EDSCALE); + } FileDialog::set_default_show_hidden_files(EDITOR_GET("filesystem/file_dialog/show_hidden_files")); EditorFileDialog::set_default_show_hidden_files(EDITOR_GET("filesystem/file_dialog/show_hidden_files")); diff --git a/editor/editor_node.h b/editor/editor_node.h index f3dad8e223..ae951808d5 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -577,6 +577,8 @@ private: void _titlebar_resized(); void _version_button_pressed(); + void _update_undo_redo_allowed(); + int _save_external_resources(); bool _validate_scene_recursive(const String &p_filename, Node *p_node); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index ba42bbf3bd..8ef394a59f 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -68,7 +68,7 @@ EditorPropertyNil::EditorPropertyNil() { void EditorPropertyText::_set_read_only(bool p_read_only) { text->set_editable(!p_read_only); -}; +} void EditorPropertyText::_text_submitted(const String &p_string) { if (updating) { @@ -133,7 +133,7 @@ EditorPropertyText::EditorPropertyText() { void EditorPropertyMultilineText::_set_read_only(bool p_read_only) { text->set_editable(!p_read_only); open_big_text->set_disabled(p_read_only); -}; +} void EditorPropertyMultilineText::_big_text_changed() { text->set_text(big_text->get_text()); @@ -236,7 +236,7 @@ EditorPropertyMultilineText::EditorPropertyMultilineText(bool p_expression) { void EditorPropertyTextEnum::_set_read_only(bool p_read_only) { option_button->set_disabled(p_read_only); edit_button->set_disabled(p_read_only); -}; +} void EditorPropertyTextEnum::_emit_changed_value(String p_string) { if (string_name) { @@ -450,7 +450,7 @@ EditorPropertyLocale::EditorPropertyLocale() { void EditorPropertyPath::_set_read_only(bool p_read_only) { path->set_editable(!p_read_only); path_edit->set_disabled(p_read_only); -}; +} void EditorPropertyPath::_path_selected(const String &p_path) { emit_changed(get_edited_property(), p_path); @@ -569,7 +569,7 @@ EditorPropertyPath::EditorPropertyPath() { HBoxContainer *path_hb = memnew(HBoxContainer); add_child(path_hb); path = memnew(LineEdit); - path->set_drag_forwarding(this); + path->set_drag_forwarding_compat(this); path->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE); path_hb->add_child(path); path->connect("text_submitted", callable_mp(this, &EditorPropertyPath::_path_selected)); @@ -588,7 +588,7 @@ EditorPropertyPath::EditorPropertyPath() { void EditorPropertyClassName::_set_read_only(bool p_read_only) { property->set_disabled(p_read_only); -}; +} void EditorPropertyClassName::setup(const String &p_base_type, const String &p_selected_type) { base_type = p_base_type; @@ -629,112 +629,11 @@ EditorPropertyClassName::EditorPropertyClassName() { add_child(dialog); } -///////////////////// MEMBER ///////////////////////// - -void EditorPropertyMember::_set_read_only(bool p_read_only) { - property->set_disabled(p_read_only); -}; - -void EditorPropertyMember::_property_selected(const String &p_selected) { - emit_changed(get_edited_property(), p_selected); - update_property(); -} - -void EditorPropertyMember::_property_select() { - if (!selector) { - selector = memnew(PropertySelector); - selector->connect("selected", callable_mp(this, &EditorPropertyMember::_property_selected)); - add_child(selector); - } - - String current = get_edited_object()->get(get_edited_property()); - - if (hint == MEMBER_METHOD_OF_VARIANT_TYPE) { - Variant::Type type = Variant::NIL; - for (int i = 0; i < Variant::VARIANT_MAX; i++) { - if (hint_text == Variant::get_type_name(Variant::Type(i))) { - type = Variant::Type(i); - } - } - if (type != Variant::NIL) { - selector->select_method_from_basic_type(type, current); - } - - } else if (hint == MEMBER_METHOD_OF_BASE_TYPE) { - selector->select_method_from_base_type(hint_text, current); - - } else if (hint == MEMBER_METHOD_OF_INSTANCE) { - Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int())); - if (instance) { - selector->select_method_from_instance(instance, current); - } - - } else if (hint == MEMBER_METHOD_OF_SCRIPT) { - Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int())); - if (Object::cast_to<Script>(obj)) { - selector->select_method_from_script(Object::cast_to<Script>(obj), current); - } - - } else if (hint == MEMBER_PROPERTY_OF_VARIANT_TYPE) { - Variant::Type type = Variant::NIL; - String tname = hint_text; - if (tname.contains(".")) { - tname = tname.get_slice(".", 0); - } - for (int i = 0; i < Variant::VARIANT_MAX; i++) { - if (tname == Variant::get_type_name(Variant::Type(i))) { - type = Variant::Type(Variant::Type(i)); - } - } - - if (type != Variant::NIL) { - selector->select_property_from_basic_type(type, current); - } - - } else if (hint == MEMBER_PROPERTY_OF_BASE_TYPE) { - selector->select_property_from_base_type(hint_text, current); - - } else if (hint == MEMBER_PROPERTY_OF_INSTANCE) { - Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int())); - if (instance) { - selector->select_property_from_instance(instance, current); - } - - } else if (hint == MEMBER_PROPERTY_OF_SCRIPT) { - Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int())); - if (Object::cast_to<Script>(obj)) { - selector->select_property_from_script(Object::cast_to<Script>(obj), current); - } - } -} - -void EditorPropertyMember::setup(Type p_hint, const String &p_hint_text) { - hint = p_hint; - hint_text = p_hint_text; -} - -void EditorPropertyMember::update_property() { - String full_path = get_edited_object()->get(get_edited_property()); - property->set_text(full_path); -} - -void EditorPropertyMember::_bind_methods() { -} - -EditorPropertyMember::EditorPropertyMember() { - selector = nullptr; - property = memnew(Button); - property->set_clip_text(true); - add_child(property); - add_focusable(property); - property->connect("pressed", callable_mp(this, &EditorPropertyMember::_property_select)); -} - ///////////////////// CHECK ///////////////////////// void EditorPropertyCheck::_set_read_only(bool p_read_only) { checkbox->set_disabled(p_read_only); -}; +} void EditorPropertyCheck::_checkbox_pressed() { emit_changed(get_edited_property(), checkbox->is_pressed()); @@ -761,7 +660,7 @@ EditorPropertyCheck::EditorPropertyCheck() { void EditorPropertyEnum::_set_read_only(bool p_read_only) { options->set_disabled(p_read_only); -}; +} void EditorPropertyEnum::_option_selected(int p_which) { int64_t val = options->get_item_metadata(p_which); @@ -820,7 +719,7 @@ void EditorPropertyFlags::_set_read_only(bool p_read_only) { for (CheckBox *check : flags) { check->set_disabled(p_read_only); } -}; +} void EditorPropertyFlags::_flag_toggled(int p_index) { uint32_t value = get_edited_object()->get(get_edited_property()); @@ -1186,7 +1085,7 @@ void EditorPropertyLayers::_notification(int p_what) { void EditorPropertyLayers::_set_read_only(bool p_read_only) { button->set_disabled(p_read_only); grid->set_read_only(p_read_only); -}; +} void EditorPropertyLayers::_grid_changed(uint32_t p_grid) { emit_changed(get_edited_property(), p_grid); @@ -1359,7 +1258,7 @@ EditorPropertyLayers::EditorPropertyLayers() { void EditorPropertyInteger::_set_read_only(bool p_read_only) { spin->set_read_only(p_read_only); -}; +} void EditorPropertyInteger::_value_changed(int64_t val) { if (setting) { @@ -1406,7 +1305,7 @@ EditorPropertyInteger::EditorPropertyInteger() { void EditorPropertyObjectID::_set_read_only(bool p_read_only) { edit->set_disabled(p_read_only); -}; +} void EditorPropertyObjectID::_edit_pressed() { emit_signal(SNAME("object_id_selected"), get_edited_property(), get_edited_object()->get(get_edited_property())); @@ -1496,7 +1395,7 @@ EditorPropertyCallable::EditorPropertyCallable() { void EditorPropertyFloat::_set_read_only(bool p_read_only) { spin->set_read_only(p_read_only); -}; +} void EditorPropertyFloat::_value_changed(double val) { if (setting) { @@ -1546,7 +1445,7 @@ EditorPropertyFloat::EditorPropertyFloat() { void EditorPropertyEasing::_set_read_only(bool p_read_only) { spin->set_read_only(p_read_only); -}; +} void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) { if (is_read_only()) { @@ -1577,7 +1476,7 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) { const Ref<InputEventMouseMotion> mm = p_ev; - if (dragging && mm.is_valid() && (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) { + if (dragging && mm.is_valid() && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) { float rel = mm->get_relative().x; if (rel == 0) { return; @@ -1769,7 +1668,7 @@ void EditorPropertyVector2::_set_read_only(bool p_read_only) { for (int i = 0; i < 2; i++) { spin[i]->set_read_only(p_read_only); } -}; +} void EditorPropertyVector2::_value_changed(double val, const String &p_name) { if (setting) { @@ -1900,7 +1799,7 @@ void EditorPropertyRect2::_set_read_only(bool p_read_only) { for (int i = 0; i < 4; i++) { spin[i]->set_read_only(p_read_only); } -}; +} void EditorPropertyRect2::_value_changed(double val, const String &p_name) { if (setting) { @@ -2003,7 +1902,7 @@ void EditorPropertyVector3::_set_read_only(bool p_read_only) { for (int i = 0; i < 3; i++) { spin[i]->set_read_only(p_read_only); } -}; +} void EditorPropertyVector3::_value_changed(double val, const String &p_name) { if (setting) { @@ -2182,7 +2081,7 @@ void EditorPropertyVector2i::_set_read_only(bool p_read_only) { for (int i = 0; i < 2; i++) { spin[i]->set_read_only(p_read_only); } -}; +} void EditorPropertyVector2i::_value_changed(double val, const String &p_name) { if (setting) { @@ -2312,7 +2211,7 @@ void EditorPropertyRect2i::_set_read_only(bool p_read_only) { for (int i = 0; i < 4; i++) { spin[i]->set_read_only(p_read_only); } -}; +} void EditorPropertyRect2i::_value_changed(double val, const String &p_name) { if (setting) { @@ -2414,7 +2313,7 @@ void EditorPropertyVector3i::_set_read_only(bool p_read_only) { for (int i = 0; i < 3; i++) { spin[i]->set_read_only(p_read_only); } -}; +} void EditorPropertyVector3i::_value_changed(double val, const String &p_name) { if (setting) { @@ -2564,7 +2463,7 @@ void EditorPropertyPlane::_set_read_only(bool p_read_only) { for (int i = 0; i < 4; i++) { spin[i]->set_read_only(p_read_only); } -}; +} void EditorPropertyPlane::_value_changed(double val, const String &p_name) { if (setting) { @@ -2660,7 +2559,7 @@ void EditorPropertyQuaternion::_set_read_only(bool p_read_only) { for (int i = 0; i < 3; i++) { euler[i]->set_read_only(p_read_only); } -}; +} void EditorPropertyQuaternion::_edit_custom_value() { if (edit_button->is_pressed()) { @@ -2873,7 +2772,7 @@ void EditorPropertyVector4::_set_read_only(bool p_read_only) { for (int i = 0; i < 4; i++) { spin[i]->set_read_only(p_read_only); } -}; +} void EditorPropertyVector4::_value_changed(double val, const String &p_name) { if (setting) { @@ -2963,7 +2862,7 @@ void EditorPropertyVector4i::_set_read_only(bool p_read_only) { for (int i = 0; i < 4; i++) { spin[i]->set_read_only(p_read_only); } -}; +} void EditorPropertyVector4i::_value_changed(double val, const String &p_name) { if (setting) { @@ -3052,7 +2951,7 @@ void EditorPropertyAABB::_set_read_only(bool p_read_only) { for (int i = 0; i < 6; i++) { spin[i]->set_read_only(p_read_only); } -}; +} void EditorPropertyAABB::_value_changed(double val, const String &p_name) { if (setting) { @@ -3135,7 +3034,7 @@ void EditorPropertyTransform2D::_set_read_only(bool p_read_only) { for (int i = 0; i < 6; i++) { spin[i]->set_read_only(p_read_only); } -}; +} void EditorPropertyTransform2D::_value_changed(double val, const String &p_name) { if (setting) { @@ -3226,7 +3125,7 @@ void EditorPropertyBasis::_set_read_only(bool p_read_only) { for (int i = 0; i < 9; i++) { spin[i]->set_read_only(p_read_only); } -}; +} void EditorPropertyBasis::_value_changed(double val, const String &p_name) { if (setting) { @@ -3316,7 +3215,7 @@ void EditorPropertyTransform3D::_set_read_only(bool p_read_only) { for (int i = 0; i < 12; i++) { spin[i]->set_read_only(p_read_only); } -}; +} void EditorPropertyTransform3D::_value_changed(double val, const String &p_name) { if (setting) { @@ -3414,7 +3313,7 @@ void EditorPropertyProjection::_set_read_only(bool p_read_only) { for (int i = 0; i < 12; i++) { spin[i]->set_read_only(p_read_only); } -}; +} void EditorPropertyProjection::_value_changed(double val, const String &p_name) { if (setting) { @@ -3517,7 +3416,7 @@ EditorPropertyProjection::EditorPropertyProjection() { void EditorPropertyColor::_set_read_only(bool p_read_only) { picker->set_disabled(p_read_only); -}; +} void EditorPropertyColor::_color_changed(const Color &p_color) { // Cancel the color change if the current color is identical to the new one. @@ -3787,7 +3686,7 @@ EditorPropertyNodePath::EditorPropertyNodePath() { assign->set_h_size_flags(SIZE_EXPAND_FILL); assign->set_clip_text(true); assign->connect("pressed", callable_mp(this, &EditorPropertyNodePath::_node_assign)); - assign->set_drag_forwarding(this); + assign->set_drag_forwarding_compat(this); hbc->add_child(assign); clear = memnew(Button); @@ -3819,7 +3718,7 @@ EditorPropertyRID::EditorPropertyRID() { void EditorPropertyResource::_set_read_only(bool p_read_only) { resource_picker->set_editable(!p_read_only); -}; +} void EditorPropertyResource::_resource_selected(const Ref<Resource> &p_resource, bool p_inspect) { if (p_resource->is_built_in() && !p_resource->get_path().is_empty()) { @@ -3847,13 +3746,91 @@ void EditorPropertyResource::_resource_selected(const Ref<Resource> &p_resource, } } +static bool _find_recursive_resources(const Variant &v, HashSet<Resource *> &resources_found) { + switch (v.get_type()) { + case Variant::ARRAY: { + Array a = v; + for (int i = 0; i < a.size(); i++) { + Variant v2 = a[i]; + if (v2.get_type() != Variant::ARRAY && v2.get_type() != Variant::DICTIONARY && v2.get_type() != Variant::OBJECT) { + continue; + } + if (_find_recursive_resources(v2, resources_found)) { + return true; + } + } + } break; + case Variant::DICTIONARY: { + Dictionary d = v; + List<Variant> keys; + d.get_key_list(&keys); + for (const Variant &k : keys) { + if (k.get_type() == Variant::ARRAY || k.get_type() == Variant::DICTIONARY || k.get_type() == Variant::OBJECT) { + if (_find_recursive_resources(k, resources_found)) { + return true; + } + } + Variant v2 = d[k]; + if (v2.get_type() == Variant::ARRAY || v2.get_type() == Variant::DICTIONARY || v2.get_type() == Variant::OBJECT) { + if (_find_recursive_resources(v2, resources_found)) { + return true; + } + } + } + } break; + case Variant::OBJECT: { + Ref<Resource> r = v; + + if (r.is_null()) { + return false; + } + + if (resources_found.has(r.ptr())) { + return true; + } + + resources_found.insert(r.ptr()); + + List<PropertyInfo> plist; + r->get_property_list(&plist); + for (const PropertyInfo &pinfo : plist) { + if (!(pinfo.usage & PROPERTY_USAGE_STORAGE)) { + continue; + } + + if (pinfo.type != Variant::ARRAY && pinfo.type != Variant::DICTIONARY && pinfo.type != Variant::OBJECT) { + continue; + } + if (_find_recursive_resources(r->get(pinfo.name), resources_found)) { + return true; + } + } + } break; + default: { + } + } + return false; +} + void EditorPropertyResource::_resource_changed(const Ref<Resource> &p_resource) { - // Make visual script the correct type. - Ref<Script> s = p_resource; + Resource *r = Object::cast_to<Resource>(get_edited_object()); + if (r) { + // Check for recursive setting of resource + HashSet<Resource *> resources_found; + resources_found.insert(r); + bool found = _find_recursive_resources(p_resource, resources_found); + if (found) { + EditorNode::get_singleton()->show_warning(TTR("Recursion detected, unable to assign resource to property.")); + emit_changed(get_edited_property(), Ref<Resource>()); + update_property(); + return; + } + } // The bool is_script applies only to an object's main script. // Changing the value of Script-type exported variables of the main script should not trigger saving/reloading properties. bool is_script = false; + Ref<Script> s = p_resource; if (get_edited_object() && s.is_valid() && get_edited_property() == CoreStringNames::get_singleton()->_script) { is_script = true; InspectorDock::get_singleton()->store_script_properties(get_edited_object()); @@ -3863,7 +3840,7 @@ void EditorPropertyResource::_resource_changed(const Ref<Resource> &p_resource) // Prevent the creation of invalid ViewportTextures when possible. Ref<ViewportTexture> vpt = p_resource; if (vpt.is_valid()) { - Resource *r = Object::cast_to<Resource>(get_edited_object()); + r = Object::cast_to<Resource>(get_edited_object()); if (r && r->get_path().is_resource_file()) { EditorNode::get_singleton()->show_warning(TTR("Can't create a ViewportTexture on resources saved as a file.\nResource needs to belong to a scene.")); emit_changed(get_edited_property(), Ref<Resource>()); @@ -4409,45 +4386,6 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ editor->set_save_mode(); } return editor; - } else if (p_hint == PROPERTY_HINT_METHOD_OF_VARIANT_TYPE || - p_hint == PROPERTY_HINT_METHOD_OF_BASE_TYPE || - p_hint == PROPERTY_HINT_METHOD_OF_INSTANCE || - p_hint == PROPERTY_HINT_METHOD_OF_SCRIPT || - p_hint == PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE || - p_hint == PROPERTY_HINT_PROPERTY_OF_BASE_TYPE || - p_hint == PROPERTY_HINT_PROPERTY_OF_INSTANCE || - p_hint == PROPERTY_HINT_PROPERTY_OF_SCRIPT) { - EditorPropertyMember *editor = memnew(EditorPropertyMember); - - EditorPropertyMember::Type type = EditorPropertyMember::MEMBER_METHOD_OF_BASE_TYPE; - switch (p_hint) { - case PROPERTY_HINT_METHOD_OF_BASE_TYPE: - type = EditorPropertyMember::MEMBER_METHOD_OF_BASE_TYPE; - break; - case PROPERTY_HINT_METHOD_OF_INSTANCE: - type = EditorPropertyMember::MEMBER_METHOD_OF_INSTANCE; - break; - case PROPERTY_HINT_METHOD_OF_SCRIPT: - type = EditorPropertyMember::MEMBER_METHOD_OF_SCRIPT; - break; - case PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE: - type = EditorPropertyMember::MEMBER_PROPERTY_OF_VARIANT_TYPE; - break; - case PROPERTY_HINT_PROPERTY_OF_BASE_TYPE: - type = EditorPropertyMember::MEMBER_PROPERTY_OF_BASE_TYPE; - break; - case PROPERTY_HINT_PROPERTY_OF_INSTANCE: - type = EditorPropertyMember::MEMBER_PROPERTY_OF_INSTANCE; - break; - case PROPERTY_HINT_PROPERTY_OF_SCRIPT: - type = EditorPropertyMember::MEMBER_PROPERTY_OF_SCRIPT; - break; - default: { - } - } - editor->setup(type, p_hint_text); - return editor; - } else { EditorPropertyText *editor = memnew(EditorPropertyText); if (p_hint == PROPERTY_HINT_PLACEHOLDER_TEXT) { diff --git a/editor/editor_properties.h b/editor/editor_properties.h index 03e318b706..a255af30ee 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -203,40 +203,6 @@ public: EditorPropertyClassName(); }; -class EditorPropertyMember : public EditorProperty { - GDCLASS(EditorPropertyMember, EditorProperty); - -public: - enum Type { - MEMBER_METHOD_OF_VARIANT_TYPE, ///< a method of a type - MEMBER_METHOD_OF_BASE_TYPE, ///< a method of a base type - MEMBER_METHOD_OF_INSTANCE, ///< a method of an instance - MEMBER_METHOD_OF_SCRIPT, ///< a method of a script & base - MEMBER_PROPERTY_OF_VARIANT_TYPE, ///< a property of a type - MEMBER_PROPERTY_OF_BASE_TYPE, ///< a property of a base type - MEMBER_PROPERTY_OF_INSTANCE, ///< a property of an instance - MEMBER_PROPERTY_OF_SCRIPT, ///< a property of a script & base - }; - -private: - Type hint; - PropertySelector *selector = nullptr; - Button *property = nullptr; - String hint_text; - - void _property_selected(const String &p_selected); - void _property_select(); - -protected: - virtual void _set_read_only(bool p_read_only) override; - static void _bind_methods(); - -public: - void setup(Type p_hint, const String &p_hint_text); - virtual void update_property() override; - EditorPropertyMember(); -}; - class EditorPropertyCheck : public EditorProperty { GDCLASS(EditorPropertyCheck, EditorProperty); CheckBox *checkbox = nullptr; diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 10f46283e6..ed667aa7c8 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -715,7 +715,7 @@ EditorPropertyArray::EditorPropertyArray() { edit->set_clip_text(true); edit->connect("pressed", callable_mp(this, &EditorPropertyArray::_edit_pressed)); edit->set_toggle_mode(true); - edit->set_drag_forwarding(this); + edit->set_drag_forwarding_compat(this); edit->connect("draw", callable_mp(this, &EditorPropertyArray::_button_draw)); add_child(edit); add_focusable(edit); diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 94152dfd49..6b733e11f7 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -950,7 +950,7 @@ EditorResourcePicker::EditorResourcePicker(bool p_hide_assign_button_controls) { assign_button->set_flat(true); assign_button->set_h_size_flags(SIZE_EXPAND_FILL); assign_button->set_clip_text(true); - assign_button->set_drag_forwarding(this); + assign_button->set_drag_forwarding_compat(this); add_child(assign_button); assign_button->connect("pressed", callable_mp(this, &EditorResourcePicker::_resource_selected)); assign_button->connect("draw", callable_mp(this, &EditorResourcePicker::_button_draw)); diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp index 5985af21cd..2881302775 100644 --- a/editor/editor_settings_dialog.cpp +++ b/editor/editor_settings_dialog.cpp @@ -793,7 +793,7 @@ EditorSettingsDialog::EditorSettingsDialog() { shortcuts->connect("item_activated", callable_mp(this, &EditorSettingsDialog::_shortcut_cell_double_clicked)); tab_shortcuts->add_child(shortcuts); - shortcuts->set_drag_forwarding(this); + shortcuts->set_drag_forwarding_compat(this); // Adding event dialog shortcut_editor = memnew(InputEventConfigurationDialog); diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index ea03b1c744..177266e366 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -253,6 +253,12 @@ void EditorSpinSlider::_value_input_gui_input(const Ref<InputEvent> &p_event) { value_input_dirty = true; set_process_internal(true); } break; + case Key::ESCAPE: { + value_input_closed_frame = Engine::get_singleton()->get_frames_drawn(); + if (value_input_popup) { + value_input_popup->hide(); + } + } break; default: break; } @@ -479,10 +485,10 @@ void EditorSpinSlider::_notification(int p_what) { } break; case NOTIFICATION_FOCUS_ENTER: { - if ((Input::get_singleton()->is_action_pressed("ui_focus_next") || Input::get_singleton()->is_action_pressed("ui_focus_prev")) && !value_input_just_closed) { + if ((Input::get_singleton()->is_action_pressed("ui_focus_next") || Input::get_singleton()->is_action_pressed("ui_focus_prev")) && value_input_closed_frame != Engine::get_singleton()->get_frames_drawn()) { _focus_entered(); } - value_input_just_closed = false; + value_input_closed_frame = 0; } break; } } @@ -553,7 +559,7 @@ void EditorSpinSlider::_evaluate_input_text() { //text_submitted signal void EditorSpinSlider::_value_input_submitted(const String &p_text) { - value_input_just_closed = true; + value_input_closed_frame = Engine::get_singleton()->get_frames_drawn(); if (value_input_popup) { value_input_popup->hide(); } @@ -562,7 +568,7 @@ void EditorSpinSlider::_value_input_submitted(const String &p_text) { //modal_closed signal void EditorSpinSlider::_value_input_closed() { _evaluate_input_text(); - value_input_just_closed = true; + value_input_closed_frame = Engine::get_singleton()->get_frames_drawn(); } //focus_exited signal @@ -578,7 +584,7 @@ void EditorSpinSlider::_value_focus_exited() { // -> TAB was pressed // -> modal_close was not called // -> need to close/hide manually - if (!value_input_just_closed) { //value_input_just_closed should do the same + if (value_input_closed_frame != Engine::get_singleton()->get_frames_drawn()) { if (value_input_popup) { value_input_popup->hide(); } @@ -672,6 +678,7 @@ void EditorSpinSlider::_ensure_input_popup() { add_child(value_input_popup); value_input = memnew(LineEdit); + value_input->set_focus_mode(FOCUS_CLICK); value_input_popup->add_child(value_input); value_input->set_anchors_and_offsets_preset(PRESET_FULL_RECT); value_input_popup->connect("hidden", callable_mp(this, &EditorSpinSlider::_value_input_closed)); diff --git a/editor/editor_spin_slider.h b/editor/editor_spin_slider.h index 99eb953166..a4d810b18b 100644 --- a/editor/editor_spin_slider.h +++ b/editor/editor_spin_slider.h @@ -65,7 +65,7 @@ class EditorSpinSlider : public Range { Control *value_input_popup = nullptr; LineEdit *value_input = nullptr; - bool value_input_just_closed = false; + uint64_t value_input_closed_frame = 0; bool value_input_dirty = false; bool hide_slider = false; diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 96c8aa6fb5..d8252bed9c 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -133,25 +133,26 @@ void EditorColorMap::create() { add_conversion_color_pair("#0e71fc", "#0350bd"); // New Autotile add_conversion_color_pair("#c6ced4", "#828f9b"); // New Atlas - // Visual script - add_conversion_color_pair("#41ecad", "#25e3a0"); // VisualScript variant - add_conversion_color_pair("#6f91f0", "#6d8eeb"); // VisualScript bool - add_conversion_color_pair("#5abbef", "#4fb2e9"); // VisualScript int - add_conversion_color_pair("#35d4f4", "#27ccf0"); // VisualScript float - add_conversion_color_pair("#4593ec", "#4690e7"); // VisualScript String - add_conversion_color_pair("#ac73f1", "#ad76ee"); // VisualScript Vector2 - add_conversion_color_pair("#f1738f", "#ee758e"); // VisualScript Rect2 - add_conversion_color_pair("#de66f0", "#dc6aed"); // VisualScript Vector3 - add_conversion_color_pair("#b9ec41", "#96ce1a"); // VisualScript Transform2D - add_conversion_color_pair("#f74949", "#f77070"); // VisualScript Plane - add_conversion_color_pair("#ec418e", "#ec69a3"); // VisualScript Quat - add_conversion_color_pair("#ee5677", "#ee7991"); // VisualScript AABB - add_conversion_color_pair("#e1ec41", "#b2bb19"); // VisualScript Basis - add_conversion_color_pair("#f68f45", "#f49047"); // VisualScript Transform - add_conversion_color_pair("#417aec", "#6993ec"); // VisualScript NodePath - add_conversion_color_pair("#41ec80", "#2ce573"); // VisualScript RID - add_conversion_color_pair("#55f3e3", "#12d5c3"); // VisualScript Object - add_conversion_color_pair("#54ed9e", "#57e99f"); // VisualScript Dictionary + // Variant types + add_conversion_color_pair("#41ecad", "#25e3a0"); // Variant + add_conversion_color_pair("#6f91f0", "#6d8eeb"); // bool + add_conversion_color_pair("#5abbef", "#4fb2e9"); // int + add_conversion_color_pair("#35d4f4", "#27ccf0"); // float + add_conversion_color_pair("#4593ec", "#4690e7"); // String + add_conversion_color_pair("#ac73f1", "#ad76ee"); // Vector2 + add_conversion_color_pair("#f1738f", "#ee758e"); // Rect2 + add_conversion_color_pair("#de66f0", "#dc6aed"); // Vector3 + add_conversion_color_pair("#b9ec41", "#96ce1a"); // Transform2D + add_conversion_color_pair("#f74949", "#f77070"); // Plane + add_conversion_color_pair("#ec418e", "#ec69a3"); // Quaternion + add_conversion_color_pair("#ee5677", "#ee7991"); // AABB + add_conversion_color_pair("#e1ec41", "#b2bb19"); // Basis + add_conversion_color_pair("#f68f45", "#f49047"); // Transform3D + add_conversion_color_pair("#417aec", "#6993ec"); // NodePath + add_conversion_color_pair("#41ec80", "#2ce573"); // RID + add_conversion_color_pair("#55f3e3", "#12d5c3"); // Object + add_conversion_color_pair("#54ed9e", "#57e99f"); // Dictionary + // Visual shaders add_conversion_color_pair("#77ce57", "#67c046"); // Vector funcs add_conversion_color_pair("#ea686c", "#d95256"); // Vector transforms diff --git a/editor/editor_title_bar.cpp b/editor/editor_title_bar.cpp index d756606029..0271bbd64a 100644 --- a/editor/editor_title_bar.cpp +++ b/editor/editor_title_bar.cpp @@ -37,7 +37,7 @@ void EditorTitleBar::input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid() && moving) { - if ((mm->get_button_mask() & MouseButton::LEFT) == MouseButton::LEFT) { + if (mm->get_button_mask().has_flag(MouseButtonMask::LEFT)) { Window *w = Object::cast_to<Window>(get_viewport()); if (w) { Point2 mouse = DisplayServer::get_singleton()->mouse_get_position(); diff --git a/editor/event_listener_line_edit.cpp b/editor/event_listener_line_edit.cpp index 3a99c4e264..274fe34c52 100644 --- a/editor/event_listener_line_edit.cpp +++ b/editor/event_listener_line_edit.cpp @@ -168,8 +168,8 @@ void EventListenerLineEdit::clear_event() { } } -void EventListenerLineEdit::set_allowed_input_types(int input_types) { - allowed_input_types = input_types; +void EventListenerLineEdit::set_allowed_input_types(int p_type_masks) { + allowed_input_types = p_type_masks; } int EventListenerLineEdit::get_allowed_input_types() const { diff --git a/editor/event_listener_line_edit.h b/editor/event_listener_line_edit.h index 0679733b6a..aa0cc91d47 100644 --- a/editor/event_listener_line_edit.h +++ b/editor/event_listener_line_edit.h @@ -67,7 +67,7 @@ public: Ref<InputEvent> get_event() const; void clear_event(); - void set_allowed_input_types(int input_types); + void set_allowed_input_types(int p_type_masks); int get_allowed_input_types() const; void grab_focus(); diff --git a/editor/export/project_export.cpp b/editor/export/project_export.cpp index 3e06633cc8..df5d2dcd29 100644 --- a/editor/export/project_export.cpp +++ b/editor/export/project_export.cpp @@ -1023,7 +1023,7 @@ ProjectExportDialog::ProjectExportDialog() { mc->set_v_size_flags(Control::SIZE_EXPAND_FILL); presets = memnew(ItemList); // TODO: Must reimplement drag forwarding. - //presets->set_drag_forwarding(this); + //presets->set_drag_forwarding_compat(this); mc->add_child(presets); presets->connect("item_selected", callable_mp(this, &ProjectExportDialog::_edit_preset)); duplicate_preset = memnew(Button); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index e66be6ce49..6eed3e3e61 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -2599,7 +2599,8 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str String fpath = p_paths[0]; String item_text = fpath.ends_with("/") ? TTR("Open in File Manager") : TTR("Show in File Manager"); - p_popup->add_icon_item(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), item_text, FILE_SHOW_IN_EXPLORER); + p_popup->add_icon_shortcut(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/show_in_explorer"), FILE_SHOW_IN_EXPLORER); + p_popup->set_item_text(p_popup->get_item_index(FILE_SHOW_IN_EXPLORER), item_text); path = fpath; } } @@ -2644,7 +2645,7 @@ void FileSystemDock::_tree_empty_click(const Vector2 &p_pos, MouseButton p_butto tree_popup->add_icon_item(get_theme_icon(SNAME("Object"), SNAME("EditorIcons")), TTR("New Resource..."), FILE_NEW_RESOURCE); tree_popup->add_icon_item(get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")), TTR("New TextFile..."), FILE_NEW_TEXTFILE); tree_popup->add_separator(); - tree_popup->add_icon_item(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), TTR("Open in File Manager"), FILE_SHOW_IN_EXPLORER); + tree_popup->add_icon_shortcut(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/show_in_explorer"), FILE_SHOW_IN_EXPLORER); tree_popup->set_position(tree->get_screen_position() + p_pos); tree_popup->reset_size(); @@ -2704,7 +2705,7 @@ void FileSystemDock::_file_list_empty_clicked(const Vector2 &p_pos, MouseButton file_list_popup->add_icon_item(get_theme_icon(SNAME("Object"), SNAME("EditorIcons")), TTR("New Resource..."), FILE_NEW_RESOURCE); file_list_popup->add_icon_item(get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")), TTR("New TextFile..."), FILE_NEW_TEXTFILE); file_list_popup->add_separator(); - file_list_popup->add_icon_item(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), TTR("Open in File Manager"), FILE_SHOW_IN_EXPLORER); + file_list_popup->add_icon_shortcut(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/show_in_explorer"), FILE_SHOW_IN_EXPLORER); file_list_popup->set_position(files->get_screen_position() + p_pos); file_list_popup->reset_size(); file_list_popup->popup(); @@ -2816,6 +2817,8 @@ void FileSystemDock::_tree_gui_input(Ref<InputEvent> p_event) { _tree_rmb_option(FILE_REMOVE); } else if (ED_IS_SHORTCUT("filesystem_dock/rename", p_event)) { _tree_rmb_option(FILE_RENAME); + } else if (ED_IS_SHORTCUT("filesystem_dock/show_in_explorer", p_event)) { + _tree_rmb_option(FILE_SHOW_IN_EXPLORER); } else if (ED_IS_SHORTCUT("editor/open_search", p_event)) { focus_on_filter(); } else { @@ -2874,6 +2877,8 @@ void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) { _file_list_rmb_option(FILE_REMOVE); } else if (ED_IS_SHORTCUT("filesystem_dock/rename", p_event)) { _file_list_rmb_option(FILE_RENAME); + } else if (ED_IS_SHORTCUT("filesystem_dock/show_in_explorer", p_event)) { + _file_list_rmb_option(FILE_SHOW_IN_EXPLORER); } else if (ED_IS_SHORTCUT("editor/open_search", p_event)) { focus_on_filter(); } else { @@ -3045,6 +3050,7 @@ FileSystemDock::FileSystemDock() { ED_SHORTCUT("filesystem_dock/delete", TTR("Delete"), Key::KEY_DELETE); ED_SHORTCUT("filesystem_dock/rename", TTR("Rename..."), Key::F2); ED_SHORTCUT_OVERRIDE("filesystem_dock/rename", "macos", Key::ENTER); + ED_SHORTCUT("filesystem_dock/show_in_explorer", TTR("Open in File Manager")); VBoxContainer *top_vbc = memnew(VBoxContainer); add_child(top_vbc); @@ -3116,7 +3122,7 @@ FileSystemDock::FileSystemDock() { tree = memnew(Tree); tree->set_hide_root(true); - tree->set_drag_forwarding(this); + tree->set_drag_forwarding_compat(this); tree->set_allow_rmb_select(true); tree->set_select_mode(Tree::SELECT_MULTI); tree->set_custom_minimum_size(Size2(0, 15 * EDSCALE)); @@ -3153,7 +3159,7 @@ FileSystemDock::FileSystemDock() { files = memnew(ItemList); files->set_v_size_flags(SIZE_EXPAND_FILL); files->set_select_mode(ItemList::SELECT_MULTI); - files->set_drag_forwarding(this); + files->set_drag_forwarding_compat(this); files->connect("item_clicked", callable_mp(this, &FileSystemDock::_file_list_item_clicked)); files->connect("gui_input", callable_mp(this, &FileSystemDock::_file_list_gui_input)); files->connect("multi_selected", callable_mp(this, &FileSystemDock::_file_multi_selected)); diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp index a9b43ba5f1..f6ec7da158 100644 --- a/editor/import/scene_import_settings.cpp +++ b/editor/import/scene_import_settings.cpp @@ -849,7 +849,7 @@ void SceneImportSettings::_viewport_input(const Ref<InputEvent> &p_input) { zoom = &md.cam_zoom; } Ref<InputEventMouseMotion> mm = p_input; - if (mm.is_valid() && (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) { + if (mm.is_valid() && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) { (*rot_x) -= mm->get_relative().y * 0.01 * EDSCALE; (*rot_y) -= mm->get_relative().x * 0.01 * EDSCALE; (*rot_x) = CLAMP((*rot_x), -Math_PI / 2, Math_PI / 2); diff --git a/editor/input_event_configuration_dialog.cpp b/editor/input_event_configuration_dialog.cpp index b137f6f668..08d4bfff4a 100644 --- a/editor/input_event_configuration_dialog.cpp +++ b/editor/input_event_configuration_dialog.cpp @@ -515,6 +515,7 @@ Ref<InputEvent> InputEventConfigurationDialog::get_event() const { void InputEventConfigurationDialog::set_allowed_input_types(int p_type_masks) { allowed_input_types = p_type_masks; + event_listener->set_allowed_input_types(p_type_masks); } InputEventConfigurationDialog::InputEventConfigurationDialog() { diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index fbe01c26b0..4cd8976e80 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -35,6 +35,7 @@ #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "editor/editor_undo_redo_manager.h" +#include "editor/filesystem_dock.h" #include "editor/plugins/script_editor_plugin.h" InspectorDock *InspectorDock::singleton = nullptr; @@ -86,6 +87,11 @@ void InspectorDock::_menu_option_confirm(int p_option, bool p_confirmed) { case RESOURCE_EDIT_CLIPBOARD: { _paste_resource(); } break; + case RESOURCE_SHOW_IN_FILESYSTEM: { + Ref<Resource> current_res = _get_current_resource(); + ERR_FAIL_COND(current_res.is_null()); + FileSystemDock::get_singleton()->navigate_to_path(current_res->get_path()); + } break; case OBJECT_REQUEST_HELP: { if (current) { @@ -257,12 +263,8 @@ void InspectorDock::_resource_file_selected(String p_file) { } void InspectorDock::_save_resource(bool save_as) { - ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current(); - Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr; - - ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj)); - - Ref<Resource> current_res = Ref<Resource>(Object::cast_to<Resource>(current_obj)); + Ref<Resource> current_res = _get_current_resource(); + ERR_FAIL_COND(current_res.is_null()); if (save_as) { EditorNode::get_singleton()->save_resource_as(current_res); @@ -272,24 +274,15 @@ void InspectorDock::_save_resource(bool save_as) { } void InspectorDock::_unref_resource() { - ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current(); - Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr; - - ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj)); - - Ref<Resource> current_res = Ref<Resource>(Object::cast_to<Resource>(current_obj)); + Ref<Resource> current_res = _get_current_resource(); + ERR_FAIL_COND(current_res.is_null()); current_res->set_path(""); EditorNode::get_singleton()->edit_current(); } void InspectorDock::_copy_resource() { - ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current(); - Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr; - - ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj)); - - Ref<Resource> current_res = Ref<Resource>(Object::cast_to<Resource>(current_obj)); - + Ref<Resource> current_res = _get_current_resource(); + ERR_FAIL_COND(current_res.is_null()); EditorSettings::get_singleton()->set_resource_clipboard(current_res); } @@ -304,6 +297,16 @@ void InspectorDock::_prepare_resource_extra_popup() { Ref<Resource> r = EditorSettings::get_singleton()->get_resource_clipboard(); PopupMenu *popup = resource_extra_button->get_popup(); popup->set_item_disabled(popup->get_item_index(RESOURCE_EDIT_CLIPBOARD), r.is_null()); + + Ref<Resource> current_res = _get_current_resource(); + ERR_FAIL_COND(current_res.is_null()); + popup->set_item_disabled(popup->get_item_index(RESOURCE_SHOW_IN_FILESYSTEM), current_res->is_built_in()); +} + +Ref<Resource> InspectorDock::_get_current_resource() const { + ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current(); + Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr; + return Ref<Resource>(Object::cast_to<Resource>(current_obj)); } void InspectorDock::_prepare_history() { @@ -662,6 +665,7 @@ InspectorDock::InspectorDock(EditorData &p_editor_data) { resource_extra_button->get_popup()->add_icon_shortcut(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), ED_SHORTCUT("property_editor/copy_resource", TTR("Copy Resource")), RESOURCE_COPY); resource_extra_button->get_popup()->set_item_disabled(1, true); resource_extra_button->get_popup()->add_separator(); + resource_extra_button->get_popup()->add_shortcut(ED_SHORTCUT("property_editor/show_in_filesystem", TTR("Show in FileSystem")), RESOURCE_SHOW_IN_FILESYSTEM); resource_extra_button->get_popup()->add_shortcut(ED_SHORTCUT("property_editor/unref_resource", TTR("Make Resource Built-In")), RESOURCE_MAKE_BUILT_IN); resource_extra_button->get_popup()->set_item_disabled(3, true); resource_extra_button->get_popup()->connect("id_pressed", callable_mp(this, &InspectorDock::_menu_option)); diff --git a/editor/inspector_dock.h b/editor/inspector_dock.h index fb2e1d53b1..c2c1b55fb1 100644 --- a/editor/inspector_dock.h +++ b/editor/inspector_dock.h @@ -51,6 +51,7 @@ class InspectorDock : public VBoxContainer { RESOURCE_LOAD, RESOURCE_SAVE, RESOURCE_SAVE_AS, + RESOURCE_SHOW_IN_FILESYSTEM, RESOURCE_MAKE_BUILT_IN, RESOURCE_COPY, RESOURCE_EDIT_CLIPBOARD, @@ -119,6 +120,7 @@ class InspectorDock : public VBoxContainer { void _copy_resource(); void _paste_resource(); void _prepare_resource_extra_popup(); + Ref<Resource> _get_current_resource() const; void _info_pressed(); void _resource_created(); diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index 3a83d9b9c2..8e94ae871b 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -410,7 +410,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) if (mm.is_valid()) { Vector2 gpoint = mm->get_position(); - if (edited_point.valid() && (wip_active || (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE)) { + if (edited_point.valid() && (wip_active || mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) { Vector2 cpoint = _get_node()->to_local(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint))); //Move the point in a single axis. Should only work when editing a polygon and while holding shift. diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index ec3f2b0f63..85cca23e64 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -200,7 +200,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven _update_edited_point_pos(); } - if (mm.is_valid() && tool_blend->is_pressed() && (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) { + if (mm.is_valid() && tool_blend->is_pressed() && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) { float blend_pos = mm->get_position().x / blend_space_draw->get_size().x; blend_pos *= blend_space->get_max_space() - blend_space->get_min_space(); blend_pos += blend_space->get_min_space(); diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index 00e7f28bb5..c22f0a9f15 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -308,7 +308,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven blend_space_draw->queue_redraw(); } - if (mm.is_valid() && tool_blend->is_pressed() && (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) { + if (mm.is_valid() && tool_blend->is_pressed() && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) { Vector2 blend_pos = (mm->get_position() / blend_space_draw->get_size()); blend_pos.y = 1.0 - blend_pos.y; blend_pos *= (blend_space->get_max_space() - blend_space->get_min_space()); diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 0ebc780604..f680993026 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -425,6 +425,11 @@ void AnimationNodeBlendTreeEditor::_connection_from_empty(const String &p_to, in } } +void AnimationNodeBlendTreeEditor::_popup_hide() { + to_node = ""; + to_slot = -1; +} + void AnimationNodeBlendTreeEditor::_node_dragged(const Vector2 &p_from, const Vector2 &p_to, const StringName &p_which) { updating = true; Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); @@ -1096,6 +1101,7 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() { add_node->set_text(TTR("Add Node...")); graph->get_zoom_hbox()->move_child(add_node, 0); add_node->get_popup()->connect("id_pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_add_node)); + add_node->get_popup()->connect("popup_hide", callable_mp(this, &AnimationNodeBlendTreeEditor::_popup_hide), CONNECT_DEFERRED); add_node->connect("about_to_popup", callable_mp(this, &AnimationNodeBlendTreeEditor::_update_options_menu).bind(false)); add_node->set_disabled(read_only); diff --git a/editor/plugins/animation_blend_tree_editor_plugin.h b/editor/plugins/animation_blend_tree_editor_plugin.h index b471d47df6..afb3394238 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.h +++ b/editor/plugins/animation_blend_tree_editor_plugin.h @@ -121,6 +121,7 @@ class AnimationNodeBlendTreeEditor : public AnimationTreeNodeEditorPlugin { void _popup_request(const Vector2 &p_position); void _connection_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_position); void _connection_from_empty(const String &p_to, int p_to_slot, const Vector2 &p_release_position); + void _popup_hide(); void _property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing); diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index ec3eb1a494..10f2ce25d9 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -267,7 +267,7 @@ void AnimationPlayerEditor::_stop_pressed() { return; } - player->stop(false); + player->pause(); play->set_pressed(false); stop->set_pressed(true); } @@ -1155,7 +1155,7 @@ void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_set, bool player->seek_delta(pos, pos - cpos); } else { - player->stop(true); + player->stop(); player->seek(pos, true); } } diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 4ea2f0c561..0de5064a00 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -337,7 +337,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv Ref<InputEventMouseMotion> mm = p_event; // Pan window - if (mm.is_valid() && (mm->get_button_mask() & MouseButton::MASK_MIDDLE) != MouseButton::NONE) { + if (mm.is_valid() && mm->get_button_mask().has_flag(MouseButtonMask::MIDDLE)) { h_scroll->set_value(h_scroll->get_value() - mm->get_relative().x); v_scroll->set_value(v_scroll->get_value() - mm->get_relative().y); } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 24e4aeb358..7f9a23463c 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1322,7 +1322,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { // Drag the pivot (in pivot mode / with V key) if (drag_type == DRAG_NONE) { if ((b.is_valid() && b->is_pressed() && b->get_button_index() == MouseButton::LEFT && tool == TOOL_EDIT_PIVOT) || - (k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_keycode() == Key::V && tool == TOOL_SELECT && k->get_modifiers_mask() == Key::NONE)) { + (k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_keycode() == Key::V && tool == TOOL_SELECT && k->get_modifiers_mask().is_empty())) { List<CanvasItem *> selection = _get_edited_canvas_items(); // Filters the selection with nodes that allow setting the pivot diff --git a/editor/plugins/control_editor_plugin.cpp b/editor/plugins/control_editor_plugin.cpp index 0fff16bf24..ad3e861b79 100644 --- a/editor/plugins/control_editor_plugin.cpp +++ b/editor/plugins/control_editor_plugin.cpp @@ -727,6 +727,7 @@ void ControlEditorToolbar::_anchors_preset_selected(int p_preset) { for (Node *E : selection) { Control *control = Object::cast_to<Control>(E); if (control) { + undo_redo->add_do_property(control, "layout_mode", LayoutMode::LAYOUT_MODE_ANCHORS); undo_redo->add_do_property(control, "anchors_preset", preset); undo_redo->add_undo_method(control, "_edit_set_state", control->_edit_get_state()); } diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index e66c5214a9..bb2bac7c04 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -44,7 +44,7 @@ void MaterialEditor::gui_input(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(p_event.is_null()); Ref<InputEventMouseMotion> mm = p_event; - if (mm.is_valid() && (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) { + if (mm.is_valid() && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) { rot.x -= mm->get_relative().y * 0.01; rot.y -= mm->get_relative().x * 0.01; diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index a9cbec00b5..ee555ae8d4 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -39,7 +39,7 @@ void MeshEditor::gui_input(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(p_event.is_null()); Ref<InputEventMouseMotion> mm = p_event; - if (mm.is_valid() && (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) { + if (mm.is_valid() && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) { rot_x -= mm->get_relative().y * 0.01; rot_y -= mm->get_relative().x * 0.01; if (rot_x < -Math_PI / 2) { diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 1147d5ff8c..4fe1a6c034 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -1911,7 +1911,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } } - if (spatial_editor->get_current_hover_gizmo().is_null() && (m->get_button_mask() & MouseButton::MASK_LEFT) == MouseButton::NONE && !_edit.gizmo.is_valid()) { + if (spatial_editor->get_current_hover_gizmo().is_null() && !m->get_button_mask().has_flag(MouseButtonMask::LEFT) && !_edit.gizmo.is_valid()) { _transform_gizmo_select(_edit.mouse_pos, true); } @@ -1924,7 +1924,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { String n = _edit.gizmo->get_handle_name(_edit.gizmo_handle, _edit.gizmo_handle_secondary); set_message(n + ": " + String(v)); - } else if ((m->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE || _edit.instant) { + } else if (m->get_button_mask().has_flag(MouseButtonMask::LEFT) || _edit.instant) { if (nav_scheme == NAVIGATION_MAYA && m->is_alt_pressed()) { nav_mode = NAVIGATION_ORBIT; } else if (nav_scheme == NAVIGATION_MODO && m->is_alt_pressed() && m->is_shift_pressed()) { @@ -1963,7 +1963,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { update_transform(m->get_position(), _get_key_modifier(m) == Key::SHIFT); } - } else if ((m->get_button_mask() & MouseButton::MASK_RIGHT) != MouseButton::NONE || freelook_active) { + } else if (m->get_button_mask().has_flag(MouseButtonMask::RIGHT) || freelook_active) { if (nav_scheme == NAVIGATION_MAYA && m->is_alt_pressed()) { nav_mode = NAVIGATION_ZOOM; } else if (freelook_active) { @@ -1972,7 +1972,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { nav_mode = NAVIGATION_PAN; } - } else if ((m->get_button_mask() & MouseButton::MASK_MIDDLE) != MouseButton::NONE) { + } else if (m->get_button_mask().has_flag(MouseButtonMask::MIDDLE)) { const Key mod = _get_key_modifier(m); if (nav_scheme == NAVIGATION_GODOT) { if (mod == _get_key_modifier_setting("editors/3d/navigation/pan_modifier")) { @@ -4921,7 +4921,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p c->add_child(viewport); surface = memnew(Control); - surface->set_drag_forwarding(this); + surface->set_drag_forwarding_compat(this); add_child(surface); surface->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); surface->set_clip_contents(true); @@ -7995,7 +7995,7 @@ void Node3DEditor::_update_preview_environment() { void Node3DEditor::_sun_direction_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> mm = p_event; - if (mm.is_valid() && (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) { + if (mm.is_valid() && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) { sun_rotation.x += mm->get_relative().y * (0.02 * EDSCALE); sun_rotation.y -= mm->get_relative().x * (0.02 * EDSCALE); sun_rotation.x = CLAMP(sun_rotation.x, -Math_TAU / 4, Math_TAU / 4); diff --git a/editor/plugins/polygon_3d_editor_plugin.cpp b/editor/plugins/polygon_3d_editor_plugin.cpp index 294aa32444..8dc0ca9431 100644 --- a/editor/plugins/polygon_3d_editor_plugin.cpp +++ b/editor/plugins/polygon_3d_editor_plugin.cpp @@ -313,7 +313,7 @@ EditorPlugin::AfterGUIInput Polygon3DEditor::forward_3d_gui_input(Camera3D *p_ca Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { - if (edited_point != -1 && (wip_active || (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE)) { + if (edited_point != -1 && (wip_active || mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) { Vector2 gpoint = mm->get_position(); Vector3 ray_from = p_camera->project_ray_origin(gpoint); diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index 27cad1cb7e..2a5529e229 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -379,7 +379,7 @@ ResourcePreloaderEditor::ResourcePreloaderEditor() { tree->set_column_expand(1, true); tree->set_v_size_flags(SIZE_EXPAND_FILL); - tree->set_drag_forwarding(this); + tree->set_drag_forwarding_compat(this); vbc->add_child(tree); dialog = memnew(AcceptDialog); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 61bf51b6dc..caa42b677c 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -223,7 +223,6 @@ void ScriptEditorBase::_bind_methods() { ADD_SIGNAL(MethodInfo("request_open_script_at_line", PropertyInfo(Variant::OBJECT, "script"), PropertyInfo(Variant::INT, "line"))); ADD_SIGNAL(MethodInfo("request_save_history")); ADD_SIGNAL(MethodInfo("go_to_help", PropertyInfo(Variant::STRING, "what"))); - // TODO: This signal is no use for VisualScript. ADD_SIGNAL(MethodInfo("search_in_files_requested", PropertyInfo(Variant::STRING, "text"))); ADD_SIGNAL(MethodInfo("replace_in_files_requested", PropertyInfo(Variant::STRING, "text"))); ADD_SIGNAL(MethodInfo("go_to_method", PropertyInfo(Variant::OBJECT, "script"), PropertyInfo(Variant::STRING, "method"))); @@ -2205,8 +2204,7 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col, if (use_external_editor && (EditorDebuggerNode::get_singleton()->get_dump_stack_script() != p_resource || EditorDebuggerNode::get_singleton()->get_debug_with_external_editor()) && - p_resource->get_path().is_resource_file() && - !p_resource->is_class("VisualScript")) { + p_resource->get_path().is_resource_file()) { String path = EDITOR_GET("text_editor/external/exec_path"); String flags = EDITOR_GET("text_editor/external/exec_flags"); @@ -2305,21 +2303,20 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col, se->set_edited_resource(p_resource); - if (!p_resource->is_class("VisualScript")) { - bool highlighter_set = false; - for (int i = 0; i < syntax_highlighters.size(); i++) { - Ref<EditorSyntaxHighlighter> highlighter = syntax_highlighters[i]->_create(); - if (highlighter.is_null()) { - continue; - } - se->add_syntax_highlighter(highlighter); + // Syntax highlighting. + bool highlighter_set = false; + for (int i = 0; i < syntax_highlighters.size(); i++) { + Ref<EditorSyntaxHighlighter> highlighter = syntax_highlighters[i]->_create(); + if (highlighter.is_null()) { + continue; + } + se->add_syntax_highlighter(highlighter); - if (scr != nullptr && !highlighter_set) { - PackedStringArray languages = highlighter->_get_supported_languages(); - if (languages.has(scr->get_language()->get_name())) { - se->set_syntax_highlighter(highlighter); - highlighter_set = true; - } + if (scr != nullptr && !highlighter_set) { + PackedStringArray languages = highlighter->_get_supported_languages(); + if (languages.has(scr->get_language()->get_name())) { + se->set_syntax_highlighter(highlighter); + highlighter_set = true; } } } @@ -2954,15 +2951,18 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co Ref<Resource> res = open_file(file); if (res.is_valid()) { - if (tab_container->get_tab_count() > num_tabs_before) { + const int num_tabs = tab_container->get_tab_count(); + if (num_tabs > num_tabs_before) { tab_container->move_child(tab_container->get_tab_control(tab_container->get_tab_count() - 1), new_index); - num_tabs_before = tab_container->get_tab_count(); - } else { /* Maybe script was already open */ + num_tabs_before = num_tabs; + } else if (num_tabs > 0) { /* Maybe script was already open */ tab_container->move_child(tab_container->get_tab_control(tab_container->get_current_tab()), new_index); } } } - tab_container->set_current_tab(new_index); + if (tab_container->get_tab_count() > 0) { + tab_container->set_current_tab(new_index); + } _update_script_names(); } } @@ -3669,7 +3669,7 @@ ScriptEditor::ScriptEditor() { _sort_list_on_update = true; script_list->connect("item_clicked", callable_mp(this, &ScriptEditor::_script_list_clicked), CONNECT_DEFERRED); script_list->set_allow_rmb_select(true); - script_list->set_drag_forwarding(this); + script_list->set_drag_forwarding_compat(this); context_menu = memnew(PopupMenu); add_child(context_menu); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 9406701ade..4d525cc5a9 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -2167,7 +2167,7 @@ ScriptTextEditor::ScriptTextEditor() { connection_info_dialog = memnew(ConnectionInfoDialog); - code_editor->get_text_editor()->set_drag_forwarding(this); + code_editor->get_text_editor()->set_drag_forwarding_compat(this); } ScriptTextEditor::~ScriptTextEditor() { diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index da6a1ea0af..a822584619 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -451,7 +451,7 @@ ShaderEditorPlugin::ShaderEditorPlugin() { vb->add_child(shader_list); shader_list->connect("item_selected", callable_mp(this, &ShaderEditorPlugin::_shader_selected)); shader_list->connect("item_clicked", callable_mp(this, &ShaderEditorPlugin::_shader_list_clicked)); - shader_list->set_drag_forwarding(this); + shader_list->set_drag_forwarding_compat(this); main_split->add_child(vb); vb->set_custom_minimum_size(Size2(200, 300) * EDSCALE); diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index 0c8fc08795..956150ec69 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -813,7 +813,7 @@ void Skeleton3DEditor::create_editors() { joint_tree->set_v_size_flags(SIZE_EXPAND_FILL); joint_tree->set_h_size_flags(SIZE_EXPAND_FILL); joint_tree->set_allow_rmb_select(true); - joint_tree->set_drag_forwarding(this); + joint_tree->set_drag_forwarding_compat(this); s_con->add_child(joint_tree); pose_editor = memnew(BoneTransformEditor(skeleton)); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 4fa56189bb..7603a5e55d 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -197,7 +197,7 @@ void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) { } const Ref<InputEventMouseMotion> mm = p_event; - if (mm.is_valid() && (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) { + if (mm.is_valid() && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) { // Select by holding down the mouse button on frames. const int idx = _sheet_preview_position_to_frame_index(mm->get_position()); @@ -238,7 +238,7 @@ void SpriteFramesEditor::_sheet_scroll_input(const Ref<InputEvent> &p_event) { } const Ref<InputEventMouseMotion> mm = p_event; - if (mm.is_valid() && (mm->get_button_mask() & MouseButton::MASK_MIDDLE) != MouseButton::NONE) { + if (mm.is_valid() && mm->get_button_mask().has_flag(MouseButtonMask::MIDDLE)) { const Vector2 dragged = Input::get_singleton()->warp_mouse_motion(mm, split_sheet_scroll->get_global_rect()); split_sheet_scroll->set_h_scroll(split_sheet_scroll->get_h_scroll() - dragged.x); split_sheet_scroll->set_v_scroll(split_sheet_scroll->get_v_scroll() - dragged.y); @@ -1408,7 +1408,7 @@ SpriteFramesEditor::SpriteFramesEditor() { frame_list->set_max_columns(0); frame_list->set_icon_mode(ItemList::ICON_MODE_TOP); frame_list->set_max_text_lines(2); - frame_list->set_drag_forwarding(this); + frame_list->set_drag_forwarding_compat(this); frame_list->connect("gui_input", callable_mp(this, &SpriteFramesEditor::_frame_list_gui_input)); frame_list->connect("item_selected", callable_mp(this, &SpriteFramesEditor::_frame_list_item_selected)); diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index f3f0542b9b..ad5881c76f 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -650,7 +650,7 @@ TextEditor::TextEditor() { goto_line_dialog = memnew(GotoLineDialog); add_child(goto_line_dialog); - code_editor->get_text_editor()->set_drag_forwarding(this); + code_editor->get_text_editor()->set_drag_forwarding_compat(this); } TextEditor::~TextEditor() { diff --git a/editor/plugins/text_shader_editor.cpp b/editor/plugins/text_shader_editor.cpp index cd160f8b14..1b29999796 100644 --- a/editor/plugins/text_shader_editor.cpp +++ b/editor/plugins/text_shader_editor.cpp @@ -301,7 +301,9 @@ void ShaderTextEditor::_load_theme_settings() { syntax_highlighter->clear_color_regions(); syntax_highlighter->add_color_region("/*", "*/", comment_color, false); syntax_highlighter->add_color_region("//", "", comment_color, true); - syntax_highlighter->set_disabled_branch_color(comment_color); + + // Disabled preprocessor branches use translucent text color to be easier to distinguish from comments. + syntax_highlighter->set_disabled_branch_color(Color(EDITOR_GET("text_editor/theme/highlighting/text_color")) * Color(1, 1, 1, 0.5)); te->clear_comment_delimiters(); te->add_comment_delimiter("/*", "*/", false); diff --git a/editor/plugins/texture_layered_editor_plugin.cpp b/editor/plugins/texture_layered_editor_plugin.cpp index 9a3b157f5b..816d081617 100644 --- a/editor/plugins/texture_layered_editor_plugin.cpp +++ b/editor/plugins/texture_layered_editor_plugin.cpp @@ -36,7 +36,7 @@ void TextureLayeredEditor::gui_input(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(p_event.is_null()); Ref<InputEventMouseMotion> mm = p_event; - if (mm.is_valid() && (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) { + if (mm.is_valid() && (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) { y_rot += -mm->get_relative().x * 0.01; x_rot += mm->get_relative().y * 0.01; _update_material(); diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index e7dc5d825b..dd4daa45b7 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -2236,7 +2236,7 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() { scene_tiles_list = memnew(ItemList); scene_tiles_list->set_h_size_flags(Control::SIZE_EXPAND_FILL); scene_tiles_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); - scene_tiles_list->set_drag_forwarding(this); + scene_tiles_list->set_drag_forwarding_compat(this); scene_tiles_list->set_select_mode(ItemList::SELECT_MULTI); scene_tiles_list->connect("multi_selected", callable_mp(this, &TileMapEditorTilesPlugin::_scenes_list_multi_selected)); scene_tiles_list->connect("empty_clicked", callable_mp(this, &TileMapEditorTilesPlugin::_scenes_list_lmb_empty_clicked)); diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp index d269a7c0ec..b44cb18dc7 100644 --- a/editor/plugins/tiles/tile_set_editor.cpp +++ b/editor/plugins/tiles/tile_set_editor.cpp @@ -728,7 +728,7 @@ TileSetEditor::TileSetEditor() { sources_list->add_user_signal(MethodInfo("sort_request")); sources_list->connect("sort_request", callable_mp(this, &TileSetEditor::_update_sources_list).bind(-1)); sources_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST); - sources_list->set_drag_forwarding(this); + sources_list->set_drag_forwarding_compat(this); split_container_left_side->add_child(sources_list); HBoxContainer *sources_bottom_actions = memnew(HBoxContainer); diff --git a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp index 5af338caa0..0ff8788626 100644 --- a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp @@ -509,7 +509,7 @@ TileSetScenesCollectionSourceEditor::TileSetScenesCollectionSourceEditor() { scene_tiles_list = memnew(ItemList); scene_tiles_list->set_h_size_flags(SIZE_EXPAND_FILL); scene_tiles_list->set_v_size_flags(SIZE_EXPAND_FILL); - scene_tiles_list->set_drag_forwarding(this); + scene_tiles_list->set_drag_forwarding_compat(this); scene_tiles_list->connect("item_selected", callable_mp(this, &TileSetScenesCollectionSourceEditor::_update_tile_inspector).unbind(1)); scene_tiles_list->connect("item_selected", callable_mp(this, &TileSetScenesCollectionSourceEditor::_update_action_buttons).unbind(1)); scene_tiles_list->connect("item_activated", callable_mp(this, &TileSetScenesCollectionSourceEditor::_scenes_list_item_activated)); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 4cf397ffd0..56dbdb49eb 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -177,8 +177,8 @@ void VisualShaderGraphPlugin::update_node(VisualShader::Type p_type, int p_node_ if (p_type != visual_shader->get_shader_type() || !links.has(p_node_id)) { return; } - remove_node(p_type, p_node_id); - add_node(p_type, p_node_id); + remove_node(p_type, p_node_id, true); + add_node(p_type, p_node_id, true); } void VisualShaderGraphPlugin::set_input_port_default_value(VisualShader::Type p_type, int p_node_id, int p_port_id, Variant p_value) { @@ -305,8 +305,8 @@ void VisualShaderGraphPlugin::update_parameter_refs() { for (KeyValue<int, Link> &E : links) { VisualShaderNodeParameterRef *ref = Object::cast_to<VisualShaderNodeParameterRef>(E.value.visual_node); if (ref) { - remove_node(E.value.type, E.key); - add_node(E.value.type, E.key); + remove_node(E.value.type, E.key, true); + add_node(E.value.type, E.key, true); } } } @@ -356,7 +356,7 @@ void VisualShaderGraphPlugin::update_theme() { vector_expanded_color[3] = editor->get_theme_color(SNAME("axis_w_color"), SNAME("Editor")); // alpha } -void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { +void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool p_just_update) { if (!visual_shader.is_valid() || p_type != visual_shader->get_shader_type()) { return; } @@ -424,7 +424,12 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { graph->add_child(node); node->set_theme(vstheme); editor->_update_created_node(node); - register_link(p_type, p_id, vsnode.ptr(), node); + + if (p_just_update) { + links[p_id].graph_node = node; + } else { + register_link(p_type, p_id, vsnode.ptr(), node); + } if (is_resizable) { size = resizable_node->get_size(); @@ -1038,11 +1043,13 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { } } -void VisualShaderGraphPlugin::remove_node(VisualShader::Type p_type, int p_id) { +void VisualShaderGraphPlugin::remove_node(VisualShader::Type p_type, int p_id, bool p_just_update) { if (visual_shader->get_shader_type() == p_type && links.has(p_id)) { links[p_id].graph_node->get_parent()->remove_child(links[p_id].graph_node); memdelete(links[p_id].graph_node); - links.erase(p_id); + if (!p_just_update) { + links.erase(p_id); + } } } @@ -1913,7 +1920,7 @@ void VisualShaderEditor::_update_graph() { graph_plugin->update_theme(); for (int n_i = 0; n_i < nodes.size(); n_i++) { - graph_plugin->add_node(type, nodes[n_i]); + graph_plugin->add_node(type, nodes[n_i], false); } graph_plugin->make_dirty(false); @@ -2967,8 +2974,8 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, Stri } undo_redo->add_do_method(visual_shader.ptr(), "add_node", type, vsnode, position, id_to_use); undo_redo->add_undo_method(visual_shader.ptr(), "remove_node", type, id_to_use); - undo_redo->add_do_method(graph_plugin.ptr(), "add_node", type, id_to_use); - undo_redo->add_undo_method(graph_plugin.ptr(), "remove_node", type, id_to_use); + undo_redo->add_do_method(graph_plugin.ptr(), "add_node", type, id_to_use, false); + undo_redo->add_undo_method(graph_plugin.ptr(), "remove_node", type, id_to_use, false); VisualShaderNodeExpression *expr = Object::cast_to<VisualShaderNodeExpression>(vsnode.ptr()); if (expr) { @@ -3361,7 +3368,7 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) { undo_redo->add_do_method(visual_shader.ptr(), "remove_node", type, F); undo_redo->add_undo_method(visual_shader.ptr(), "add_node", type, node, visual_shader->get_node_position(type, F), F); - undo_redo->add_undo_method(graph_plugin.ptr(), "add_node", type, F); + undo_redo->add_undo_method(graph_plugin.ptr(), "add_node", type, F, false); VisualShaderNodeParameter *parameter = Object::cast_to<VisualShaderNodeParameter>(node.ptr()); if (parameter) { @@ -3391,7 +3398,7 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) { // delete nodes from the graph for (const int &F : p_nodes) { - undo_redo->add_do_method(graph_plugin.ptr(), "remove_node", type, F); + undo_redo->add_do_method(graph_plugin.ptr(), "remove_node", type, F, false); } // update parameter refs if any parameter has been deleted @@ -4131,7 +4138,7 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, List<CopyItem> &r_items, c } undo_redo->add_do_method(visual_shader.ptr(), "add_node", type, node, item.position + p_offset, id_from); - undo_redo->add_do_method(graph_plugin.ptr(), "add_node", type, id_from); + undo_redo->add_do_method(graph_plugin.ptr(), "add_node", type, id_from, false); added_set.insert(id_from); id_from++; @@ -4153,7 +4160,7 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, List<CopyItem> &r_items, c continue; } undo_redo->add_undo_method(visual_shader.ptr(), "remove_node", type, id_from); - undo_redo->add_undo_method(graph_plugin.ptr(), "remove_node", type, id_from); + undo_redo->add_undo_method(graph_plugin.ptr(), "remove_node", type, id_from, false); id_from++; } @@ -4915,7 +4922,7 @@ VisualShaderEditor::VisualShaderEditor() { graph->set_h_size_flags(SIZE_EXPAND_FILL); graph->set_show_zoom_label(true); add_child(graph); - graph->set_drag_forwarding(this); + graph->set_drag_forwarding_compat(this); float graph_minimap_opacity = EDITOR_GET("editors/visual_editors/minimap_opacity"); graph->set_minimap_opacity(graph_minimap_opacity); float graph_lines_curvature = EDITOR_GET("editors/visual_editors/lines_curvature"); @@ -5146,7 +5153,7 @@ VisualShaderEditor::VisualShaderEditor() { members = memnew(Tree); members_vb->add_child(members); - members->set_drag_forwarding(this); + members->set_drag_forwarding_compat(this); members->set_h_size_flags(SIZE_EXPAND_FILL); members->set_v_size_flags(SIZE_EXPAND_FILL); members->set_hide_root(true); diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index a43d44473f..88f5e3359c 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -119,8 +119,8 @@ public: void make_dirty(bool p_enabled); void update_node(VisualShader::Type p_type, int p_id); void update_node_deferred(VisualShader::Type p_type, int p_node_id); - void add_node(VisualShader::Type p_type, int p_id); - void remove_node(VisualShader::Type p_type, int p_id); + void add_node(VisualShader::Type p_type, int p_id, bool p_just_update); + void remove_node(VisualShader::Type p_type, int p_id, bool p_just_update); void connect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port); void disconnect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port); void show_port_preview(VisualShader::Type p_type, int p_node_id, int p_port_id); diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp index 22d118cd90..8396d50a0e 100644 --- a/editor/project_converter_3_to_4.cpp +++ b/editor/project_converter_3_to_4.cpp @@ -122,9 +122,6 @@ static const char *enum_renames[][2] = { { "JOINT_SLIDER", "JOINT_TYPE_SLIDER" }, // PhysicsServer3D { "KEY_CONTROL", "KEY_CTRL" }, // Globals { "LOOP_PING_PONG", "LOOP_PINGPONG" }, // AudioStreamWAV - { "MATH_RAND", "MATH_RANDF_RANGE" }, // VisualScriptBuiltinFunc - { "MATH_RANDOM", "MATH_RANDI_RANGE" }, // VisualScriptBuiltinFunc - { "MATH_STEPIFY", "MATH_STEP_DECIMALS" }, // VisualScriptBuiltinFunc { "MODE_KINEMATIC", "FREEZE_MODE_KINEMATIC" }, // RigidBody { "MODE_OPEN_ANY", "FILE_MODE_OPEN_ANY" }, // FileDialog { "MODE_OPEN_DIR", "FILE_MODE_OPEN_DIR" }, // FileDialog @@ -239,6 +236,7 @@ static const char *gdscript_function_renames[][2] = { { "body_add_torque", "body_apply_torque" }, // PhysicsServer2D { "bumpmap_to_normalmap", "bump_map_to_normal_map" }, // Image { "can_be_hidden", "_can_be_hidden" }, // EditorNode3DGizmoPlugin + { "can_drop_data", "_can_drop_data" }, // Control { "can_drop_data_fw", "_can_drop_data_fw" }, // ScriptEditor { "can_generate_small_preview", "_can_generate_small_preview" }, // EditorResourcePreviewGenerator { "can_instance", "can_instantiate" }, // PackedScene, Script @@ -265,6 +263,7 @@ static const char *gdscript_function_renames[][2] = { { "delete_char_at_cursor", "delete_char_at_caret" }, // LineEdit { "deselect_items", "deselect_all" }, // FileDialog { "disable_plugin", "_disable_plugin" }, // EditorPlugin + { "drop_data", "_drop_data" }, // Control { "drop_data_fw", "_drop_data_fw" }, // ScriptEditor { "exclude_polygons_2d", "exclude_polygons" }, // Geometry2D { "find_node", "find_child" }, // Node @@ -694,6 +693,7 @@ static const char *csharp_function_renames[][2] = { { "BindChildNodeToBone", "SetBoneChildren" }, // Skeleton3D { "BumpmapToNormalmap", "BumpMapToNormalMap" }, // Image { "CanBeHidden", "_CanBeHidden" }, // EditorNode3DGizmoPlugin + { "CanDropData", "_CanDropData" }, // Control { "CanDropDataFw", "_CanDropDataFw" }, // ScriptEditor { "CanGenerateSmallPreview", "_CanGenerateSmallPreview" }, // EditorResourcePreviewGenerator { "CanInstance", "CanInstantiate" }, // PackedScene, Script @@ -717,6 +717,7 @@ static const char *csharp_function_renames[][2] = { { "DampedStringJointSetParam", "DampedSpringJointSetParam" }, // PhysicsServer2D { "DeleteCharAtCursor", "DeleteCharAtCaret" }, // LineEdit { "DeselectItems", "DeselectAll" }, // FileDialog + { "DropData", "_DropData" }, // Control { "DropDataFw", "_DropDataFw" }, // ScriptEditor { "ExcludePolygons2d", "ExcludePolygons" }, // Geometry2D { "FindScancodeFromString", "FindKeycodeFromString" }, // OS diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index dc755cab41..b4ffc7d78d 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -3008,7 +3008,10 @@ ProjectManager::ProjectManager() { SceneTree::get_singleton()->get_root()->connect("files_dropped", callable_mp(this, &ProjectManager::_files_dropped)); // Define a minimum window size to prevent UI elements from overlapping or being cut off. - DisplayServer::get_singleton()->window_set_min_size(Size2(520, 350) * EDSCALE); + Window *w = Object::cast_to<Window>(SceneTree::get_singleton()->get_root()); + if (w) { + w->set_min_size(Size2(520, 350) * EDSCALE); + } // Resize the bootsplash window based on Editor display scale EDSCALE. float scale_factor = MAX(1, EDSCALE); diff --git a/editor/scene_create_dialog.cpp b/editor/scene_create_dialog.cpp index c1dbd4d6bc..c861fadcf0 100644 --- a/editor/scene_create_dialog.cpp +++ b/editor/scene_create_dialog.cpp @@ -171,7 +171,9 @@ Node *SceneCreateDialog::create_scene_root() { break; case ROOT_USER_INTERFACE: { Control *gui_ctl = memnew(Control); + // Making the root control full rect by default is more useful for resizable UIs. gui_ctl->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); + gui_ctl->set_grow_direction_preset(Control::PRESET_FULL_RECT); root = gui_ctl; } break; case ROOT_OTHER: diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index d2d5f249dd..ac6bceaa55 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1184,7 +1184,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; case TOOL_CREATE_USER_INTERFACE: { Control *node = memnew(Control); - node->set_anchors_and_offsets_preset(PRESET_FULL_RECT); //more useful for resizable UIs. + // Making the root control full rect by default is more useful for resizable UIs. + node->set_anchors_and_offsets_preset(PRESET_FULL_RECT); + node->set_grow_direction_preset(PRESET_FULL_RECT); new_node = node; } break; diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index dad584ea92..2f50172f54 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -1415,7 +1415,7 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope add_child(tree); - tree->set_drag_forwarding(this); + tree->set_drag_forwarding_compat(this); if (p_can_rename) { tree->set_allow_rmb_select(true); tree->connect("item_mouse_selected", callable_mp(this, &SceneTreeEditor::_rmb_select)); |