diff options
Diffstat (limited to 'editor')
46 files changed, 704 insertions, 421 deletions
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 7ffec0835b..530708f3e5 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -1592,7 +1592,7 @@ void AnimationBezierTrackEdit::duplicate_selection() { } Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); - undo_redo->create_action(TTR("Anim Duplicate Keys")); + undo_redo->create_action(TTR("Animation Duplicate Keys")); List<Pair<int, real_t>> new_selection_values; @@ -1638,7 +1638,7 @@ void AnimationBezierTrackEdit::duplicate_selection() { void AnimationBezierTrackEdit::delete_selection() { if (selection.size()) { Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); - undo_redo->create_action(TTR("Anim Delete Keys")); + undo_redo->create_action(TTR("Animation Delete Keys")); for (SelectionSet::Element *E = selection.back(); E; E = E->prev()) { undo_redo->add_do_method(animation.ptr(), "track_remove_key", E->get().first, E->get().second); diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index ecc465ef64..2ee06a0dbd 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -137,7 +137,7 @@ public: setting = true; Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); - undo_redo->create_action(TTR("Anim Change Keyframe Time"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Change Keyframe Time"), UndoRedo::MERGE_ENDS); Variant val = animation->track_get_key_value(track, key); float trans = animation->track_get_key_transition(track, key); @@ -165,7 +165,7 @@ public: float prev_val = animation->track_get_key_transition(track, key); setting = true; Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); - undo_redo->create_action(TTR("Anim Change Transition"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Change Transition"), UndoRedo::MERGE_ENDS); undo_redo->add_do_method(animation.ptr(), "track_set_key_transition", track, key, val); undo_redo->add_undo_method(animation.ptr(), "track_set_key_transition", track, key, prev_val); undo_redo->add_do_method(this, "_update_obj", animation); @@ -221,7 +221,7 @@ public: } setting = true; - undo_redo->create_action(TTR("Anim Change Keyframe Value"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Change Keyframe Value"), UndoRedo::MERGE_ENDS); Variant prev = animation->track_get_key_value(track, key); undo_redo->add_do_method(animation.ptr(), "track_set_key_value", track, key, value); undo_redo->add_undo_method(animation.ptr(), "track_set_key_value", track, key, prev); @@ -281,9 +281,9 @@ public: } if (mergeable) { - undo_redo->create_action(TTR("Anim Change Call"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Change Call"), UndoRedo::MERGE_ENDS); } else { - undo_redo->create_action(TTR("Anim Change Call")); + undo_redo->create_action(TTR("Animation Change Call")); } setting = true; @@ -304,7 +304,7 @@ public: const Variant &value = p_value; setting = true; - undo_redo->create_action(TTR("Anim Change Keyframe Value"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Change Keyframe Value"), UndoRedo::MERGE_ENDS); float prev = animation->bezier_track_get_key_value(track, key); undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_value", track, key, value); undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_value", track, key, prev); @@ -320,7 +320,7 @@ public: const Variant &value = p_value; setting = true; - undo_redo->create_action(TTR("Anim Change Keyframe Value"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Change Keyframe Value"), UndoRedo::MERGE_ENDS); Vector2 prev = animation->bezier_track_get_key_in_handle(track, key); undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_in_handle", track, key, value); undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_in_handle", track, key, prev); @@ -336,7 +336,7 @@ public: const Variant &value = p_value; setting = true; - undo_redo->create_action(TTR("Anim Change Keyframe Value"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Change Keyframe Value"), UndoRedo::MERGE_ENDS); Vector2 prev = animation->bezier_track_get_key_out_handle(track, key); undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_out_handle", track, key, value); undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_out_handle", track, key, prev); @@ -352,7 +352,7 @@ public: const Variant &value = p_value; setting = true; - undo_redo->create_action(TTR("Anim Change Keyframe Value"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Change Keyframe Value"), UndoRedo::MERGE_ENDS); int prev = animation->bezier_track_get_key_handle_mode(track, key); undo_redo->add_do_method(this, "_bezier_track_set_key_handle_mode", animation.ptr(), track, key, value); undo_redo->add_undo_method(this, "_bezier_track_set_key_handle_mode", animation.ptr(), track, key, prev); @@ -369,7 +369,7 @@ public: Ref<AudioStream> stream = p_value; setting = true; - undo_redo->create_action(TTR("Anim Change Keyframe Value"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Change Keyframe Value"), UndoRedo::MERGE_ENDS); Ref<Resource> prev = animation->audio_track_get_key_stream(track, key); undo_redo->add_do_method(animation.ptr(), "audio_track_set_key_stream", track, key, stream); undo_redo->add_undo_method(animation.ptr(), "audio_track_set_key_stream", track, key, prev); @@ -385,7 +385,7 @@ public: float value = p_value; setting = true; - undo_redo->create_action(TTR("Anim Change Keyframe Value"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Change Keyframe Value"), UndoRedo::MERGE_ENDS); float prev = animation->audio_track_get_key_start_offset(track, key); undo_redo->add_do_method(animation.ptr(), "audio_track_set_key_start_offset", track, key, value); undo_redo->add_undo_method(animation.ptr(), "audio_track_set_key_start_offset", track, key, prev); @@ -401,7 +401,7 @@ public: float value = p_value; setting = true; - undo_redo->create_action(TTR("Anim Change Keyframe Value"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Change Keyframe Value"), UndoRedo::MERGE_ENDS); float prev = animation->audio_track_get_key_end_offset(track, key); undo_redo->add_do_method(animation.ptr(), "audio_track_set_key_end_offset", track, key, value); undo_redo->add_undo_method(animation.ptr(), "audio_track_set_key_end_offset", track, key, prev); @@ -418,7 +418,7 @@ public: StringName anim_name = p_value; setting = true; - undo_redo->create_action(TTR("Anim Change Keyframe Value"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Change Keyframe Value"), UndoRedo::MERGE_ENDS); StringName prev = animation->animation_track_get_key_animation(track, key); undo_redo->add_do_method(animation.ptr(), "animation_track_set_key_animation", track, key, anim_name); undo_redo->add_undo_method(animation.ptr(), "animation_track_set_key_animation", track, key, prev); @@ -818,7 +818,7 @@ public: Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); if (!setting) { setting = true; - undo_redo->create_action(TTR("Anim Multi Change Keyframe Time"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Multi Change Keyframe Time"), UndoRedo::MERGE_ENDS); } Variant val = animation->track_get_key_value(track, key); @@ -843,7 +843,7 @@ public: Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); if (!setting) { setting = true; - undo_redo->create_action(TTR("Anim Multi Change Transition"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Multi Change Transition"), UndoRedo::MERGE_ENDS); } undo_redo->add_do_method(animation.ptr(), "track_set_key_transition", track, key, val); undo_redo->add_undo_method(animation.ptr(), "track_set_key_transition", track, key, prev_val); @@ -873,7 +873,7 @@ public: } setting = true; - undo_redo->create_action(vformat(TTR("Anim Multi Change %s"), chan)); + undo_redo->create_action(vformat(TTR("Animation Multi Change %s"), chan)); } undo_redo->add_do_method(animation.ptr(), "track_set_key_value", track, key, p_value); undo_redo->add_undo_method(animation.ptr(), "track_set_key_value", track, key, old); @@ -890,7 +890,7 @@ public: if (!setting) { setting = true; - undo_redo->create_action(TTR("Anim Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS); } Variant prev = animation->track_get_key_value(track, key); undo_redo->add_do_method(animation.ptr(), "track_set_key_value", track, key, value); @@ -948,9 +948,9 @@ public: if (!setting) { if (mergeable) { - undo_redo->create_action(TTR("Anim Multi Change Call"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Multi Change Call"), UndoRedo::MERGE_ENDS); } else { - undo_redo->create_action(TTR("Anim Multi Change Call")); + undo_redo->create_action(TTR("Animation Multi Change Call")); } setting = true; @@ -966,7 +966,7 @@ public: if (!setting) { setting = true; - undo_redo->create_action(TTR("Anim Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS); } float prev = animation->bezier_track_get_key_value(track, key); undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_value", track, key, value); @@ -977,7 +977,7 @@ public: if (!setting) { setting = true; - undo_redo->create_action(TTR("Anim Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS); } Vector2 prev = animation->bezier_track_get_key_in_handle(track, key); undo_redo->add_do_method(this, "_bezier_track_set_key_in_handle", track, key, value); @@ -988,7 +988,7 @@ public: if (!setting) { setting = true; - undo_redo->create_action(TTR("Anim Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS); } Vector2 prev = animation->bezier_track_get_key_out_handle(track, key); undo_redo->add_do_method(this, "_bezier_track_set_key_out_handle", track, key, value); @@ -999,7 +999,7 @@ public: if (!setting) { setting = true; - undo_redo->create_action(TTR("Anim Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS); } int prev = animation->bezier_track_get_key_handle_mode(track, key); undo_redo->add_do_method(this, "_bezier_track_set_key_handle_mode", animation.ptr(), track, key, value); @@ -1013,7 +1013,7 @@ public: if (!setting) { setting = true; - undo_redo->create_action(TTR("Anim Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS); } Ref<Resource> prev = animation->audio_track_get_key_stream(track, key); undo_redo->add_do_method(animation.ptr(), "audio_track_set_key_stream", track, key, stream); @@ -1024,7 +1024,7 @@ public: if (!setting) { setting = true; - undo_redo->create_action(TTR("Anim Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS); } float prev = animation->audio_track_get_key_start_offset(track, key); undo_redo->add_do_method(animation.ptr(), "audio_track_set_key_start_offset", track, key, value); @@ -1035,7 +1035,7 @@ public: if (!setting) { setting = true; - undo_redo->create_action(TTR("Anim Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS); } float prev = animation->audio_track_get_key_end_offset(track, key); undo_redo->add_do_method(animation.ptr(), "audio_track_set_key_end_offset", track, key, value); @@ -1049,7 +1049,7 @@ public: if (!setting) { setting = true; - undo_redo->create_action(TTR("Anim Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Animation Multi Change Keyframe Value"), UndoRedo::MERGE_ENDS); } StringName prev = animation->animation_track_get_key_animation(track, key); undo_redo->add_do_method(animation.ptr(), "animation_track_set_key_animation", track, key, anim_name); @@ -3814,7 +3814,7 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) { void AnimationTrackEditor::_insert_track(bool p_reset_wanted, bool p_create_beziers) { Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); - undo_redo->create_action(TTR("Anim Insert")); + undo_redo->create_action(TTR("Animation Insert Key")); Ref<Animation> reset_anim; if (p_reset_wanted) { @@ -4153,7 +4153,7 @@ Ref<Animation> AnimationTrackEditor::_create_and_get_reset_animation() { void AnimationTrackEditor::_confirm_insert_list() { Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); - undo_redo->create_action(TTR("Anim Create & Insert")); + undo_redo->create_action(TTR("Animation Insert Key")); bool create_reset = insert_confirm_reset->is_visible() && insert_confirm_reset->is_pressed(); Ref<Animation> reset_anim; @@ -4340,7 +4340,6 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD } } created = true; - undo_redo->create_action(TTR("Anim Insert Track & Key")); p_id.track_idx = p_next_tracks.normal; @@ -4349,9 +4348,6 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD if (p_id.type == Animation::TYPE_VALUE) { undo_redo->add_do_method(animation.ptr(), "value_track_set_update_mode", p_id.track_idx, update_mode); } - - } else { - undo_redo->create_action(TTR("Anim Insert Key")); } float time = timeline->get_play_position(); @@ -4422,8 +4418,6 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD } } - undo_redo->commit_action(); - return p_next_tracks; } @@ -5359,7 +5353,7 @@ void AnimationTrackEditor::_select_at_anim(const Ref<Animation> &p_anim, int p_t void AnimationTrackEditor::_move_selection_commit() { Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); - undo_redo->create_action(TTR("Anim Move Keys")); + undo_redo->create_action(TTR("Animation Move Keys")); List<_AnimMoveRestore> to_restore; @@ -5611,7 +5605,7 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { int start_track = transpose ? _get_track_selected() : top_track; Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); - undo_redo->create_action(TTR("Anim Duplicate Keys")); + undo_redo->create_action(TTR("Animation Duplicate Keys")); List<Pair<int, float>> new_selection_values; @@ -5911,7 +5905,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { ERR_FAIL_COND_MSG(s == 0, "Can't scale to 0."); Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); - undo_redo->create_action(TTR("Anim Scale Keys")); + undo_redo->create_action(TTR("Animation Scale Keys")); List<_AnimMoveRestore> to_restore; @@ -6098,7 +6092,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } break; case EDIT_ADD_RESET_KEY: { Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); - undo_redo->create_action(TTR("Anim Add RESET Keys")); + undo_redo->create_action(TTR("Animation Add RESET Keys")); Ref<Animation> reset = _create_and_get_reset_animation(); int reset_tracks = reset->get_track_count(); @@ -6159,7 +6153,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { if (selection.size()) { Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); - undo_redo->create_action(TTR("Anim Delete Keys")); + undo_redo->create_action(TTR("Animation Delete Keys")); for (RBMap<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { undo_redo->add_do_method(animation.ptr(), "track_remove_key", E->key().track, E->key().key); diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 926c01b334..7ae0db7b48 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -873,6 +873,10 @@ void CodeTextEditor::_reset_zoom() { } void CodeTextEditor::_line_col_changed() { + if (!code_complete_timer->is_stopped() && code_complete_timer_line != text_editor->get_caret_line()) { + code_complete_timer->stop(); + } + String line = text_editor->get_line(text_editor->get_caret_line()); int positional_column = 0; @@ -902,6 +906,7 @@ void CodeTextEditor::_line_col_changed() { void CodeTextEditor::_text_changed() { if (text_editor->is_insert_text_operation()) { + code_complete_timer_line = text_editor->get_caret_line(); code_complete_timer->start(); } diff --git a/editor/code_editor.h b/editor/code_editor.h index ded7518287..4d7034fbd0 100644 --- a/editor/code_editor.h +++ b/editor/code_editor.h @@ -158,6 +158,7 @@ class CodeTextEditor : public VBoxContainer { Label *info = nullptr; Timer *idle = nullptr; Timer *code_complete_timer = nullptr; + int code_complete_timer_line = 0; Timer *font_resize_timer = nullptr; int font_resize_val; diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 2bd77bf99c..1f0cc1dc77 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -788,23 +788,7 @@ bool ConnectionsDock::_is_item_signal(TreeItem &p_item) { } bool ConnectionsDock::_is_connection_inherited(Connection &p_connection) { - Node *scene_root = EditorNode::get_singleton()->get_edited_scene(); - Ref<PackedScene> scn = ResourceLoader::load(scene_root->get_scene_file_path()); - ERR_FAIL_NULL_V(scn, false); - - Ref<SceneState> state = scn->get_state(); - ERR_FAIL_NULL_V(state, false); - - Node *source = Object::cast_to<Node>(p_connection.signal.get_object()); - Node *target = Object::cast_to<Node>(p_connection.callable.get_object()); - - const NodePath source_path = scene_root->get_path_to(source); - const NodePath target_path = scene_root->get_path_to(target); - const StringName signal_name = p_connection.signal.get_name(); - const StringName method_name = p_connection.callable.get_method(); - - // If it cannot be found in PackedScene, this connection was inherited. - return !state->has_connection(source_path, signal_name, target_path, method_name, true); + return bool(p_connection.flags & CONNECT_INHERITED); } /* diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 2adab089e4..5292b51032 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -284,8 +284,9 @@ void CreateDialog::_configure_search_option_item(TreeItem *r_item, const String bool can_instantiate = (p_type_category == TypeCategory::CPP_TYPE && ClassDB::can_instantiate(p_type)) || p_type_category == TypeCategory::OTHER_TYPE; + bool is_virtual = ClassDB::class_exists(p_type) && ClassDB::is_virtual(p_type); - if (can_instantiate && !ClassDB::is_virtual(p_type)) { + if (can_instantiate && !is_virtual) { r_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type, icon_fallback)); } else { r_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type, "NodeDisabled")); diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index 14a2640e63..65e73d8df4 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -701,7 +701,7 @@ void DocTools::generate(bool p_basic_types) { if (rt != Variant::NIL) { // Has operator. // Skip String % operator as it's registered separately for each Variant arg type, // we'll add it manually below. - if (i == Variant::STRING && Variant::Operator(j) == Variant::OP_MODULE) { + if ((i == Variant::STRING || i == Variant::STRING_NAME) && Variant::Operator(j) == Variant::OP_MODULE) { continue; } MethodInfo mi; @@ -718,7 +718,7 @@ void DocTools::generate(bool p_basic_types) { } } - if (i == Variant::STRING) { + if (i == Variant::STRING || i == Variant::STRING_NAME) { // We skipped % operator above, and we register it manually once for Variant arg type here. MethodInfo mi; mi.name = "operator %"; diff --git a/editor/editor_command_palette.cpp b/editor/editor_command_palette.cpp index b92b0fca59..609afeb40a 100644 --- a/editor/editor_command_palette.cpp +++ b/editor/editor_command_palette.cpp @@ -38,6 +38,9 @@ EditorCommandPalette *EditorCommandPalette::singleton = nullptr; +static Rect2i prev_rect = Rect2i(); +static bool was_showed = false; + float EditorCommandPalette::_score_path(const String &p_search, const String &p_path) { float score = 0.9f + .1f * (p_search.length() / (float)p_path.length()); @@ -145,6 +148,17 @@ void EditorCommandPalette::_bind_methods() { ClassDB::bind_method(D_METHOD("remove_command", "key_name"), &EditorCommandPalette::remove_command); } +void EditorCommandPalette::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_VISIBILITY_CHANGED: { + if (!is_visible()) { + prev_rect = Rect2i(get_position(), get_size()); + was_showed = true; + } + } break; + } +} + void EditorCommandPalette::_sbox_input(const Ref<InputEvent> &p_ie) { Ref<InputEventKey> k = p_ie; if (k.is_valid()) { @@ -171,12 +185,10 @@ void EditorCommandPalette::_confirmed() { } void EditorCommandPalette::open_popup() { - static bool was_showed = false; - if (!was_showed) { - was_showed = true; - popup_centered_clamped(Size2(600, 440) * EDSCALE, 0.8f); + if (was_showed) { + popup(prev_rect); } else { - show(); + popup_centered_clamped(Size2(600, 440) * EDSCALE, 0.8f); } command_search_box->clear(); diff --git a/editor/editor_command_palette.h b/editor/editor_command_palette.h index 15200552b4..81cf401851 100644 --- a/editor/editor_command_palette.h +++ b/editor/editor_command_palette.h @@ -91,6 +91,7 @@ class EditorCommandPalette : public ConfirmationDialog { protected: static void _bind_methods(); + void _notification(int p_what); public: void open_popup(); diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 678ec04b9d..b98480b594 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -31,7 +31,7 @@ #include "editor_file_system.h" #include "core/config/project_settings.h" -#include "core/extension/native_extension_manager.h" +#include "core/extension/gdextension_manager.h" #include "core/io/file_access.h" #include "core/io/resource_importer.h" #include "core/io/resource_loader.h" @@ -2335,7 +2335,7 @@ ResourceUID::ID EditorFileSystem::_resource_saver_get_resource_id_for_path(const static void _scan_extensions_dir(EditorFileSystemDirectory *d, HashSet<String> &extensions) { int fc = d->get_file_count(); for (int i = 0; i < fc; i++) { - if (d->get_file_type(i) == SNAME("NativeExtension")) { + if (d->get_file_type(i) == SNAME("GDExtension")) { extensions.insert(d->get_file_path(i)); } } @@ -2356,19 +2356,19 @@ bool EditorFileSystem::_scan_extensions() { Vector<String> extensions_removed; for (const String &E : extensions) { - if (!NativeExtensionManager::get_singleton()->is_extension_loaded(E)) { + if (!GDExtensionManager::get_singleton()->is_extension_loaded(E)) { extensions_added.push_back(E); } } - Vector<String> loaded_extensions = NativeExtensionManager::get_singleton()->get_loaded_extensions(); + Vector<String> loaded_extensions = GDExtensionManager::get_singleton()->get_loaded_extensions(); for (int i = 0; i < loaded_extensions.size(); i++) { if (!extensions.has(loaded_extensions[i])) { extensions_removed.push_back(loaded_extensions[i]); } } - String extension_list_config_file = NativeExtension::get_extension_list_config_file(); + String extension_list_config_file = GDExtension::get_extension_list_config_file(); if (extensions.size()) { if (extensions_added.size() || extensions_removed.size()) { //extensions were added or removed Ref<FileAccess> f = FileAccess::open(extension_list_config_file, FileAccess::WRITE); @@ -2385,18 +2385,18 @@ bool EditorFileSystem::_scan_extensions() { bool needs_restart = false; for (int i = 0; i < extensions_added.size(); i++) { - NativeExtensionManager::LoadStatus st = NativeExtensionManager::get_singleton()->load_extension(extensions_added[i]); - if (st == NativeExtensionManager::LOAD_STATUS_FAILED) { + GDExtensionManager::LoadStatus st = GDExtensionManager::get_singleton()->load_extension(extensions_added[i]); + if (st == GDExtensionManager::LOAD_STATUS_FAILED) { EditorNode::get_singleton()->add_io_error("Error loading extension: " + extensions_added[i]); - } else if (st == NativeExtensionManager::LOAD_STATUS_NEEDS_RESTART) { + } else if (st == GDExtensionManager::LOAD_STATUS_NEEDS_RESTART) { needs_restart = true; } } for (int i = 0; i < extensions_removed.size(); i++) { - NativeExtensionManager::LoadStatus st = NativeExtensionManager::get_singleton()->unload_extension(extensions_removed[i]); - if (st == NativeExtensionManager::LOAD_STATUS_FAILED) { + GDExtensionManager::LoadStatus st = GDExtensionManager::get_singleton()->unload_extension(extensions_removed[i]); + if (st == GDExtensionManager::LOAD_STATUS_FAILED) { EditorNode::get_singleton()->add_io_error("Error removing extension: " + extensions_added[i]); - } else if (st == NativeExtensionManager::LOAD_STATUS_NEEDS_RESTART) { + } else if (st == GDExtensionManager::LOAD_STATUS_NEEDS_RESTART) { needs_restart = true; } } diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 6bd67fbcb9..21119048cb 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -55,8 +55,6 @@ void EditorHelp::_update_theme() { qualifier_color = get_theme_color(SNAME("qualifier_color"), SNAME("EditorHelp")); type_color = get_theme_color(SNAME("type_color"), SNAME("EditorHelp")); - class_desc->add_theme_style_override("normal", get_theme_stylebox(SNAME("background"), SNAME("EditorHelp"))); - class_desc->add_theme_style_override("focus", get_theme_stylebox(SNAME("background"), SNAME("EditorHelp"))); class_desc->add_theme_color_override("selection_color", get_theme_color(SNAME("selection_color"), SNAME("EditorHelp"))); class_desc->add_theme_constant_override("line_separation", get_theme_constant(SNAME("line_separation"), SNAME("EditorHelp"))); class_desc->add_theme_constant_override("table_h_separation", get_theme_constant(SNAME("table_h_separation"), SNAME("EditorHelp"))); @@ -196,10 +194,11 @@ void EditorHelp::_class_desc_resized(bool p_force_update_theme) { if (display_margin != new_display_margin || p_force_update_theme) { display_margin = new_display_margin; - Ref<StyleBox> class_desc_stylebox = EditorNode::get_singleton()->get_theme_base()->get_theme_stylebox(SNAME("normal"), SNAME("RichTextLabel"))->duplicate(); + Ref<StyleBox> class_desc_stylebox = EditorNode::get_singleton()->get_theme_base()->get_theme_stylebox(SNAME("background"), SNAME("EditorHelp"))->duplicate(); class_desc_stylebox->set_default_margin(SIDE_LEFT, display_margin); class_desc_stylebox->set_default_margin(SIDE_RIGHT, display_margin); class_desc->add_theme_style_override("normal", class_desc_stylebox); + class_desc->add_theme_style_override("focused", class_desc_stylebox); } } diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index 286dcf4b8e..b48fbb805a 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -443,6 +443,10 @@ bool EditorHelpSearch::Runner::_phase_member_items_init() { } bool EditorHelpSearch::Runner::_phase_member_items() { + if (!iterator_match) { + return true; + } + ClassMatch &match = iterator_match->value; if (!match.doc || match.doc->name.is_empty()) { diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 06e1e8b22e..463e8f6bdc 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -6038,14 +6038,7 @@ EditorNode::EditorNode() { Input *id = Input::get_singleton(); if (id) { - bool found_touchscreen = false; - for (int i = 0; i < DisplayServer::get_singleton()->get_screen_count(); i++) { - if (DisplayServer::get_singleton()->screen_is_touchscreen(i)) { - found_touchscreen = true; - } - } - - if (!found_touchscreen && Input::get_singleton()) { + if (!DisplayServer::get_singleton()->is_touchscreen_available() && Input::get_singleton()) { // Only if no touchscreen ui hint, disable emulation just in case. id->set_emulate_touch_from_mouse(false); } diff --git a/editor/editor_quick_open.cpp b/editor/editor_quick_open.cpp index bb533b88d6..6ddccba0e2 100644 --- a/editor/editor_quick_open.cpp +++ b/editor/editor_quick_open.cpp @@ -34,23 +34,24 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" -void EditorQuickOpen::popup_dialog(const String &p_base, bool p_enable_multi, bool p_dontclear) { +static Rect2i prev_rect = Rect2i(); +static bool was_showed = false; + +void EditorQuickOpen::popup_dialog(const String &p_base, bool p_enable_multi, bool p_dont_clear) { base_type = p_base; allow_multi_select = p_enable_multi; search_options->set_select_mode(allow_multi_select ? Tree::SELECT_MULTI : Tree::SELECT_SINGLE); - static bool was_showed = false; - if (!was_showed) { - was_showed = true; - popup_centered_clamped(Size2(600, 440) * EDSCALE, 0.8f); + if (was_showed) { + popup(prev_rect); } else { - show(); + popup_centered_clamped(Size2(600, 440) * EDSCALE, 0.8f); } EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem(); _build_search_cache(efsd); - if (p_dontclear) { + if (p_dont_clear) { search_box->select_all(); _update_search(); } else { @@ -251,6 +252,13 @@ void EditorQuickOpen::_notification(int p_what) { search_box->set_clear_button_enabled(true); } break; + case NOTIFICATION_VISIBILITY_CHANGED: { + if (!is_visible()) { + prev_rect = Rect2i(get_position(), get_size()); + was_showed = true; + } + } break; + case NOTIFICATION_EXIT_TREE: { disconnect("confirmed", callable_mp(this, &EditorQuickOpen::_confirmed)); } break; diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index 11a8fce9c3..9128143619 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -582,6 +582,7 @@ void EditorSpinSlider::_value_focus_exited() { //tab was pressed } else { //enter, click, esc + grab_focus(); } } diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp index c01db215da..d0dcbc3bfd 100644 --- a/editor/export/editor_export_platform.cpp +++ b/editor/export/editor_export_platform.cpp @@ -32,7 +32,7 @@ #include "core/config/project_settings.h" #include "core/crypto/crypto_core.h" -#include "core/extension/native_extension.h" +#include "core/extension/gdextension.h" #include "core/io/file_access_encrypted.h" #include "core/io/file_access_pack.h" // PACK_HEADER_MAGIC, PACK_FORMAT_VERSION #include "core/io/zip_io.h" @@ -1267,7 +1267,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & } } - String extension_list_config_file = NativeExtension::get_extension_list_config_file(); + String extension_list_config_file = GDExtension::get_extension_list_config_file(); if (FileAccess::exists(extension_list_config_file)) { Vector<uint8_t> array = FileAccess::get_file_as_bytes(extension_list_config_file); err = p_func(p_udata, extension_list_config_file, array, idx, total, enc_in_filters, enc_ex_filters, key); diff --git a/editor/export/editor_export_platform_pc.cpp b/editor/export/editor_export_platform_pc.cpp index 5345346c48..9de2f94900 100644 --- a/editor/export/editor_export_platform_pc.cpp +++ b/editor/export/editor_export_platform_pc.cpp @@ -81,8 +81,8 @@ bool EditorExportPlatformPC::has_valid_export_configuration(const Ref<EditorExpo // Look for export templates (first official, and if defined custom templates). String arch = p_preset->get("binary_format/architecture"); - bool dvalid = exists_export_template(get_template_file_name("template_debug", arch), &err); - bool rvalid = exists_export_template(get_template_file_name("template_release", arch), &err); + bool dvalid = exists_export_template(get_template_file_name("debug", arch), &err); + bool rvalid = exists_export_template(get_template_file_name("release", arch), &err); if (p_preset->get("custom_template/debug") != "") { dvalid = FileAccess::exists(p_preset->get("custom_template/debug")); diff --git a/editor/export/editor_export_plugin.h b/editor/export/editor_export_plugin.h index 3f37ed40be..88eeaf821d 100644 --- a/editor/export/editor_export_plugin.h +++ b/editor/export/editor_export_plugin.h @@ -31,7 +31,7 @@ #ifndef EDITOR_EXPORT_PLUGIN_H #define EDITOR_EXPORT_PLUGIN_H -#include "core/extension/native_extension.h" +#include "core/extension/gdextension.h" #include "editor_export_preset.h" #include "editor_export_shared_object.h" #include "scene/main/node.h" diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 8df5808b11..6316a7f545 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1414,7 +1414,7 @@ void FileSystemDock::_update_dependencies_after_move(const HashMap<String, Strin Error err = ResourceLoader::rename_dependencies(file, p_renames); if (err == OK) { if (ResourceLoader::get_resource_type(file) == "PackedScene") { - EditorNode::get_singleton()->reload_scene(file); + callable_mp(EditorNode::get_singleton(), &EditorNode::reload_scene).bind(file).call_deferred(); } } else { EditorNode::get_singleton()->add_io_error(TTR("Unable to update dependencies:") + "\n" + remaps[i] + "\n"); diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index 666444eaf9..b7e7200b11 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -769,7 +769,7 @@ void FindInFilesPanel::draw_result_text(Object *item_obj, Rect2 rect) { Rect2 match_rect = rect; match_rect.position.x += font->get_string_size(item_text.left(r.begin_trimmed), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).x - 1; - match_rect.size.x = font->get_string_size(_search_text_label->get_text(), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).x + 2; + match_rect.size.x = font->get_string_size(_search_text_label->get_text(), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).x + 1; match_rect.position.y += 1 * EDSCALE; match_rect.size.y -= 2 * EDSCALE; diff --git a/editor/icons/OneWayTile.svg b/editor/icons/OneWayTile.svg new file mode 100644 index 0000000000..273b1a183b --- /dev/null +++ b/editor/icons/OneWayTile.svg @@ -0,0 +1 @@ +<svg clip-rule="evenodd" fill-rule="evenodd" height="16" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m10.958984 1.5-1.4785152 1.4667969-1.4785157 1.46875-1.4804687-1.4667969-1.4785156-1.4667969-.5214844.5136719-.5214844.5136719 2 1.9863281 2 1.984375 2-1.984375 2-1.9824219-.519531-.5175781zm0 8-1.4785152 1.466797-1.4785157 1.46875-1.4804687-1.466797-1.4785156-1.4667969-.5214844.5136719-.5214844.513672 2 1.986328 2 1.984375 2-1.984375 2-1.982422-.519531-.517578z" fill="#fff"/></svg> diff --git a/editor/icons/TileSelection.svg b/editor/icons/TileSelection.svg new file mode 100644 index 0000000000..418382aa1c --- /dev/null +++ b/editor/icons/TileSelection.svg @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + height="5" + viewBox="0 0 5 5" + width="5" + version="1.1" + id="svg10" + sodipodi:docname="TileSelection.svg" + inkscape:version="1.1 (c68e22c387, 2021-05-23)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"> + <defs + id="defs14"> + <linearGradient + id="linearGradient1060" + inkscape:swatch="solid"> + <stop + style="stop-color:#000000;stop-opacity:1;" + offset="0" + id="stop1058" /> + </linearGradient> + </defs> + <sodipodi:namedview + id="namedview12" + pagecolor="#505050" + bordercolor="#ffffff" + borderopacity="1" + inkscape:pageshadow="0" + inkscape:pageopacity="0" + inkscape:pagecheckerboard="1" + showgrid="false" + inkscape:zoom="64" + inkscape:cx="4.3125" + inkscape:cy="1.984375" + inkscape:window-width="3840" + inkscape:window-height="2066" + inkscape:window-x="-11" + inkscape:window-y="-11" + inkscape:window-maximized="1" + inkscape:current-layer="svg10" /> + <rect + style="fill:none;stroke:#ffffff;stroke-width:1.00038;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="rect940" + width="3.9996195" + height="3.999619" + x="0.50019002" + y="0.50019002" /> + <rect + style="fill:none;stroke:#000000;stroke-width:0.999543;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="rect3062" + width="2.000457" + height="2.000457" + x="1.4997715" + y="1.4997715" /> +</svg> diff --git a/editor/plugins/gdextension_export_plugin.h b/editor/plugins/gdextension_export_plugin.h index d62691c76d..41edf9ac75 100644 --- a/editor/plugins/gdextension_export_plugin.h +++ b/editor/plugins/gdextension_export_plugin.h @@ -40,7 +40,7 @@ protected: }; void GDExtensionExportPlugin::_export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) { - if (p_type != "NativeExtension") { + if (p_type != "GDExtension") { return; } @@ -55,7 +55,7 @@ void GDExtensionExportPlugin::_export_file(const String &p_path, const String &p String entry_symbol = config->get_value("configuration", "entry_symbol"); PackedStringArray tags; - String library_path = NativeExtension::find_extension_library( + String library_path = GDExtension::find_extension_library( p_path, config, [p_features](String p_feature) { return p_features.has(p_feature); }, &tags); if (!library_path.is_empty()) { add_shared_object(library_path, tags); @@ -85,7 +85,7 @@ void GDExtensionExportPlugin::_export_file(const String &p_path, const String &p for (const String &E : p_features) { features_vector.append(E); } - ERR_FAIL_MSG(vformat("No suitable library found. The libraries' tags referred to an invalid feature flag. Possible feature flags for your platform: %s", p_path, String(", ").join(tags))); + ERR_FAIL_MSG(vformat("No suitable library found for GDExtension: %s. Possible feature flags for your platform: %s", p_path, String(", ").join(features_vector))); } List<String> dependencies; diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp index 57e8046f32..aec43290f9 100644 --- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp @@ -41,6 +41,7 @@ #include "scene/gui/menu_button.h" #include "scene/resources/concave_polygon_shape_3d.h" #include "scene/resources/convex_polygon_shape_3d.h" +#include "scene/scene_string_names.h" void MeshInstance3DEditor::_node_removed(Node *p_node) { if (p_node == node) { @@ -87,8 +88,8 @@ void MeshInstance3DEditor::_menu_option(int p_option) { ur->add_do_method(node, "add_child", body, true); ur->add_do_method(body, "set_owner", owner); ur->add_do_method(cshape, "set_owner", owner); - ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", body); - ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", cshape); + ur->add_do_method(Node3DEditor::get_singleton(), SceneStringNames::get_singleton()->_request_gizmo, body); + ur->add_do_method(Node3DEditor::get_singleton(), SceneStringNames::get_singleton()->_request_gizmo, cshape); ur->add_do_reference(body); ur->add_undo_method(node, "remove_child", body); ur->commit_action(); @@ -123,8 +124,8 @@ void MeshInstance3DEditor::_menu_option(int p_option) { ur->add_do_method(instance, "add_child", body, true); ur->add_do_method(body, "set_owner", owner); ur->add_do_method(cshape, "set_owner", owner); - ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", body); - ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", cshape); + ur->add_do_method(Node3DEditor::get_singleton(), SceneStringNames::get_singleton()->_request_gizmo, body); + ur->add_do_method(Node3DEditor::get_singleton(), SceneStringNames::get_singleton()->_request_gizmo, cshape); ur->add_do_reference(body); ur->add_undo_method(instance, "remove_child", body); } @@ -158,7 +159,7 @@ void MeshInstance3DEditor::_menu_option(int p_option) { ur->add_do_method(node->get_parent(), "add_child", cshape, true); ur->add_do_method(node->get_parent(), "move_child", cshape, node->get_index() + 1); ur->add_do_method(cshape, "set_owner", owner); - ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", cshape); + ur->add_do_method(Node3DEditor::get_singleton(), SceneStringNames::get_singleton()->_request_gizmo, cshape); ur->add_do_reference(cshape); ur->add_undo_method(node->get_parent(), "remove_child", cshape); ur->commit_action(); @@ -198,7 +199,7 @@ void MeshInstance3DEditor::_menu_option(int p_option) { ur->add_do_method(node->get_parent(), "add_child", cshape, true); ur->add_do_method(node->get_parent(), "move_child", cshape, node->get_index() + 1); ur->add_do_method(cshape, "set_owner", owner); - ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", cshape); + ur->add_do_method(Node3DEditor::get_singleton(), SceneStringNames::get_singleton()->_request_gizmo, cshape); ur->add_do_reference(cshape); ur->add_undo_method(node->get_parent(), "remove_child", cshape); @@ -237,7 +238,7 @@ void MeshInstance3DEditor::_menu_option(int p_option) { ur->add_do_method(node->get_parent(), "add_child", cshape); ur->add_do_method(node->get_parent(), "move_child", cshape, node->get_index() + 1); ur->add_do_method(cshape, "set_owner", owner); - ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", cshape); + ur->add_do_method(Node3DEditor::get_singleton(), SceneStringNames::get_singleton()->_request_gizmo, cshape); ur->add_do_reference(cshape); ur->add_undo_method(node->get_parent(), "remove_child", cshape); } @@ -263,7 +264,7 @@ void MeshInstance3DEditor::_menu_option(int p_option) { ur->add_do_method(node, "add_child", nmi, true); ur->add_do_method(nmi, "set_owner", owner); - ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", nmi); + ur->add_do_method(Node3DEditor::get_singleton(), SceneStringNames::get_singleton()->_request_gizmo, nmi); ur->add_do_reference(nmi); ur->add_undo_method(node, "remove_child", nmi); @@ -498,7 +499,7 @@ void MeshInstance3DEditor::_create_outline_mesh() { ur->add_do_method(node, "add_child", mi, true); ur->add_do_method(mi, "set_owner", owner); - ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", mi); + ur->add_do_method(Node3DEditor::get_singleton(), SceneStringNames::get_singleton()->_request_gizmo, mi); ur->add_do_reference(mi); ur->add_undo_method(node, "remove_child", mi); diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 0af2a13df2..c8b80db334 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -30,6 +30,7 @@ #include "node_3d_editor_gizmos.h" +#include "core/config/project_settings.h" #include "core/math/convex_hull.h" #include "core/math/geometry_2d.h" #include "core/math/geometry_3d.h" @@ -1732,6 +1733,24 @@ Camera3DGizmoPlugin::Camera3DGizmoPlugin() { create_handle_material("handles"); } +Size2i Camera3DGizmoPlugin::_get_viewport_size(Camera3D *p_camera) { + Viewport *viewport = p_camera->get_viewport(); + + Window *window = Object::cast_to<Window>(viewport); + if (window) { + return window->get_size(); + } + + SubViewport *sub_viewport = Object::cast_to<SubViewport>(viewport); + ERR_FAIL_NULL_V(sub_viewport, Size2i()); + + if (sub_viewport == EditorNode::get_singleton()->get_scene_root()) { + return Size2(GLOBAL_GET("display/window/size/viewport_width"), GLOBAL_GET("display/window/size/viewport_height")); + } + + return sub_viewport->get_size(); +} + bool Camera3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { return Object::cast_to<Camera3D>(p_spatial) != nullptr; } @@ -1830,6 +1849,10 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Ref<Material> material = get_material("camera_material", p_gizmo); + const Size2i viewport_size = _get_viewport_size(camera); + const real_t viewport_aspect = viewport_size.x > 0 && viewport_size.y > 0 ? viewport_size.aspect() : 1.0; + const Size2 size_factor = viewport_aspect > 1.0 ? Size2(1.0, 1.0 / viewport_aspect) : Size2(viewport_aspect, 1.0); + #define ADD_TRIANGLE(m_a, m_b, m_c) \ { \ lines.push_back(m_a); \ @@ -1857,10 +1880,11 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { // The real FOV is halved for accurate representation float fov = camera->get_fov() / 2.0; - Vector3 side = Vector3(Math::sin(Math::deg_to_rad(fov)), 0, -Math::cos(Math::deg_to_rad(fov))); - Vector3 nside = side; - nside.x = -nside.x; - Vector3 up = Vector3(0, side.x, 0); + const float hsize = Math::sin(Math::deg_to_rad(fov)); + const float depth = -Math::cos(Math::deg_to_rad(fov)); + Vector3 side = Vector3(hsize * size_factor.x, 0, depth); + Vector3 nside = Vector3(-side.x, side.y, side.z); + Vector3 up = Vector3(0, hsize * size_factor.y, 0); ADD_TRIANGLE(Vector3(), side + up, side - up); ADD_TRIANGLE(Vector3(), nside + up, nside - up); @@ -1868,18 +1892,18 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { ADD_TRIANGLE(Vector3(), side - up, nside - up); handles.push_back(side); - side.x *= 0.25; - nside.x *= 0.25; - Vector3 tup(0, up.y * 3 / 2, side.z); + side.x = MIN(side.x, hsize * 0.25); + nside.x = -side.x; + Vector3 tup(0, up.y + hsize / 2, side.z); ADD_TRIANGLE(tup, side + up, nside + up); - } break; + case Camera3D::PROJECTION_ORTHOGONAL: { float size = camera->get_size(); float hsize = size * 0.5; - Vector3 right(hsize, 0, 0); - Vector3 up(0, hsize, 0); + Vector3 right(hsize * size_factor.x, 0, 0); + Vector3 up(0, hsize * size_factor.y, 0); Vector3 back(0, 0, -1.0); Vector3 front(0, 0, 0); @@ -1890,18 +1914,19 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { handles.push_back(right + back); - right.x *= 0.25; - Vector3 tup(0, up.y * 3 / 2, back.z); + right.x = MIN(right.x, hsize * 0.25); + Vector3 tup(0, up.y + hsize / 2, back.z); ADD_TRIANGLE(tup, right + up + back, -right + up + back); } break; + case Camera3D::PROJECTION_FRUSTUM: { float hsize = camera->get_size() / 2.0; Vector3 side = Vector3(hsize, 0, -camera->get_near()).normalized(); - Vector3 nside = side; - nside.x = -nside.x; - Vector3 up = Vector3(0, side.x, 0); + side.x *= size_factor.x; + Vector3 nside = Vector3(-side.x, side.y, side.z); + Vector3 up = Vector3(0, hsize * size_factor.y, 0); Vector3 offset = Vector3(camera->get_frustum_offset().x, camera->get_frustum_offset().y, 0.0); ADD_TRIANGLE(Vector3(), side + up + offset, side - up + offset); @@ -1909,11 +1934,11 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { ADD_TRIANGLE(Vector3(), side + up + offset, nside + up + offset); ADD_TRIANGLE(Vector3(), side - up + offset, nside - up + offset); - side.x *= 0.25; - nside.x *= 0.25; - Vector3 tup(0, up.y * 3 / 2, side.z); + side.x = MIN(side.x, hsize * 0.25); + nside.x = -side.x; + Vector3 tup(0, up.y + hsize / 2, side.z); ADD_TRIANGLE(tup + offset, side + up + offset, nside + up + offset); - } + } break; } #undef ADD_TRIANGLE @@ -1921,7 +1946,10 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { p_gizmo->add_lines(lines, material); p_gizmo->add_collision_segments(lines); - p_gizmo->add_handles(handles, get_material("handles")); + + if (!handles.is_empty()) { + p_gizmo->add_handles(handles, get_material("handles")); + } } ////// diff --git a/editor/plugins/node_3d_editor_gizmos.h b/editor/plugins/node_3d_editor_gizmos.h index d7e3e03f61..60d44ad787 100644 --- a/editor/plugins/node_3d_editor_gizmos.h +++ b/editor/plugins/node_3d_editor_gizmos.h @@ -264,6 +264,9 @@ public: class Camera3DGizmoPlugin : public EditorNode3DGizmoPlugin { GDCLASS(Camera3DGizmoPlugin, EditorNode3DGizmoPlugin); +private: + static Size2i _get_viewport_size(Camera3D *p_camera); + public: bool has_gizmo(Node3D *p_spatial) override; String get_gizmo_name() const override; diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index c97de80a76..f5dd893377 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -7477,6 +7477,8 @@ void Node3DEditor::_notification(int p_what) { sun_state->set_custom_minimum_size(sun_vb->get_combined_minimum_size()); environ_state->set_custom_minimum_size(environ_vb->get_combined_minimum_size()); + + EditorNode::get_singleton()->connect("project_settings_changed", callable_mp(this, &Node3DEditor::update_all_gizmos).bind(Variant())); } break; case NOTIFICATION_ENTER_TREE: { @@ -7637,6 +7639,13 @@ void Node3DEditor::_request_gizmo(Object *p_obj) { } } +void Node3DEditor::_request_gizmo_for_id(ObjectID p_id) { + Node3D *node = Object::cast_to<Node3D>(ObjectDB::get_instance(p_id)); + if (node) { + _request_gizmo(node); + } +} + void Node3DEditor::_set_subgizmo_selection(Object *p_obj, Ref<Node3DGizmo> p_gizmo, int p_id, Transform3D p_transform) { if (p_id == -1) { _clear_subgizmo_selection(p_obj); @@ -7817,6 +7826,7 @@ void Node3DEditor::_register_all_gizmos() { void Node3DEditor::_bind_methods() { ClassDB::bind_method("_get_editor_data", &Node3DEditor::_get_editor_data); ClassDB::bind_method("_request_gizmo", &Node3DEditor::_request_gizmo); + ClassDB::bind_method("_request_gizmo_for_id", &Node3DEditor::_request_gizmo_for_id); ClassDB::bind_method("_set_subgizmo_selection", &Node3DEditor::_set_subgizmo_selection); ClassDB::bind_method("_clear_subgizmo_selection", &Node3DEditor::_clear_subgizmo_selection); ClassDB::bind_method("_refresh_menu_icons", &Node3DEditor::_refresh_menu_icons); @@ -8420,7 +8430,7 @@ Node3DEditor::Node3DEditor() { EDITOR_DEF("editors/3d/manipulator_gizmo_opacity", 0.9); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::FLOAT, "editors/3d/manipulator_gizmo_opacity", PROPERTY_HINT_RANGE, "0,1,0.01")); EDITOR_DEF_RST("editors/3d/navigation/show_viewport_rotation_gizmo", true); - EDITOR_DEF_RST("editors/3d/navigation/show_viewport_navigation_gizmo", DisplayServer::get_singleton()->screen_is_touchscreen()); + EDITOR_DEF_RST("editors/3d/navigation/show_viewport_navigation_gizmo", DisplayServer::get_singleton()->is_touchscreen_available()); current_hover_gizmo_handle = -1; current_hover_gizmo_handle_secondary = false; diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index ed555d86c3..fc252822c4 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -716,6 +716,7 @@ private: Node3D *selected = nullptr; void _request_gizmo(Object *p_obj); + void _request_gizmo_for_id(ObjectID p_id); void _set_subgizmo_selection(Object *p_obj, Ref<Node3DGizmo> p_gizmo, int p_id, Transform3D p_transform = Transform3D()); void _clear_subgizmo_selection(Object *p_obj = nullptr); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 747fdfd041..38639ac811 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1223,7 +1223,9 @@ void ScriptTextEditor::_edit_option(int p_op) { code_editor->duplicate_selection(); } break; case EDIT_TOGGLE_FOLD_LINE: { - tx->toggle_foldable_line(tx->get_caret_line()); + for (int caret_idx = 0; caret_idx < tx->get_caret_count(); caret_idx++) { + tx->toggle_foldable_line(tx->get_caret_line(caret_idx)); + } tx->queue_redraw(); } break; case EDIT_FOLD_ALL_LINES: { @@ -1291,28 +1293,28 @@ void ScriptTextEditor::_edit_option(int p_op) { } break; case EDIT_EVALUATE: { Expression expression; - Vector<String> lines = code_editor->get_text_editor()->get_selected_text().split("\n"); - PackedStringArray results; - - for (int i = 0; i < lines.size(); i++) { - String line = lines[i]; - String whitespace = line.substr(0, line.size() - line.strip_edges(true, false).size()); //extract the whitespace at the beginning - - if (expression.parse(line) == OK) { - Variant result = expression.execute(Array(), Variant(), false, true); - if (expression.get_error_text().is_empty()) { - results.push_back(whitespace + result.get_construct_string()); + tx->begin_complex_operation(); + for (int caret_idx = 0; caret_idx < tx->get_caret_count(); caret_idx++) { + Vector<String> lines = tx->get_selected_text(caret_idx).split("\n"); + PackedStringArray results; + + for (int i = 0; i < lines.size(); i++) { + String line = lines[i]; + String whitespace = line.substr(0, line.size() - line.strip_edges(true, false).size()); // Extract the whitespace at the beginning. + if (expression.parse(line) == OK) { + Variant result = expression.execute(Array(), Variant(), false, true); + if (expression.get_error_text().is_empty()) { + results.push_back(whitespace + result.get_construct_string()); + } else { + results.push_back(line); + } } else { results.push_back(line); } - } else { - results.push_back(line); } + tx->insert_text_at_caret(String("\n").join(results), caret_idx); } - - code_editor->get_text_editor()->begin_complex_operation(); //prevents creating a two-step undo - code_editor->get_text_editor()->insert_text_at_caret(String("\n").join(results)); - code_editor->get_text_editor()->end_complex_operation(); + tx->end_complex_operation(); } break; case SEARCH_FIND: { code_editor->get_find_replace_bar()->popup_search(); @@ -1327,14 +1329,14 @@ void ScriptTextEditor::_edit_option(int p_op) { code_editor->get_find_replace_bar()->popup_replace(); } break; case SEARCH_IN_FILES: { - String selected_text = code_editor->get_text_editor()->get_selected_text(); + String selected_text = tx->get_selected_text(); // Yep, because it doesn't make sense to instance this dialog for every single script open... // So this will be delegated to the ScriptEditor. emit_signal(SNAME("search_in_files_requested"), selected_text); } break; case REPLACE_IN_FILES: { - String selected_text = code_editor->get_text_editor()->get_selected_text(); + String selected_text = tx->get_selected_text(); emit_signal(SNAME("replace_in_files_requested"), selected_text); } break; @@ -1358,10 +1360,12 @@ void ScriptTextEditor::_edit_option(int p_op) { code_editor->remove_all_bookmarks(); } break; case DEBUG_TOGGLE_BREAKPOINT: { - int line = tx->get_caret_line(); - bool dobreak = !tx->is_line_breakpointed(line); - tx->set_line_as_breakpoint(line, dobreak); - EditorDebuggerNode::get_singleton()->set_breakpoint(script->get_path(), line + 1, dobreak); + for (int caret_idx = 0; caret_idx < tx->get_caret_count(); caret_idx++) { + int line = tx->get_caret_line(caret_idx); + bool dobreak = !tx->is_line_breakpointed(line); + tx->set_line_as_breakpoint(line, dobreak); + EditorDebuggerNode::get_singleton()->set_breakpoint(script->get_path(), line + 1, dobreak); + } } break; case DEBUG_REMOVE_ALL_BREAKPOINTS: { PackedInt32Array bpoints = tx->get_breakpointed_lines(); @@ -1379,26 +1383,14 @@ void ScriptTextEditor::_edit_option(int p_op) { return; } - tx->remove_secondary_carets(); - int line = tx->get_caret_line(); - - // wrap around - if (line >= (int)bpoints[bpoints.size() - 1]) { - tx->unfold_line(bpoints[0]); - tx->set_caret_line(bpoints[0]); - tx->center_viewport_to_caret(); - } else { - for (int i = 0; i < bpoints.size(); i++) { - int bline = bpoints[i]; - if (bline > line) { - tx->unfold_line(bline); - tx->set_caret_line(bline); - tx->center_viewport_to_caret(); - return; - } + int current_line = tx->get_caret_line(); + int bpoint_idx = 0; + if (current_line < (int)bpoints[bpoints.size() - 1]) { + while (bpoint_idx < bpoints.size() && bpoints[bpoint_idx] <= current_line) { + bpoint_idx++; } } - + code_editor->goto_line_centered(bpoints[bpoint_idx]); } break; case DEBUG_GOTO_PREV_BREAKPOINT: { PackedInt32Array bpoints = tx->get_breakpointed_lines(); @@ -1406,25 +1398,14 @@ void ScriptTextEditor::_edit_option(int p_op) { return; } - tx->remove_secondary_carets(); - int line = tx->get_caret_line(); - // wrap around - if (line <= (int)bpoints[0]) { - tx->unfold_line(bpoints[bpoints.size() - 1]); - tx->set_caret_line(bpoints[bpoints.size() - 1]); - tx->center_viewport_to_caret(); - } else { - for (int i = bpoints.size() - 1; i >= 0; i--) { - int bline = bpoints[i]; - if (bline < line) { - tx->unfold_line(bline); - tx->set_caret_line(bline); - tx->center_viewport_to_caret(); - return; - } + int current_line = tx->get_caret_line(); + int bpoint_idx = bpoints.size() - 1; + if (current_line > (int)bpoints[0]) { + while (bpoint_idx >= 0 && bpoints[bpoint_idx] >= current_line) { + bpoint_idx--; } } - + code_editor->goto_line_centered(bpoints[bpoint_idx]); } break; case HELP_CONTEXTUAL: { String text = tx->get_selected_text(0); @@ -1835,7 +1816,7 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { base = _find_node_for_script(base, base, script); } ScriptLanguage::LookupResult result; - if (script->get_language()->lookup_code(code_editor->get_text_editor()->get_text_for_symbol_lookup(), word_at_pos, script->get_path(), base, result) == OK) { + if (script->get_language()->lookup_code(tx->get_text_for_symbol_lookup(), word_at_pos, script->get_path(), base, result) == OK) { open_docs = true; } } diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h index 1ae419053e..4f0894a1a9 100644 --- a/editor/plugins/shader_editor_plugin.h +++ b/editor/plugins/shader_editor_plugin.h @@ -96,6 +96,7 @@ protected: static void _bind_methods(); public: + virtual String get_name() const override { return "Shader"; } virtual void edit(Object *p_object) override; virtual bool handles(Object *p_object) const override; virtual void make_visible(bool p_visible) override; diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index e8bbfd1b91..f79a001efb 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -47,6 +47,7 @@ #include "scene/resources/skeleton_profile.h" #include "scene/resources/sphere_shape_3d.h" #include "scene/resources/surface_tool.h" +#include "scene/scene_string_names.h" void BoneTransformEditor::create_editors() { const Color section_color = get_theme_color(SNAME("prop_subsection"), SNAME("Editor")); @@ -399,8 +400,8 @@ void Skeleton3DEditor::create_physical_skeleton() { ur->add_do_method(physical_bone, "set_joint_type", PhysicalBone3D::JOINT_TYPE_PIN); } - ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", physical_bone); - ur->add_do_method(Node3DEditor::get_singleton(), "_request_gizmo", collision_shape); + ur->add_do_method(Node3DEditor::get_singleton(), SceneStringNames::get_singleton()->_request_gizmo, physical_bone); + ur->add_do_method(Node3DEditor::get_singleton(), SceneStringNames::get_singleton()->_request_gizmo, collision_shape); ur->add_do_reference(physical_bone); ur->add_undo_method(skeleton, "remove_child", physical_bone); diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index baf5e363f8..d6079d6285 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -353,7 +353,9 @@ void TextEditor::_edit_option(int p_op) { code_editor->duplicate_selection(); } break; case EDIT_TOGGLE_FOLD_LINE: { - tx->toggle_foldable_line(tx->get_caret_line()); + for (int caret_idx = 0; caret_idx < tx->get_caret_count(); caret_idx++) { + tx->toggle_foldable_line(tx->get_caret_line(caret_idx)); + } tx->queue_redraw(); } break; case EDIT_FOLD_ALL_LINES: { diff --git a/editor/plugins/tiles/atlas_merging_dialog.cpp b/editor/plugins/tiles/atlas_merging_dialog.cpp index e266d26b73..f892f3637d 100644 --- a/editor/plugins/tiles/atlas_merging_dialog.cpp +++ b/editor/plugins/tiles/atlas_merging_dialog.cpp @@ -236,7 +236,7 @@ void AtlasMergingDialog::update_tile_set(Ref<TileSet> p_tile_set) { if (atlas_source.is_valid()) { Ref<Texture2D> texture = atlas_source->get_texture(); if (texture.is_valid()) { - String item_text = vformat("%s (id:%d)", texture->get_path().get_file(), source_id); + String item_text = vformat(TTR("%s (ID: %d)"), texture->get_path().get_file(), source_id); atlas_merging_atlases_list->add_item(item_text, texture); atlas_merging_atlases_list->set_item_metadata(-1, source_id); } diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index 993f606f2f..57f9b3135a 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -1207,8 +1207,6 @@ TileDataDefaultEditor::TileDataDefaultEditor() { label->set_theme_type_variation("HeaderSmall"); add_child(label); - toolbar->add_child(memnew(VSeparator)); - picker_button = memnew(Button); picker_button->set_flat(true); picker_button->set_toggle_mode(true); @@ -1603,12 +1601,31 @@ void TileDataCollisionEditor::draw_over_tile(CanvasItem *p_canvas_item, Transfor } RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), p_transform); + + Ref<Texture2D> one_way_icon = get_theme_icon(SNAME("OneWayTile"), SNAME("EditorIcons")); for (int i = 0; i < tile_data->get_collision_polygons_count(physics_layer); i++) { Vector<Vector2> polygon = tile_data->get_collision_polygon_points(physics_layer, i); - if (polygon.size() >= 3) { - p_canvas_item->draw_polygon(polygon, color); + if (polygon.size() < 3) { + continue; + } + + p_canvas_item->draw_polygon(polygon, color); + + if (tile_data->is_collision_polygon_one_way(physics_layer, i)) { + PackedVector2Array uvs; + uvs.resize(polygon.size()); + Vector2 size_1 = Vector2(1, 1) / tile_set->get_tile_size(); + + for (int j = 0; j < polygon.size(); j++) { + uvs.write[j] = polygon[j] * size_1 + Vector2(0.5, 0.5); + } + + Vector<Color> color2; + color2.push_back(Color(1, 1, 1, 0.4)); + p_canvas_item->draw_polygon(polygon, color2, uvs, one_way_icon); } } + RenderingServer::get_singleton()->canvas_item_add_set_transform(p_canvas_item->get_canvas_item(), Transform2D()); } @@ -2640,8 +2657,6 @@ TileDataTerrainsEditor::TileDataTerrainsEditor() { add_child(label); // Toolbar - toolbar->add_child(memnew(VSeparator)); - picker_button = memnew(Button); picker_button->set_flat(true); picker_button->set_toggle_mode(true); diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index e622a0817a..0331e3f69e 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -156,7 +156,7 @@ void TileMapEditorTilesPlugin::_update_tile_set_sources_list() { // Common to all type of sources. if (!source->get_name().is_empty()) { - item_text = vformat(TTR("%s (id:%d)"), source->get_name(), source_id); + item_text = vformat(TTR("%s (ID: %d)"), source->get_name(), source_id); } // Atlas source. @@ -165,7 +165,7 @@ void TileMapEditorTilesPlugin::_update_tile_set_sources_list() { texture = atlas_source->get_texture(); if (item_text.is_empty()) { if (texture.is_valid()) { - item_text = vformat("%s (ID: %d)", texture->get_path().get_file(), source_id); + item_text = vformat(TTR("%s (ID: %d)"), texture->get_path().get_file(), source_id); } else { item_text = vformat(TTR("No Texture Atlas Source (ID: %d)"), source_id); } @@ -472,6 +472,7 @@ void TileMapEditorTilesPlugin::_update_theme() { random_tile_toggle->set_icon(tiles_bottom_panel->get_theme_icon(SNAME("RandomNumberGenerator"), SNAME("EditorIcons"))); missing_atlas_texture_icon = tiles_bottom_panel->get_theme_icon(SNAME("TileSet"), SNAME("EditorIcons")); + _update_tile_set_sources_list(); } bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { @@ -1164,7 +1165,7 @@ HashMap<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_bucket_fill(Vecto } // Get surrounding tiles (handles different tile shapes). - TypedArray<Vector2i> around = tile_map->get_surrounding_tiles(coords); + TypedArray<Vector2i> around = tile_map->get_surrounding_cells(coords); for (int i = 0; i < around.size(); i++) { to_check.push_back(around[i]); } @@ -1697,7 +1698,7 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_draw() { if (frame > 0) { color.a *= 0.3; } - tile_atlas_control->draw_rect(atlas->get_tile_texture_region(E.get_atlas_coords(), frame), color, false); + TilesEditorPlugin::draw_selection_rect(tile_atlas_control, atlas->get_tile_texture_region(E.get_atlas_coords(), frame), color); } } } @@ -1705,11 +1706,8 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_draw() { // Draw the hovered tile. if (hovered_tile.get_atlas_coords() != TileSetSource::INVALID_ATLAS_COORDS && hovered_tile.alternative_tile == 0 && !tile_set_dragging_selection) { for (int frame = 0; frame < atlas->get_tile_animation_frames_count(hovered_tile.get_atlas_coords()); frame++) { - Color color = Color(1.0, 1.0, 1.0); - if (frame > 0) { - color.a *= 0.3; - } - tile_atlas_control->draw_rect(atlas->get_tile_texture_region(hovered_tile.get_atlas_coords(), frame), color, false); + Color color = Color(1.0, 0.8, 0.0, frame == 0 ? 0.6 : 0.3); + TilesEditorPlugin::draw_selection_rect(tile_atlas_control, atlas->get_tile_texture_region(hovered_tile.get_atlas_coords(), frame), color); } } @@ -1730,9 +1728,8 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_draw() { } } } - Color selection_rect_color = selection_color.lightened(0.2); for (const Vector2i &E : to_draw) { - tile_atlas_control->draw_rect(atlas->get_tile_texture_region(E), selection_rect_color, false); + TilesEditorPlugin::draw_selection_rect(tile_atlas_control, atlas->get_tile_texture_region(E)); } } } @@ -1881,7 +1878,7 @@ void TileMapEditorTilesPlugin::_tile_alternatives_control_draw() { if (E.source_id == source_id && E.get_atlas_coords() != TileSetSource::INVALID_ATLAS_COORDS && E.alternative_tile > 0) { Rect2i rect = tile_atlas_view->get_alternative_tile_rect(E.get_atlas_coords(), E.alternative_tile); if (rect != Rect2i()) { - alternative_tiles_control->draw_rect(rect, Color(0.2, 0.2, 1.0), false); + TilesEditorPlugin::draw_selection_rect(alternative_tiles_control, rect); } } } @@ -1890,7 +1887,7 @@ void TileMapEditorTilesPlugin::_tile_alternatives_control_draw() { if (hovered_tile.get_atlas_coords() != TileSetSource::INVALID_ATLAS_COORDS && hovered_tile.alternative_tile > 0) { Rect2i rect = tile_atlas_view->get_alternative_tile_rect(hovered_tile.get_atlas_coords(), hovered_tile.alternative_tile); if (rect != Rect2i()) { - alternative_tiles_control->draw_rect(rect, Color(1.0, 1.0, 1.0), false); + TilesEditorPlugin::draw_selection_rect(alternative_tiles_control, rect, Color(1.0, 0.8, 0.0, 0.5)); } } } @@ -2547,7 +2544,7 @@ RBSet<Vector2i> TileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i output.insert(coords); // Get surrounding tiles (handles different tile shapes). - TypedArray<Vector2i> around = tile_map->get_surrounding_tiles(coords); + TypedArray<Vector2i> around = tile_map->get_surrounding_cells(coords); for (int i = 0; i < around.size(); i++) { to_check.push_back(around[i]); } diff --git a/editor/plugins/tiles/tile_proxies_manager_dialog.cpp b/editor/plugins/tiles/tile_proxies_manager_dialog.cpp index 40557f9b8e..b31fb1aa58 100644 --- a/editor/plugins/tiles/tile_proxies_manager_dialog.cpp +++ b/editor/plugins/tiles/tile_proxies_manager_dialog.cpp @@ -77,7 +77,7 @@ void TileProxiesManagerDialog::_delete_selected_bindings() { Vector<int> alternative_level_selected = alternative_level_list->get_selected_items(); for (int i = 0; i < alternative_level_selected.size(); i++) { Array key = alternative_level_list->get_item_metadata(alternative_level_selected[i]); - Array val = tile_set->get_coords_level_tile_proxy(key[0], key[1]); + Array val = tile_set->get_alternative_level_tile_proxy(key[0], key[1], key[2]); undo_redo->add_do_method(*tile_set, "remove_alternative_level_tile_proxy", key[0], key[1], key[2]); undo_redo->add_undo_method(*tile_set, "set_alternative_level_tile_proxy", key[0], key[1], key[2], val[0], val[1], val[2]); } diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index 7ed84423bc..a6cb48cb5d 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -64,11 +64,15 @@ void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::set_id(int p_id) { emit_signal(SNAME("changed"), "id"); } -int TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::get_id() { +int TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::get_id() const { return source_id; } bool TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_set(const StringName &p_name, const Variant &p_value) { + if (p_name == "id") { + set_id(p_value); + return true; + } String name = p_name; if (name == "name") { // Use the resource_name property to store the source's name. @@ -86,6 +90,10 @@ bool TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_get(const StringN if (!tile_set_atlas_source) { return false; } + if (p_name == "id") { + r_ret = get_id(); + return true; + } String name = p_name; if (name == "name") { // Use the resource_name property to store the source's name. @@ -97,6 +105,8 @@ bool TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_get(const StringN } void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_get_property_list(List<PropertyInfo> *p_list) const { + p_list->push_back(PropertyInfo(Variant::NIL, TTR("Atlas"), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_CATEGORY)); + p_list->push_back(PropertyInfo(Variant::INT, "id", PROPERTY_HINT_RANGE, "0," + itos(INT_MAX) + ",1")); p_list->push_back(PropertyInfo(Variant::STRING, "name", PROPERTY_HINT_NONE, "")); p_list->push_back(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D")); p_list->push_back(PropertyInfo(Variant::VECTOR2I, "margins", PROPERTY_HINT_NONE, "suffix:px")); @@ -106,12 +116,6 @@ void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_get_property_list } void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_bind_methods() { - // -- Shape and layout -- - ClassDB::bind_method(D_METHOD("set_id", "id"), &TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::set_id); - ClassDB::bind_method(D_METHOD("get_id"), &TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::get_id); - - ADD_PROPERTY(PropertyInfo(Variant::INT, "id", PROPERTY_HINT_RANGE, "0," + itos(INT_MAX) + ",1"), "set_id", "get_id"); - ADD_SIGNAL(MethodInfo("changed", PropertyInfo(Variant::STRING, "what"))); } @@ -383,11 +387,15 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pro // ID and size related properties. if (tiles.size() == 1) { if (tiles.front()->get().alternative == 0) { - p_list->push_back(PropertyInfo(Variant::VECTOR2I, "atlas_coords", PROPERTY_HINT_NONE, "")); - p_list->push_back(PropertyInfo(Variant::VECTOR2I, "size_in_atlas", PROPERTY_HINT_NONE, "")); + p_list->push_back(PropertyInfo(Variant::NIL, TTR("Base Tile"), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_CATEGORY)); + p_list->push_back(PropertyInfo(Variant::VECTOR2I, "atlas_coords")); + p_list->push_back(PropertyInfo(Variant::VECTOR2I, "size_in_atlas")); } else { - p_list->push_back(PropertyInfo(Variant::INT, "alternative_id", PROPERTY_HINT_NONE, "")); + p_list->push_back(PropertyInfo(Variant::NIL, TTR("Alternative Tile"), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_CATEGORY)); + p_list->push_back(PropertyInfo(Variant::INT, "alternative_id")); } + } else { + p_list->push_back(PropertyInfo(Variant::NIL, TTR("Tiles"), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_CATEGORY)); } // Animation. @@ -443,6 +451,11 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pro HashMap<String, int> counts; // Counts the number of time a property appears (useful for groups that may appear more than once) for (List<PropertyInfo>::Element *E_property = list.front(); E_property; E_property = E_property->next()) { + // Don't show category for TileData. + if (E_property->get().usage & PROPERTY_USAGE_CATEGORY) { + continue; + } + const String &property_string = E_property->get().name; if (!tile_data->is_allowing_transform() && (property_string == "flip_h" || property_string == "flip_v" || property_string == "transpose")) { continue; @@ -566,7 +579,6 @@ void TileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles() { void TileSetAtlasSourceEditor::_update_atlas_source_inspector() { // Update visibility. bool inspector_visible = tools_button_group->get_pressed_button() == tool_setup_atlas_source_button; - atlas_source_inspector_label->set_visible(inspector_visible); atlas_source_inspector->set_visible(inspector_visible); } @@ -576,11 +588,9 @@ void TileSetAtlasSourceEditor::_update_tile_inspector() { if (!selection.is_empty()) { tile_proxy_object->edit(tile_set_atlas_source, selection); } - tile_inspector_label->show(); tile_inspector->set_visible(!selection.is_empty()); tile_inspector_no_tile_selected_label->set_visible(selection.is_empty()); } else { - tile_inspector_label->hide(); tile_inspector->hide(); tile_inspector_no_tile_selected_label->hide(); } @@ -798,6 +808,8 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { tile_data_editor_dropdown_button->set_text(TTR("Select a property editor")); } tile_data_editors_label->set_visible(is_visible); + tile_data_editors_tree->set_visible(is_visible); + tile_data_painting_editor_container->set_visible(is_visible); } void TileSetAtlasSourceEditor::_update_current_tile_data_editor() { @@ -954,21 +966,18 @@ void TileSetAtlasSourceEditor::_update_toolbar() { if (current_tile_data_editor_toolbar) { current_tile_data_editor_toolbar->hide(); } - tool_settings_vsep->show(); tools_settings_erase_button->show(); tool_advanced_menu_buttom->show(); } else if (tools_button_group->get_pressed_button() == tool_select_button) { if (current_tile_data_editor_toolbar) { current_tile_data_editor_toolbar->hide(); } - tool_settings_vsep->hide(); tools_settings_erase_button->hide(); tool_advanced_menu_buttom->hide(); } else if (tools_button_group->get_pressed_button() == tool_paint_button) { if (current_tile_data_editor_toolbar) { current_tile_data_editor_toolbar->show(); } - tool_settings_vsep->hide(); tools_settings_erase_button->hide(); tool_advanced_menu_buttom->hide(); } @@ -1684,10 +1693,6 @@ Array TileSetAtlasSourceEditor::_get_selection_as_array() { } void TileSetAtlasSourceEditor::_tile_atlas_control_draw() { - // Colors. - Color grid_color = EDITOR_GET("editors/tiles_editor/grid_color"); - Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0); - // Draw the selected tile. if (tools_button_group->get_pressed_button() == tool_select_button) { for (const TileSelection &E : selection) { @@ -1695,12 +1700,9 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() { if (selected.alternative == 0) { // Draw the rect. for (int frame = 0; frame < tile_set_atlas_source->get_tile_animation_frames_count(selected.tile); frame++) { - Color color = selection_color; - if (frame > 0) { - color.a *= 0.3; - } + Color color = Color(0.0, 1.0, 0.0, frame == 0 ? 1.0 : 0.3); Rect2 region = tile_set_atlas_source->get_tile_texture_region(selected.tile, frame); - tile_atlas_control->draw_rect(region, color, false); + TilesEditorPlugin::draw_selection_rect(tile_atlas_control, region, color); } } } @@ -1742,7 +1744,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() { // Draw the tiles to be removed. for (const Vector2i &E : drag_modified_tiles) { for (int frame = 0; frame < tile_set_atlas_source->get_tile_animation_frames_count(E); frame++) { - tile_atlas_control->draw_rect(tile_set_atlas_source->get_tile_texture_region(E, frame), Color(0.0, 0.0, 0.0), false); + TilesEditorPlugin::draw_selection_rect(tile_atlas_control, tile_set_atlas_source->get_tile_texture_region(E, frame), Color(0.0, 0.0, 0.0)); } } } else if (drag_type == DRAG_TYPE_RECT_SELECT || drag_type == DRAG_TYPE_REMOVE_TILES_USING_RECT) { @@ -1754,7 +1756,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() { Color color = Color(0.0, 0.0, 0.0); if (drag_type == DRAG_TYPE_RECT_SELECT) { - color = selection_color.lightened(0.2); + color = Color(1.0, 1.0, 0.0); } RBSet<Vector2i> to_paint; @@ -1769,7 +1771,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() { for (const Vector2i &E : to_paint) { Vector2i coords = E; - tile_atlas_control->draw_rect(tile_set_atlas_source->get_tile_texture_region(coords), color, false); + TilesEditorPlugin::draw_selection_rect(tile_atlas_control, tile_set_atlas_source->get_tile_texture_region(coords), color); } } else if (drag_type == DRAG_TYPE_CREATE_TILES_USING_RECT) { // Draw tiles to be created. @@ -1786,7 +1788,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() { Vector2i coords = Vector2i(x, y); if (tile_set_atlas_source->get_tile_at_coords(coords) == TileSetSource::INVALID_ATLAS_COORDS) { Vector2i origin = margins + (coords * (tile_size + separation)); - tile_atlas_control->draw_rect(Rect2i(origin, tile_size), Color(1.0, 1.0, 1.0), false); + TilesEditorPlugin::draw_selection_rect(tile_atlas_control, Rect2i(origin, tile_size)); } } } @@ -1803,7 +1805,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() { Vector2i separation = tile_set_atlas_source->get_separation(); Vector2i tile_size = tile_set_atlas_source->get_texture_region_size(); Vector2i origin = margins + (area.position * (tile_size + separation)); - tile_atlas_control->draw_rect(Rect2i(origin, area.size * tile_size), Color(1.0, 1.0, 1.0), false); + TilesEditorPlugin::draw_selection_rect(tile_atlas_control, Rect2i(origin, area.size * tile_size)); } else { Vector2i grid_size = tile_set_atlas_source->get_atlas_grid_size(); if (hovered_base_tile_coords.x >= 0 && hovered_base_tile_coords.y >= 0 && hovered_base_tile_coords.x < grid_size.x && hovered_base_tile_coords.y < grid_size.y) { @@ -1811,11 +1813,8 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() { if (hovered_tile != TileSetSource::INVALID_ATLAS_COORDS) { // Draw existing hovered tile. for (int frame = 0; frame < tile_set_atlas_source->get_tile_animation_frames_count(hovered_tile); frame++) { - Color color = Color(1.0, 1.0, 1.0); - if (frame > 0) { - color.a *= 0.3; - } - tile_atlas_control->draw_rect(tile_set_atlas_source->get_tile_texture_region(hovered_tile, frame), color, false); + Color color = Color(1.0, 0.8, 0.0, frame == 0 ? 0.6 : 0.3); + TilesEditorPlugin::draw_selection_rect(tile_atlas_control, tile_set_atlas_source->get_tile_texture_region(hovered_tile, frame), color); } } else { // Draw empty tile, only in add/remove tiles mode. @@ -1824,7 +1823,7 @@ void TileSetAtlasSourceEditor::_tile_atlas_control_draw() { Vector2i separation = tile_set_atlas_source->get_separation(); Vector2i tile_size = tile_set_atlas_source->get_texture_region_size(); Vector2i origin = margins + (hovered_base_tile_coords * (tile_size + separation)); - tile_atlas_control->draw_rect(Rect2i(origin, tile_size), Color(1.0, 1.0, 1.0), false); + TilesEditorPlugin::draw_selection_rect(tile_atlas_control, Rect2i(origin, tile_size)); } } } @@ -1976,9 +1975,6 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_mouse_exited() { } void TileSetAtlasSourceEditor::_tile_alternatives_control_draw() { - Color grid_color = EDITOR_GET("editors/tiles_editor/grid_color"); - Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0); - // Update the hovered alternative tile. if (tools_button_group->get_pressed_button() == tool_select_button) { // Draw hovered tile. @@ -1986,7 +1982,7 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_draw() { if (coords != TileSetSource::INVALID_ATLAS_COORDS) { Rect2i rect = tile_atlas_view->get_alternative_tile_rect(coords, hovered_alternative_tile_coords.z); if (rect != Rect2i()) { - alternative_tiles_control->draw_rect(rect, Color(1.0, 1.0, 1.0), false); + TilesEditorPlugin::draw_selection_rect(alternative_tiles_control, rect, Color(1.0, 0.8, 0.0, 0.5)); } } @@ -1996,7 +1992,7 @@ void TileSetAtlasSourceEditor::_tile_alternatives_control_draw() { if (selected.alternative >= 1) { Rect2i rect = tile_atlas_view->get_alternative_tile_rect(selected.tile, selected.alternative); if (rect != Rect2i()) { - alternative_tiles_control->draw_rect(rect, selection_color, false); + TilesEditorPlugin::draw_selection_rect(alternative_tiles_control, rect); } } } @@ -2368,38 +2364,65 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() { set_process_unhandled_key_input(true); set_process_internal(true); - // -- Right side -- - HSplitContainer *split_container_right_side = memnew(HSplitContainer); - split_container_right_side->set_h_size_flags(SIZE_EXPAND_FILL); - add_child(split_container_right_side); - // Middle panel. - ScrollContainer *middle_panel = memnew(ScrollContainer); - middle_panel->set_horizontal_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); - middle_panel->set_custom_minimum_size(Size2(200, 0) * EDSCALE); - split_container_right_side->add_child(middle_panel); - VBoxContainer *middle_vbox_container = memnew(VBoxContainer); - middle_vbox_container->set_h_size_flags(SIZE_EXPAND_FILL); - middle_panel->add_child(middle_vbox_container); + middle_vbox_container->set_custom_minimum_size(Size2(200, 0) * EDSCALE); + add_child(middle_vbox_container); - // Tile inspector. - tile_inspector_label = memnew(Label); - tile_inspector_label->set_text(TTR("Tile Properties:")); - tile_inspector_label->set_theme_type_variation("HeaderSmall"); - middle_vbox_container->add_child(tile_inspector_label); + // -- Toolbox -- + tools_button_group.instantiate(); + tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles).unbind(1)); + tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_tile_id_label).unbind(1)); + tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_atlas_source_inspector).unbind(1)); + tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_tile_inspector).unbind(1)); + tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_tile_data_editors).unbind(1)); + tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_current_tile_data_editor).unbind(1)); + tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_atlas_view).unbind(1)); + tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_toolbar).unbind(1)); + + HBoxContainer *toolbox = memnew(HBoxContainer); + middle_vbox_container->add_child(toolbox); + tool_setup_atlas_source_button = memnew(Button); + tool_setup_atlas_source_button->set_text(TTR("Setup")); + tool_setup_atlas_source_button->set_flat(true); + tool_setup_atlas_source_button->set_toggle_mode(true); + tool_setup_atlas_source_button->set_pressed(true); + tool_setup_atlas_source_button->set_button_group(tools_button_group); + tool_setup_atlas_source_button->set_tooltip_text(TTR("Atlas setup. Add/Remove tiles tool (use the shift key to create big tiles, control for rectangle editing).")); + toolbox->add_child(tool_setup_atlas_source_button); + + tool_select_button = memnew(Button); + tool_select_button->set_text(TTR("Select")); + tool_select_button->set_flat(true); + tool_select_button->set_toggle_mode(true); + tool_select_button->set_pressed(false); + tool_select_button->set_button_group(tools_button_group); + tool_select_button->set_tooltip_text(TTR("Select tiles.")); + toolbox->add_child(tool_select_button); + + tool_paint_button = memnew(Button); + tool_paint_button->set_text(TTR("Paint")); + tool_paint_button->set_flat(true); + tool_paint_button->set_toggle_mode(true); + tool_paint_button->set_button_group(tools_button_group); + tool_paint_button->set_tooltip_text(TTR("Paint properties.")); + toolbox->add_child(tool_paint_button); + + // Tile inspector. tile_proxy_object = memnew(AtlasTileProxyObject(this)); tile_proxy_object->connect("changed", callable_mp(this, &TileSetAtlasSourceEditor::_tile_proxy_object_changed)); tile_inspector = memnew(EditorInspector); - tile_inspector->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); + tile_inspector->set_v_size_flags(SIZE_EXPAND_FILL); + tile_inspector->set_show_categories(true); tile_inspector->edit(tile_proxy_object); tile_inspector->set_use_folding(true); tile_inspector->connect("property_selected", callable_mp(this, &TileSetAtlasSourceEditor::_inspector_property_selected)); middle_vbox_container->add_child(tile_inspector); tile_inspector_no_tile_selected_label = memnew(Label); + tile_inspector_no_tile_selected_label->set_v_size_flags(SIZE_EXPAND | SIZE_SHRINK_CENTER); tile_inspector_no_tile_selected_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); tile_inspector_no_tile_selected_label->set_text(TTR("No tiles selected.")); middle_vbox_container->add_child(tile_inspector_no_tile_selected_label); @@ -2431,77 +2454,22 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() { middle_vbox_container->add_child(tile_data_painting_editor_container); // Atlas source inspector. - atlas_source_inspector_label = memnew(Label); - atlas_source_inspector_label->set_text(TTR("Atlas Properties:")); - atlas_source_inspector_label->set_theme_type_variation("HeaderSmall"); - middle_vbox_container->add_child(atlas_source_inspector_label); - atlas_source_proxy_object = memnew(TileSetAtlasSourceProxyObject()); atlas_source_proxy_object->connect("changed", callable_mp(this, &TileSetAtlasSourceEditor::_atlas_source_proxy_object_changed)); atlas_source_inspector = memnew(EditorInspector); - atlas_source_inspector->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); + atlas_source_inspector->set_v_size_flags(SIZE_EXPAND_FILL); + atlas_source_inspector->set_show_categories(true); atlas_source_inspector->edit(atlas_source_proxy_object); middle_vbox_container->add_child(atlas_source_inspector); - // Right panel. - VBoxContainer *right_panel = memnew(VBoxContainer); - right_panel->set_h_size_flags(SIZE_EXPAND_FILL); - right_panel->set_v_size_flags(SIZE_EXPAND_FILL); - split_container_right_side->add_child(right_panel); - - // -- Dialogs -- - confirm_auto_create_tiles = memnew(AcceptDialog); - confirm_auto_create_tiles->set_title(TTR("Auto Create Tiles in Non-Transparent Texture Regions?")); - confirm_auto_create_tiles->set_text(TTR("The atlas's texture was modified.\nWould you like to automatically create tiles in the atlas?")); - confirm_auto_create_tiles->set_ok_button_text(TTR("Yes")); - confirm_auto_create_tiles->add_cancel_button()->set_text(TTR("No")); - confirm_auto_create_tiles->connect("confirmed", callable_mp(this, &TileSetAtlasSourceEditor::_auto_create_tiles)); - add_child(confirm_auto_create_tiles); - - // -- Toolbox -- - tools_button_group.instantiate(); - tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles).unbind(1)); - tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_tile_id_label).unbind(1)); - tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_atlas_source_inspector).unbind(1)); - tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_tile_inspector).unbind(1)); - tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_tile_data_editors).unbind(1)); - tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_current_tile_data_editor).unbind(1)); - tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_atlas_view).unbind(1)); - tools_button_group->connect("pressed", callable_mp(this, &TileSetAtlasSourceEditor::_update_toolbar).unbind(1)); - - toolbox = memnew(HBoxContainer); - right_panel->add_child(toolbox); - - tool_setup_atlas_source_button = memnew(Button); - tool_setup_atlas_source_button->set_flat(true); - tool_setup_atlas_source_button->set_toggle_mode(true); - tool_setup_atlas_source_button->set_pressed(true); - tool_setup_atlas_source_button->set_button_group(tools_button_group); - tool_setup_atlas_source_button->set_tooltip_text(TTR("Atlas setup. Add/Remove tiles tool (use the shift key to create big tiles, control for rectangle editing).")); - toolbox->add_child(tool_setup_atlas_source_button); - - tool_select_button = memnew(Button); - tool_select_button->set_flat(true); - tool_select_button->set_toggle_mode(true); - tool_select_button->set_pressed(false); - tool_select_button->set_button_group(tools_button_group); - tool_select_button->set_tooltip_text(TTR("Select tiles.")); - toolbox->add_child(tool_select_button); - - tool_paint_button = memnew(Button); - tool_paint_button->set_flat(true); - tool_paint_button->set_toggle_mode(true); - tool_paint_button->set_button_group(tools_button_group); - tool_paint_button->set_tooltip_text(TTR("Paint properties.")); - toolbox->add_child(tool_paint_button); + // -- Right side -- + VBoxContainer *right_vbox_container = memnew(VBoxContainer); + add_child(right_vbox_container); // Tool settings. tool_settings = memnew(HBoxContainer); - toolbox->add_child(tool_settings); - - tool_settings_vsep = memnew(VSeparator); - tool_settings->add_child(tool_settings_vsep); + right_vbox_container->add_child(tool_settings); tool_settings_tile_data_toolbar_container = memnew(HBoxContainer); tool_settings->add_child(tool_settings_tile_data_toolbar_container); @@ -2518,24 +2486,31 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() { tool_advanced_menu_buttom->get_popup()->add_item(TTR("Create Tiles in Non-Transparent Texture Regions"), ADVANCED_AUTO_CREATE_TILES); tool_advanced_menu_buttom->get_popup()->add_item(TTR("Remove Tiles in Fully Transparent Texture Regions"), ADVANCED_AUTO_REMOVE_TILES); tool_advanced_menu_buttom->get_popup()->connect("id_pressed", callable_mp(this, &TileSetAtlasSourceEditor::_menu_option)); - toolbox->add_child(tool_advanced_menu_buttom); + tool_settings->add_child(tool_advanced_menu_buttom); _update_toolbar(); // Right side of toolbar. Control *middle_space = memnew(Control); middle_space->set_h_size_flags(SIZE_EXPAND_FILL); - toolbox->add_child(middle_space); + tool_settings->add_child(middle_space); tool_tile_id_label = memnew(Label); tool_tile_id_label->set_mouse_filter(Control::MOUSE_FILTER_STOP); - toolbox->add_child(tool_tile_id_label); + tool_settings->add_child(tool_tile_id_label); _update_tile_id_label(); + // Right panel. + VBoxContainer *right_panel = memnew(VBoxContainer); + right_panel->set_h_size_flags(SIZE_EXPAND_FILL); + right_panel->set_v_size_flags(SIZE_EXPAND_FILL); + right_vbox_container->add_child(right_panel); + // Tile atlas view. tile_atlas_view = memnew(TileAtlasView); tile_atlas_view->set_h_size_flags(SIZE_EXPAND_FILL); tile_atlas_view->set_v_size_flags(SIZE_EXPAND_FILL); + tile_atlas_view->set_custom_minimum_size(Size2(200, 0) * EDSCALE); tile_atlas_view->connect("transform_changed", callable_mp(TilesEditorPlugin::get_singleton(), &TilesEditorPlugin::set_atlas_view_transform)); tile_atlas_view->connect("transform_changed", callable_mp(this, &TileSetAtlasSourceEditor::_tile_atlas_view_transform_changed).unbind(2)); right_panel->add_child(tile_atlas_view); @@ -2578,17 +2553,17 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() { tile_atlas_view->add_control_over_alternative_tiles(alternative_tiles_control_unscaled, false); alternative_tiles_control_unscaled->set_mouse_filter(Control::MOUSE_FILTER_IGNORE); - tile_atlas_view_missing_source_label = memnew(Label); - tile_atlas_view_missing_source_label->set_text(TTR("Add or select an atlas texture to the left panel.")); - tile_atlas_view_missing_source_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); - tile_atlas_view_missing_source_label->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER); - tile_atlas_view_missing_source_label->set_h_size_flags(SIZE_EXPAND_FILL); - tile_atlas_view_missing_source_label->set_v_size_flags(SIZE_EXPAND_FILL); - tile_atlas_view_missing_source_label->hide(); - right_panel->add_child(tile_atlas_view_missing_source_label); - EditorNode::get_singleton()->get_editor_data().add_undo_redo_inspector_hook_callback(callable_mp(this, &TileSetAtlasSourceEditor::_undo_redo_inspector_callback)); + // -- Dialogs -- + confirm_auto_create_tiles = memnew(AcceptDialog); + confirm_auto_create_tiles->set_title(TTR("Auto Create Tiles in Non-Transparent Texture Regions?")); + confirm_auto_create_tiles->set_text(TTR("The atlas's texture was modified.\nWould you like to automatically create tiles in the atlas?")); + confirm_auto_create_tiles->set_ok_button_text(TTR("Yes")); + confirm_auto_create_tiles->add_cancel_button()->set_text(TTR("No")); + confirm_auto_create_tiles->connect("confirmed", callable_mp(this, &TileSetAtlasSourceEditor::_auto_create_tiles)); + add_child(confirm_auto_create_tiles); + // Inspector plugin. Ref<EditorInspectorPluginTileData> tile_data_inspector_plugin; tile_data_inspector_plugin.instantiate(); diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.h b/editor/plugins/tiles/tile_set_atlas_source_editor.h index 14e120e2a3..2e25841248 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.h +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.h @@ -42,8 +42,8 @@ class TileSet; class Tree; class VSeparator; -class TileSetAtlasSourceEditor : public HBoxContainer { - GDCLASS(TileSetAtlasSourceEditor, HBoxContainer); +class TileSetAtlasSourceEditor : public HSplitContainer { + GDCLASS(TileSetAtlasSourceEditor, HSplitContainer); public: // A class to store which tiles are selected. @@ -77,7 +77,7 @@ public: public: void set_id(int p_id); - int get_id(); + int get_id() const; void edit(Ref<TileSet> p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id); TileSetAtlasSource *get_edited() { return tile_set_atlas_source; }; @@ -137,19 +137,15 @@ private: // -- Inspector -- AtlasTileProxyObject *tile_proxy_object = nullptr; - Label *tile_inspector_label = nullptr; EditorInspector *tile_inspector = nullptr; Label *tile_inspector_no_tile_selected_label = nullptr; String selected_property; void _inspector_property_selected(String p_property); TileSetAtlasSourceProxyObject *atlas_source_proxy_object = nullptr; - Label *atlas_source_inspector_label = nullptr; EditorInspector *atlas_source_inspector = nullptr; // -- Atlas view -- - HBoxContainer *toolbox = nullptr; - Label *tile_atlas_view_missing_source_label = nullptr; TileAtlasView *tile_atlas_view = nullptr; // Dragging @@ -210,7 +206,6 @@ private: // Tool settings. HBoxContainer *tool_settings = nullptr; - VSeparator *tool_settings_vsep = nullptr; HBoxContainer *tool_settings_tile_data_toolbar_container = nullptr; Button *tools_settings_erase_button = nullptr; MenuButton *tool_advanced_menu_buttom = nullptr; diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp index b24c5059b0..e8ceacf8f8 100644 --- a/editor/plugins/tiles/tile_set_editor.cpp +++ b/editor/plugins/tiles/tile_set_editor.cpp @@ -120,7 +120,9 @@ bool TileSetEditor::_can_drop_data_fw(const Point2 &p_point, const Variant &p_da } void TileSetEditor::_update_sources_list(int force_selected_id) { - ERR_FAIL_COND(!tile_set.is_valid()); + if (tile_set.is_null()) { + return; + } // Get the previously selected id. int old_selected = TileSet::INVALID_SOURCE; @@ -151,7 +153,7 @@ void TileSetEditor::_update_sources_list(int force_selected_id) { // Common to all type of sources. if (!source->get_name().is_empty()) { - item_text = vformat(TTR("%s (id:%d)"), source->get_name(), source_id); + item_text = vformat(TTR("%s (ID: %d)"), source->get_name(), source_id); } // Atlas source. @@ -160,7 +162,7 @@ void TileSetEditor::_update_sources_list(int force_selected_id) { texture = atlas_source->get_texture(); if (item_text.is_empty()) { if (texture.is_valid()) { - item_text = vformat("%s (ID: %d)", texture->get_path().get_file(), source_id); + item_text = vformat(TTR("%s (ID: %d)"), texture->get_path().get_file(), source_id); } else { item_text = vformat(TTR("No Texture Atlas Source (ID: %d)"), source_id); } @@ -346,6 +348,7 @@ void TileSetEditor::_notification(int p_what) { source_sort_button->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons"))); sources_advanced_menu_button->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); missing_texture_texture = get_theme_icon(SNAME("TileSet"), SNAME("EditorIcons")); + _update_sources_list(); } break; case NOTIFICATION_INTERNAL_PROCESS: { diff --git a/editor/plugins/tiles/tiles_editor_plugin.cpp b/editor/plugins/tiles/tiles_editor_plugin.cpp index 5d93f58f34..ee29913334 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.cpp +++ b/editor/plugins/tiles/tiles_editor_plugin.cpp @@ -385,6 +385,15 @@ bool TilesEditorPlugin::handles(Object *p_object) const { return p_object->is_class("TileMap") || p_object->is_class("TileSet"); } +void TilesEditorPlugin::draw_selection_rect(CanvasItem *p_ci, const Rect2 &p_rect, const Color &p_color) { + real_t scale = p_ci->get_global_transform().get_scale().x * 0.5; + p_ci->draw_set_transform(p_rect.position, 0, Vector2(1, 1) / scale); + RS::get_singleton()->canvas_item_add_nine_patch( + p_ci->get_canvas_item(), Rect2(Vector2(), p_rect.size * scale), Rect2(), EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("TileSelection"), SNAME("EditorIcons"))->get_rid(), + Vector2(2, 2), Vector2(2, 2), RS::NINE_PATCH_STRETCH, RS::NINE_PATCH_STRETCH, false, p_color); + p_ci->draw_set_transform_matrix(Transform2D()); +} + TilesEditorPlugin::TilesEditorPlugin() { set_process_internal(true); diff --git a/editor/plugins/tiles/tiles_editor_plugin.h b/editor/plugins/tiles/tiles_editor_plugin.h index fe0d8179bc..825a10dac2 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.h +++ b/editor/plugins/tiles/tiles_editor_plugin.h @@ -128,6 +128,8 @@ public: virtual bool handles(Object *p_object) const override; virtual void make_visible(bool p_visible) override; + static void draw_selection_rect(CanvasItem *p_ci, const Rect2 &p_rect, const Color &p_color = Color(1.0, 1.0, 1.0)); + TilesEditorPlugin(); ~TilesEditorPlugin(); }; diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp index 86aa897c78..369a59c443 100644 --- a/editor/plugins/version_control_editor_plugin.cpp +++ b/editor/plugins/version_control_editor_plugin.cpp @@ -988,7 +988,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { metadata_dialog->set_title(TTR("Create Version Control Metadata")); metadata_dialog->set_min_size(Size2(200, 40)); metadata_dialog->get_ok_button()->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_create_vcs_metadata_files)); - version_control_actions->add_child(metadata_dialog); + add_child(metadata_dialog); VBoxContainer *metadata_vb = memnew(VBoxContainer); metadata_dialog->add_child(metadata_vb); @@ -1017,7 +1017,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { set_up_dialog->set_min_size(Size2(600, 100)); set_up_dialog->add_cancel_button("Cancel"); set_up_dialog->set_hide_on_ok(true); - version_control_actions->add_child(set_up_dialog); + add_child(set_up_dialog); Button *set_up_apply_button = set_up_dialog->get_ok_button(); set_up_apply_button->set_text(TTR("Apply")); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 9990d5c06f..cf811067c9 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -269,6 +269,19 @@ void VisualShaderGraphPlugin::set_expression(VisualShader::Type p_type, int p_no links[p_node_id].expression_edit->set_text(p_expression); } +Ref<Script> VisualShaderGraphPlugin::get_node_script(int p_node_id) const { + if (!links.has(p_node_id)) { + return Ref<Script>(); + } + + Ref<VisualShaderNodeCustom> custom = Ref<VisualShaderNodeCustom>(links[p_node_id].visual_node); + if (custom.is_valid()) { + return custom->get_script(); + } + + return Ref<Script>(); +} + void VisualShaderGraphPlugin::update_node_size(int p_node_id) { if (!links.has(p_node_id)) { return; @@ -1137,10 +1150,6 @@ void VisualShaderEditor::edit(VisualShader *p_visual_shader) { } } -void VisualShaderEditor::update_nodes() { - _update_nodes(); -} - void VisualShaderEditor::add_plugin(const Ref<VisualShaderNodePlugin> &p_plugin) { if (plugins.has(p_plugin)) { return; @@ -1202,6 +1211,228 @@ void VisualShaderEditor::add_custom_type(const String &p_name, const Ref<Script> add_options.push_back(ao); } +Dictionary VisualShaderEditor::get_custom_node_data(Ref<VisualShaderNodeCustom> &p_custom_node) { + Dictionary dict; + dict["script"] = p_custom_node->get_script(); + + String name; + if (p_custom_node->has_method("_get_name")) { + name = (String)p_custom_node->call("_get_name"); + } else { + name = "Unnamed"; + } + dict["name"] = name; + + String description = ""; + if (p_custom_node->has_method("_get_description")) { + description = (String)p_custom_node->call("_get_description"); + } + dict["description"] = description; + + int return_icon_type = -1; + if (p_custom_node->has_method("_get_return_icon_type")) { + return_icon_type = (int)p_custom_node->call("_get_return_icon_type"); + } + dict["return_icon_type"] = return_icon_type; + + String category = ""; + if (p_custom_node->has_method("_get_category")) { + category = (String)p_custom_node->call("_get_category"); + } + category = category.rstrip("/"); + category = category.lstrip("/"); + category = "Addons/" + category; + + String subcategory = ""; + if (p_custom_node->has_method("_get_subcategory")) { + subcategory = (String)p_custom_node->call("_get_subcategory"); + } + if (!subcategory.is_empty()) { + category += "/" + subcategory; + } + dict["category"] = category; + + bool highend = false; + if (p_custom_node->has_method("_is_highend")) { + highend = (bool)p_custom_node->call("_is_highend"); + } + dict["highend"] = highend; + + return dict; +} + +void VisualShaderEditor::update_custom_type(const Ref<Resource> &p_resource) { + Ref<Script> scr = Ref<Script>(p_resource.ptr()); + if (scr.is_null() || scr->get_instance_base_type() != String("VisualShaderNodeCustom")) { + return; + } + + Ref<VisualShaderNodeCustom> ref; + ref.instantiate(); + ref->set_script(scr); + if (!ref->is_available(visual_shader->get_mode(), visual_shader->get_shader_type())) { + for (int i = 0; i < add_options.size(); i++) { + if (add_options[i].is_custom && add_options[i].script == scr) { + add_options.remove_at(i); + _update_options_menu(); + // TODO: Make indication for the existed custom nodes with that script on graph to be disabled. + break; + } + } + return; + } + Dictionary dict = get_custom_node_data(ref); + + bool found_type = false; + bool need_rebuild = false; + + for (int i = 0; i < add_options.size(); i++) { + if (add_options[i].is_custom && add_options[i].script == scr) { + found_type = true; + + add_options.write[i].name = dict["name"]; + add_options.write[i].return_type = dict["return_icon_type"]; + add_options.write[i].description = dict["description"]; + add_options.write[i].category = dict["category"]; + add_options.write[i].highend = dict["highend"]; + + int max_type = 0; + int type_offset = 0; + switch (visual_shader->get_mode()) { + case Shader::MODE_CANVAS_ITEM: + case Shader::MODE_SPATIAL: { + max_type = 3; + } break; + case Shader::MODE_PARTICLES: { + max_type = 5; + type_offset = 3; + } break; + case Shader::MODE_SKY: { + max_type = 1; + type_offset = 8; + } break; + case Shader::MODE_FOG: { + max_type = 1; + type_offset = 9; + } break; + default: { + } break; + } + max_type = type_offset + max_type; + + for (int t = type_offset; t < max_type; t++) { + VisualShader::Type type = (VisualShader::Type)t; + Vector<int> nodes = visual_shader->get_node_list(type); + + List<VisualShader::Connection> node_connections; + visual_shader->get_node_connections(type, &node_connections); + + List<VisualShader::Connection> custom_node_input_connections; + List<VisualShader::Connection> custom_node_output_connections; + for (const VisualShader::Connection &E : node_connections) { + int from = E.from_node; + int from_idx = E.from_port; + int to = E.to_node; + int to_idx = E.to_port; + + if (graph_plugin->get_node_script(from) == scr) { + custom_node_output_connections.push_back({ from, from_idx, to, to_idx }); + } else if (graph_plugin->get_node_script(to) == scr) { + custom_node_input_connections.push_back({ from, from_idx, to, to_idx }); + } + } + + for (int j = 0; j < nodes.size(); j++) { + int node_id = nodes[j]; + + Ref<VisualShaderNode> vsnode = visual_shader->get_node(type, node_id); + if (vsnode.is_null()) { + continue; + } + Ref<VisualShaderNodeCustom> custom_node = Ref<VisualShaderNodeCustom>(vsnode.ptr()); + if (custom_node.is_null() || custom_node->get_script() != scr) { + continue; + } + need_rebuild = true; + + // Removes invalid connections. + { + int prev_input_port_count = custom_node->get_input_port_count(); + int prev_output_port_count = custom_node->get_output_port_count(); + + custom_node->update_ports(); + + int input_port_count = custom_node->get_input_port_count(); + int output_port_count = custom_node->get_output_port_count(); + + if (output_port_count != prev_output_port_count) { + for (const VisualShader::Connection &E : custom_node_output_connections) { + int from = E.from_node; + int from_idx = E.from_port; + int to = E.to_node; + int to_idx = E.to_port; + + if (from_idx >= output_port_count) { + visual_shader->disconnect_nodes(type, from, from_idx, to, to_idx); + graph_plugin->disconnect_nodes(type, from, from_idx, to, to_idx); + } + } + } + if (input_port_count != prev_input_port_count) { + for (const VisualShader::Connection &E : custom_node_input_connections) { + int from = E.from_node; + int from_idx = E.from_port; + int to = E.to_node; + int to_idx = E.to_port; + + if (to_idx >= input_port_count) { + visual_shader->disconnect_nodes(type, from, from_idx, to, to_idx); + graph_plugin->disconnect_nodes(type, from, from_idx, to, to_idx); + } + } + } + } + + graph_plugin->update_node(type, node_id); + } + } + break; + } + } + + if (!found_type) { + add_custom_type(dict["name"], dict["script"], dict["description"], dict["return_icon_type"], dict["category"], dict["highend"]); + } + + // To prevent updating options multiple times when multiple scripts are saved. + if (!_block_update_options_menu) { + _block_update_options_menu = true; + + call_deferred(SNAME("_update_options_menu_deferred")); + } + + // To prevent rebuilding the shader multiple times when multiple scripts are saved. + if (need_rebuild && !_block_rebuild_shader) { + _block_rebuild_shader = true; + + call_deferred(SNAME("_rebuild_shader_deferred")); + } +} + +void VisualShaderEditor::_update_options_menu_deferred() { + _update_options_menu(); + + _block_update_options_menu = false; +} + +void VisualShaderEditor::_rebuild_shader_deferred() { + if (visual_shader.is_valid()) { + visual_shader->rebuild(); + } + + _block_rebuild_shader = false; +} + bool VisualShaderEditor::_is_available(int p_mode) { int current_mode = edit_type->get_selected(); @@ -1243,57 +1474,10 @@ void VisualShaderEditor::_update_nodes() { if (!ref->is_available(visual_shader->get_mode(), visual_shader->get_shader_type())) { continue; } - - String name; - if (ref->has_method("_get_name")) { - name = (String)ref->call("_get_name"); - } else { - name = "Unnamed"; - } - - String description = ""; - if (ref->has_method("_get_description")) { - description = (String)ref->call("_get_description"); - } - - int return_icon_type = -1; - if (ref->has_method("_get_return_icon_type")) { - return_icon_type = (int)ref->call("_get_return_icon_type"); - } - - String category = ""; - if (ref->has_method("_get_category")) { - category = (String)ref->call("_get_category"); - } - - String subcategory = ""; - if (ref->has_method("_get_subcategory")) { - subcategory = (String)ref->call("_get_subcategory"); - } - - bool highend = false; - if (ref->has_method("_is_highend")) { - highend = (bool)ref->call("_is_highend"); - } - - Dictionary dict; - dict["name"] = name; - dict["script"] = scr; - dict["description"] = description; - dict["return_icon_type"] = return_icon_type; - - category = category.rstrip("/"); - category = category.lstrip("/"); - category = "Addons/" + category; - if (!subcategory.is_empty()) { - category += "/" + subcategory; - } - - dict["category"] = category; - dict["highend"] = highend; + Dictionary dict = get_custom_node_data(ref); String key; - key = category + "/" + name; + key = String(dict["category"]) + "/" + String(dict["name"]); added[key] = dict; } @@ -4694,6 +4878,8 @@ void VisualShaderEditor::_bind_methods() { ClassDB::bind_method("_update_constant", &VisualShaderEditor::_update_constant); ClassDB::bind_method("_update_parameter", &VisualShaderEditor::_update_parameter); ClassDB::bind_method("_expand_output_port", &VisualShaderEditor::_expand_output_port); + ClassDB::bind_method("_update_options_menu_deferred", &VisualShaderEditor::_update_options_menu_deferred); + ClassDB::bind_method("_rebuild_shader_deferred", &VisualShaderEditor::_rebuild_shader_deferred); ClassDB::bind_method(D_METHOD("_get_drag_data_fw"), &VisualShaderEditor::get_drag_data_fw); ClassDB::bind_method(D_METHOD("_can_drop_data_fw"), &VisualShaderEditor::can_drop_data_fw); @@ -4704,6 +4890,7 @@ void VisualShaderEditor::_bind_methods() { VisualShaderEditor::VisualShaderEditor() { ShaderLanguage::get_keyword_list(&keyword_list); + EditorNode::get_singleton()->connect("resource_saved", callable_mp(this, &VisualShaderEditor::update_custom_type)); graph = memnew(GraphEdit); graph->get_zoom_hbox()->set_h_size_flags(SIZE_EXPAND_FILL); diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index 8afad9f668..d559237569 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -133,6 +133,7 @@ public: void update_curve_xyz(int p_node_id); void set_expression(VisualShader::Type p_type, int p_node_id, const String &p_expression); int get_constant_index(float p_constant) const; + Ref<Script> get_node_script(int p_node_id) const; void update_node_size(int p_node_id); void update_theme(); VisualShader::Type get_shader_type() const; @@ -190,6 +191,9 @@ class VisualShaderEditor : public VBoxContainer { PanelContainer *error_panel = nullptr; Label *error_label = nullptr; + bool _block_update_options_menu = false; + bool _block_rebuild_shader = false; + Point2 saved_node_pos; bool saved_node_pos_dirty = false; @@ -497,6 +501,9 @@ class VisualShaderEditor : public VBoxContainer { void _update_parameter_refs(HashSet<String> &p_names); void _update_varyings(); + void _update_options_menu_deferred(); + void _rebuild_shader_deferred(); + void _visibility_changed(); protected: @@ -504,7 +511,6 @@ protected: static void _bind_methods(); public: - void update_nodes(); void add_plugin(const Ref<VisualShaderNodePlugin> &p_plugin); void remove_plugin(const Ref<VisualShaderNodePlugin> &p_plugin); @@ -513,6 +519,9 @@ public: void clear_custom_types(); void add_custom_type(const String &p_name, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, bool p_highend); + Dictionary get_custom_node_data(Ref<VisualShaderNodeCustom> &p_custom_node); + void update_custom_type(const Ref<Resource> &p_resource); + virtual Size2 get_minimum_size() const override; void edit(VisualShader *p_visual_shader); VisualShaderEditor(); diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp index d42dc3c3bf..e07c672f5c 100644 --- a/editor/project_converter_3_to_4.cpp +++ b/editor/project_converter_3_to_4.cpp @@ -1398,7 +1398,7 @@ static const char *class_renames[][2] = { // { "Physics2DDirectBodyStateSW", "GodotPhysicsDirectBodyState2D" }, // Class is not visible in ClassDB // { "Physics2DShapeQueryResult", "PhysicsShapeQueryResult2D" }, // Class is not visible in ClassDB // { "PhysicsShapeQueryResult", "PhysicsShapeQueryResult3D" }, // Class is not visible in ClassDB - // { "NativeScript","NativeExtension"}, ?? + // { "NativeScript","GDExtension"}, ?? { "ARVRAnchor", "XRAnchor3D" }, { "ARVRCamera", "XRCamera3D" }, { "ARVRController", "XRController3D" }, diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 1e917e6b3d..b406b2a1ce 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -280,6 +280,8 @@ void ProjectSettingsEditor::_add_feature_overrides() { presets.insert("debug"); presets.insert("release"); presets.insert("template"); + presets.insert("double"); + presets.insert("single"); presets.insert("32"); presets.insert("64"); presets.insert("movie"); |