diff options
Diffstat (limited to 'editor')
96 files changed, 1516 insertions, 999 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 4991b2cfaf..e3b1288e9f 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -52,13 +52,9 @@ public: bool setting = false; bool animation_read_only = false; - bool _hide_script_from_inspector() { - return true; - } - - bool _dont_undo_redo() { - return true; - } + bool _hide_script_from_inspector() { return true; } + bool _hide_metadata_from_inspector() { return true; } + bool _dont_undo_redo() { return true; } bool _is_read_only() { return animation_read_only; @@ -68,6 +64,7 @@ public: ClassDB::bind_method(D_METHOD("_update_obj"), &AnimationTrackKeyEdit::_update_obj); ClassDB::bind_method(D_METHOD("_key_ofs_changed"), &AnimationTrackKeyEdit::_key_ofs_changed); ClassDB::bind_method(D_METHOD("_hide_script_from_inspector"), &AnimationTrackKeyEdit::_hide_script_from_inspector); + ClassDB::bind_method(D_METHOD("_hide_metadata_from_inspector"), &AnimationTrackKeyEdit::_hide_metadata_from_inspector); ClassDB::bind_method(D_METHOD("get_root_path"), &AnimationTrackKeyEdit::get_root_path); ClassDB::bind_method(D_METHOD("_dont_undo_redo"), &AnimationTrackKeyEdit::_dont_undo_redo); ClassDB::bind_method(D_METHOD("_is_read_only"), &AnimationTrackKeyEdit::_is_read_only); @@ -719,13 +716,9 @@ public: bool setting = false; bool animation_read_only = false; - bool _hide_script_from_inspector() { - return true; - } - - bool _dont_undo_redo() { - return true; - } + bool _hide_script_from_inspector() { return true; } + bool _hide_metadata_from_inspector() { return true; } + bool _dont_undo_redo() { return true; } bool _is_read_only() { return animation_read_only; @@ -735,6 +728,7 @@ public: ClassDB::bind_method(D_METHOD("_update_obj"), &AnimationMultiTrackKeyEdit::_update_obj); ClassDB::bind_method(D_METHOD("_key_ofs_changed"), &AnimationMultiTrackKeyEdit::_key_ofs_changed); ClassDB::bind_method(D_METHOD("_hide_script_from_inspector"), &AnimationMultiTrackKeyEdit::_hide_script_from_inspector); + ClassDB::bind_method(D_METHOD("_hide_metadata_from_inspector"), &AnimationMultiTrackKeyEdit::_hide_metadata_from_inspector); ClassDB::bind_method(D_METHOD("get_root_path"), &AnimationMultiTrackKeyEdit::get_root_path); ClassDB::bind_method(D_METHOD("_dont_undo_redo"), &AnimationMultiTrackKeyEdit::_dont_undo_redo); ClassDB::bind_method(D_METHOD("_is_read_only"), &AnimationMultiTrackKeyEdit::_is_read_only); @@ -2417,7 +2411,7 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool draw_texture( icon_to_draw, ofs, - p_index == hovering_key_idx ? get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog")) : Color(1, 1, 1)); + p_index == hovering_key_idx ? get_theme_color(SNAME("folder_icon_color"), SNAME("FileDialog")) : Color(1, 1, 1)); } // Helper. @@ -3524,7 +3518,7 @@ void AnimationTrackEditor::set_root(Node *p_root) { root = p_root; if (root) { - root->connect("tree_exiting", callable_mp(this, &AnimationTrackEditor::_root_removed), CONNECT_ONESHOT); + root->connect("tree_exiting", callable_mp(this, &AnimationTrackEditor::_root_removed), CONNECT_ONE_SHOT); } _update_tracks(); @@ -4772,7 +4766,7 @@ void AnimationTrackEditor::_notification(int p_what) { view_group->set_icon(get_theme_icon(view_group->is_pressed() ? SNAME("AnimationTrackList") : SNAME("AnimationTrackGroup"), SNAME("EditorIcons"))); selected_filter->set_icon(get_theme_icon(SNAME("AnimationFilter"), SNAME("EditorIcons"))); imported_anim_warning->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons"))); - main_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + main_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); edit->get_popup()->set_item_icon(edit->get_popup()->get_item_index(EDIT_APPLY_RESET), get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); } break; diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 2d5e70e1ff..9aa913a892 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1001,7 +1001,7 @@ void CodeTextEditor::update_editor_settings() { // Appearance: Caret text_editor->set_caret_type((TextEdit::CaretType)EditorSettings::get_singleton()->get("text_editor/appearance/caret/type").operator int()); text_editor->set_caret_blink_enabled(EditorSettings::get_singleton()->get("text_editor/appearance/caret/caret_blink")); - text_editor->set_caret_blink_speed(EditorSettings::get_singleton()->get("text_editor/appearance/caret/caret_blink_speed")); + text_editor->set_caret_blink_interval(EditorSettings::get_singleton()->get("text_editor/appearance/caret/caret_blink_interval")); text_editor->set_highlight_current_line(EditorSettings::get_singleton()->get("text_editor/appearance/caret/highlight_current_line")); text_editor->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/appearance/caret/highlight_all_occurrences")); diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index dce9ca2b93..861d05f17a 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -289,8 +289,8 @@ bool ConnectDialog::get_deferred() const { return deferred->is_pressed(); } -bool ConnectDialog::get_oneshot() const { - return oneshot->is_pressed(); +bool ConnectDialog::get_one_shot() const { + return one_shot->is_pressed(); } /* @@ -322,10 +322,10 @@ void ConnectDialog::init(ConnectionData p_cd, bool p_edit) { _update_ok_enabled(); bool b_deferred = (p_cd.flags & CONNECT_DEFERRED) == CONNECT_DEFERRED; - bool b_oneshot = (p_cd.flags & CONNECT_ONESHOT) == CONNECT_ONESHOT; + bool b_oneshot = (p_cd.flags & CONNECT_ONE_SHOT) == CONNECT_ONE_SHOT; deferred->set_pressed(b_deferred); - oneshot->set_pressed(b_oneshot); + one_shot->set_pressed(b_oneshot); MethodInfo r_signal; Ref<Script> source_script = source->get_script(); @@ -484,11 +484,11 @@ ConnectDialog::ConnectDialog() { deferred->set_tooltip_text(TTR("Defers the signal, storing it in a queue and only firing it at idle time.")); vbc_right->add_child(deferred); - oneshot = memnew(CheckBox); - oneshot->set_h_size_flags(0); - oneshot->set_text(TTR("Oneshot")); - oneshot->set_tooltip_text(TTR("Disconnects the signal after its first emission.")); - vbc_right->add_child(oneshot); + one_shot = memnew(CheckBox); + one_shot->set_h_size_flags(0); + one_shot->set_text(TTR("Oneshot")); + one_shot->set_tooltip_text(TTR("Disconnects the signal after its first emission.")); + vbc_right->add_child(one_shot); cdbinds = memnew(ConnectDialogBinds); @@ -564,8 +564,8 @@ void ConnectionsDock::_make_or_edit_connection() { cd.binds = connect_dialog->get_binds(); } bool b_deferred = connect_dialog->get_deferred(); - bool b_oneshot = connect_dialog->get_oneshot(); - cd.flags = CONNECT_PERSIST | (b_deferred ? CONNECT_DEFERRED : 0) | (b_oneshot ? CONNECT_ONESHOT : 0); + bool b_oneshot = connect_dialog->get_one_shot(); + cd.flags = CONNECT_PERSIST | (b_deferred ? CONNECT_DEFERRED : 0) | (b_oneshot ? CONNECT_ONE_SHOT : 0); // Conditions to add function: must have a script and must not have the method already // (in the class, the script itself, or inherited). @@ -1083,8 +1083,8 @@ void ConnectionsDock::update_tree() { if (cd.flags & CONNECT_DEFERRED) { path += " (deferred)"; } - if (cd.flags & CONNECT_ONESHOT) { - path += " (oneshot)"; + if (cd.flags & CONNECT_ONE_SHOT) { + path += " (one-shot)"; } if (cd.unbinds > 0) { path += " unbinds(" + itos(cd.unbinds) + ")"; diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h index 352c5c99d6..e37246e7a0 100644 --- a/editor/connections_dialog.h +++ b/editor/connections_dialog.h @@ -121,7 +121,7 @@ private: EditorInspector *bind_editor = nullptr; OptionButton *type_list = nullptr; CheckBox *deferred = nullptr; - CheckBox *oneshot = nullptr; + CheckBox *one_shot = nullptr; CheckButton *advanced = nullptr; Vector<Control *> bind_controls; @@ -153,7 +153,7 @@ public: Vector<Variant> get_binds() const; bool get_deferred() const; - bool get_oneshot() const; + bool get_one_shot() const; bool is_editing() const; void init(ConnectionData p_cd, bool p_edit = false); diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index b1253ed7cb..99821d8983 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -1027,7 +1027,7 @@ void EditorAudioBuses::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - bus_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + bus_scroll->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); } break; case NOTIFICATION_READY: { diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 231ae198d2..1febec2c04 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -1056,7 +1056,7 @@ void EditorSelection::add_node(Node *p_node) { } selection[p_node] = meta; - p_node->connect("tree_exiting", callable_mp(this, &EditorSelection::_node_removed).bind(p_node), CONNECT_ONESHOT); + p_node->connect("tree_exiting", callable_mp(this, &EditorSelection::_node_removed).bind(p_node), CONNECT_ONE_SHOT); } void EditorSelection::remove_node(Node *p_node) { diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp index 3bb050ce77..f464ca3b3c 100644 --- a/editor/editor_dir_dialog.cpp +++ b/editor/editor_dir_dialog.cpp @@ -44,7 +44,7 @@ void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p p_item->set_metadata(0, p_dir->get_path()); p_item->set_icon(0, tree->get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); - p_item->set_icon_modulate(0, tree->get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog"))); + p_item->set_icon_modulate(0, tree->get_theme_color(SNAME("folder_icon_color"), SNAME("FileDialog"))); if (!p_item->get_parent()) { p_item->set_text(0, "res://"); diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index fca9907c20..36ca1619a4 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -69,13 +69,49 @@ VBoxContainer *EditorFileDialog::get_vbox() { return vbox; } +void EditorFileDialog::_update_theme_item_cache() { + ConfirmationDialog::_update_theme_item_cache(); + + theme_cache.parent_folder = get_theme_icon(SNAME("ArrowUp"), SNAME("EditorIcons")); + theme_cache.forward_folder = get_theme_icon(SNAME("Forward"), SNAME("EditorIcons")); + theme_cache.back_folder = get_theme_icon(SNAME("Back"), SNAME("EditorIcons")); + theme_cache.reload = get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")); + theme_cache.toggle_hidden = get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")); + theme_cache.favorite = get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons")); + theme_cache.mode_thumbnails = get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons")); + theme_cache.mode_list = get_theme_icon(SNAME("FileList"), SNAME("EditorIcons")); + theme_cache.favorites_up = get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")); + theme_cache.favorites_down = get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons")); + + theme_cache.folder = get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")); + theme_cache.folder_icon_color = get_theme_color(SNAME("folder_icon_color"), SNAME("FileDialog")); + + theme_cache.action_copy = get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")); + theme_cache.action_delete = get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")); + theme_cache.filesystem = get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")); + + theme_cache.folder_medium_thumbnail = get_theme_icon(SNAME("FolderMediumThumb"), SNAME("EditorIcons")); + theme_cache.file_medium_thumbnail = get_theme_icon(SNAME("FileMediumThumb"), SNAME("EditorIcons")); + theme_cache.folder_big_thumbnail = get_theme_icon(SNAME("FolderBigThumb"), SNAME("EditorIcons")); + theme_cache.file_big_thumbnail = get_theme_icon(SNAME("FileBigThumb"), SNAME("EditorIcons")); + + theme_cache.progress[0] = get_theme_icon("Progress1", SNAME("EditorIcons")); + theme_cache.progress[1] = get_theme_icon("Progress2", SNAME("EditorIcons")); + theme_cache.progress[2] = get_theme_icon("Progress3", SNAME("EditorIcons")); + theme_cache.progress[3] = get_theme_icon("Progress4", SNAME("EditorIcons")); + theme_cache.progress[4] = get_theme_icon("Progress5", SNAME("EditorIcons")); + theme_cache.progress[5] = get_theme_icon("Progress6", SNAME("EditorIcons")); + theme_cache.progress[6] = get_theme_icon("Progress7", SNAME("EditorIcons")); + theme_cache.progress[7] = get_theme_icon("Progress8", SNAME("EditorIcons")); +} + void EditorFileDialog::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_READY: case NOTIFICATION_THEME_CHANGED: case Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_TRANSLATION_CHANGED: { _update_icons(); + invalidate(); } break; case NOTIFICATION_PROCESS: { @@ -86,7 +122,8 @@ void EditorFileDialog::_notification(int p_what) { if (preview_wheel_index >= 8) { preview_wheel_index = 0; } - Ref<Texture2D> frame = item_list->get_theme_icon("Progress" + itos(preview_wheel_index + 1), SNAME("EditorIcons")); + + Ref<Texture2D> frame = theme_cache.progress[preview_wheel_index]; preview->set_texture(frame); preview_wheel_timeout = 0.1; } @@ -100,7 +137,6 @@ void EditorFileDialog::_notification(int p_what) { } set_display_mode((DisplayMode)EditorSettings::get_singleton()->get("filesystem/file_dialog/display_mode").operator int()); - _update_icons(); // DO NOT CALL UPDATE FILE LIST HERE, ALL HUNDREDS OF HIDDEN DIALOGS WILL RESPOND, CALL INVALIDATE INSTEAD invalidate(); } break; @@ -289,49 +325,7 @@ void EditorFileDialog::_post_popup() { } if (is_visible()) { - Ref<Texture2D> folder = item_list->get_theme_icon(SNAME("folder"), SNAME("FileDialog")); - const Color folder_color = item_list->get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog")); - recent->clear(); - - bool res = (access == ACCESS_RESOURCES); - Vector<String> recentd = EditorSettings::get_singleton()->get_recent_dirs(); - Vector<String> recentd_paths; - Vector<String> recentd_names; - - for (int i = 0; i < recentd.size(); i++) { - bool cres = recentd[i].begins_with("res://"); - if (cres != res) { - continue; - } - - if (!dir_access->dir_exists(recentd[i])) { - // Remove invalid directory from the list of Recent directories. - recentd.remove_at(i--); - continue; - } - - // Compute recent directory display text. - String name = recentd[i]; - if (res && name == "res://") { - name = "/"; - } else { - if (name.ends_with("/")) { - name = name.substr(0, name.length() - 1); - } - name = name.get_file(); - } - recentd_paths.append(recentd[i]); - recentd_names.append(name); - } - - EditorNode::disambiguate_filenames(recentd_paths, recentd_names); - - for (int i = 0; i < recentd_paths.size(); i++) { - recent->add_item(recentd_names[i], folder); - recent->set_item_metadata(-1, recentd_paths[i]); - recent->set_item_icon_modulate(-1, folder_color); - } - EditorSettings::get_singleton()->set_recent_dirs(recentd); + _update_recent(); local_history.clear(); local_history_pos = -1; @@ -626,16 +620,16 @@ void EditorFileDialog::_item_list_item_rmb_clicked(int p_item, const Vector2 &p_ } if (single_item_selected) { - item_menu->add_icon_item(item_list->get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), TTR("Copy Path"), ITEM_MENU_COPY_PATH); + item_menu->add_icon_item(theme_cache.action_copy, TTR("Copy Path"), ITEM_MENU_COPY_PATH); } if (allow_delete) { - item_menu->add_icon_item(item_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete"), ITEM_MENU_DELETE, Key::KEY_DELETE); + item_menu->add_icon_item(theme_cache.action_delete, TTR("Delete"), ITEM_MENU_DELETE, Key::KEY_DELETE); } if (single_item_selected) { item_menu->add_separator(); Dictionary item_meta = item_list->get_item_metadata(p_item); String item_text = item_meta["dir"] ? TTR("Open in File Manager") : TTR("Show in File Manager"); - item_menu->add_icon_item(item_list->get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), item_text, ITEM_MENU_SHOW_IN_EXPLORER); + item_menu->add_icon_item(theme_cache.filesystem, item_text, ITEM_MENU_SHOW_IN_EXPLORER); } if (item_menu->get_item_count() > 0) { @@ -663,11 +657,11 @@ void EditorFileDialog::_item_list_empty_clicked(const Vector2 &p_pos, MouseButto item_menu->reset_size(); if (can_create_dir) { - item_menu->add_icon_item(item_list->get_theme_icon(SNAME("folder"), SNAME("FileDialog")), TTR("New Folder..."), ITEM_MENU_NEW_FOLDER, KeyModifierMask::CMD | Key::N); + item_menu->add_icon_item(theme_cache.folder, TTR("New Folder..."), ITEM_MENU_NEW_FOLDER, KeyModifierMask::CMD | Key::N); } - item_menu->add_icon_item(item_list->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")), TTR("Refresh"), ITEM_MENU_REFRESH, Key::F5); + item_menu->add_icon_item(theme_cache.reload, TTR("Refresh"), ITEM_MENU_REFRESH, Key::F5); item_menu->add_separator(); - item_menu->add_icon_item(item_list->get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), TTR("Open in File Manager"), ITEM_MENU_SHOW_IN_EXPLORER); + item_menu->add_icon_item(theme_cache.filesystem, TTR("Open in File Manager"), ITEM_MENU_SHOW_IN_EXPLORER); item_menu->set_position(item_list->get_screen_position() + p_pos); item_menu->reset_size(); @@ -773,11 +767,11 @@ void EditorFileDialog::update_file_list() { item_list->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size)); if (thumbnail_size < 64) { - folder_thumbnail = item_list->get_theme_icon(SNAME("FolderMediumThumb"), SNAME("EditorIcons")); - file_thumbnail = item_list->get_theme_icon(SNAME("FileMediumThumb"), SNAME("EditorIcons")); + folder_thumbnail = theme_cache.folder_medium_thumbnail; + file_thumbnail = theme_cache.file_medium_thumbnail; } else { - folder_thumbnail = item_list->get_theme_icon(SNAME("FolderBigThumb"), SNAME("EditorIcons")); - file_thumbnail = item_list->get_theme_icon(SNAME("FileBigThumb"), SNAME("EditorIcons")); + folder_thumbnail = theme_cache.folder_big_thumbnail; + file_thumbnail = theme_cache.file_big_thumbnail; } preview_vb->hide(); @@ -797,8 +791,6 @@ void EditorFileDialog::update_file_list() { dir_access->list_dir_begin(); - Ref<Texture2D> folder = item_list->get_theme_icon(SNAME("folder"), SNAME("FileDialog")); - const Color folder_color = item_list->get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog")); List<String> files; List<String> dirs; @@ -838,7 +830,7 @@ void EditorFileDialog::update_file_list() { if (display_mode == DISPLAY_THUMBNAILS) { item_list->set_item_icon(-1, folder_thumbnail); } else { - item_list->set_item_icon(-1, folder); + item_list->set_item_icon(-1, theme_cache.folder); } Dictionary d; @@ -847,7 +839,7 @@ void EditorFileDialog::update_file_list() { d["dir"] = true; item_list->set_item_metadata(-1, d); - item_list->set_item_icon_modulate(-1, folder_color); + item_list->set_item_icon_modulate(-1, theme_cache.folder_icon_color); dirs.pop_front(); } @@ -1120,6 +1112,7 @@ void EditorFileDialog::invalidate() { if (is_visible()) { update_file_list(); _update_favorites(); + _update_recent(); invalidated = false; } else { invalidated = true; @@ -1235,22 +1228,25 @@ void EditorFileDialog::_update_drives(bool p_select) { void EditorFileDialog::_update_icons() { // Update icons. - mode_thumbnails->set_icon(item_list->get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons"))); - mode_list->set_icon(item_list->get_theme_icon(SNAME("FileList"), SNAME("EditorIcons"))); + + mode_thumbnails->set_icon(theme_cache.mode_thumbnails); + mode_list->set_icon(theme_cache.mode_list); + if (is_layout_rtl()) { - dir_prev->set_icon(item_list->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); - dir_next->set_icon(item_list->get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); + dir_prev->set_icon(theme_cache.forward_folder); + dir_next->set_icon(theme_cache.back_folder); } else { - dir_prev->set_icon(item_list->get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); - dir_next->set_icon(item_list->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); + dir_prev->set_icon(theme_cache.back_folder); + dir_next->set_icon(theme_cache.forward_folder); } - dir_up->set_icon(item_list->get_theme_icon(SNAME("ArrowUp"), SNAME("EditorIcons"))); - refresh->set_icon(item_list->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); - favorite->set_icon(item_list->get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); - show_hidden->set_icon(item_list->get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"))); + dir_up->set_icon(theme_cache.parent_folder); - fav_up->set_icon(item_list->get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons"))); - fav_down->set_icon(item_list->get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons"))); + refresh->set_icon(theme_cache.reload); + favorite->set_icon(theme_cache.favorite); + show_hidden->set_icon(theme_cache.toggle_hidden); + + fav_up->set_icon(theme_cache.favorites_up); + fav_down->set_icon(theme_cache.favorites_down); } void EditorFileDialog::_favorite_selected(int p_idx) { @@ -1335,8 +1331,6 @@ void EditorFileDialog::_update_favorites() { bool res = (access == ACCESS_RESOURCES); String current = get_current_dir(); - Ref<Texture2D> folder_icon = item_list->get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")); - const Color folder_color = item_list->get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog")); favorites->clear(); favorite->set_pressed(false); @@ -1389,9 +1383,9 @@ void EditorFileDialog::_update_favorites() { EditorNode::disambiguate_filenames(favorited_paths, favorited_names); for (int i = 0; i < favorited_paths.size(); i++) { - favorites->add_item(favorited_names[i], folder_icon); + favorites->add_item(favorited_names[i], theme_cache.folder); favorites->set_item_metadata(-1, favorited_paths[i]); - favorites->set_item_icon_modulate(-1, folder_color); + favorites->set_item_icon_modulate(-1, theme_cache.folder_icon_color); if (i == current_favorite) { favorite->set_pressed(true); @@ -1435,6 +1429,50 @@ void EditorFileDialog::_favorite_pressed() { _update_favorites(); } +void EditorFileDialog::_update_recent() { + recent->clear(); + + bool res = (access == ACCESS_RESOURCES); + Vector<String> recentd = EditorSettings::get_singleton()->get_recent_dirs(); + Vector<String> recentd_paths; + Vector<String> recentd_names; + + for (int i = 0; i < recentd.size(); i++) { + bool cres = recentd[i].begins_with("res://"); + if (cres != res) { + continue; + } + + if (!dir_access->dir_exists(recentd[i])) { + // Remove invalid directory from the list of Recent directories. + recentd.remove_at(i--); + continue; + } + + // Compute recent directory display text. + String name = recentd[i]; + if (res && name == "res://") { + name = "/"; + } else { + if (name.ends_with("/")) { + name = name.substr(0, name.length() - 1); + } + name = name.get_file(); + } + recentd_paths.append(recentd[i]); + recentd_names.append(name); + } + + EditorNode::disambiguate_filenames(recentd_paths, recentd_names); + + for (int i = 0; i < recentd_paths.size(); i++) { + recent->add_item(recentd_names[i], theme_cache.folder); + recent->set_item_metadata(-1, recentd_paths[i]); + recent->set_item_icon_modulate(-1, theme_cache.folder_icon_color); + } + EditorSettings::get_singleton()->set_recent_dirs(recentd); +} + void EditorFileDialog::_recent_selected(int p_idx) { Vector<String> recentd = EditorSettings::get_singleton()->get_recent_dirs(); ERR_FAIL_INDEX(p_idx, recentd.size()); diff --git a/editor/editor_file_dialog.h b/editor/editor_file_dialog.h index 51629f2682..6d11cb10ed 100644 --- a/editor/editor_file_dialog.h +++ b/editor/editor_file_dialog.h @@ -148,6 +148,33 @@ private: bool disable_overwrite_warning = false; bool invalidated = true; + struct ThemeCache { + Ref<Texture2D> parent_folder; + Ref<Texture2D> forward_folder; + Ref<Texture2D> back_folder; + Ref<Texture2D> reload; + Ref<Texture2D> toggle_hidden; + Ref<Texture2D> favorite; + Ref<Texture2D> mode_thumbnails; + Ref<Texture2D> mode_list; + Ref<Texture2D> favorites_up; + Ref<Texture2D> favorites_down; + + Ref<Texture2D> folder; + Color folder_icon_color; + + Ref<Texture2D> action_copy; + Ref<Texture2D> action_delete; + Ref<Texture2D> filesystem; + + Ref<Texture2D> folder_medium_thumbnail; + Ref<Texture2D> file_medium_thumbnail; + Ref<Texture2D> folder_big_thumbnail; + Ref<Texture2D> file_big_thumbnail; + + Ref<Texture2D> progress[8]{}; + } theme_cache; + void update_dir(); void update_file_name(); void update_file_list(); @@ -161,6 +188,7 @@ private: void _favorite_move_up(); void _favorite_move_down(); + void _update_recent(); void _recent_selected(int p_idx); void _item_selected(int p_item); @@ -206,6 +234,8 @@ private: bool _is_open_should_be_disabled(); protected: + virtual void _update_theme_item_cache() override; + void _notification(int p_what); static void _bind_methods(); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 97f5363bb8..b8f115e82e 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -567,6 +567,8 @@ void EditorHelp::_update_doc() { class_desc->pop(); // font class_desc->add_newline(); + const String non_breaking_space = String::chr(160); + // Inheritance tree // Ascendents @@ -579,7 +581,7 @@ void EditorHelp::_update_doc() { while (!inherits.is_empty()) { _add_type_icon(inherits); - class_desc->add_text(" "); // Extra space, otherwise icon borrows hyperlink from _add_type(). + class_desc->add_text(non_breaking_space); // Otherwise icon borrows hyperlink from _add_type(). _add_type(inherits); inherits = doc->class_list[inherits].inherits; @@ -612,7 +614,7 @@ void EditorHelp::_update_doc() { class_desc->add_text(" , "); } _add_type_icon(E.value.name); - class_desc->add_text(" "); // Extra space, otherwise icon borrows hyperlink from _add_type(). + class_desc->add_text(non_breaking_space); // Otherwise icon borrows hyperlink from _add_type(). _add_type(E.value.name); prev = true; } @@ -1660,19 +1662,19 @@ void EditorHelp::_help_callback(const String &p_topic) { } } -static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { +static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, Control *p_owner_node) { DocTools *doc = EditorHelp::get_doc_data(); String base_path; - Ref<Font> doc_font = p_rt->get_theme_font(SNAME("doc"), SNAME("EditorFonts")); - Ref<Font> doc_bold_font = p_rt->get_theme_font(SNAME("doc_bold"), SNAME("EditorFonts")); - Ref<Font> doc_italic_font = p_rt->get_theme_font(SNAME("doc_italic"), SNAME("EditorFonts")); - Ref<Font> doc_code_font = p_rt->get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); - Ref<Font> doc_kbd_font = p_rt->get_theme_font(SNAME("doc_keyboard"), SNAME("EditorFonts")); + Ref<Font> doc_font = p_owner_node->get_theme_font(SNAME("doc"), SNAME("EditorFonts")); + Ref<Font> doc_bold_font = p_owner_node->get_theme_font(SNAME("doc_bold"), SNAME("EditorFonts")); + Ref<Font> doc_italic_font = p_owner_node->get_theme_font(SNAME("doc_italic"), SNAME("EditorFonts")); + Ref<Font> doc_code_font = p_owner_node->get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); + Ref<Font> doc_kbd_font = p_owner_node->get_theme_font(SNAME("doc_keyboard"), SNAME("EditorFonts")); - Color link_color = p_rt->get_theme_color(SNAME("link_color"), SNAME("EditorHelp")); - Color code_color = p_rt->get_theme_color(SNAME("code_color"), SNAME("EditorHelp")); - Color kbd_color = p_rt->get_theme_color(SNAME("kbd_color"), SNAME("EditorHelp")); + Color link_color = p_owner_node->get_theme_color(SNAME("link_color"), SNAME("EditorHelp")); + Color code_color = p_owner_node->get_theme_color(SNAME("code_color"), SNAME("EditorHelp")); + Color kbd_color = p_owner_node->get_theme_color(SNAME("kbd_color"), SNAME("EditorHelp")); String bbcode = p_bbcode.dedent().replace("\t", "").replace("\r", "").strip_edges(); @@ -1964,7 +1966,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { } void EditorHelp::_add_text(const String &p_bbcode) { - _add_text_to_rt(p_bbcode, class_desc); + _add_text_to_rt(p_bbcode, class_desc, this); } Thread EditorHelp::thread; @@ -2190,11 +2192,10 @@ void EditorHelpBit::_bind_methods() { void EditorHelpBit::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { rich_text->add_theme_color_override("selection_color", get_theme_color(SNAME("selection_color"), SNAME("EditorHelp"))); rich_text->clear(); - _add_text_to_rt(text, rich_text); + _add_text_to_rt(text, rich_text, this); rich_text->reset_size(); // Force recalculating size after parsing bbcode. } break; } @@ -2203,7 +2204,7 @@ void EditorHelpBit::_notification(int p_what) { void EditorHelpBit::set_text(const String &p_text) { text = p_text; rich_text->clear(); - _add_text_to_rt(text, rich_text); + _add_text_to_rt(text, rich_text, this); } EditorHelpBit::EditorHelpBit() { diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index 2e35f21e47..af0cff9ad6 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -231,6 +231,7 @@ EditorHelpSearch::EditorHelpSearch() { filter_combo->add_item(TTR("Methods Only"), SEARCH_METHODS); filter_combo->add_item(TTR("Operators Only"), SEARCH_OPERATORS); filter_combo->add_item(TTR("Signals Only"), SEARCH_SIGNALS); + filter_combo->add_item(TTR("Annotations Only"), SEARCH_ANNOTATIONS); filter_combo->add_item(TTR("Constants Only"), SEARCH_CONSTANTS); filter_combo->add_item(TTR("Properties Only"), SEARCH_PROPERTIES); filter_combo->add_item(TTR("Theme Properties Only"), SEARCH_THEME_ITEMS); @@ -339,8 +340,9 @@ bool EditorHelpSearch::Runner::_phase_match_classes() { match.name = (term.is_empty() && (!class_doc.is_script_doc || class_doc.name[0] != '\"')) || _match_string(term, class_doc.name); } - // Match members if the term is long enough. - if (term.length() > 1) { + // Match members only if the term is long enough, to avoid slow performance from building a large tree. + // Make an exception for annotations, since there are not that many of them. + if (term.length() > 1 || term == "@") { if (search_flags & SEARCH_CONSTRUCTORS) { for (int i = 0; i < class_doc.constructors.size(); i++) { String method_name = (search_flags & SEARCH_CASE_SENSITIVE) ? class_doc.constructors[i].name : class_doc.constructors[i].name.to_lower(); @@ -402,6 +404,13 @@ bool EditorHelpSearch::Runner::_phase_match_classes() { } } } + if (search_flags & SEARCH_ANNOTATIONS) { + for (int i = 0; i < class_doc.annotations.size(); i++) { + if (_match_string(term, class_doc.annotations[i].name)) { + match.annotations.push_back(const_cast<DocData::MethodDoc *>(&class_doc.annotations[i])); + } + } + } matches[class_doc.name] = match; } matches[class_doc.name] = match; @@ -485,6 +494,10 @@ bool EditorHelpSearch::Runner::_phase_member_items() { for (int i = 0; i < match.theme_properties.size(); i++) { _create_theme_property_item(parent, match.doc, match.theme_properties[i]); } + for (int i = 0; i < match.annotations.size(); i++) { + // Hide the redundant leading @ symbol. + _create_annotation_item(parent, match.doc, match.annotations[i]->name.substr(1), match.annotations[i]); + } ++iterator_match; return !iterator_match; @@ -523,6 +536,22 @@ void EditorHelpSearch::Runner::_match_item(TreeItem *p_item, const String &p_tex } } +String EditorHelpSearch::Runner::_build_method_tooltip(const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc) const { + String tooltip = p_doc->return_type + " " + p_class_doc->name + "." + p_doc->name + "("; + for (int i = 0; i < p_doc->arguments.size(); i++) { + const DocData::ArgumentDoc &arg = p_doc->arguments[i]; + tooltip += arg.type + " " + arg.name; + if (!arg.default_value.is_empty()) { + tooltip += " = " + arg.default_value; + } + if (i < p_doc->arguments.size() - 1) { + tooltip += ", "; + } + } + tooltip += ")"; + return tooltip; +} + TreeItem *EditorHelpSearch::Runner::_create_class_hierarchy(const ClassMatch &p_match) { if (p_match.doc->name.is_empty()) { return nullptr; @@ -576,37 +605,20 @@ TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const } TreeItem *EditorHelpSearch::Runner::_create_method_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const String &p_text, const DocData::MethodDoc *p_doc) { - String tooltip = p_doc->return_type + " " + p_class_doc->name + "." + p_doc->name + "("; - for (int i = 0; i < p_doc->arguments.size(); i++) { - const DocData::ArgumentDoc &arg = p_doc->arguments[i]; - tooltip += arg.type + " " + arg.name; - if (!arg.default_value.is_empty()) { - tooltip += " = " + arg.default_value; - } - if (i < p_doc->arguments.size() - 1) { - tooltip += ", "; - } - } - tooltip += ")"; + String tooltip = _build_method_tooltip(p_class_doc, p_doc); return _create_member_item(p_parent, p_class_doc->name, "MemberMethod", p_doc->name, p_text, TTRC("Method"), "method", tooltip); } TreeItem *EditorHelpSearch::Runner::_create_signal_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc) { - String tooltip = p_doc->return_type + " " + p_class_doc->name + "." + p_doc->name + "("; - for (int i = 0; i < p_doc->arguments.size(); i++) { - const DocData::ArgumentDoc &arg = p_doc->arguments[i]; - tooltip += arg.type + " " + arg.name; - if (!arg.default_value.is_empty()) { - tooltip += " = " + arg.default_value; - } - if (i < p_doc->arguments.size() - 1) { - tooltip += ", "; - } - } - tooltip += ")"; + String tooltip = _build_method_tooltip(p_class_doc, p_doc); return _create_member_item(p_parent, p_class_doc->name, "MemberSignal", p_doc->name, p_doc->name, TTRC("Signal"), "signal", tooltip); } +TreeItem *EditorHelpSearch::Runner::_create_annotation_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const String &p_text, const DocData::MethodDoc *p_doc) { + String tooltip = _build_method_tooltip(p_class_doc, p_doc); + return _create_member_item(p_parent, p_class_doc->name, "MemberAnnotation", p_doc->name, p_text, TTRC("Annotation"), "annotation", tooltip); +} + TreeItem *EditorHelpSearch::Runner::_create_constant_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ConstantDoc *p_doc) { String tooltip = p_class_doc->name + "." + p_doc->name; return _create_member_item(p_parent, p_class_doc->name, "MemberConstant", p_doc->name, p_doc->name, TTRC("Constant"), "constant", tooltip); diff --git a/editor/editor_help_search.h b/editor/editor_help_search.h index 3f17c992ac..26abaec6e6 100644 --- a/editor/editor_help_search.h +++ b/editor/editor_help_search.h @@ -50,7 +50,8 @@ class EditorHelpSearch : public ConfirmationDialog { SEARCH_CONSTANTS = 1 << 5, SEARCH_PROPERTIES = 1 << 6, SEARCH_THEME_ITEMS = 1 << 7, - SEARCH_ALL = SEARCH_CLASSES | SEARCH_CONSTRUCTORS | SEARCH_METHODS | SEARCH_OPERATORS | SEARCH_SIGNALS | SEARCH_CONSTANTS | SEARCH_PROPERTIES | SEARCH_THEME_ITEMS, + SEARCH_ANNOTATIONS = 1 << 8, + SEARCH_ALL = SEARCH_CLASSES | SEARCH_CONSTRUCTORS | SEARCH_METHODS | SEARCH_OPERATORS | SEARCH_SIGNALS | SEARCH_CONSTANTS | SEARCH_PROPERTIES | SEARCH_THEME_ITEMS | SEARCH_ANNOTATIONS, SEARCH_CASE_SENSITIVE = 1 << 29, SEARCH_SHOW_HIERARCHY = 1 << 30 }; @@ -108,9 +109,10 @@ class EditorHelpSearch::Runner : public RefCounted { Vector<DocData::ConstantDoc *> constants; Vector<DocData::PropertyDoc *> properties; Vector<DocData::ThemeItemDoc *> theme_properties; + Vector<DocData::MethodDoc *> annotations; bool required() { - return name || methods.size() || signals.size() || constants.size() || properties.size() || theme_properties.size(); + return name || methods.size() || signals.size() || constants.size() || properties.size() || theme_properties.size() || annotations.size(); } }; @@ -141,12 +143,15 @@ class EditorHelpSearch::Runner : public RefCounted { bool _phase_member_items(); bool _phase_select_match(); + String _build_method_tooltip(const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc) const; + bool _match_string(const String &p_term, const String &p_string) const; void _match_item(TreeItem *p_item, const String &p_text); TreeItem *_create_class_hierarchy(const ClassMatch &p_match); TreeItem *_create_class_item(TreeItem *p_parent, const DocData::ClassDoc *p_doc, bool p_gray); TreeItem *_create_method_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const String &p_text, const DocData::MethodDoc *p_doc); TreeItem *_create_signal_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc); + TreeItem *_create_annotation_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const String &p_text, const DocData::MethodDoc *p_doc); TreeItem *_create_constant_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ConstantDoc *p_doc); TreeItem *_create_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc); TreeItem *_create_theme_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ThemeItemDoc *p_doc); diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index bdf1c314f8..c1a7b15121 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -2711,6 +2711,11 @@ void EditorInspector::update_tree() { continue; } + // Hide the "MultiNodeEdit" category for MultiNodeEdit. + if (Object::cast_to<MultiNodeEdit>(object) && p.name == "MultiNodeEdit") { + continue; + } + // Iterate over remaining properties. If no properties in category, skip the category. List<PropertyInfo>::Element *N = E_property->next(); bool valid = true; @@ -2819,6 +2824,11 @@ void EditorInspector::update_tree() { continue; } + if (p.name.begins_with("metadata/") && bool(object->call("_hide_metadata_from_inspector"))) { + // Hide metadata from inspector if required. + continue; + } + // Get the path for property. String path = p.name; @@ -3089,6 +3099,8 @@ void EditorInspector::update_tree() { StringName classname = doc_name == "" ? object->get_class_name() : doc_name; if (!object_class.is_empty()) { classname = object_class; + } else if (Object::cast_to<MultiNodeEdit>(object)) { + classname = Object::cast_to<MultiNodeEdit>(object)->get_edited_class_name(); } StringName propname = property_prefix + p.name; @@ -3242,7 +3254,7 @@ void EditorInspector::update_tree() { } } - if (!hide_metadata) { + if (!hide_metadata && !object->call("_hide_metadata_from_inspector")) { // Add 4px of spacing between the "Add Metadata" button and the content above it. Control *spacer = memnew(Control); spacer->set_custom_minimum_size(Size2(0, 4) * EDSCALE); @@ -3475,9 +3487,9 @@ void EditorInspector::_update_inspector_bg() { n = n->get_parent(); } count_subinspectors = MIN(15, count_subinspectors); - add_theme_style_override("bg", get_theme_stylebox("sub_inspector_bg" + itos(count_subinspectors), SNAME("Editor"))); + add_theme_style_override("panel", get_theme_stylebox("sub_inspector_bg" + itos(count_subinspectors), SNAME("Editor"))); } else { - add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); } } void EditorInspector::set_sub_inspector(bool p_enable) { diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index c2820389c6..96b229b7ee 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -37,7 +37,7 @@ #include "core/io/image_loader.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" -#include "core/io/stream_peer_ssl.h" +#include "core/io/stream_peer_tls.h" #include "core/object/class_db.h" #include "core/object/message_queue.h" #include "core/os/keyboard.h" @@ -762,11 +762,8 @@ void EditorNode::_notification(int p_what) { gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Background"), SNAME("EditorStyles"))); scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Content"), SNAME("EditorStyles"))); - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); - + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanel"), SNAME("EditorStyles"))); tabbar_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("tabbar_background"), SNAME("TabContainer"))); - scene_tabs->add_theme_style_override("tab_selected", gui_base->get_theme_stylebox(SNAME("SceneTabFG"), SNAME("EditorStyles"))); - scene_tabs->add_theme_style_override("tab_unselected", gui_base->get_theme_stylebox(SNAME("SceneTabBG"), SNAME("EditorStyles"))); main_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); } @@ -1071,7 +1068,7 @@ void EditorNode::_sources_changed(bool p_exist) { // Reload the global shader variables, but this time // loading textures, as they are now properly imported. - RenderingServer::get_singleton()->global_shader_uniforms_load_settings(true); + RenderingServer::get_singleton()->global_shader_parameters_load_settings(true); // Start preview thread now that it's safe. if (!singleton->cmdline_export_mode) { @@ -3098,14 +3095,14 @@ void EditorNode::_screenshot(bool p_use_utc) { } void EditorNode::_save_screenshot(NodePath p_path) { - Control *editor_main_control = EditorInterface::get_singleton()->get_editor_main_control(); - ERR_FAIL_COND_MSG(!editor_main_control, "Cannot get editor main control."); - Viewport *viewport = editor_main_control->get_viewport(); - ERR_FAIL_COND_MSG(!viewport, "Cannot get editor main control viewport."); + Control *editor_main_screen = EditorInterface::get_singleton()->get_editor_main_screen(); + ERR_FAIL_COND_MSG(!editor_main_screen, "Cannot get the editor main screen control."); + Viewport *viewport = editor_main_screen->get_viewport(); + ERR_FAIL_COND_MSG(!viewport, "Cannot get a viewport from the editor main screen."); Ref<ViewportTexture> texture = viewport->get_texture(); - ERR_FAIL_COND_MSG(texture.is_null(), "Cannot get editor main control viewport texture."); + ERR_FAIL_COND_MSG(texture.is_null(), "Cannot get a viewport texture from the editor main screen."); Ref<Image> img = texture->get_image(); - ERR_FAIL_COND_MSG(img.is_null(), "Cannot get editor main control viewport texture image."); + ERR_FAIL_COND_MSG(img.is_null(), "Cannot get an image from a viewport texture of the editor main screen."); Error error = img->save_png(p_path); ERR_FAIL_COND_MSG(error != OK, "Cannot save screenshot to file '" + p_path + "'."); } @@ -3289,8 +3286,8 @@ void EditorNode::_update_file_menu_closed() { file_menu->set_item_disabled(file_menu->get_item_index(FILE_OPEN_PREV), false); } -Control *EditorNode::get_main_control() { - return main_control; +VBoxContainer *EditorNode::get_main_screen_control() { + return main_screen_vbox; } void EditorNode::_editor_select(int p_which) { @@ -5475,7 +5472,7 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) { // This is the debug panel which uses tabs, so the top section should be smaller. bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))); } else { - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanel"), SNAME("EditorStyles"))); } center_split->set_dragger_visibility(SplitContainer::DRAGGER_VISIBLE); center_split->set_collapsed(false); @@ -5485,7 +5482,7 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) { bottom_panel_raise->show(); } else { - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanel"), SNAME("EditorStyles"))); bottom_panel_items[p_idx].button->set_pressed(false); bottom_panel_items[p_idx].control->set_visible(false); center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN); @@ -6528,8 +6525,6 @@ EditorNode::EditorNode() { tabbar_panel->add_child(tabbar_container); scene_tabs = memnew(TabBar); - scene_tabs->add_theme_style_override("tab_selected", gui_base->get_theme_stylebox(SNAME("SceneTabFG"), SNAME("EditorStyles"))); - scene_tabs->add_theme_style_override("tab_unselected", gui_base->get_theme_stylebox(SNAME("SceneTabBG"), SNAME("EditorStyles"))); scene_tabs->set_select_with_rmb(true); scene_tabs->add_tab("unsaved"); scene_tabs->set_tab_close_display_policy((TabBar::CloseButtonDisplayPolicy)EDITOR_GET("interface/scene_tabs/display_close_button").operator int()); @@ -6588,10 +6583,11 @@ EditorNode::EditorNode() { scene_root->set_disable_input(true); scene_root->set_as_audio_listener_2d(true); - main_control = memnew(VBoxContainer); - main_control->set_v_size_flags(Control::SIZE_EXPAND_FILL); - main_control->add_theme_constant_override("separation", 0); - scene_root_parent->add_child(main_control); + main_screen_vbox = memnew(VBoxContainer); + main_screen_vbox->set_name("MainScreen"); + main_screen_vbox->set_v_size_flags(Control::SIZE_EXPAND_FILL); + main_screen_vbox->add_theme_constant_override("separation", 0); + scene_root_parent->add_child(main_screen_vbox); bool global_menu = !bool(EDITOR_GET("interface/editor/use_embedded_menu")) && DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU); bool can_expand = bool(EDITOR_GET("interface/editor/expand_to_title")) && DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_EXTEND_TO_TITLE); @@ -7093,7 +7089,7 @@ EditorNode::EditorNode() { // Bottom panels. bottom_panel = memnew(PanelContainer); - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanel"), SNAME("EditorStyles"))); center_split->add_child(bottom_panel); center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN); diff --git a/editor/editor_node.h b/editor/editor_node.h index c3b4c985cc..df3d2ae0f8 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -323,7 +323,7 @@ private: Control *vp_base = nullptr; EditorTitleBar *menu_hb = nullptr; - Control *main_control = nullptr; + VBoxContainer *main_screen_vbox = nullptr; MenuBar *main_menu = nullptr; PopupMenu *file_menu = nullptr; PopupMenu *project_menu = nullptr; @@ -788,7 +788,7 @@ public: bool is_changing_scene() const; - Control *get_main_control(); + VBoxContainer *get_main_screen_control(); SubViewport *get_scene_root() { return scene_root; } // Root of the scene being edited. void set_edited_scene(Node *p_scene); diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp index a8f8f7ab97..d1f41dad84 100644 --- a/editor/editor_path.cpp +++ b/editor/editor_path.cpp @@ -33,6 +33,7 @@ #include "editor/editor_data.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" +#include "editor/multi_node_edit.h" void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) { if (p_depth > 8) { @@ -121,14 +122,22 @@ void EditorPath::update_path() { continue; } - Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj); + Ref<Texture2D> icon; + if (Object::cast_to<MultiNodeEdit>(obj)) { + icon = EditorNode::get_singleton()->get_class_icon(Object::cast_to<MultiNodeEdit>(obj)->get_edited_class_name()); + } else { + icon = EditorNode::get_singleton()->get_object_icon(obj); + } + if (icon.is_valid()) { current_object_icon->set_texture(icon); } if (i == history->get_path_size() - 1) { String name; - if (Object::cast_to<Resource>(obj)) { + if (obj->has_method("_get_editor_name")) { + name = obj->call("_get_editor_name"); + } else if (Object::cast_to<Resource>(obj)) { Resource *r = Object::cast_to<Resource>(obj); if (r->get_path().is_resource_file()) { name = r->get_path().get_file(); @@ -149,7 +158,7 @@ void EditorPath::update_path() { name = obj->get_class(); } - current_object_label->set_text(" " + name); // An extra space so the text is not too close of the icon. + current_object_label->set_text(name); set_tooltip_text(obj->get_class()); } } @@ -161,12 +170,12 @@ void EditorPath::clear_path() { current_object_label->set_text(""); current_object_icon->set_texture(nullptr); - sub_objects_icon->set_visible(false); + sub_objects_icon->hide(); } void EditorPath::enable_path() { set_disabled(false); - sub_objects_icon->set_visible(true); + sub_objects_icon->show(); } void EditorPath::_id_pressed(int p_idx) { @@ -186,7 +195,7 @@ void EditorPath::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { update_path(); - sub_objects_icon->set_texture(get_theme_icon(SNAME("select_arrow"), SNAME("Tree"))); + sub_objects_icon->set_texture(get_theme_icon(SNAME("arrow"), SNAME("OptionButton"))); current_object_label->add_theme_font_override("font", get_theme_font(SNAME("main"), SNAME("EditorFonts"))); } break; @@ -216,13 +225,12 @@ EditorPath::EditorPath(EditorSelectionHistory *p_history) { main_hb->add_child(current_object_icon); current_object_label = memnew(Label); - current_object_label->set_clip_text(true); - current_object_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_LEFT); + current_object_label->set_text_overrun_behavior(TextServer::OVERRUN_TRIM_ELLIPSIS); current_object_label->set_h_size_flags(SIZE_EXPAND_FILL); main_hb->add_child(current_object_label); sub_objects_icon = memnew(TextureRect); - sub_objects_icon->set_visible(false); + sub_objects_icon->hide(); sub_objects_icon->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED); main_hb->add_child(sub_objects_icon); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 4fc6947636..f3ac8f4ba0 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -48,7 +48,7 @@ #include "scene/gui/popup_menu.h" #include "servers/rendering_server.h" -TypedArray<Texture2D> EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_size) { +TypedArray<Texture2D> EditorInterface::_make_mesh_previews(const TypedArray<Mesh> &p_meshes, int p_preview_size) { Vector<Ref<Mesh>> meshes; for (int i = 0; i < p_meshes.size(); i++) { @@ -156,8 +156,8 @@ void EditorInterface::set_main_screen_editor(const String &p_name) { EditorNode::get_singleton()->select_editor_by_name(p_name); } -Control *EditorInterface::get_editor_main_control() { - return EditorNode::get_singleton()->get_main_control(); +VBoxContainer *EditorInterface::get_editor_main_screen() { + return EditorNode::get_singleton()->get_main_screen_control(); } void EditorInterface::edit_resource(const Ref<Resource> &p_resource) { @@ -352,7 +352,7 @@ void EditorInterface::_bind_methods() { ClassDB::bind_method(D_METHOD("get_edited_scene_root"), &EditorInterface::get_edited_scene_root); ClassDB::bind_method(D_METHOD("get_resource_previewer"), &EditorInterface::get_resource_previewer); ClassDB::bind_method(D_METHOD("get_resource_filesystem"), &EditorInterface::get_resource_file_system); - ClassDB::bind_method(D_METHOD("get_editor_main_control"), &EditorInterface::get_editor_main_control); + ClassDB::bind_method(D_METHOD("get_editor_main_screen"), &EditorInterface::get_editor_main_screen); ClassDB::bind_method(D_METHOD("make_mesh_previews", "meshes", "preview_size"), &EditorInterface::_make_mesh_previews); ClassDB::bind_method(D_METHOD("select_file", "file"), &EditorInterface::select_file); ClassDB::bind_method(D_METHOD("get_selected_path"), &EditorInterface::get_selected_path); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 8357f0960a..fe01524bea 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -67,12 +67,12 @@ protected: static void _bind_methods(); static EditorInterface *singleton; - TypedArray<Texture2D> _make_mesh_previews(const Array &p_meshes, int p_preview_size); + TypedArray<Texture2D> _make_mesh_previews(const TypedArray<Mesh> &p_meshes, int p_preview_size); public: static EditorInterface *get_singleton() { return singleton; } - Control *get_editor_main_control(); + VBoxContainer *get_editor_main_screen(); void edit_resource(const Ref<Resource> &p_resource); void edit_node(Node *p_node); void edit_script(const Ref<Script> &p_script, int p_line = -1, int p_col = 0, bool p_grab_focus = true); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index d78fee6ad6..7364258a07 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -4182,8 +4182,8 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, const Varian } struct EditorPropertyRangeHint { - bool greater = true; - bool lesser = true; + bool or_greater = true; + bool or_less = true; double min = -99999.0; double max = 99999.0; double step = 1.0; @@ -4201,8 +4201,8 @@ static EditorPropertyRangeHint _parse_range_hint(PropertyHint p_hint, const Stri ERR_FAIL_COND_V_MSG(slices.size() < 2, hint, vformat("Invalid PROPERTY_HINT_RANGE with hint \"%s\": Missing required min and/or max values.", p_hint_text)); - hint.greater = false; // If using ranged, assume false by default. - hint.lesser = false; + hint.or_greater = false; // If using ranged, assume false by default. + hint.or_less = false; hint.min = slices[0].to_float(); hint.max = slices[1].to_float(); @@ -4215,9 +4215,9 @@ static EditorPropertyRangeHint _parse_range_hint(PropertyHint p_hint, const Stri for (int i = 2; i < slices.size(); i++) { String slice = slices[i].strip_edges(); if (slice == "or_greater") { - hint.greater = true; - } else if (slice == "or_lesser") { - hint.lesser = true; + hint.or_greater = true; + } else if (slice == "or_less") { + hint.or_less = true; } else if (slice == "no_slider") { hint.hide_slider = true; } else if (slice == "exp") { @@ -4314,7 +4314,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ EditorPropertyInteger *editor = memnew(EditorPropertyInteger); EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1); - editor->setup(hint.min, hint.max, hint.step, hint.greater, hint.lesser, hint.suffix); + editor->setup(hint.min, hint.max, hint.step, hint.or_greater, hint.or_less, hint.suffix); return editor; } @@ -4342,7 +4342,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ EditorPropertyFloat *editor = memnew(EditorPropertyFloat); EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step); - editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.exp_range, hint.greater, hint.lesser, hint.suffix, hint.radians); + editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.exp_range, hint.or_greater, hint.or_less, hint.suffix, hint.radians); return editor; } diff --git a/editor/editor_properties_array_dict.h b/editor/editor_properties_array_dict.h index 82aeebe14a..ae61418528 100644 --- a/editor/editor_properties_array_dict.h +++ b/editor/editor_properties_array_dict.h @@ -151,7 +151,7 @@ class EditorPropertyDictionary : public EditorProperty { Button *edit = nullptr; MarginContainer *container = nullptr; VBoxContainer *property_vbox = nullptr; - EditorSpinSlider *size_sliderv; + EditorSpinSlider *size_sliderv = nullptr; Button *button_add_item = nullptr; EditorPaginator *paginator = nullptr; diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index f717188b3b..5346052f4d 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -769,7 +769,7 @@ void EditorResourcePicker::_notification(int p_what) { } break; case NOTIFICATION_DRAW: { - draw_style_box(get_theme_stylebox(SNAME("bg"), SNAME("Tree")), Rect2(Point2(), get_size())); + draw_style_box(get_theme_stylebox(SNAME("panel"), SNAME("Tree")), Rect2(Point2(), get_size())); } break; case NOTIFICATION_DRAG_BEGIN: { diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp index 94ee741db5..e078bea037 100644 --- a/editor/editor_sectioned_inspector.cpp +++ b/editor/editor_sectioned_inspector.cpp @@ -113,18 +113,13 @@ class SectionedInspectorFilter : public Object { } } - bool property_can_revert(const StringName &p_name) { + bool _property_can_revert(const StringName &p_name) const { return edited->property_can_revert(section + "/" + p_name); } - Variant property_get_revert(const StringName &p_name) { - return edited->property_get_revert(section + "/" + p_name); - } - -protected: - static void _bind_methods() { - ClassDB::bind_method("property_can_revert", &SectionedInspectorFilter::property_can_revert); - ClassDB::bind_method("property_get_revert", &SectionedInspectorFilter::property_get_revert); + bool _property_get_revert(const StringName &p_name, Variant &r_property) const { + r_property = edited->property_get_revert(section + "/" + p_name); + return true; } public: diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index edd44b0a3a..5dd0a1052a 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -510,7 +510,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { // Appearance: Caret EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/appearance/caret/type", 0, "Line,Block") _initial_set("text_editor/appearance/caret/caret_blink", true); - EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "text_editor/appearance/caret/caret_blink_speed", 0.5, "0.1,10,0.01") + EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "text_editor/appearance/caret/caret_blink_interval", 0.5, "0.1,10,0.01") _initial_set("text_editor/appearance/caret/highlight_current_line", true); _initial_set("text_editor/appearance/caret/highlight_all_occurrences", true); @@ -1536,7 +1536,7 @@ Ref<Shortcut> ED_SHORTCUT_ARRAY(const String &p_path, const String &p_name, cons return sc; } -void EditorSettings::set_builtin_action_override(const String &p_name, const Array &p_events) { +void EditorSettings::set_builtin_action_override(const String &p_name, const TypedArray<InputEvent> &p_events) { List<Ref<InputEvent>> event_list; // Override the whole list, since events may have their order changed or be added, removed or edited. diff --git a/editor/editor_settings.h b/editor/editor_settings.h index 09bc4caa22..4dcf3a9cad 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -175,7 +175,7 @@ public: Ref<Shortcut> get_shortcut(const String &p_name) const; void get_shortcut_list(List<String> *r_shortcuts); - void set_builtin_action_override(const String &p_name, const Array &p_events); + void set_builtin_action_override(const String &p_name, const TypedArray<InputEvent> &p_events); const Array get_builtin_action_overrides(const String &p_name) const; void notify_changes(); diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp index d190ab57c3..9b8d46a923 100644 --- a/editor/editor_settings_dialog.cpp +++ b/editor/editor_settings_dialog.cpp @@ -193,7 +193,7 @@ void EditorSettingsDialog::_update_icons() { shortcut_search_box->set_clear_button_enabled(true); restart_close_button->set_icon(shortcuts->get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); - restart_container->add_theme_style_override("panel", shortcuts->get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + restart_container->add_theme_style_override("panel", shortcuts->get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); restart_icon->set_texture(shortcuts->get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); restart_label->add_theme_color_override("font_color", shortcuts->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); } diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index 33632649c8..58020cf682 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -42,7 +42,7 @@ String EditorSpinSlider::get_tooltip(const Point2 &p_pos) const { #else Key key = Key::CTRL; #endif - return TS->format_number(rtos(get_value())) + "\n\n" + vformat(TTR("Hold %s to round to integers. Hold Shift for more precise changes."), find_keycode_name(key)); + return TS->format_number(rtos(get_value())) + "\n\n" + vformat(TTR("Hold %s to round to integers.\nHold Shift for more precise changes."), find_keycode_name(key)); } return TS->format_number(rtos(get_value())); } diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index d0bb63dde9..5bf79635b8 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -182,7 +182,7 @@ static Ref<StyleBoxFlat> make_flat_stylebox(Color p_color, float p_margin_left = Ref<StyleBoxFlat> style(memnew(StyleBoxFlat)); style->set_bg_color(p_color); // Adjust level of detail based on the corners' effective sizes. - style->set_corner_detail(Math::ceil(1.5 * p_corner_width * EDSCALE)); + style->set_corner_detail(Math::ceil(0.8 * p_corner_width * EDSCALE)); style->set_corner_radius_all(p_corner_width * EDSCALE); style->set_default_margin(SIDE_LEFT, p_margin_left * EDSCALE); style->set_default_margin(SIDE_RIGHT, p_margin_right * EDSCALE); @@ -593,7 +593,6 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { Ref<StyleBoxFlat> style_default = make_flat_stylebox(base_color, default_margin_size, default_margin_size, default_margin_size, default_margin_size, corner_width); style_default->set_border_width_all(border_width); style_default->set_border_color(base_color); - style_default->set_draw_center(true); // Button and widgets const float extra_spacing = EDITOR_GET("interface/theme/additional_spacing"); @@ -635,6 +634,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { const Color shadow_color = Color(0, 0, 0, dark_theme ? 0.3 : 0.1); style_popup->set_shadow_color(shadow_color); style_popup->set_shadow_size(4 * EDSCALE); + // Popups are separate windows by default in the editor. Windows currently don't support per-pixel transparency + // in 4.0, and even if it was, it may not always work in practice (e.g. running with compositing disabled). + style_popup->set_corner_radius_all(0); Ref<StyleBoxLine> style_popup_separator(memnew(StyleBoxLine)); style_popup_separator->set_color(separator_color); @@ -661,14 +663,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { style_tab_base->set_border_width_all(0); // Don't round the top corners to avoid creating a small blank space between the tabs and the main panel. // This also makes the top highlight look better. - style_tab_base->set_corner_detail(corner_width); - style_tab_base->set_corner_radius_all(0); - style_tab_base->set_corner_radius(CORNER_TOP_LEFT, corner_radius * EDSCALE); - style_tab_base->set_corner_radius(CORNER_TOP_RIGHT, corner_radius * EDSCALE); - - // Prevent visible artifacts and cover the top-left rounded corner of the panel below the tab if selected - // We can't prevent them with both rounded corners and non-zero border width, though - style_tab_base->set_expand_margin_size(SIDE_BOTTOM, corner_width > 0 ? corner_width : border_width); + style_tab_base->set_corner_radius(CORNER_BOTTOM_LEFT, 0); + style_tab_base->set_corner_radius(CORNER_BOTTOM_RIGHT, 0); + // When using a border width greater than 0, visually line up the left of the selected tab with the underlying panel. style_tab_base->set_expand_margin_size(SIDE_LEFT, -border_width); @@ -897,15 +894,15 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("hover", "CheckButton", style_menu); theme->set_stylebox("hover_pressed", "CheckButton", style_menu); - theme->set_icon("on", "CheckButton", theme->get_icon(SNAME("GuiToggleOn"), SNAME("EditorIcons"))); - theme->set_icon("on_disabled", "CheckButton", theme->get_icon(SNAME("GuiToggleOnDisabled"), SNAME("EditorIcons"))); - theme->set_icon("off", "CheckButton", theme->get_icon(SNAME("GuiToggleOff"), SNAME("EditorIcons"))); - theme->set_icon("off_disabled", "CheckButton", theme->get_icon(SNAME("GuiToggleOffDisabled"), SNAME("EditorIcons"))); + theme->set_icon("checked", "CheckButton", theme->get_icon(SNAME("GuiToggleOn"), SNAME("EditorIcons"))); + theme->set_icon("checked_disabled", "CheckButton", theme->get_icon(SNAME("GuiToggleOnDisabled"), SNAME("EditorIcons"))); + theme->set_icon("unchecked", "CheckButton", theme->get_icon(SNAME("GuiToggleOff"), SNAME("EditorIcons"))); + theme->set_icon("unchecked_disabled", "CheckButton", theme->get_icon(SNAME("GuiToggleOffDisabled"), SNAME("EditorIcons"))); - theme->set_icon("on_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOnMirrored"), SNAME("EditorIcons"))); - theme->set_icon("on_disabled_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOnDisabledMirrored"), SNAME("EditorIcons"))); - theme->set_icon("off_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOffMirrored"), SNAME("EditorIcons"))); - theme->set_icon("off_disabled_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOffDisabledMirrored"), SNAME("EditorIcons"))); + theme->set_icon("checked_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOnMirrored"), SNAME("EditorIcons"))); + theme->set_icon("checked_disabled_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOnDisabledMirrored"), SNAME("EditorIcons"))); + theme->set_icon("unchecked_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOffMirrored"), SNAME("EditorIcons"))); + theme->set_icon("unchecked_disabled_mirrored", "CheckButton", theme->get_icon(SNAME("GuiToggleOffDisabledMirrored"), SNAME("EditorIcons"))); theme->set_color("font_color", "CheckButton", font_color); theme->set_color("font_hover_color", "CheckButton", font_hover_color); @@ -921,7 +918,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("icon_disabled_color", "CheckButton", icon_disabled_color); theme->set_constant("h_separation", "CheckButton", 8 * EDSCALE); - theme->set_constant("check_v_adjust", "CheckButton", 0 * EDSCALE); + theme->set_constant("check_v_offset", "CheckButton", 0 * EDSCALE); // Checkbox Ref<StyleBoxFlat> sb_checkbox = style_menu->duplicate(); @@ -958,7 +955,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("icon_disabled_color", "CheckBox", icon_disabled_color); theme->set_constant("h_separation", "CheckBox", 8 * EDSCALE); - theme->set_constant("check_v_adjust", "CheckBox", 0 * EDSCALE); + theme->set_constant("check_v_offset", "CheckBox", 0 * EDSCALE); // PopupDialog theme->set_stylebox("panel", "PopupDialog", style_popup); @@ -975,9 +972,6 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // Always display a border for PopupMenus so they can be distinguished from their background. style_popup_menu->set_border_width_all(EDSCALE); style_popup_menu->set_border_color(dark_color_2); - // Popups are separate windows by default in the editor. Windows currently don't support per-pixel transparency - // in 4.0, and even if it was, it may not always work in practice (e.g. running with compositing disabled). - style_popup_menu->set_corner_radius_all(0); theme->set_stylebox("panel", "PopupMenu", style_popup_menu); Ref<StyleBoxFlat> style_menu_hover = style_widget_hover->duplicate(); @@ -1101,7 +1095,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // Make Trees easier to distinguish from other controls by using a darker background color. style_tree_bg->set_bg_color(dark_color_1.lerp(dark_color_2, 0.5)); style_tree_bg->set_border_color(dark_color_3); - theme->set_stylebox("bg", "Tree", style_tree_bg); + theme->set_stylebox("panel", "Tree", style_tree_bg); // Tree theme->set_icon("checked", "Tree", theme->get_icon(SNAME("GuiChecked"), SNAME("EditorIcons"))); @@ -1112,7 +1106,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("arrow_collapsed_mirrored", "Tree", theme->get_icon(SNAME("GuiTreeArrowLeft"), SNAME("EditorIcons"))); theme->set_icon("updown", "Tree", theme->get_icon(SNAME("GuiTreeUpdown"), SNAME("EditorIcons"))); theme->set_icon("select_arrow", "Tree", theme->get_icon(SNAME("GuiDropdown"), SNAME("EditorIcons"))); - theme->set_stylebox("bg_focus", "Tree", style_widget_focus); + theme->set_stylebox("focus", "Tree", style_widget_focus); theme->set_stylebox("custom_button", "Tree", make_empty_stylebox()); theme->set_stylebox("custom_button_pressed", "Tree", make_empty_stylebox()); theme->set_stylebox("custom_button_hover", "Tree", style_widget); @@ -1203,26 +1197,24 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { style_itemlist_cursor->set_draw_center(false); style_itemlist_cursor->set_border_width_all(border_width); style_itemlist_cursor->set_border_color(highlight_color); + theme->set_stylebox("panel", "ItemList", style_itemlist_bg); + theme->set_stylebox("focus", "ItemList", style_widget_focus); theme->set_stylebox("cursor", "ItemList", style_itemlist_cursor); theme->set_stylebox("cursor_unfocused", "ItemList", style_itemlist_cursor); theme->set_stylebox("selected_focus", "ItemList", style_tree_focus); theme->set_stylebox("selected", "ItemList", style_tree_selected); - theme->set_stylebox("bg_focus", "ItemList", style_widget_focus); - theme->set_stylebox("bg", "ItemList", style_itemlist_bg); theme->set_color("font_color", "ItemList", font_color); theme->set_color("font_selected_color", "ItemList", mono_color); theme->set_color("guide_color", "ItemList", guide_color); - theme->set_constant("v_separation", "ItemList", widget_default_margin.y - EDSCALE); + theme->set_constant("v_separation", "ItemList", force_even_vsep * 0.5 * EDSCALE); theme->set_constant("h_separation", "ItemList", 6 * EDSCALE); theme->set_constant("icon_margin", "ItemList", 6 * EDSCALE); theme->set_constant("line_separation", "ItemList", 3 * EDSCALE); // TabBar & TabContainer - Ref<StyleBoxFlat> style_tabbar_background = make_flat_stylebox(dark_color_1, 0, 0, 0, 0); - style_tabbar_background->set_expand_margin_size(SIDE_BOTTOM, corner_width > 0 ? corner_width : border_width); - style_tabbar_background->set_corner_detail(corner_width); - style_tabbar_background->set_corner_radius(CORNER_TOP_LEFT, corner_radius * EDSCALE); - style_tabbar_background->set_corner_radius(CORNER_TOP_RIGHT, corner_radius * EDSCALE); + Ref<StyleBoxFlat> style_tabbar_background = make_flat_stylebox(dark_color_1, 0, 0, 0, 0, corner_radius * EDSCALE); + style_tabbar_background->set_corner_radius(CORNER_BOTTOM_LEFT, 0); + style_tabbar_background->set_corner_radius(CORNER_BOTTOM_RIGHT, 0); theme->set_stylebox("tabbar_background", "TabContainer", style_tabbar_background); theme->set_stylebox("tab_selected", "TabContainer", style_tab_selected); @@ -1233,8 +1225,6 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("tab_disabled", "TabBar", style_tab_disabled); theme->set_stylebox("button_pressed", "TabBar", style_menu); theme->set_stylebox("button_highlight", "TabBar", style_menu); - theme->set_stylebox("SceneTabFG", "EditorStyles", style_tab_selected); - theme->set_stylebox("SceneTabBG", "EditorStyles", style_tab_unselected); theme->set_color("font_selected_color", "TabContainer", font_color); theme->set_color("font_unselected_color", "TabContainer", font_disabled_color); theme->set_color("font_selected_color", "TabBar", font_color); @@ -1254,22 +1244,28 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("decrement_highlight", "TabContainer", theme->get_icon(SNAME("GuiScrollArrowLeftHl"), SNAME("EditorIcons"))); theme->set_icon("drop_mark", "TabContainer", theme->get_icon(SNAME("GuiTabDropMark"), SNAME("EditorIcons"))); theme->set_icon("drop_mark", "TabBar", theme->get_icon(SNAME("GuiTabDropMark"), SNAME("EditorIcons"))); + theme->set_constant("side_margin", "TabContainer", 0); theme->set_constant("h_separation", "TabBar", 4 * EDSCALE); - // Content of each tab + // Content of each tab. Ref<StyleBoxFlat> style_content_panel = style_default->duplicate(); style_content_panel->set_border_color(dark_color_3); style_content_panel->set_border_width_all(border_width); style_content_panel->set_border_width(Side::SIDE_TOP, 0); style_content_panel->set_corner_radius(CORNER_TOP_LEFT, 0); style_content_panel->set_corner_radius(CORNER_TOP_RIGHT, 0); - // compensate the border + // Compensate for the border. style_content_panel->set_default_margin(SIDE_TOP, (2 + margin_size_extra) * EDSCALE); style_content_panel->set_default_margin(SIDE_RIGHT, margin_size_extra * EDSCALE); style_content_panel->set_default_margin(SIDE_BOTTOM, margin_size_extra * EDSCALE); style_content_panel->set_default_margin(SIDE_LEFT, margin_size_extra * EDSCALE); theme->set_stylebox("panel", "TabContainer", style_content_panel); + // Bottom panel. + Ref<StyleBoxFlat> style_bottom_panel = style_content_panel->duplicate(); + style_bottom_panel->set_corner_radius_all(corner_radius * EDSCALE); + theme->set_stylebox("BottomPanel", "EditorStyles", style_bottom_panel); + // TabContainerOdd can be used on tabs against the base color background (e.g. nested tabs). theme->set_type_variation("TabContainerOdd", "TabContainer"); @@ -1348,7 +1344,6 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("normal", "TextEdit", style_line_edit); theme->set_stylebox("focus", "TextEdit", style_widget_focus); theme->set_stylebox("read_only", "TextEdit", style_line_edit_disabled); - theme->set_constant("side_margin", "TabContainer", 0); theme->set_icon("tab", "TextEdit", theme->get_icon(SNAME("GuiTab"), SNAME("EditorIcons"))); theme->set_icon("space", "TextEdit", theme->get_icon(SNAME("GuiSpace"), SNAME("EditorIcons"))); theme->set_color("font_color", "TextEdit", font_color); @@ -1425,6 +1420,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // AcceptDialog theme->set_stylebox("panel", "AcceptDialog", style_window_title); + theme->set_constant("buttons_separation", "AcceptDialog", 8 * EDSCALE); // HScrollBar Ref<Texture2D> empty_icon = memnew(ImageTexture); @@ -1552,8 +1548,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("updown_disabled", "SpinBox", theme->get_icon(SNAME("GuiSpinboxUpdownDisabled"), SNAME("EditorIcons"))); // ProgressBar - theme->set_stylebox("bg", "ProgressBar", make_stylebox(theme->get_icon(SNAME("GuiProgressBar"), SNAME("EditorIcons")), 4, 4, 4, 4, 0, 0, 0, 0)); - theme->set_stylebox("fg", "ProgressBar", make_stylebox(theme->get_icon(SNAME("GuiProgressFill"), SNAME("EditorIcons")), 6, 6, 6, 6, 2, 1, 2, 1)); + theme->set_stylebox("background", "ProgressBar", make_stylebox(theme->get_icon(SNAME("GuiProgressBar"), SNAME("EditorIcons")), 4, 4, 4, 4, 0, 0, 0, 0)); + theme->set_stylebox("fill", "ProgressBar", make_stylebox(theme->get_icon(SNAME("GuiProgressFill"), SNAME("EditorIcons")), 6, 6, 6, 6, 2, 1, 2, 1)); theme->set_color("font_color", "ProgressBar", font_color); // GraphEdit @@ -1653,6 +1649,11 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { graphsbcomment->set_border_width(SIDE_TOP, 24 * EDSCALE); graphsbcommentselected->set_border_width(SIDE_TOP, 24 * EDSCALE); + graphsb->set_corner_detail(corner_radius * EDSCALE); + graphsbselected->set_corner_detail(corner_radius * EDSCALE); + graphsbcomment->set_corner_detail(corner_radius * EDSCALE); + graphsbcommentselected->set_corner_detail(corner_radius * EDSCALE); + theme->set_stylebox("frame", "GraphNode", graphsb); theme->set_stylebox("selected_frame", "GraphNode", graphsbselected); theme->set_stylebox("comment", "GraphNode", graphsbcomment); @@ -1694,7 +1695,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("toggle_hidden", "FileDialog", theme->get_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"))); // Use a different color for folder icons to make them easier to distinguish from files. // On a light theme, the icon will be dark, so we need to lighten it before blending it with the accent color. - theme->set_color("folder_icon_modulate", "FileDialog", (dark_theme ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25)).lerp(accent_color, 0.7)); + theme->set_color("folder_icon_color", "FileDialog", (dark_theme ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25)).lerp(accent_color, 0.7)); theme->set_color("files_disabled", "FileDialog", font_disabled_color); // ColorPicker diff --git a/editor/editor_toaster.cpp b/editor/editor_toaster.cpp index 5b015fc95c..e66b782f3c 100644 --- a/editor/editor_toaster.cpp +++ b/editor/editor_toaster.cpp @@ -284,7 +284,7 @@ void EditorToaster::_draw_button() { void EditorToaster::_draw_progress(Control *panel) { if (toasts.has(panel) && toasts[panel].remaining_time > 0 && toasts[panel].duration > 0) { Size2 size = panel->get_size(); - size.x *= MIN(1, Math::range_lerp(toasts[panel].remaining_time, 0, toasts[panel].duration, 0, 2)); + size.x *= MIN(1, Math::remap(toasts[panel].remaining_time, 0, toasts[panel].duration, 0, 2)); Ref<StyleBoxFlat> stylebox; switch (toasts[panel].severity) { diff --git a/editor/editor_translation_parser.cpp b/editor/editor_translation_parser.cpp index eb4df3b630..eb38e203a5 100644 --- a/editor/editor_translation_parser.cpp +++ b/editor/editor_translation_parser.cpp @@ -38,8 +38,8 @@ EditorTranslationParser *EditorTranslationParser::singleton = nullptr; Error EditorTranslationParserPlugin::parse_file(const String &p_path, Vector<String> *r_ids, Vector<Vector<String>> *r_ids_ctx_plural) { - Array ids; - Array ids_ctx_plural; + TypedArray<String> ids; + TypedArray<Array> ids_ctx_plural; if (GDVIRTUAL_CALL(_parse_file, p_path, ids, ids_ctx_plural)) { // Add user's extracted translatable messages. diff --git a/editor/editor_translation_parser.h b/editor/editor_translation_parser.h index bd770250f9..0fe166a0b0 100644 --- a/editor/editor_translation_parser.h +++ b/editor/editor_translation_parser.h @@ -35,6 +35,7 @@ #include "core/object/gdvirtual.gen.inc" #include "core/object/ref_counted.h" #include "core/object/script_language.h" +#include "core/variant/typed_array.h" class EditorTranslationParserPlugin : public RefCounted { GDCLASS(EditorTranslationParserPlugin, RefCounted); @@ -42,7 +43,7 @@ class EditorTranslationParserPlugin : public RefCounted { protected: static void _bind_methods(); - GDVIRTUAL3(_parse_file, String, Array, Array) + GDVIRTUAL3(_parse_file, String, TypedArray<String>, TypedArray<Array>) GDVIRTUAL0RC(Vector<String>, _get_recognized_extensions) public: diff --git a/editor/editor_vcs_interface.cpp b/editor/editor_vcs_interface.cpp index 0c6c876b2f..d22c7bd149 100644 --- a/editor/editor_vcs_interface.cpp +++ b/editor/editor_vcs_interface.cpp @@ -57,7 +57,7 @@ void EditorVCSInterface::set_credentials(String p_username, String p_password, S } List<String> EditorVCSInterface::get_remotes() { - Array result; + TypedArray<Dictionary> result; if (!GDVIRTUAL_CALL(_get_remotes, result)) { UNIMPLEMENTED(); return {}; @@ -71,7 +71,7 @@ List<String> EditorVCSInterface::get_remotes() { } List<EditorVCSInterface::StatusFile> EditorVCSInterface::get_modified_files_data() { - Array result; + TypedArray<Dictionary> result; if (!GDVIRTUAL_CALL(_get_modified_files_data, result)) { UNIMPLEMENTED(); return {}; @@ -123,7 +123,7 @@ List<EditorVCSInterface::DiffFile> EditorVCSInterface::get_diff(String p_identif } List<EditorVCSInterface::Commit> EditorVCSInterface::get_previous_commits(int p_max_commits) { - Array result; + TypedArray<Dictionary> result; if (!GDVIRTUAL_CALL(_get_previous_commits, p_max_commits, result)) { UNIMPLEMENTED(); return {}; @@ -137,7 +137,7 @@ List<EditorVCSInterface::Commit> EditorVCSInterface::get_previous_commits(int p_ } List<String> EditorVCSInterface::get_branch_list() { - Array result; + TypedArray<Dictionary> result; if (!GDVIRTUAL_CALL(_get_branch_list, result)) { UNIMPLEMENTED(); return {}; @@ -210,7 +210,7 @@ void EditorVCSInterface::fetch(String p_remote) { } List<EditorVCSInterface::DiffHunk> EditorVCSInterface::get_line_diff(String p_file_path, String p_text) { - Array result; + TypedArray<Dictionary> result; if (!GDVIRTUAL_CALL(_get_line_diff, p_file_path, p_text, result)) { UNIMPLEMENTED(); return {}; @@ -257,11 +257,11 @@ Dictionary EditorVCSInterface::create_diff_hunk(int p_old_start, int p_new_start diff_hunk["old_lines"] = p_old_lines; diff_hunk["new_start"] = p_new_start; diff_hunk["old_start"] = p_old_start; - diff_hunk["diff_lines"] = Array(); + diff_hunk["diff_lines"] = TypedArray<Dictionary>(); return diff_hunk; } -Dictionary EditorVCSInterface::add_line_diffs_into_diff_hunk(Dictionary p_diff_hunk, Array p_line_diffs) { +Dictionary EditorVCSInterface::add_line_diffs_into_diff_hunk(Dictionary p_diff_hunk, TypedArray<Dictionary> p_line_diffs) { p_diff_hunk["diff_lines"] = p_line_diffs; return p_diff_hunk; } @@ -270,7 +270,7 @@ Dictionary EditorVCSInterface::create_diff_file(String p_new_file, String p_old_ Dictionary file_diff; file_diff["new_file"] = p_new_file; file_diff["old_file"] = p_old_file; - file_diff["diff_hunks"] = Array(); + file_diff["diff_hunks"] = TypedArray<Dictionary>(); return file_diff; } @@ -284,7 +284,7 @@ Dictionary EditorVCSInterface::create_commit(String p_msg, String p_author, Stri return commit_info; } -Dictionary EditorVCSInterface::add_diff_hunks_into_diff_file(Dictionary p_diff_file, Array p_diff_hunks) { +Dictionary EditorVCSInterface::add_diff_hunks_into_diff_file(Dictionary p_diff_file, TypedArray<Dictionary> p_diff_hunks) { p_diff_file["diff_hunks"] = p_diff_hunks; return p_diff_file; } @@ -312,7 +312,7 @@ EditorVCSInterface::DiffHunk EditorVCSInterface::_convert_diff_hunk(Dictionary p dh.old_lines = p_diff_hunk["old_lines"]; dh.new_start = p_diff_hunk["new_start"]; dh.old_start = p_diff_hunk["old_start"]; - Array diff_lines = p_diff_hunk["diff_lines"]; + TypedArray<Dictionary> diff_lines = p_diff_hunk["diff_lines"]; for (int i = 0; i < diff_lines.size(); i++) { DiffLine dl = _convert_diff_line(diff_lines[i]); dh.diff_lines.push_back(dl); @@ -324,7 +324,7 @@ EditorVCSInterface::DiffFile EditorVCSInterface::_convert_diff_file(Dictionary p DiffFile df; df.new_file = p_diff_file["new_file"]; df.old_file = p_diff_file["old_file"]; - Array diff_hunks = p_diff_file["diff_hunks"]; + TypedArray<Dictionary> diff_hunks = p_diff_file["diff_hunks"]; for (int i = 0; i < diff_hunks.size(); i++) { DiffHunk dh = _convert_diff_hunk(diff_hunks[i]); df.diff_hunks.push_back(dh); diff --git a/editor/editor_vcs_interface.h b/editor/editor_vcs_interface.h index e23e032ab9..5d4901cefa 100644 --- a/editor/editor_vcs_interface.h +++ b/editor/editor_vcs_interface.h @@ -108,7 +108,7 @@ protected: // Proxy endpoints for extensions to implement GDVIRTUAL1R(bool, _initialize, String); GDVIRTUAL5(_set_credentials, String, String, String, String, String); - GDVIRTUAL0R(Array, _get_modified_files_data); + GDVIRTUAL0R(TypedArray<Dictionary>, _get_modified_files_data); GDVIRTUAL1(_stage_file, String); GDVIRTUAL1(_unstage_file, String); GDVIRTUAL1(_discard_file, String); @@ -116,9 +116,9 @@ protected: GDVIRTUAL2R(TypedArray<Dictionary>, _get_diff, String, int); GDVIRTUAL0R(bool, _shut_down); GDVIRTUAL0R(String, _get_vcs_name); - GDVIRTUAL1R(Array, _get_previous_commits, int); - GDVIRTUAL0R(Array, _get_branch_list); - GDVIRTUAL0R(Array, _get_remotes); + GDVIRTUAL1R(TypedArray<Dictionary>, _get_previous_commits, int); + GDVIRTUAL0R(TypedArray<Dictionary>, _get_branch_list); + GDVIRTUAL0R(TypedArray<Dictionary>, _get_remotes); GDVIRTUAL1(_create_branch, String); GDVIRTUAL1(_remove_branch, String); GDVIRTUAL2(_create_remote, String, String); @@ -128,7 +128,7 @@ protected: GDVIRTUAL1(_pull, String); GDVIRTUAL2(_push, String, bool); GDVIRTUAL1(_fetch, String); - GDVIRTUAL2R(Array, _get_line_diff, String, String); + GDVIRTUAL2R(TypedArray<Dictionary>, _get_line_diff, String, String); public: static EditorVCSInterface *get_singleton(); @@ -171,8 +171,8 @@ public: Dictionary create_diff_file(String p_new_file, String p_old_file); Dictionary create_commit(String p_msg, String p_author, String p_id, int64_t p_unix_timestamp, int64_t p_offset_minutes); Dictionary create_status_file(String p_file_path, ChangeType p_change, TreeArea p_area); - Dictionary add_line_diffs_into_diff_hunk(Dictionary p_diff_hunk, Array p_line_diffs); - Dictionary add_diff_hunks_into_diff_file(Dictionary p_diff_file, Array p_diff_hunks); + Dictionary add_line_diffs_into_diff_hunk(Dictionary p_diff_hunk, TypedArray<Dictionary> p_line_diffs); + Dictionary add_diff_hunks_into_diff_file(Dictionary p_diff_file, TypedArray<Dictionary> p_diff_hunks); void popup_error(String p_msg); }; diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp index 525a962222..2a444bb04f 100644 --- a/editor/export/editor_export_platform.cpp +++ b/editor/export/editor_export_platform.cpp @@ -287,7 +287,7 @@ Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_pat Ref<ImageTexture> EditorExportPlatform::get_option_icon(int p_index) const { Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme(); ERR_FAIL_COND_V(theme.is_null(), Ref<ImageTexture>()); - if (EditorNode::get_singleton()->get_main_control()->is_layout_rtl()) { + if (EditorNode::get_singleton()->get_main_screen_control()->is_layout_rtl()) { return theme->get_icon(SNAME("PlayBackwards"), SNAME("EditorIcons")); } else { return theme->get_icon(SNAME("Play"), SNAME("EditorIcons")); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 19788e70da..ef8173eae4 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -76,7 +76,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory subdirectory_item->set_text(0, dname); subdirectory_item->set_structured_text_bidi_override(0, TextServer::STRUCTURED_TEXT_FILE); subdirectory_item->set_icon(0, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); - subdirectory_item->set_icon_modulate(0, get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog"))); + subdirectory_item->set_icon_modulate(0, get_theme_color(SNAME("folder_icon_color"), SNAME("FileDialog"))); subdirectory_item->set_selectable(0, true); String lpath = p_dir->get_path(); subdirectory_item->set_metadata(0, lpath); @@ -246,7 +246,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo } Ref<Texture2D> folder_icon = get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")); - const Color folder_color = get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog")); + const Color folder_color = get_theme_color(SNAME("folder_icon_color"), SNAME("FileDialog")); String text; Ref<Texture2D> icon; @@ -778,7 +778,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { } Ref<Texture2D> folder_icon = (use_thumbnails) ? folder_thumbnail : get_theme_icon(SNAME("folder"), SNAME("FileDialog")); - const Color folder_color = get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog")); + const Color folder_color = get_theme_color(SNAME("folder_icon_color"), SNAME("FileDialog")); // Build the FileInfo list. List<FileInfo> file_list; diff --git a/editor/icons/MemberAnnotation.svg b/editor/icons/MemberAnnotation.svg new file mode 100644 index 0000000000..c73ebf7b9b --- /dev/null +++ b/editor/icons/MemberAnnotation.svg @@ -0,0 +1 @@ +<svg width="16" height="16" version="1.0" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><script id="custom-useragent-string-page-script"/><path d="m13.821 12.756c-5.0033 3.9148-12.551 2.248-12.49-4.538 0.67424-11.471 17.312-7.4502 12.446 2.1173-1.0549 1.1955-2.0737 1.4617-3.1983 0.4329-0.21023-0.19282-0.44783-1.1594-0.3819-1.5089 0.35827-1.8946 1.0885-4.0778-0.72151-4.7234-2.4171-0.86457-4.5592 1.6495-4.9697 4.0193-0.47396 2.7343 2.284 3.3749 4.1487 1.9879 0.4553-0.36324 1.6433-1.3796 1.6806-1.9742" fill="none" stroke="#e0e0e0" stroke-linejoin="round" stroke-width="1.4928"/></svg> diff --git a/editor/icons/SceneUniqueName.svg b/editor/icons/SceneUniqueName.svg index 34279a14a6..c8aca7b3e6 100644 --- a/editor/icons/SceneUniqueName.svg +++ b/editor/icons/SceneUniqueName.svg @@ -1 +1,2 @@ -<svg height="16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="M4.378 2.224q1.235 0 2.084.866.865.85.865 2.083 0 1.17-.881 2.036-.866.85-2.068.85-1.218 0-2.083-.85-.866-.866-.866-2.068t.866-2.051q.865-.866 2.083-.866zm.962 1.988q-.4-.4-.962-.4-.56 0-.961.4-.401.384-.401.93 0 .56.4.961.401.385.962.385.561 0 .962-.385.4-.4.4-.946 0-.56-.4-.945zm5.45-2.116h1.218L5.677 13.78H4.442Zm1.17 5.722q1.234 0 2.083.866.866.849.866 2.1 0 1.17-.882 2.035-.865.85-2.068.85-1.218 0-2.083-.85-.866-.866-.866-2.084 0-1.202.866-2.051.865-.866 2.083-.866zm.961 1.987q-.4-.4-.962-.4-.56 0-.961.4-.4.385-.4.946 0 .561.4.962.4.384.961.384.561 0 .962-.384.4-.4.4-.946 0-.56-.4-.962z" aria-label="%" style="font-weight:600;font-size:16.0277px;font-family:FreeSans;-inkscape-font-specification:'FreeSans Semi-Bold';letter-spacing:0;word-spacing:0;fill:#e0e0e0;fill-opacity:.996078;stroke-width:.400692"/></svg> +<svg height="16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m4.378 2.224q1.235 0 2.084.866.865.85.865 2.083 0 1.17-.881 2.036-.866.85-2.068.85-1.218 0-2.083-.85-.866-.866-.866-2.068t.866-2.051q.865-.866 2.083-.866zm.962 1.988q-.4-.4-.962-.4-.56 0-.961.4-.401.384-.401.93 0 .56.4.961.401.385.962.385.561 0 .962-.385.4-.4.4-.946 0-.56-.4-.945zm5.45-2.116h1.218l-6.331 11.684h-1.235zm1.17 5.722q1.234 0 2.083.866.866.849.866 2.1 0 1.17-.882 2.035-.865.85-2.068.85-1.218 0-2.083-.85-.866-.866-.866-2.084 0-1.202.866-2.051.865-.866 2.083-.866zm.961 1.987q-.4-.4-.962-.4-.56 0-.961.4-.4.385-.4.946 0 .561.4.962.4.384.961.384.561 0 .962-.384.4-.4.4-.946 0-.56-.4-.962z" fill="#e0e0e0" stroke-width=".400692"/></svg> + diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp index 405d8d2169..d1f37179f3 100644 --- a/editor/import/dynamic_font_import_settings.cpp +++ b/editor/import/dynamic_font_import_settings.cpp @@ -1343,8 +1343,8 @@ DynamicFontImportSettings::DynamicFontImportSettings() { for (int i = 0; i < 16; i++) { glyph_table->set_column_title(i + 1, String::num_int64(i, 16)); } - glyph_table->add_theme_style_override("selected", glyph_table->get_theme_stylebox(SNAME("bg"))); - glyph_table->add_theme_style_override("selected_focus", glyph_table->get_theme_stylebox(SNAME("bg"))); + glyph_table->add_theme_style_override("selected", glyph_table->get_theme_stylebox(SNAME("panel"))); + glyph_table->add_theme_style_override("selected_focus", glyph_table->get_theme_stylebox(SNAME("panel"))); glyph_table->add_theme_constant_override("h_separation", 0); glyph_table->set_h_size_flags(Control::SIZE_EXPAND_FILL); glyph_table->set_v_size_flags(Control::SIZE_EXPAND_FILL); diff --git a/editor/import/editor_import_plugin.cpp b/editor/import/editor_import_plugin.cpp index 3305f241c0..5211f003c1 100644 --- a/editor/import/editor_import_plugin.cpp +++ b/editor/import/editor_import_plugin.cpp @@ -164,7 +164,7 @@ bool EditorImportPlugin::get_option_visibility(const String &p_path, const Strin Error EditorImportPlugin::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { Dictionary options; - Array platform_variants, gen_files; + TypedArray<String> platform_variants, gen_files; HashMap<StringName, Variant>::ConstIterator E = p_options.begin(); while (E) { diff --git a/editor/import/editor_import_plugin.h b/editor/import/editor_import_plugin.h index e9749c240f..1468ed082b 100644 --- a/editor/import/editor_import_plugin.h +++ b/editor/import/editor_import_plugin.h @@ -51,7 +51,7 @@ protected: GDVIRTUAL0RC(float, _get_priority) GDVIRTUAL0RC(int, _get_import_order) GDVIRTUAL3RC(bool, _get_option_visibility, String, StringName, Dictionary) - GDVIRTUAL5RC(int, _import, String, String, Dictionary, Array, Array) + GDVIRTUAL5RC(int, _import, String, String, Dictionary, TypedArray<String>, TypedArray<String>) public: EditorImportPlugin(); diff --git a/editor/import/post_import_plugin_skeleton_renamer.cpp b/editor/import/post_import_plugin_skeleton_renamer.cpp index 69c0a047e4..72ccb832c7 100644 --- a/editor/import/post_import_plugin_skeleton_renamer.cpp +++ b/editor/import/post_import_plugin_skeleton_renamer.cpp @@ -143,7 +143,7 @@ void PostImportPluginSkeletonRenamer::internal_process(InternalImportCategory p_ // Make unique skeleton. if (bool(p_options["retarget/bone_renamer/unique_node/make_unique"])) { String unique_name = String(p_options["retarget/bone_renamer/unique_node/skeleton_name"]); - ERR_FAIL_COND_MSG(unique_name == String(), "Skeleton unique name cannot be empty."); + ERR_FAIL_COND_MSG(unique_name.is_empty(), "Skeleton unique name cannot be empty."); TypedArray<Node> nodes = p_base_scene->find_children("*", "AnimationPlayer"); while (nodes.size()) { diff --git a/editor/import/post_import_plugin_skeleton_rest_fixer.cpp b/editor/import/post_import_plugin_skeleton_rest_fixer.cpp index 6f775c7ea8..a5ef2e7f97 100644 --- a/editor/import/post_import_plugin_skeleton_rest_fixer.cpp +++ b/editor/import/post_import_plugin_skeleton_rest_fixer.cpp @@ -90,16 +90,9 @@ void PostImportPluginSkeletonRestFixer::internal_process(InternalImportCategory } } - // Apply node transforms. + // Get global transform. + Transform3D global_transform; if (bool(p_options["retarget/rest_fixer/apply_node_transforms"])) { - LocalVector<Transform3D> old_skeleton_rest; - LocalVector<Transform3D> old_skeleton_global_rest; - for (int i = 0; i < src_skeleton->get_bone_count(); i++) { - old_skeleton_rest.push_back(src_skeleton->get_bone_rest(i)); - old_skeleton_global_rest.push_back(src_skeleton->get_bone_global_rest(i)); - } - - Transform3D global_transform; Node *pr = src_skeleton; while (pr) { Node3D *pr3d = Object::cast_to<Node3D>(pr); @@ -109,6 +102,47 @@ void PostImportPluginSkeletonRestFixer::internal_process(InternalImportCategory } pr = pr->get_parent(); } + global_transform.origin = Vector3(); // Translation by a Node is not a bone animation, so the retargeted model should be at the origin. + } + + // Calc IBM difference. + LocalVector<Vector<Transform3D>> ibm_diffs; + { + TypedArray<Node> nodes = p_base_scene->find_children("*", "ImporterMeshInstance3D"); + while (nodes.size()) { + ImporterMeshInstance3D *mi = Object::cast_to<ImporterMeshInstance3D>(nodes.pop_back()); + ERR_CONTINUE(!mi); + + Ref<Skin> skin = mi->get_skin(); + ERR_CONTINUE(!skin.is_valid()); + + Node *node = mi->get_node(mi->get_skeleton_path()); + ERR_CONTINUE(!node); + + Skeleton3D *mesh_skeleton = Object::cast_to<Skeleton3D>(node); + if (!mesh_skeleton || mesh_skeleton != src_skeleton) { + continue; + } + + Vector<Transform3D> ibm_diff; + ibm_diff.resize(src_skeleton->get_bone_count()); + Transform3D *ibm_diff_w = ibm_diff.ptrw(); + + int skin_len = skin->get_bind_count(); + for (int i = 0; i < skin_len; i++) { + StringName bn = skin->get_bind_name(i); + int bone_idx = src_skeleton->find_bone(bn); + if (bone_idx >= 0) { + ibm_diff_w[bone_idx] = global_transform * src_skeleton->get_bone_global_rest(bone_idx) * skin->get_bind_pose(i); + } + } + + ibm_diffs.push_back(ibm_diff); + } + } + + // Apply node transforms. + if (bool(p_options["retarget/rest_fixer/apply_node_transforms"])) { Vector3 scl = global_transform.basis.get_scale_local(); Vector<int> bones_to_process = src_skeleton->get_parentless_bones(); @@ -148,38 +182,42 @@ void PostImportPluginSkeletonRestFixer::internal_process(InternalImportCategory String track_path = String(anim->track_get_path(i).get_concatenated_names()); Node *node = (ap->get_node(ap->get_root()))->get_node(NodePath(track_path)); - if (node) { - Skeleton3D *track_skeleton = Object::cast_to<Skeleton3D>(node); - if (track_skeleton && track_skeleton == src_skeleton) { - StringName bn = anim->track_get_path(i).get_subname(0); - if (bn) { - int bone_idx = src_skeleton->find_bone(bn); - int key_len = anim->track_get_key_count(i); - if (anim->track_get_type(i) == Animation::TYPE_POSITION_3D) { - if (bones_to_process.has(bone_idx)) { - for (int j = 0; j < key_len; j++) { - Vector3 ps = static_cast<Vector3>(anim->track_get_key_value(i, j)); - anim->track_set_key_value(i, j, global_transform.basis.xform(ps) + global_transform.origin); - } - } else { - for (int j = 0; j < key_len; j++) { - Vector3 ps = static_cast<Vector3>(anim->track_get_key_value(i, j)); - anim->track_set_key_value(i, j, ps * scl); - } - } - } else if (bones_to_process.has(bone_idx)) { - if (anim->track_get_type(i) == Animation::TYPE_ROTATION_3D) { - for (int j = 0; j < key_len; j++) { - Quaternion qt = static_cast<Quaternion>(anim->track_get_key_value(i, j)); - anim->track_set_key_value(i, j, global_transform.basis.get_rotation_quaternion() * qt); - } - } else { - for (int j = 0; j < key_len; j++) { - Basis sc = Basis().scaled(static_cast<Vector3>(anim->track_get_key_value(i, j))); - anim->track_set_key_value(i, j, (global_transform.basis * sc).get_scale()); - } - } - } + ERR_CONTINUE(!node); + + Skeleton3D *track_skeleton = Object::cast_to<Skeleton3D>(node); + if (!track_skeleton || track_skeleton != src_skeleton) { + continue; + } + + StringName bn = anim->track_get_path(i).get_subname(0); + if (!bn) { + continue; + } + + int bone_idx = src_skeleton->find_bone(bn); + int key_len = anim->track_get_key_count(i); + if (anim->track_get_type(i) == Animation::TYPE_POSITION_3D) { + if (bones_to_process.has(bone_idx)) { + for (int j = 0; j < key_len; j++) { + Vector3 ps = static_cast<Vector3>(anim->track_get_key_value(i, j)); + anim->track_set_key_value(i, j, global_transform.basis.xform(ps) + global_transform.origin); + } + } else { + for (int j = 0; j < key_len; j++) { + Vector3 ps = static_cast<Vector3>(anim->track_get_key_value(i, j)); + anim->track_set_key_value(i, j, ps * scl); + } + } + } else if (bones_to_process.has(bone_idx)) { + if (anim->track_get_type(i) == Animation::TYPE_ROTATION_3D) { + for (int j = 0; j < key_len; j++) { + Quaternion qt = static_cast<Quaternion>(anim->track_get_key_value(i, j)); + anim->track_set_key_value(i, j, global_transform.basis.get_rotation_quaternion() * qt); + } + } else { + for (int j = 0; j < key_len; j++) { + Basis sc = Basis().scaled(static_cast<Vector3>(anim->track_get_key_value(i, j))); + anim->track_set_key_value(i, j, (global_transform.basis * sc).get_scale()); } } } @@ -220,24 +258,26 @@ void PostImportPluginSkeletonRestFixer::internal_process(InternalImportCategory } } - if (found_skeleton) { - // Search and insert rot track if it doesn't exist. - for (int prof_idx = 0; prof_idx < prof_skeleton->get_bone_count(); prof_idx++) { - String bone_name = is_renamed ? prof_skeleton->get_bone_name(prof_idx) : String(bone_map->get_skeleton_bone_name(prof_skeleton->get_bone_name(prof_idx))); - if (bone_name == String()) { - continue; - } - int src_idx = src_skeleton->find_bone(bone_name); - if (src_idx == -1) { - continue; - } - String insert_path = track_path + ":" + bone_name; - int rot_track = anim->find_track(insert_path, Animation::TYPE_ROTATION_3D); - if (rot_track == -1) { - int track = anim->add_track(Animation::TYPE_ROTATION_3D); - anim->track_set_path(track, insert_path); - anim->rotation_track_insert_key(track, 0, src_skeleton->get_bone_rest(src_idx).basis.get_rotation_quaternion()); - } + if (!found_skeleton) { + continue; + } + + // Search and insert rot track if it doesn't exist. + for (int prof_idx = 0; prof_idx < prof_skeleton->get_bone_count(); prof_idx++) { + String bone_name = is_renamed ? prof_skeleton->get_bone_name(prof_idx) : String(bone_map->get_skeleton_bone_name(prof_skeleton->get_bone_name(prof_idx))); + if (bone_name.is_empty()) { + continue; + } + int src_idx = src_skeleton->find_bone(bone_name); + if (src_idx == -1) { + continue; + } + String insert_path = track_path + ":" + bone_name; + int rot_track = anim->find_track(insert_path, Animation::TYPE_ROTATION_3D); + if (rot_track == -1) { + int track = anim->add_track(Animation::TYPE_ROTATION_3D); + anim->track_set_path(track, insert_path); + anim->rotation_track_insert_key(track, 0, src_skeleton->get_bone_rest(src_idx).basis.get_rotation_quaternion()); } } } @@ -385,19 +425,23 @@ void PostImportPluginSkeletonRestFixer::internal_process(InternalImportCategory String track_path = String(anim->track_get_path(i).get_concatenated_names()); Node *node = (ap->get_node(ap->get_root()))->get_node(NodePath(track_path)); - if (node) { - Skeleton3D *track_skeleton = Object::cast_to<Skeleton3D>(node); - if (track_skeleton && track_skeleton == src_skeleton) { - StringName bn = anim->track_get_path(i).get_concatenated_subnames(); - if (bn == scale_base_bone_name) { - int key_len = anim->track_get_key_count(i); - for (int j = 0; j < key_len; j++) { - Vector3 pos = static_cast<Vector3>(anim->track_get_key_value(i, j)); - pos.y += base_adjustment; - anim->track_set_key_value(i, j, pos); - } - } - } + ERR_CONTINUE(!node); + + Skeleton3D *track_skeleton = Object::cast_to<Skeleton3D>(node); + if (!track_skeleton || track_skeleton != src_skeleton) { + continue; + } + + StringName bn = anim->track_get_path(i).get_concatenated_subnames(); + if (bn != scale_base_bone_name) { + continue; + } + + int key_len = anim->track_get_key_count(i); + for (int j = 0; j < key_len; j++) { + Vector3 pos = static_cast<Vector3>(anim->track_get_key_value(i, j)); + pos.y += base_adjustment; + anim->track_set_key_value(i, j, pos); } } } @@ -441,16 +485,18 @@ void PostImportPluginSkeletonRestFixer::internal_process(InternalImportCategory String track_path = String(anim->track_get_path(i).get_concatenated_names()); Node *node = (ap->get_node(ap->get_root()))->get_node(NodePath(track_path)); - if (node) { - Skeleton3D *track_skeleton = Object::cast_to<Skeleton3D>(node); - if (track_skeleton && track_skeleton == src_skeleton) { - real_t mlt = 1 / src_skeleton->get_motion_scale(); - int key_len = anim->track_get_key_count(i); - for (int j = 0; j < key_len; j++) { - Vector3 pos = static_cast<Vector3>(anim->track_get_key_value(i, j)); - anim->track_set_key_value(i, j, pos * mlt); - } - } + ERR_CONTINUE(!node); + + Skeleton3D *track_skeleton = Object::cast_to<Skeleton3D>(node); + if (!track_skeleton || track_skeleton != src_skeleton) { + continue; + } + + real_t mlt = 1 / src_skeleton->get_motion_scale(); + int key_len = anim->track_get_key_count(i); + for (int j = 0; j < key_len; j++) { + Vector3 pos = static_cast<Vector3>(anim->track_get_key_value(i, j)); + anim->track_set_key_value(i, j, pos * mlt); } } } @@ -518,6 +564,7 @@ void PostImportPluginSkeletonRestFixer::internal_process(InternalImportCategory TypedArray<Node> nodes = p_base_scene->find_children("*", "AnimationPlayer"); while (nodes.size()) { AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(nodes.pop_back()); + ERR_CONTINUE(!ap); List<StringName> anims; ap->get_animation_list(&anims); for (const StringName &name : anims) { @@ -534,53 +581,57 @@ void PostImportPluginSkeletonRestFixer::internal_process(InternalImportCategory String track_path = String(anim->track_get_path(i).get_concatenated_names()); Node *node = (ap->get_node(ap->get_root()))->get_node(NodePath(track_path)); - if (node) { - Skeleton3D *track_skeleton = Object::cast_to<Skeleton3D>(node); - if (track_skeleton && track_skeleton == src_skeleton) { - StringName bn = anim->track_get_path(i).get_subname(0); - if (bn) { - int bone_idx = src_skeleton->find_bone(bn); - - Transform3D old_rest = old_skeleton_rest[bone_idx]; - Transform3D new_rest = src_skeleton->get_bone_rest(bone_idx); - Transform3D old_pg; - Transform3D new_pg; - int parent_idx = src_skeleton->get_bone_parent(bone_idx); - if (parent_idx >= 0) { - old_pg = old_skeleton_global_rest[parent_idx]; - new_pg = src_skeleton->get_bone_global_rest(parent_idx); - } - - int key_len = anim->track_get_key_count(i); - if (anim->track_get_type(i) == Animation::TYPE_ROTATION_3D) { - Quaternion old_rest_q = old_rest.basis.get_rotation_quaternion(); - Quaternion new_rest_q = new_rest.basis.get_rotation_quaternion(); - Quaternion old_pg_q = old_pg.basis.get_rotation_quaternion(); - Quaternion new_pg_q = new_pg.basis.get_rotation_quaternion(); - for (int j = 0; j < key_len; j++) { - Quaternion qt = static_cast<Quaternion>(anim->track_get_key_value(i, j)); - anim->track_set_key_value(i, j, new_pg_q.inverse() * old_pg_q * qt * old_rest_q.inverse() * old_pg_q.inverse() * new_pg_q * new_rest_q); - } - } else if (anim->track_get_type(i) == Animation::TYPE_SCALE_3D) { - Basis old_rest_b = old_rest.basis; - Basis new_rest_b = new_rest.basis; - Basis old_pg_b = old_pg.basis; - Basis new_pg_b = new_pg.basis; - for (int j = 0; j < key_len; j++) { - Basis sc = Basis().scaled(static_cast<Vector3>(anim->track_get_key_value(i, j))); - anim->track_set_key_value(i, j, (new_pg_b.inverse() * old_pg_b * sc * old_rest_b.inverse() * old_pg_b.inverse() * new_pg_b * new_rest_b).get_scale()); - } - } else { - Vector3 old_rest_o = old_rest.origin; - Vector3 new_rest_o = new_rest.origin; - Quaternion old_pg_q = old_pg.basis.get_rotation_quaternion(); - Quaternion new_pg_q = new_pg.basis.get_rotation_quaternion(); - for (int j = 0; j < key_len; j++) { - Vector3 ps = static_cast<Vector3>(anim->track_get_key_value(i, j)); - anim->track_set_key_value(i, j, new_pg_q.xform_inv(old_pg_q.xform(ps - old_rest_o)) + new_rest_o); - } - } - } + ERR_CONTINUE(!node); + + Skeleton3D *track_skeleton = Object::cast_to<Skeleton3D>(node); + if (!track_skeleton || track_skeleton != src_skeleton) { + continue; + } + + StringName bn = anim->track_get_path(i).get_subname(0); + if (!bn) { + continue; + } + + int bone_idx = src_skeleton->find_bone(bn); + + Transform3D old_rest = old_skeleton_rest[bone_idx]; + Transform3D new_rest = src_skeleton->get_bone_rest(bone_idx); + Transform3D old_pg; + Transform3D new_pg; + int parent_idx = src_skeleton->get_bone_parent(bone_idx); + if (parent_idx >= 0) { + old_pg = old_skeleton_global_rest[parent_idx]; + new_pg = src_skeleton->get_bone_global_rest(parent_idx); + } + + int key_len = anim->track_get_key_count(i); + if (anim->track_get_type(i) == Animation::TYPE_ROTATION_3D) { + Quaternion old_rest_q = old_rest.basis.get_rotation_quaternion(); + Quaternion new_rest_q = new_rest.basis.get_rotation_quaternion(); + Quaternion old_pg_q = old_pg.basis.get_rotation_quaternion(); + Quaternion new_pg_q = new_pg.basis.get_rotation_quaternion(); + for (int j = 0; j < key_len; j++) { + Quaternion qt = static_cast<Quaternion>(anim->track_get_key_value(i, j)); + anim->track_set_key_value(i, j, new_pg_q.inverse() * old_pg_q * qt * old_rest_q.inverse() * old_pg_q.inverse() * new_pg_q * new_rest_q); + } + } else if (anim->track_get_type(i) == Animation::TYPE_SCALE_3D) { + Basis old_rest_b = old_rest.basis; + Basis new_rest_b = new_rest.basis; + Basis old_pg_b = old_pg.basis; + Basis new_pg_b = new_pg.basis; + for (int j = 0; j < key_len; j++) { + Basis sc = Basis().scaled(static_cast<Vector3>(anim->track_get_key_value(i, j))); + anim->track_set_key_value(i, j, (new_pg_b.inverse() * old_pg_b * sc * old_rest_b.inverse() * old_pg_b.inverse() * new_pg_b * new_rest_b).get_scale()); + } + } else { + Vector3 old_rest_o = old_rest.origin; + Vector3 new_rest_o = new_rest.origin; + Quaternion old_pg_q = old_pg.basis.get_rotation_quaternion(); + Quaternion new_pg_q = new_pg.basis.get_rotation_quaternion(); + for (int j = 0; j < key_len; j++) { + Vector3 ps = static_cast<Vector3>(anim->track_get_key_value(i, j)); + anim->track_set_key_value(i, j, new_pg_q.xform_inv(old_pg_q.xform(ps - old_rest_o)) + new_rest_o); } } } @@ -595,26 +646,35 @@ void PostImportPluginSkeletonRestFixer::internal_process(InternalImportCategory // Fix skin. { TypedArray<Node> nodes = p_base_scene->find_children("*", "ImporterMeshInstance3D"); + int skin_idx = 0; while (nodes.size()) { ImporterMeshInstance3D *mi = Object::cast_to<ImporterMeshInstance3D>(nodes.pop_back()); + ERR_CONTINUE(!mi); + Ref<Skin> skin = mi->get_skin(); - if (skin.is_valid()) { - Node *node = mi->get_node(mi->get_skeleton_path()); - if (node) { - Skeleton3D *mesh_skeleton = Object::cast_to<Skeleton3D>(node); - if (mesh_skeleton && node == src_skeleton) { - int skin_len = skin->get_bind_count(); - for (int i = 0; i < skin_len; i++) { - StringName bn = skin->get_bind_name(i); - int bone_idx = src_skeleton->find_bone(bn); - if (bone_idx >= 0) { - Transform3D new_rest = silhouette_diff[i] * src_skeleton->get_bone_global_rest(bone_idx); - skin->set_bind_pose(i, new_rest.inverse()); - } - } - } + ERR_CONTINUE(!skin.is_valid()); + + Node *node = mi->get_node(mi->get_skeleton_path()); + ERR_CONTINUE(!node); + + Skeleton3D *mesh_skeleton = Object::cast_to<Skeleton3D>(node); + if (!mesh_skeleton || mesh_skeleton != src_skeleton) { + continue; + } + + Vector<Transform3D> ibm_diff = ibm_diffs[skin_idx]; + + int skin_len = skin->get_bind_count(); + for (int i = 0; i < skin_len; i++) { + StringName bn = skin->get_bind_name(i); + int bone_idx = src_skeleton->find_bone(bn); + if (bone_idx >= 0) { + Transform3D new_rest = silhouette_diff[i] * src_skeleton->get_bone_global_rest(bone_idx); + skin->set_bind_pose(i, new_rest.inverse() * ibm_diff[bone_idx]); } } + + skin_idx++; } } diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 62cb6e4167..41061c3fc3 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -368,6 +368,185 @@ static void _pre_gen_shape_list(Ref<ImporterMesh> &mesh, Vector<Ref<Shape3D>> &r } } +struct ScalableNodeCollection { + HashSet<Node3D *> node_3ds; + HashSet<Ref<ImporterMesh>> importer_meshes; + HashSet<Ref<Skin>> skins; + HashSet<Ref<Animation>> animations; +}; + +void _rescale_importer_mesh(Vector3 p_scale, Ref<ImporterMesh> p_mesh, bool is_shadow = false) { + // MESH and SKIN data divide, to compensate for object position multiplying. + + const int surf_count = p_mesh->get_surface_count(); + const int blendshape_count = p_mesh->get_blend_shape_count(); + struct LocalSurfData { + Mesh::PrimitiveType prim = {}; + Array arr; + Array bsarr; + Dictionary lods; + String name; + Ref<Material> mat; + int fmt_compress_flags = 0; + }; + + Vector<LocalSurfData> surf_data_by_mesh; + + Vector<String> blendshape_names; + for (int bsidx = 0; bsidx < blendshape_count; bsidx++) { + blendshape_names.append(p_mesh->get_blend_shape_name(bsidx)); + } + + for (int surf_idx = 0; surf_idx < surf_count; surf_idx++) { + Mesh::PrimitiveType prim = p_mesh->get_surface_primitive_type(surf_idx); + const int fmt_compress_flags = p_mesh->get_surface_format(surf_idx); + Array arr = p_mesh->get_surface_arrays(surf_idx); + String name = p_mesh->get_surface_name(surf_idx); + Dictionary lods = Dictionary(); + Ref<Material> mat = p_mesh->get_surface_material(surf_idx); + { + Vector<Vector3> vertex_array = arr[ArrayMesh::ARRAY_VERTEX]; + for (int vert_arr_i = 0; vert_arr_i < vertex_array.size(); vert_arr_i++) { + vertex_array.write[vert_arr_i] = vertex_array[vert_arr_i] * p_scale; + } + arr[ArrayMesh::ARRAY_VERTEX] = vertex_array; + } + Array blendshapes; + for (int bsidx = 0; bsidx < blendshape_count; bsidx++) { + Array current_bsarr = p_mesh->get_surface_blend_shape_arrays(surf_idx, bsidx); + Vector<Vector3> current_bs_vertex_array = current_bsarr[ArrayMesh::ARRAY_VERTEX]; + int current_bs_vert_arr_len = current_bs_vertex_array.size(); + for (int32_t bs_vert_arr_i = 0; bs_vert_arr_i < current_bs_vert_arr_len; bs_vert_arr_i++) { + current_bs_vertex_array.write[bs_vert_arr_i] = current_bs_vertex_array[bs_vert_arr_i] * p_scale; + } + current_bsarr[ArrayMesh::ARRAY_VERTEX] = current_bs_vertex_array; + blendshapes.push_back(current_bsarr); + } + + LocalSurfData surf_data_dictionary = LocalSurfData(); + surf_data_dictionary.prim = prim; + surf_data_dictionary.arr = arr; + surf_data_dictionary.bsarr = blendshapes; + surf_data_dictionary.lods = lods; + surf_data_dictionary.fmt_compress_flags = fmt_compress_flags; + surf_data_dictionary.name = name; + surf_data_dictionary.mat = mat; + + surf_data_by_mesh.push_back(surf_data_dictionary); + } + + p_mesh->clear(); + + for (int bsidx = 0; bsidx < blendshape_count; bsidx++) { + p_mesh->add_blend_shape(blendshape_names[bsidx]); + } + + for (int surf_idx = 0; surf_idx < surf_count; surf_idx++) { + const Mesh::PrimitiveType prim = surf_data_by_mesh[surf_idx].prim; + const Array arr = surf_data_by_mesh[surf_idx].arr; + const Array bsarr = surf_data_by_mesh[surf_idx].bsarr; + const Dictionary lods = surf_data_by_mesh[surf_idx].lods; + const int fmt_compress_flags = surf_data_by_mesh[surf_idx].fmt_compress_flags; + const String name = surf_data_by_mesh[surf_idx].name; + const Ref<Material> mat = surf_data_by_mesh[surf_idx].mat; + + p_mesh->add_surface(prim, arr, bsarr, lods, mat, name, fmt_compress_flags); + } + + if (!is_shadow && p_mesh->get_shadow_mesh() != p_mesh && p_mesh->get_shadow_mesh().is_valid()) { + _rescale_importer_mesh(p_scale, p_mesh->get_shadow_mesh(), true); + } +} + +void _rescale_skin(Vector3 p_scale, Ref<Skin> p_skin) { + // MESH and SKIN data divide, to compensate for object position multiplying. + for (int i = 0; i < p_skin->get_bind_count(); i++) { + Transform3D transform = p_skin->get_bind_pose(i); + p_skin->set_bind_pose(i, Transform3D(transform.basis, p_scale * transform.origin)); + } +} + +void _rescale_animation(Vector3 p_scale, Ref<Animation> p_animation) { + for (int track_idx = 0; track_idx < p_animation->get_track_count(); track_idx++) { + if (p_animation->track_get_type(track_idx) == Animation::TYPE_POSITION_3D) { + for (int key_idx = 0; key_idx < p_animation->track_get_key_count(track_idx); key_idx++) { + Vector3 value = p_animation->track_get_key_value(track_idx, key_idx); + value = p_scale * value; + p_animation->track_set_key_value(track_idx, key_idx, value); + } + } + } +} + +void _apply_basis_to_scalable_node_collection(ScalableNodeCollection &p_dictionary, Vector3 p_scale) { + for (Node3D *node_3d : p_dictionary.node_3ds) { + if (node_3d) { + node_3d->set_position(p_scale * node_3d->get_position()); + + Skeleton3D *skeleton_3d = Object::cast_to<Skeleton3D>(node_3d); + if (skeleton_3d) { + for (int i = 0; i < skeleton_3d->get_bone_count(); i++) { + Transform3D rest = skeleton_3d->get_bone_rest(i); + skeleton_3d->set_bone_rest(i, Transform3D(rest.basis, p_scale * rest.origin)); + skeleton_3d->set_bone_pose_position(i, p_scale * rest.origin); + } + } + } + } + for (Ref<ImporterMesh> mesh : p_dictionary.importer_meshes) { + _rescale_importer_mesh(p_scale, mesh, false); + } + for (Ref<Skin> skin : p_dictionary.skins) { + _rescale_skin(p_scale, skin); + } + for (Ref<Animation> animation : p_dictionary.animations) { + _rescale_animation(p_scale, animation); + } +} + +void _populate_scalable_nodes_collection(Node *p_node, ScalableNodeCollection &p_dictionary) { + if (!p_node) { + return; + } + Node3D *node_3d = Object::cast_to<Node3D>(p_node); + if (node_3d) { + p_dictionary.node_3ds.insert(node_3d); + ImporterMeshInstance3D *mesh_instance_3d = Object::cast_to<ImporterMeshInstance3D>(p_node); + if (mesh_instance_3d) { + Ref<ImporterMesh> mesh = mesh_instance_3d->get_mesh(); + if (mesh.is_valid()) { + p_dictionary.importer_meshes.insert(mesh); + } + Ref<Skin> skin = mesh_instance_3d->get_skin(); + if (skin.is_valid()) { + p_dictionary.skins.insert(skin); + } + } + } + AnimationPlayer *animation_player = Object::cast_to<AnimationPlayer>(p_node); + if (animation_player) { + List<StringName> animation_list; + animation_player->get_animation_list(&animation_list); + + for (const StringName &E : animation_list) { + Ref<Animation> animation = animation_player->get_animation(E); + p_dictionary.animations.insert(animation); + } + } + + for (int i = 0; i < p_node->get_child_count(); i++) { + Node *child = p_node->get_child(i); + _populate_scalable_nodes_collection(child, p_dictionary); + } +} + +void _apply_permanent_rotation_scale_to_node(Node *p_node) { + Transform3D transform = Object::cast_to<Node3D>(p_node)->get_transform(); + ScalableNodeCollection scalable_node_collection; + _populate_scalable_nodes_collection(p_node, scalable_node_collection); + _apply_basis_to_scalable_node_collection(scalable_node_collection, transform.basis.get_scale()); +} + Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, HashMap<Ref<ImporterMesh>, Vector<Ref<Shape3D>>> &r_collision_map, Pair<PackedVector3Array, PackedInt32Array> *r_occluder_arrays, List<Pair<NodePath, Node *>> &r_node_renames) { // Children first. for (int i = 0; i < p_node->get_child_count(); i++) { @@ -1678,6 +1857,7 @@ void ResourceImporterScene::get_import_options(const String &p_path, List<Import script_ext_hint += "*." + E; } + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "nodes/apply_root_scale"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "nodes/root_scale", PROPERTY_HINT_RANGE, "0.001,1000,0.001"), 1.0)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/ensure_tangents"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/generate_lods"), true)); @@ -2144,6 +2324,21 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p return err; } + bool apply_root = true; + if (p_options.has("nodes/apply_root_scale")) { + apply_root = p_options["nodes/apply_root_scale"]; + } + real_t root_scale = 1; + if (p_options.has("nodes/root_scale")) { + root_scale = p_options["nodes/root_scale"]; + } + if (Object::cast_to<Node3D>(scene)) { + Object::cast_to<Node3D>(scene)->scale(Vector3(root_scale, root_scale, root_scale)); + } + if (apply_root) { + _apply_permanent_rotation_scale_to_node(scene); + Object::cast_to<Node3D>(scene)->scale(Vector3(root_scale, root_scale, root_scale).inverse()); + } Dictionary subresources = p_options["_subresources"]; Dictionary node_data; @@ -2199,12 +2394,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p scene->set_script(Variant(root_script)); } - float root_scale = 1.0; - if (Object::cast_to<Node3D>(scene)) { - root_scale = p_options["nodes/root_scale"]; - Object::cast_to<Node3D>(scene)->scale(Vector3(root_scale, root_scale, root_scale)); - } - if (p_options["nodes/root_name"] != "Scene Root") { scene->set_name(p_options["nodes/root_name"]); } else { diff --git a/editor/import/scene_import_settings.h b/editor/import/scene_import_settings.h index 104a7a9f7e..0e12a83116 100644 --- a/editor/import/scene_import_settings.h +++ b/editor/import/scene_import_settings.h @@ -192,7 +192,7 @@ class SceneImportSettings : public ConfirmationDialog { bool editing_animation = false; - Timer *update_view_timer; + Timer *update_view_timer = nullptr; protected: void _notification(int p_what); diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 7af04e17c1..74fdbdebd7 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -311,7 +311,6 @@ void InspectorDock::_prepare_history() { history_menu->get_popup()->clear(); - Ref<Texture2D> base_icon = get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); HashSet<ObjectID> already; for (int i = editor_history->get_history_len() - 1; i >= history_to; i--) { ObjectID id = editor_history->get_history_obj(i); @@ -325,13 +324,12 @@ void InspectorDock::_prepare_history() { already.insert(id); - Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj, ""); - if (icon.is_null()) { - icon = base_icon; - } + Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj, "Object"); String text; - if (Object::cast_to<Resource>(obj)) { + if (obj->has_method("_get_editor_name")) { + text = obj->call("_get_editor_name"); + } else if (Object::cast_to<Resource>(obj)) { Resource *r = Object::cast_to<Resource>(obj); if (r->get_path().is_resource_file()) { text = r->get_path().get_file(); @@ -349,14 +347,14 @@ void InspectorDock::_prepare_history() { } if (i == editor_history->get_history_pos() && current) { - text = "[" + text + "]"; + text += " " + TTR("(Current)"); } history_menu->get_popup()->add_icon_item(icon, text, i); } } void InspectorDock::_select_history(int p_idx) { - //push it to the top, it is not correct, but it's more useful + // Push it to the top, it is not correct, but it's more useful. ObjectID id = EditorNode::get_singleton()->get_editor_selection_history()->get_history_obj(p_idx); Object *obj = ObjectDB::get_instance(id); if (!obj) { diff --git a/editor/multi_node_edit.cpp b/editor/multi_node_edit.cpp index 70cc54668d..a386fba84d 100644 --- a/editor/multi_node_edit.cpp +++ b/editor/multi_node_edit.cpp @@ -46,7 +46,7 @@ bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value, String name = p_name; - if (name == "scripts") { // script set is intercepted at object level (check Variant Object::get() ) ,so use a different name + if (name == "scripts") { // Script set is intercepted at object level (check Variant Object::get()), so use a different name. name = "script"; } @@ -57,13 +57,9 @@ bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value, Ref<EditorUndoRedoManager> &ur = EditorNode::get_undo_redo(); - ur->create_action(TTR("MultiNode Set") + " " + String(name), UndoRedo::MERGE_ENDS); + ur->create_action(vformat(TTR("Set %s on %d nodes"), name, get_node_count()), UndoRedo::MERGE_ENDS); for (const NodePath &E : nodes) { - if (!es->has_node(E)) { - continue; - } - - Node *n = es->get_node(E); + Node *n = es->get_node_or_null(E); if (!n) { continue; } @@ -100,16 +96,12 @@ bool MultiNodeEdit::_get(const StringName &p_name, Variant &r_ret) const { } String name = p_name; - if (name == "scripts") { // script set is intercepted at object level (check Variant Object::get() ) ,so use a different name + if (name == "scripts") { // Script set is intercepted at object level (check Variant Object::get()), so use a different name. name = "script"; } for (const NodePath &E : nodes) { - if (!es->has_node(E)) { - continue; - } - - const Node *n = es->get_node(E); + const Node *n = es->get_node_or_null(E); if (!n) { continue; } @@ -137,11 +129,7 @@ void MultiNodeEdit::_get_property_list(List<PropertyInfo> *p_list) const { List<PLData *> data_list; for (const NodePath &E : nodes) { - if (!es->has_node(E)) { - continue; - } - - Node *n = es->get_node(E); + Node *n = es->get_node_or_null(E); if (!n) { continue; } @@ -151,7 +139,7 @@ void MultiNodeEdit::_get_property_list(List<PropertyInfo> *p_list) const { for (const PropertyInfo &F : plist) { if (F.name == "script") { - continue; //added later manually, since this is intercepted before being set (check Variant Object::get() ) + continue; // Added later manually, since this is intercepted before being set (check Variant Object::get()). } if (!usage.has(F.name)) { PLData pld; @@ -161,7 +149,7 @@ void MultiNodeEdit::_get_property_list(List<PropertyInfo> *p_list) const { data_list.push_back(usage.getptr(F.name)); } - // Make sure only properties with the same exact PropertyInfo data will appear + // Make sure only properties with the same exact PropertyInfo data will appear. if (usage[F.name].info == F) { usage[F.name].uses++; } @@ -179,6 +167,66 @@ void MultiNodeEdit::_get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::OBJECT, "scripts", PROPERTY_HINT_RESOURCE_TYPE, "Script")); } +String MultiNodeEdit::_get_editor_name() const { + return vformat(TTR("%s (%d Selected)"), get_edited_class_name(), get_node_count()); +} + +bool MultiNodeEdit::_property_can_revert(const StringName &p_name) const { + Node *es = EditorNode::get_singleton()->get_edited_scene(); + if (!es) { + return false; + } + + if (ClassDB::has_property(get_edited_class_name(), p_name)) { + StringName class_name; + for (const NodePath &E : nodes) { + Node *node = es->get_node_or_null(E); + if (!node) { + continue; + } + + class_name = node->get_class_name(); + } + + Variant default_value = ClassDB::class_get_default_property_value(class_name, p_name); + for (const NodePath &E : nodes) { + Node *node = es->get_node_or_null(E); + if (!node) { + continue; + } + + if (node->get(p_name) != default_value) { + // A node that doesn't have the default value has been found, so show the revert button. + return true; + } + } + + return false; + } + + // Don't show the revert button if the edited class doesn't have the property. + return false; +} + +bool MultiNodeEdit::_property_get_revert(const StringName &p_name, Variant &r_property) const { + Node *es = EditorNode::get_singleton()->get_edited_scene(); + if (!es) { + return false; + } + + for (const NodePath &E : nodes) { + Node *node = es->get_node_or_null(E); + if (!node) { + continue; + } + + r_property = ClassDB::class_get_default_property_value(node->get_class_name(), p_name); + return true; + } + + return false; +} + void MultiNodeEdit::add_node(const NodePath &p_node) { nodes.push_back(p_node); } @@ -192,9 +240,69 @@ NodePath MultiNodeEdit::get_node(int p_index) const { return nodes[p_index]; } +StringName MultiNodeEdit::get_edited_class_name() const { + Node *es = EditorNode::get_singleton()->get_edited_scene(); + if (!es) { + return SNAME("Node"); + } + + // Get the class name of the first node. + StringName class_name; + for (const NodePath &E : nodes) { + Node *node = es->get_node_or_null(E); + if (!node) { + continue; + } + + class_name = node->get_class_name(); + break; + } + + if (class_name == StringName()) { + return SNAME("Node"); + } + + bool check_again = true; + while (check_again) { + check_again = false; + + if (class_name == SNAME("Node") || class_name == StringName()) { + // All nodes inherit from Node, so no need to continue checking. + return SNAME("Node"); + } + + // Check that all nodes inherit from class_name. + for (const NodePath &E : nodes) { + Node *node = es->get_node_or_null(E); + if (!node) { + continue; + } + + const StringName node_class_name = node->get_class_name(); + if (class_name == node_class_name || ClassDB::is_parent_class(node_class_name, class_name)) { + // class_name is the same or a parent of the node's class. + continue; + } + + // class_name is not a parent of the node's class, so check again with the parent class. + class_name = ClassDB::get_parent_class(class_name); + check_again = true; + break; + } + } + + return class_name; +} + void MultiNodeEdit::set_property_field(const StringName &p_property, const Variant &p_value, const String &p_field) { _set_impl(p_property, p_value, p_field); } +void MultiNodeEdit::_bind_methods() { + ClassDB::bind_method("_hide_script_from_inspector", &MultiNodeEdit::_hide_script_from_inspector); + ClassDB::bind_method("_hide_metadata_from_inspector", &MultiNodeEdit::_hide_metadata_from_inspector); + ClassDB::bind_method("_get_editor_name", &MultiNodeEdit::_get_editor_name); +} + MultiNodeEdit::MultiNodeEdit() { } diff --git a/editor/multi_node_edit.h b/editor/multi_node_edit.h index 31678d7b01..9c0ec85e20 100644 --- a/editor/multi_node_edit.h +++ b/editor/multi_node_edit.h @@ -45,15 +45,25 @@ class MultiNodeEdit : public RefCounted { bool _set_impl(const StringName &p_name, const Variant &p_value, const String &p_field); protected: + static void _bind_methods(); + bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const; void _get_property_list(List<PropertyInfo> *p_list) const; public: + bool _hide_script_from_inspector() { return true; } + bool _hide_metadata_from_inspector() { return true; } + + bool _property_can_revert(const StringName &p_name) const; + bool _property_get_revert(const StringName &p_name, Variant &r_property) const; + String _get_editor_name() const; + void add_node(const NodePath &p_node); int get_node_count() const; NodePath get_node(int p_index) const; + StringName get_edited_class_name() const; void set_property_field(const StringName &p_property, const Variant &p_value, const String &p_field); diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index b79f4c90bf..0e941ad433 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -552,9 +552,9 @@ void AnimationNodeBlendSpace1DEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); - panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); tool_blend->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons"))); tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); tool_create->set_icon(get_theme_icon(SNAME("EditKey"), SNAME("EditorIcons"))); diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index 1646a1cef4..f75dcdf2d6 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -774,9 +774,9 @@ void AnimationNodeBlendSpace2DEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); - panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); tool_blend->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons"))); tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); tool_create->set_icon(get_theme_icon(SNAME("EditKey"), SNAME("EditorIcons"))); diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 8dd3223b19..e2d4c9fb6f 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -800,7 +800,7 @@ void AnimationNodeBlendTreeEditor::_update_editor_settings() { } void AnimationNodeBlendTreeEditor::_update_theme() { - error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); } diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 1ab60e8fc8..5ac63ce4db 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -1524,19 +1524,19 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() { // Render every past/future step with the capture shader. RS::get_singleton()->canvas_item_set_material(onion.capture.canvas_item, onion.capture.material->get_rid()); - onion.capture.material->set_shader_uniform("bkg_color", GLOBAL_GET("rendering/environment/defaults/default_clear_color")); - onion.capture.material->set_shader_uniform("differences_only", onion.differences_only); - onion.capture.material->set_shader_uniform("present", onion.differences_only ? RS::get_singleton()->viewport_get_texture(present_rid) : RID()); + onion.capture.material->set_shader_parameter("bkg_color", GLOBAL_GET("rendering/environment/defaults/default_clear_color")); + onion.capture.material->set_shader_parameter("differences_only", onion.differences_only); + onion.capture.material->set_shader_parameter("present", onion.differences_only ? RS::get_singleton()->viewport_get_texture(present_rid) : RID()); int step_off_a = onion.past ? -onion.steps : 0; int step_off_b = onion.future ? onion.steps : 0; int cidx = 0; - onion.capture.material->set_shader_uniform("dir_color", onion.force_white_modulate ? Color(1, 1, 1) : Color(EDITOR_GET("editors/animation/onion_layers_past_color"))); + onion.capture.material->set_shader_parameter("dir_color", onion.force_white_modulate ? Color(1, 1, 1) : Color(EDITOR_GET("editors/animation/onion_layers_past_color"))); for (int step_off = step_off_a; step_off <= step_off_b; step_off++) { if (step_off == 0) { // Skip present step and switch to the color of future. if (!onion.force_white_modulate) { - onion.capture.material->set_shader_uniform("dir_color", EDITOR_GET("editors/animation/onion_layers_future_color")); + onion.capture.material->set_shader_parameter("dir_color", EDITOR_GET("editors/animation/onion_layers_future_color")); } continue; } diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 2809eb01cd..461326a47b 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -267,6 +267,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv for (int i = node_rects.size() - 1; i >= 0; i--) { //inverse to draw order if (node_rects[i].node.has_point(mb->get_position())) { //select node since nothing else was selected connecting = true; + connection_follows_cursor = true; connecting_from = node_rects[i].node_name; connecting_to = mb->get_position(); connecting_to_node = StringName(); @@ -296,6 +297,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv _open_menu(mb->get_position()); } connecting_to_node = StringName(); + connection_follows_cursor = false; state_machine_draw->queue_redraw(); } @@ -332,7 +334,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv } // Move mouse while connecting - if (mm.is_valid() && connecting && !read_only) { + if (mm.is_valid() && connecting && connection_follows_cursor && !read_only) { connecting_to = mm->get_position(); connecting_to_node = StringName(); state_machine_draw->queue_redraw(); @@ -1023,11 +1025,9 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) { } updating = true; - undo_redo->create_action(TTR("Add Node")); + undo_redo->create_action(TTR("Add Node and Transition")); undo_redo->add_do_method(state_machine.ptr(), "add_node", name, node, add_node_pos); undo_redo->add_undo_method(state_machine.ptr(), "remove_node", name); - undo_redo->add_do_method(this, "_update_graph"); - undo_redo->add_undo_method(this, "_update_graph"); connecting_to_node = name; _add_transition(true); undo_redo->commit_action(); @@ -1051,11 +1051,9 @@ void AnimationNodeStateMachineEditor::_add_animation_type(int p_index) { } updating = true; - undo_redo->create_action(TTR("Add Node")); + undo_redo->create_action(TTR("Add Node and Transition")); undo_redo->add_do_method(state_machine.ptr(), "add_node", name, anim, add_node_pos); undo_redo->add_undo_method(state_machine.ptr(), "remove_node", name); - undo_redo->add_do_method(this, "_update_graph"); - undo_redo->add_undo_method(this, "_update_graph"); connecting_to_node = name; _add_transition(true); undo_redo->commit_action(); @@ -1083,16 +1081,16 @@ void AnimationNodeStateMachineEditor::_add_transition(const bool p_nested_action if (!p_nested_action) { updating = true; + undo_redo->create_action(TTR("Add Transition")); } - undo_redo->create_action(TTR("Add Transition")); undo_redo->add_do_method(state_machine.ptr(), "add_transition", connecting_from, connecting_to_node, tr); undo_redo->add_undo_method(state_machine.ptr(), "remove_transition", connecting_from, connecting_to_node); undo_redo->add_do_method(this, "_update_graph"); undo_redo->add_undo_method(this, "_update_graph"); - undo_redo->commit_action(); if (!p_nested_action) { + undo_redo->commit_action(); updating = false; } @@ -1553,9 +1551,9 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_TRANSLATION_CHANGED: { - error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); - panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); tool_create->set_icon(get_theme_icon(SNAME("ToolAddNode"), SNAME("EditorIcons"))); diff --git a/editor/plugins/animation_state_machine_editor.h b/editor/plugins/animation_state_machine_editor.h index 3a59e94a5f..d0828a5f52 100644 --- a/editor/plugins/animation_state_machine_editor.h +++ b/editor/plugins/animation_state_machine_editor.h @@ -100,8 +100,8 @@ class AnimationNodeStateMachineEditor : public AnimationTreeNodeEditorPlugin { Vector2 add_node_pos; - ConfirmationDialog *delete_window; - Tree *delete_tree; + ConfirmationDialog *delete_window = nullptr; + Tree *delete_tree = nullptr; bool box_selecting = false; Point2 box_selecting_from; @@ -117,6 +117,7 @@ class AnimationNodeStateMachineEditor : public AnimationTreeNodeEditorPlugin { StringName snap_y; bool connecting = false; + bool connection_follows_cursor = false; StringName connecting_from; Vector2 connecting_to; StringName connecting_to_node; diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 41383edafe..1231ac10ab 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -32,7 +32,7 @@ #include "core/input/input.h" #include "core/io/json.h" -#include "core/io/stream_peer_ssl.h" +#include "core/io/stream_peer_tls.h" #include "core/os/keyboard.h" #include "core/version.h" #include "editor/editor_file_dialog.h" @@ -584,17 +584,19 @@ void EditorAssetLibrary::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { error_tr->set_texture(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - library_scroll_bg->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); - downloads_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + library_scroll_bg->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); + downloads_scroll->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); error_label->add_theme_color_override("color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); } break; case NOTIFICATION_VISIBILITY_CHANGED: { if (is_visible()) { +#ifndef ANDROID_ENABLED // Focus the search box automatically when switching to the Templates tab (in the Project Manager) // or switching to the AssetLib tab (in the editor). // The Project Manager's project filter box is automatically focused in the project manager code. filter->grab_focus(); +#endif if (initial_loading) { _repository_changed(0); // Update when shown for the first time. @@ -1600,7 +1602,7 @@ bool AssetLibraryEditorPlugin::is_available() { // directly from GitHub which does not set CORS. return false; #else - return StreamPeerSSL::is_available(); + return StreamPeerTLS::is_available(); #endif } @@ -1615,7 +1617,7 @@ void AssetLibraryEditorPlugin::make_visible(bool p_visible) { AssetLibraryEditorPlugin::AssetLibraryEditorPlugin() { addon_library = memnew(EditorAssetLibrary); addon_library->set_v_size_flags(Control::SIZE_EXPAND_FILL); - EditorNode::get_singleton()->get_main_control()->add_child(addon_library); + EditorNode::get_singleton()->get_main_screen_control()->add_child(addon_library); addon_library->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); addon_library->hide(); } diff --git a/editor/plugins/bone_map_editor_plugin.h b/editor/plugins/bone_map_editor_plugin.h index 0541ce6eac..55261ab477 100644 --- a/editor/plugins/bone_map_editor_plugin.h +++ b/editor/plugins/bone_map_editor_plugin.h @@ -62,7 +62,7 @@ private: bool selected = false; bool require = false; - TextureRect *circle; + TextureRect *circle = nullptr; void fetch_textures(); @@ -87,8 +87,8 @@ class BoneMapperItem : public VBoxContainer { Ref<BoneMap> bone_map; - EditorPropertyText *skeleton_bone_selector; - Button *picker_button; + EditorPropertyText *skeleton_bone_selector = nullptr; + Button *picker_button = nullptr; void _update_property(); void _open_picker(); @@ -135,24 +135,24 @@ public: class BoneMapper : public VBoxContainer { GDCLASS(BoneMapper, VBoxContainer); - Skeleton3D *skeleton; + Skeleton3D *skeleton = nullptr; Ref<BoneMap> bone_map; - EditorPropertyResource *profile_selector; + EditorPropertyResource *profile_selector = nullptr; Vector<BoneMapperItem *> bone_mapper_items; - Button *clear_mapping_button; + Button *clear_mapping_button = nullptr; - VBoxContainer *mapper_item_vbox; + VBoxContainer *mapper_item_vbox = nullptr; int current_group_idx = 0; int current_bone_idx = -1; - AspectRatioContainer *bone_mapper_field; - EditorPropertyEnum *profile_group_selector; - ColorRect *profile_bg; - TextureRect *profile_texture; + AspectRatioContainer *bone_mapper_field = nullptr; + EditorPropertyEnum *profile_group_selector = nullptr; + ColorRect *profile_bg = nullptr; + TextureRect *profile_texture = nullptr; Vector<BoneMapperButton *> bone_mapper_buttons; void create_editor(); @@ -201,9 +201,9 @@ public: class BoneMapEditor : public VBoxContainer { GDCLASS(BoneMapEditor, VBoxContainer); - Skeleton3D *skeleton; + Skeleton3D *skeleton = nullptr; Ref<BoneMap> bone_map; - BoneMapper *bone_mapper; + BoneMapper *bone_mapper = nullptr; void fetch_objects(); void clear_editors(); @@ -219,7 +219,7 @@ public: class EditorInspectorPluginBoneMap : public EditorInspectorPlugin { GDCLASS(EditorInspectorPluginBoneMap, EditorInspectorPlugin); - BoneMapEditor *editor; + BoneMapEditor *editor = nullptr; public: virtual bool can_handle(Object *p_object) override; diff --git a/editor/plugins/camera_3d_editor_plugin.cpp b/editor/plugins/camera_3d_editor_plugin.cpp index 141837244a..1aedb3b4ce 100644 --- a/editor/plugins/camera_3d_editor_plugin.cpp +++ b/editor/plugins/camera_3d_editor_plugin.cpp @@ -98,7 +98,7 @@ void Camera3DEditorPlugin::make_visible(bool p_visible) { Camera3DEditorPlugin::Camera3DEditorPlugin() { /* camera_editor = memnew( CameraEditor ); - EditorNode::get_singleton()->get_main_control()->add_child(camera_editor); + EditorNode::get_singleton()->get_main_screen_control()->add_child(camera_editor); camera_editor->set_anchor(SIDE_LEFT,Control::ANCHOR_END); camera_editor->set_anchor(SIDE_RIGHT,Control::ANCHOR_END); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index c4a32d6d4b..9deb516ec4 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -5459,7 +5459,7 @@ void CanvasItemEditorPlugin::set_state(const Dictionary &p_state) { CanvasItemEditorPlugin::CanvasItemEditorPlugin() { canvas_item_editor = memnew(CanvasItemEditor); canvas_item_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); - EditorNode::get_singleton()->get_main_control()->add_child(canvas_item_editor); + EditorNode::get_singleton()->get_main_screen_control()->add_child(canvas_item_editor); canvas_item_editor->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); canvas_item_editor->hide(); } diff --git a/editor/plugins/cast_2d_editor_plugin.h b/editor/plugins/cast_2d_editor_plugin.h index 85ff497bc7..ceed9b9111 100644 --- a/editor/plugins/cast_2d_editor_plugin.h +++ b/editor/plugins/cast_2d_editor_plugin.h @@ -42,7 +42,7 @@ class Cast2DEditor : public Control { Ref<EditorUndoRedoManager> undo_redo; CanvasItemEditor *canvas_item_editor = nullptr; - Node2D *node; + Node2D *node = nullptr; bool pressed = false; Point2 original_target_position; diff --git a/editor/plugins/control_editor_plugin.h b/editor/plugins/control_editor_plugin.h index 584d05aab0..22267cbc04 100644 --- a/editor/plugins/control_editor_plugin.h +++ b/editor/plugins/control_editor_plugin.h @@ -186,7 +186,7 @@ public: class SizeFlagPresetPicker : public ControlEditorPresetPicker { GDCLASS(SizeFlagPresetPicker, ControlEditorPresetPicker); - CheckBox *expand_button; + CheckBox *expand_button = nullptr; bool vertical = false; diff --git a/editor/plugins/cpu_particles_3d_editor_plugin.cpp b/editor/plugins/cpu_particles_3d_editor_plugin.cpp index 775c2dbb2a..ad12b8bef0 100644 --- a/editor/plugins/cpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_3d_editor_plugin.cpp @@ -126,7 +126,7 @@ void CPUParticles3DEditorPlugin::make_visible(bool p_visible) { CPUParticles3DEditorPlugin::CPUParticles3DEditorPlugin() { particles_editor = memnew(CPUParticles3DEditor); - EditorNode::get_singleton()->get_main_control()->add_child(particles_editor); + EditorNode::get_singleton()->get_main_screen_control()->add_child(particles_editor); particles_editor->hide(); } diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index 0e84381279..8d1df0b32c 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -640,7 +640,7 @@ void CurveEditor::_draw() { // Background Vector2 view_size = get_rect().size; - draw_style_box(get_theme_stylebox(SNAME("bg"), SNAME("Tree")), Rect2(Point2(), view_size)); + draw_style_box(get_theme_stylebox(SNAME("panel"), SNAME("Tree")), Rect2(Point2(), view_size)); // Grid diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 0ec36736bd..59b8f31720 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -307,7 +307,7 @@ Ref<Texture2D> EditorMaterialPreviewPlugin::generate(const Ref<Resource> &p_from if (material->get_shader_mode() == Shader::MODE_SPATIAL) { RS::get_singleton()->mesh_surface_set_material(sphere, 0, material->get_rid()); - RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<EditorMaterialPreviewPlugin *>(this), &EditorMaterialPreviewPlugin::_generate_frame_started), Object::CONNECT_ONESHOT); + RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<EditorMaterialPreviewPlugin *>(this), &EditorMaterialPreviewPlugin::_generate_frame_started), Object::CONNECT_ONE_SHOT); preview_done.wait(); @@ -709,7 +709,7 @@ Ref<Texture2D> EditorMeshPreviewPlugin::generate(const Ref<Resource> &p_from, co xform.origin.z -= rot_aabb.size.z * 2; RS::get_singleton()->instance_set_transform(mesh_instance, xform); - RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<EditorMeshPreviewPlugin *>(this), &EditorMeshPreviewPlugin::_generate_frame_started), Object::CONNECT_ONESHOT); + RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<EditorMeshPreviewPlugin *>(this), &EditorMeshPreviewPlugin::_generate_frame_started), Object::CONNECT_ONE_SHOT); preview_done.wait(); @@ -826,7 +826,7 @@ Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path, const float fg = c.get_luminance() < 0.5 ? 1.0 : 0.0; sampled_font->draw_string(canvas_item, pos, sample, HORIZONTAL_ALIGNMENT_LEFT, -1.f, 50, Color(fg, fg, fg)); - RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<EditorFontPreviewPlugin *>(this), &EditorFontPreviewPlugin::_generate_frame_started), Object::CONNECT_ONESHOT); + RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<EditorFontPreviewPlugin *>(this), &EditorFontPreviewPlugin::_generate_frame_started), Object::CONNECT_ONE_SHOT); preview_done.wait(); diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp index ebc92bf531..d91cbb6571 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp @@ -454,7 +454,7 @@ void GPUParticles3DEditorPlugin::make_visible(bool p_visible) { GPUParticles3DEditorPlugin::GPUParticles3DEditorPlugin() { particles_editor = memnew(GPUParticles3DEditor); - EditorNode::get_singleton()->get_main_control()->add_child(particles_editor); + EditorNode::get_singleton()->get_main_screen_control()->add_child(particles_editor); particles_editor->hide(); } diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index d204873f92..76d05624d6 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -40,33 +40,39 @@ #include "scene/resources/particle_process_material.h" #include "scene/resources/sky_material.h" -void MaterialEditor::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_READY: { - //get_scene()->connect("node_removed",this,"_node_removed"); +void MaterialEditor::_update_theme_item_cache() { + Control::_update_theme_item_cache(); - if (first_enter) { - //it's in propertyeditor so.. could be moved around + theme_cache.light_1_on = get_theme_icon(SNAME("MaterialPreviewLight1"), SNAME("EditorIcons")); + theme_cache.light_1_off = get_theme_icon(SNAME("MaterialPreviewLight1Off"), SNAME("EditorIcons")); + theme_cache.light_2_on = get_theme_icon(SNAME("MaterialPreviewLight2"), SNAME("EditorIcons")); + theme_cache.light_2_off = get_theme_icon(SNAME("MaterialPreviewLight2Off"), SNAME("EditorIcons")); - light_1_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight1"), SNAME("EditorIcons"))); - light_1_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight1Off"), SNAME("EditorIcons"))); - light_2_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight2"), SNAME("EditorIcons"))); - light_2_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight2Off"), SNAME("EditorIcons"))); + theme_cache.sphere_on = get_theme_icon(SNAME("MaterialPreviewSphere"), SNAME("EditorIcons")); + theme_cache.sphere_off = get_theme_icon(SNAME("MaterialPreviewSphereOff"), SNAME("EditorIcons")); + theme_cache.box_on = get_theme_icon(SNAME("MaterialPreviewCube"), SNAME("EditorIcons")); + theme_cache.box_off = get_theme_icon(SNAME("MaterialPreviewCubeOff"), SNAME("EditorIcons")); - sphere_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewSphereOff"), SNAME("EditorIcons"))); - sphere_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewSphere"), SNAME("EditorIcons"))); - box_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewCubeOff"), SNAME("EditorIcons"))); - box_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewCube"), SNAME("EditorIcons"))); + theme_cache.checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); +} - first_enter = false; - } +void MaterialEditor::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_THEME_CHANGED: { + light_1_switch->set_normal_texture(theme_cache.light_1_on); + light_1_switch->set_pressed_texture(theme_cache.light_1_off); + light_2_switch->set_normal_texture(theme_cache.light_2_on); + light_2_switch->set_pressed_texture(theme_cache.light_2_off); + + sphere_switch->set_normal_texture(theme_cache.sphere_off); + sphere_switch->set_pressed_texture(theme_cache.sphere_on); + box_switch->set_normal_texture(theme_cache.box_off); + box_switch->set_pressed_texture(theme_cache.box_on); } break; case NOTIFICATION_DRAW: { - Ref<Texture2D> checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); Size2 size = get_size(); - - draw_texture_rect(checkerboard, Rect2(Point2(), size), true); + draw_texture_rect(theme_cache.checkerboard, Rect2(Point2(), size), true); } break; } } @@ -231,8 +237,6 @@ MaterialEditor::MaterialEditor() { vb_light->add_child(light_2_switch); light_2_switch->connect("pressed", callable_mp(this, &MaterialEditor::_button_pressed).bind(light_2_switch)); - first_enter = true; - if (EditorSettings::get_singleton()->get_project_metadata("inspector_options", "material_preview_on_sphere", true)) { box_instance->hide(); } else { @@ -344,17 +348,17 @@ Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p smat->set_shader(shader); List<PropertyInfo> params; - RS::get_singleton()->shader_get_shader_uniform_list(mat->get_shader_rid(), ¶ms); + RS::get_singleton()->get_shader_parameter_list(mat->get_shader_rid(), ¶ms); for (const PropertyInfo &E : params) { // Texture parameter has to be treated specially since StandardMaterial3D saved it // as RID but ShaderMaterial needs Texture itself Ref<Texture2D> texture = mat->get_texture_by_name(E.name); if (texture.is_valid()) { - smat->set_shader_uniform(E.name, texture); + smat->set_shader_parameter(E.name, texture); } else { Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); - smat->set_shader_uniform(E.name, value); + smat->set_shader_parameter(E.name, value); } } @@ -390,17 +394,17 @@ Ref<Resource> ORMMaterial3DConversionPlugin::convert(const Ref<Resource> &p_reso smat->set_shader(shader); List<PropertyInfo> params; - RS::get_singleton()->shader_get_shader_uniform_list(mat->get_shader_rid(), ¶ms); + RS::get_singleton()->get_shader_parameter_list(mat->get_shader_rid(), ¶ms); for (const PropertyInfo &E : params) { // Texture parameter has to be treated specially since ORMMaterial3D saved it // as RID but ShaderMaterial needs Texture itself Ref<Texture2D> texture = mat->get_texture_by_name(E.name); if (texture.is_valid()) { - smat->set_shader_uniform(E.name, texture); + smat->set_shader_parameter(E.name, texture); } else { Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); - smat->set_shader_uniform(E.name, value); + smat->set_shader_parameter(E.name, value); } } @@ -436,11 +440,11 @@ Ref<Resource> ParticleProcessMaterialConversionPlugin::convert(const Ref<Resourc smat->set_shader(shader); List<PropertyInfo> params; - RS::get_singleton()->shader_get_shader_uniform_list(mat->get_shader_rid(), ¶ms); + RS::get_singleton()->get_shader_parameter_list(mat->get_shader_rid(), ¶ms); for (const PropertyInfo &E : params) { Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); - smat->set_shader_uniform(E.name, value); + smat->set_shader_parameter(E.name, value); } smat->set_render_priority(mat->get_render_priority()); @@ -475,11 +479,11 @@ Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p smat->set_shader(shader); List<PropertyInfo> params; - RS::get_singleton()->shader_get_shader_uniform_list(mat->get_shader_rid(), ¶ms); + RS::get_singleton()->get_shader_parameter_list(mat->get_shader_rid(), ¶ms); for (const PropertyInfo &E : params) { Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); - smat->set_shader_uniform(E.name, value); + smat->set_shader_parameter(E.name, value); } smat->set_render_priority(mat->get_render_priority()); @@ -514,11 +518,11 @@ Ref<Resource> ProceduralSkyMaterialConversionPlugin::convert(const Ref<Resource> smat->set_shader(shader); List<PropertyInfo> params; - RS::get_singleton()->shader_get_shader_uniform_list(mat->get_shader_rid(), ¶ms); + RS::get_singleton()->get_shader_parameter_list(mat->get_shader_rid(), ¶ms); for (const PropertyInfo &E : params) { Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); - smat->set_shader_uniform(E.name, value); + smat->set_shader_parameter(E.name, value); } smat->set_render_priority(mat->get_render_priority()); @@ -553,11 +557,11 @@ Ref<Resource> PanoramaSkyMaterialConversionPlugin::convert(const Ref<Resource> & smat->set_shader(shader); List<PropertyInfo> params; - RS::get_singleton()->shader_get_shader_uniform_list(mat->get_shader_rid(), ¶ms); + RS::get_singleton()->get_shader_parameter_list(mat->get_shader_rid(), ¶ms); for (const PropertyInfo &E : params) { Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); - smat->set_shader_uniform(E.name, value); + smat->set_shader_parameter(E.name, value); } smat->set_render_priority(mat->get_render_priority()); @@ -592,11 +596,11 @@ Ref<Resource> PhysicalSkyMaterialConversionPlugin::convert(const Ref<Resource> & smat->set_shader(shader); List<PropertyInfo> params; - RS::get_singleton()->shader_get_shader_uniform_list(mat->get_shader_rid(), ¶ms); + RS::get_singleton()->get_shader_parameter_list(mat->get_shader_rid(), ¶ms); for (const PropertyInfo &E : params) { Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); - smat->set_shader_uniform(E.name, value); + smat->set_shader_parameter(E.name, value); } smat->set_render_priority(mat->get_render_priority()); @@ -631,11 +635,11 @@ Ref<Resource> FogMaterialConversionPlugin::convert(const Ref<Resource> &p_resour smat->set_shader(shader); List<PropertyInfo> params; - RS::get_singleton()->shader_get_shader_uniform_list(mat->get_shader_rid(), ¶ms); + RS::get_singleton()->get_shader_parameter_list(mat->get_shader_rid(), ¶ms); for (const PropertyInfo &E : params) { Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); - smat->set_shader_uniform(E.name, value); + smat->set_shader_parameter(E.name, value); } smat->set_render_priority(mat->get_render_priority()); diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h index 828dd9f972..7ce6deee65 100644 --- a/editor/plugins/material_editor_plugin.h +++ b/editor/plugins/material_editor_plugin.h @@ -70,12 +70,23 @@ class MaterialEditor : public Control { Ref<Material> material; + struct ThemeCache { + Ref<Texture2D> light_1_on; + Ref<Texture2D> light_1_off; + Ref<Texture2D> light_2_on; + Ref<Texture2D> light_2_off; + Ref<Texture2D> sphere_on; + Ref<Texture2D> sphere_off; + Ref<Texture2D> box_on; + Ref<Texture2D> box_off; + Ref<Texture2D> checkerboard; + } theme_cache; + void _button_pressed(Node *p_button); - bool first_enter; protected: + virtual void _update_theme_item_cache() override; void _notification(int p_what); - static void _bind_methods(); public: diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index d8977ea6fc..be26baaea5 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -49,20 +49,22 @@ void MeshEditor::gui_input(const Ref<InputEvent> &p_event) { } } +void MeshEditor::_update_theme_item_cache() { + SubViewportContainer::_update_theme_item_cache(); + + theme_cache.light_1_on = get_theme_icon(SNAME("MaterialPreviewLight1"), SNAME("EditorIcons")); + theme_cache.light_1_off = get_theme_icon(SNAME("MaterialPreviewLight1Off"), SNAME("EditorIcons")); + theme_cache.light_2_on = get_theme_icon(SNAME("MaterialPreviewLight2"), SNAME("EditorIcons")); + theme_cache.light_2_off = get_theme_icon(SNAME("MaterialPreviewLight2Off"), SNAME("EditorIcons")); +} + void MeshEditor::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_READY: { - //get_scene()->connect("node_removed",this,"_node_removed"); - - if (first_enter) { - //it's in propertyeditor so. could be moved around - - light_1_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight1"), SNAME("EditorIcons"))); - light_1_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight1Off"), SNAME("EditorIcons"))); - light_2_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight2"), SNAME("EditorIcons"))); - light_2_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight2Off"), SNAME("EditorIcons"))); - first_enter = false; - } + case NOTIFICATION_THEME_CHANGED: { + light_1_switch->set_normal_texture(theme_cache.light_1_on); + light_1_switch->set_pressed_texture(theme_cache.light_1_off); + light_2_switch->set_normal_texture(theme_cache.light_2_on); + light_2_switch->set_pressed_texture(theme_cache.light_2_off); } break; } } @@ -160,8 +162,6 @@ MeshEditor::MeshEditor() { vb_light->add_child(light_2_switch); light_2_switch->connect("pressed", callable_mp(this, &MeshEditor::_button_pressed).bind(light_2_switch)); - first_enter = true; - rot_x = 0; rot_y = 0; } diff --git a/editor/plugins/mesh_editor_plugin.h b/editor/plugins/mesh_editor_plugin.h index ab7b5db7c4..6394cb1171 100644 --- a/editor/plugins/mesh_editor_plugin.h +++ b/editor/plugins/mesh_editor_plugin.h @@ -58,12 +58,18 @@ class MeshEditor : public SubViewportContainer { TextureButton *light_1_switch = nullptr; TextureButton *light_2_switch = nullptr; - void _button_pressed(Node *p_button); - bool first_enter; + struct ThemeCache { + Ref<Texture2D> light_1_on; + Ref<Texture2D> light_1_off; + Ref<Texture2D> light_2_on; + Ref<Texture2D> light_2_off; + } theme_cache; + void _button_pressed(Node *p_button); void _update_rotation(); protected: + virtual void _update_theme_item_cache() override; void _notification(int p_what); void gui_input(const Ref<InputEvent> &p_event) override; diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp index 7bd406b869..c502d47669 100644 --- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp @@ -567,7 +567,7 @@ void MeshInstance3DEditorPlugin::make_visible(bool p_visible) { MeshInstance3DEditorPlugin::MeshInstance3DEditorPlugin() { mesh_editor = memnew(MeshInstance3DEditor); - EditorNode::get_singleton()->get_main_control()->add_child(mesh_editor); + EditorNode::get_singleton()->get_main_screen_control()->add_child(mesh_editor); mesh_editor->options->hide(); } diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp index 319f6ee9de..420ebe5942 100644 --- a/editor/plugins/mesh_library_editor_plugin.cpp +++ b/editor/plugins/mesh_library_editor_plugin.cpp @@ -319,7 +319,7 @@ void MeshLibraryEditorPlugin::make_visible(bool p_visible) { MeshLibraryEditorPlugin::MeshLibraryEditorPlugin() { mesh_library_editor = memnew(MeshLibraryEditor); - EditorNode::get_singleton()->get_main_control()->add_child(mesh_library_editor); + EditorNode::get_singleton()->get_main_screen_control()->add_child(mesh_library_editor); mesh_library_editor->set_anchors_and_offsets_preset(Control::PRESET_TOP_WIDE); mesh_library_editor->set_end(Point2(0, 22)); mesh_library_editor->hide(); diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp index fc4dc5bc2f..b0e206b020 100644 --- a/editor/plugins/multimesh_editor_plugin.cpp +++ b/editor/plugins/multimesh_editor_plugin.cpp @@ -379,7 +379,7 @@ void MultiMeshEditorPlugin::make_visible(bool p_visible) { MultiMeshEditorPlugin::MultiMeshEditorPlugin() { multimesh_editor = memnew(MultiMeshEditor); - EditorNode::get_singleton()->get_main_control()->add_child(multimesh_editor); + EditorNode::get_singleton()->get_main_screen_control()->add_child(multimesh_editor); multimesh_editor->options->hide(); } diff --git a/editor/plugins/navigation_link_2d_editor_plugin.h b/editor/plugins/navigation_link_2d_editor_plugin.h index 1c1251bec7..0a3d9b8810 100644 --- a/editor/plugins/navigation_link_2d_editor_plugin.h +++ b/editor/plugins/navigation_link_2d_editor_plugin.h @@ -42,7 +42,7 @@ class NavigationLink2DEditor : public Control { Ref<EditorUndoRedoManager> undo_redo; CanvasItemEditor *canvas_item_editor = nullptr; - NavigationLink2D *node; + NavigationLink2D *node = nullptr; bool start_grabbed = false; Vector2 original_start_location; diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 0bb044e679..13fd406e87 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -2624,14 +2624,14 @@ void Node3DEditorViewport::_notification(int p_what) { cpu_time_label->add_theme_color_override( "font_color", frame_time_gradient->get_color_at_offset( - Math::range_lerp(cpu_time, 0, 30, 0, 1))); + Math::remap(cpu_time, 0, 30, 0, 1))); gpu_time_label->set_text(vformat(TTR("GPU Time: %s ms"), rtos(gpu_time).pad_decimals(2))); // Middle point is at 15 ms. gpu_time_label->add_theme_color_override( "font_color", frame_time_gradient->get_color_at_offset( - Math::range_lerp(gpu_time, 0, 30, 0, 1))); + Math::remap(gpu_time, 0, 30, 0, 1))); const double fps = 1000.0 / gpu_time; fps_label->set_text(vformat(TTR("FPS: %d"), fps)); @@ -2639,7 +2639,7 @@ void Node3DEditorViewport::_notification(int p_what) { fps_label->add_theme_color_override( "font_color", frame_time_gradient->get_color_at_offset( - Math::range_lerp(fps, 110, 10, 0, 1))); + Math::remap(fps, 110, 10, 0, 1))); } bool show_cinema = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_CINEMATIC_PREVIEW)); @@ -6408,7 +6408,7 @@ void fragment() { Ref<ShaderMaterial> rotate_mat = memnew(ShaderMaterial); rotate_mat->set_render_priority(Material::RENDER_PRIORITY_MAX); rotate_mat->set_shader(rotate_shader); - rotate_mat->set_shader_uniform("albedo", col); + rotate_mat->set_shader_parameter("albedo", col); rotate_gizmo_color[i] = rotate_mat; Array arrays = surftool->commit_to_arrays(); @@ -6416,7 +6416,7 @@ void fragment() { rotate_gizmo[i]->surface_set_material(0, rotate_mat); Ref<ShaderMaterial> rotate_mat_hl = rotate_mat->duplicate(); - rotate_mat_hl->set_shader_uniform("albedo", albedo); + rotate_mat_hl->set_shader_parameter("albedo", albedo); rotate_gizmo_color_hl[i] = rotate_mat_hl; if (i == 2) { // Rotation white outline @@ -6457,7 +6457,7 @@ void fragment() { )"); border_mat->set_shader(border_shader); - border_mat->set_shader_uniform("albedo", Color(0.75, 0.75, 0.75, col.a / 3.0)); + border_mat->set_shader_parameter("albedo", Color(0.75, 0.75, 0.75, col.a / 3.0)); rotate_gizmo[3] = Ref<ArrayMesh>(memnew(ArrayMesh)); rotate_gizmo[3]->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, arrays); @@ -6710,8 +6710,8 @@ void Node3DEditor::_init_grid() { fade_size = CLAMP(fade_size, min_fade_size, max_fade_size); real_t grid_fade_size = (grid_size - primary_grid_steps) * fade_size; - grid_mat[c]->set_shader_uniform("grid_size", grid_fade_size); - grid_mat[c]->set_shader_uniform("orthogonal", orthogonal); + grid_mat[c]->set_shader_parameter("grid_size", grid_fade_size); + grid_mat[c]->set_shader_parameter("orthogonal", orthogonal); // Cache these so we don't have to re-access memory. Vector<Vector3> &ref_grid = grid_points[c]; @@ -7571,9 +7571,9 @@ void Node3DEditor::_sun_direction_draw() { sun_direction->draw_rect(Rect2(Vector2(), sun_direction->get_size()), Color(1, 1, 1, 1)); Vector3 z_axis = preview_sun->get_transform().basis.get_column(Vector3::AXIS_Z); z_axis = get_editor_viewport(0)->camera->get_camera_transform().basis.xform_inv(z_axis); - sun_direction_material->set_shader_uniform("sun_direction", Vector3(z_axis.x, -z_axis.y, z_axis.z)); + sun_direction_material->set_shader_parameter("sun_direction", Vector3(z_axis.x, -z_axis.y, z_axis.z)); Color color = sun_color->get_pick_color() * sun_energy->get_value(); - sun_direction_material->set_shader_uniform("sun_color", Vector3(color.r, color.g, color.b)); + sun_direction_material->set_shader_parameter("sun_color", Vector3(color.r, color.g, color.b)); } void Node3DEditor::_preview_settings_changed() { @@ -8174,8 +8174,8 @@ void fragment() { )"); sun_direction_material.instantiate(); sun_direction_material->set_shader(sun_direction_shader); - sun_direction_material->set_shader_uniform("sun_direction", Vector3(0, 0, 1)); - sun_direction_material->set_shader_uniform("sun_color", Vector3(1, 1, 1)); + sun_direction_material->set_shader_parameter("sun_direction", Vector3(0, 0, 1)); + sun_direction_material->set_shader_parameter("sun_color", Vector3(1, 1, 1)); sun_direction->set_material(sun_direction_material); HBoxContainer *sun_angle_hbox = memnew(HBoxContainer); @@ -8449,7 +8449,7 @@ void Node3DEditor::remove_gizmo_plugin(Ref<EditorNode3DGizmoPlugin> p_plugin) { Node3DEditorPlugin::Node3DEditorPlugin() { spatial_editor = memnew(Node3DEditor); spatial_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); - EditorNode::get_singleton()->get_main_control()->add_child(spatial_editor); + EditorNode::get_singleton()->get_main_screen_control()->add_child(spatial_editor); spatial_editor->hide(); } diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index a652d1d12f..328ad0ccbc 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -94,8 +94,8 @@ void Polygon2DEditor::_notification(int p_what) { [[fallthrough]]; } case NOTIFICATION_THEME_CHANGED: { - uv_edit_draw->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); - bone_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + uv_edit_draw->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); + bone_scroll->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); } break; case NOTIFICATION_VISIBILITY_CHANGED: { diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index ad114e022f..953f72bd05 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -882,7 +882,7 @@ void ScriptEditor::_queue_close_tabs() { // Maybe there are unsaved changes. if (se->is_unsaved()) { _ask_close_current_unsaved_tab(se); - erase_tab_confirm->connect(SceneStringNames::get_singleton()->visibility_changed, callable_mp(this, &ScriptEditor::_queue_close_tabs), CONNECT_ONESHOT); + erase_tab_confirm->connect(SceneStringNames::get_singleton()->visibility_changed, callable_mp(this, &ScriptEditor::_queue_close_tabs), CONNECT_ONE_SHOT); break; } } @@ -4049,7 +4049,7 @@ void ScriptEditorPlugin::edited_scene_changed() { ScriptEditorPlugin::ScriptEditorPlugin() { script_editor = memnew(ScriptEditor); - EditorNode::get_singleton()->get_main_control()->add_child(script_editor); + EditorNode::get_singleton()->get_main_screen_control()->add_child(script_editor); script_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); script_editor->hide(); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index fff956a05e..cc955eae76 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -340,7 +340,9 @@ void ScriptTextEditor::set_edit_state(const Variant &p_state) { } if (editor_enabled) { +#ifndef ANDROID_ENABLED ensure_focus(); +#endif } } diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 6674d15268..246bc4b183 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -355,7 +355,7 @@ void ShaderTextEditor::_check_shader_mode() { } static ShaderLanguage::DataType _get_global_shader_uniform_type(const StringName &p_variable) { - RS::GlobalShaderUniformType gvt = RS::get_singleton()->global_shader_uniform_get_type(p_variable); + RS::GlobalShaderParameterType gvt = RS::get_singleton()->global_shader_parameter_get_type(p_variable); return (ShaderLanguage::DataType)RS::global_shader_uniform_type_get_shader_datatype(gvt); } diff --git a/editor/plugins/skeleton_2d_editor_plugin.cpp b/editor/plugins/skeleton_2d_editor_plugin.cpp index 3dc068a72a..dbad81d743 100644 --- a/editor/plugins/skeleton_2d_editor_plugin.cpp +++ b/editor/plugins/skeleton_2d_editor_plugin.cpp @@ -131,7 +131,7 @@ void Skeleton2DEditorPlugin::make_visible(bool p_visible) { Skeleton2DEditorPlugin::Skeleton2DEditorPlugin() { sprite_editor = memnew(Skeleton2DEditor); - EditorNode::get_singleton()->get_main_control()->add_child(sprite_editor); + EditorNode::get_singleton()->get_main_screen_control()->add_child(sprite_editor); make_visible(false); //sprite_editor->options->hide(); diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index 8836799c87..37d05e5fa7 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -711,7 +711,6 @@ void Skeleton3DEditor::create_editors() { ne->add_control_to_menu_panel(skeleton_options); skeleton_options->set_text(TTR("Skeleton3D")); - skeleton_options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Skeleton3D"), SNAME("EditorIcons"))); // Skeleton options. PopupMenu *p = skeleton_options->get_popup(); @@ -824,7 +823,6 @@ void Skeleton3DEditor::create_editors() { void Skeleton3DEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - create_editors(); update_joint_tree(); update_editors(); @@ -837,13 +835,14 @@ void Skeleton3DEditor::_notification(int p_what) { skeleton->connect("show_rest_only_changed", callable_mp(this, &Skeleton3DEditor::_update_gizmo_visible)); #endif - get_tree()->connect("node_removed", callable_mp(this, &Skeleton3DEditor::_node_removed), Object::CONNECT_ONESHOT); + get_tree()->connect("node_removed", callable_mp(this, &Skeleton3DEditor::_node_removed), Object::CONNECT_ONE_SHOT); } break; case NOTIFICATION_READY: { // Will trigger NOTIFICATION_THEME_CHANGED, but won't cause any loops if called here. add_theme_constant_override("separation", 0); } break; case NOTIFICATION_THEME_CHANGED: { + skeleton_options->set_icon(get_theme_icon(SNAME("Skeleton3D"), SNAME("EditorIcons"))); edit_mode_button->set_icon(get_theme_icon(SNAME("ToolBoneSelect"), SNAME("EditorIcons"))); key_loc_button->set_icon(get_theme_icon(SNAME("KeyPosition"), SNAME("EditorIcons"))); key_rot_button->set_icon(get_theme_icon(SNAME("KeyRotation"), SNAME("EditorIcons"))); @@ -853,6 +852,20 @@ void Skeleton3DEditor::_notification(int p_what) { update_joint_tree(); } break; + case NOTIFICATION_PREDELETE: { + if (skeleton) { + select_bone(-1); // Requires that the joint_tree has not been deleted. +#ifdef TOOLS_ENABLED + skeleton->disconnect("show_rest_only_changed", callable_mp(this, &Skeleton3DEditor::_update_gizmo_visible)); + skeleton->disconnect("bone_enabled_changed", callable_mp(this, &Skeleton3DEditor::_bone_enabled_changed)); + skeleton->disconnect("pose_updated", callable_mp(this, &Skeleton3DEditor::_draw_gizmo)); + skeleton->disconnect("pose_updated", callable_mp(this, &Skeleton3DEditor::_update_properties)); + skeleton->set_transform_gizmo_visible(true); +#endif + handles_mesh_instance->get_parent()->remove_child(handles_mesh_instance); + } + edit_mode_toggled(false); + } break; } } @@ -921,13 +934,15 @@ void fragment() { )"); handle_material->set_shader(handle_shader); Ref<Texture2D> handle = EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("EditorBoneHandle"), SNAME("EditorIcons")); - handle_material->set_shader_uniform("point_size", handle->get_width()); - handle_material->set_shader_uniform("texture_albedo", handle); + handle_material->set_shader_parameter("point_size", handle->get_width()); + handle_material->set_shader_parameter("texture_albedo", handle); handles_mesh_instance = memnew(MeshInstance3D); handles_mesh_instance->set_cast_shadows_setting(GeometryInstance3D::SHADOW_CASTING_SETTING_OFF); handles_mesh.instantiate(); handles_mesh_instance->set_mesh(handles_mesh); + + create_editors(); } void Skeleton3DEditor::update_bone_original() { @@ -1065,18 +1080,7 @@ void Skeleton3DEditor::select_bone(int p_idx) { } Skeleton3DEditor::~Skeleton3DEditor() { - if (skeleton) { - select_bone(-1); -#ifdef TOOLS_ENABLED - skeleton->disconnect("show_rest_only_changed", callable_mp(this, &Skeleton3DEditor::_update_gizmo_visible)); - skeleton->disconnect("bone_enabled_changed", callable_mp(this, &Skeleton3DEditor::_bone_enabled_changed)); - skeleton->disconnect("pose_updated", callable_mp(this, &Skeleton3DEditor::_draw_gizmo)); - skeleton->disconnect("pose_updated", callable_mp(this, &Skeleton3DEditor::_update_properties)); - skeleton->set_transform_gizmo_visible(true); -#endif - handles_mesh_instance->get_parent()->remove_child(handles_mesh_instance); - } - edit_mode_toggled(false); + singleton = nullptr; handles_mesh_instance->queue_delete(); @@ -1127,7 +1131,7 @@ Skeleton3DEditorPlugin::Skeleton3DEditorPlugin() { EditorPlugin::AfterGUIInput Skeleton3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) { Skeleton3DEditor *se = Skeleton3DEditor::get_singleton(); Node3DEditor *ne = Node3DEditor::get_singleton(); - if (se->is_edit_mode()) { + if (se && se->is_edit_mode()) { const Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT) { if (ne->get_tool_mode() != Node3DEditor::TOOL_MODE_SELECT) { diff --git a/editor/plugins/sprite_2d_editor_plugin.cpp b/editor/plugins/sprite_2d_editor_plugin.cpp index 615fd5dba9..b78b70cd5c 100644 --- a/editor/plugins/sprite_2d_editor_plugin.cpp +++ b/editor/plugins/sprite_2d_editor_plugin.cpp @@ -604,7 +604,7 @@ void Sprite2DEditorPlugin::make_visible(bool p_visible) { Sprite2DEditorPlugin::Sprite2DEditorPlugin() { sprite_editor = memnew(Sprite2DEditor); - EditorNode::get_singleton()->get_main_control()->add_child(sprite_editor); + EditorNode::get_singleton()->get_main_screen_control()->add_child(sprite_editor); make_visible(false); //sprite_editor->options->hide(); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 9508835442..ae21aad337 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -428,7 +428,7 @@ void SpriteFramesEditor::_notification(int p_what) { split_sheet_zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); split_sheet_zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons"))); split_sheet_zoom_in->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons"))); - split_sheet_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + split_sheet_scroll->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); } break; case NOTIFICATION_READY: { diff --git a/editor/plugins/texture_3d_editor_plugin.cpp b/editor/plugins/texture_3d_editor_plugin.cpp index c2517b4b79..3ea62184c6 100644 --- a/editor/plugins/texture_3d_editor_plugin.cpp +++ b/editor/plugins/texture_3d_editor_plugin.cpp @@ -57,8 +57,8 @@ void Texture3DEditor::_texture_changed() { } void Texture3DEditor::_update_material() { - material->set_shader_uniform("layer", (layer->get_value() + 0.5) / texture->get_depth()); - material->set_shader_uniform("tex", texture->get_rid()); + material->set_shader_parameter("layer", (layer->get_value() + 0.5) / texture->get_depth()); + material->set_shader_parameter("tex", texture->get_rid()); String format = Image::get_format_name(texture->get_format()); diff --git a/editor/plugins/texture_layered_editor_plugin.cpp b/editor/plugins/texture_layered_editor_plugin.cpp index 1118f18605..dd8633360e 100644 --- a/editor/plugins/texture_layered_editor_plugin.cpp +++ b/editor/plugins/texture_layered_editor_plugin.cpp @@ -68,9 +68,9 @@ void TextureLayeredEditor::_texture_changed() { } void TextureLayeredEditor::_update_material() { - materials[0]->set_shader_uniform("layer", layer->get_value()); - materials[2]->set_shader_uniform("layer", layer->get_value()); - materials[texture->get_layered_type()]->set_shader_uniform("tex", texture->get_rid()); + materials[0]->set_shader_parameter("layer", layer->get_value()); + materials[2]->set_shader_parameter("layer", layer->get_value()); + materials[texture->get_layered_type()]->set_shader_parameter("tex", texture->get_rid()); Vector3 v(1, 1, 1); v.normalize(); @@ -79,10 +79,10 @@ void TextureLayeredEditor::_update_material() { b.rotate(Vector3(1, 0, 0), x_rot); b.rotate(Vector3(0, 1, 0), y_rot); - materials[1]->set_shader_uniform("normal", v); - materials[1]->set_shader_uniform("rot", b); - materials[2]->set_shader_uniform("normal", v); - materials[2]->set_shader_uniform("rot", b); + materials[1]->set_shader_parameter("normal", v); + materials[1]->set_shader_parameter("rot", b); + materials[2]->set_shader_parameter("normal", v); + materials[2]->set_shader_parameter("rot", b); String format = Image::get_format_name(texture->get_format()); diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index f0e3619060..8e04391a94 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -823,7 +823,7 @@ void TextureRegionEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - edit_draw->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + edit_draw->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); } break; case NOTIFICATION_READY: { zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index ec406ef9ba..3f2710f858 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -577,7 +577,7 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p _fix_invalid_tiles_in_tile_map_selection(); } break; case DRAG_TYPE_BUCKET: { - Vector<Vector2i> line = TileMapEditor::get_line(tile_map, tile_map->world_to_map(drag_last_mouse_pos), tile_map->world_to_map(mpos)); + Vector<Vector2i> line = TileMapEditor::get_line(tile_map, tile_map->local_to_map(drag_last_mouse_pos), tile_map->local_to_map(mpos)); for (int i = 0; i < line.size(); i++) { if (!drag_modified.has(line[i])) { HashMap<Vector2i, TileMapCell> to_draw = _draw_bucket_fill(line[i], bucket_contiguous_checkbox->is_pressed(), drag_erasing); @@ -624,7 +624,7 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p } } else if (tool_buttons_group->get_pressed_button() == select_tool_button) { drag_start_mouse_pos = mpos; - if (tile_map_selection.has(tile_map->world_to_map(drag_start_mouse_pos)) && !mb->is_shift_pressed()) { + if (tile_map_selection.has(tile_map->local_to_map(drag_start_mouse_pos)) && !mb->is_shift_pressed()) { // Move the selection _update_selection_pattern_from_tilemap_selection(); // Make sure the pattern is up to date before moving. drag_type = DRAG_TYPE_MOVE; @@ -673,7 +673,7 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p drag_type = DRAG_TYPE_BUCKET; drag_start_mouse_pos = mpos; drag_modified.clear(); - Vector<Vector2i> line = TileMapEditor::get_line(tile_map, tile_map->world_to_map(drag_last_mouse_pos), tile_map->world_to_map(mpos)); + Vector<Vector2i> line = TileMapEditor::get_line(tile_map, tile_map->local_to_map(drag_last_mouse_pos), tile_map->local_to_map(mpos)); for (int i = 0; i < line.size(); i++) { if (!drag_modified.has(line[i])) { HashMap<Vector2i, TileMapCell> to_draw = _draw_bucket_fill(line[i], bucket_contiguous_checkbox->is_pressed(), drag_erasing); @@ -752,14 +752,14 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over if (drag_type == DRAG_TYPE_PICK) { // Draw the area being picked. - Rect2i rect = Rect2i(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(drag_last_mouse_pos) - tile_map->world_to_map(drag_start_mouse_pos)).abs(); + Rect2i rect = Rect2i(tile_map->local_to_map(drag_start_mouse_pos), tile_map->local_to_map(drag_last_mouse_pos) - tile_map->local_to_map(drag_start_mouse_pos)).abs(); rect.size += Vector2i(1, 1); for (int x = rect.position.x; x < rect.get_end().x; x++) { for (int y = rect.position.y; y < rect.get_end().y; y++) { Vector2i coords = Vector2i(x, y); if (tile_map->get_cell_source_id(tile_map_layer, coords) != TileSet::INVALID_SOURCE) { Transform2D tile_xform; - tile_xform.set_origin(tile_map->map_to_world(coords)); + tile_xform.set_origin(tile_map->map_to_local(coords)); tile_xform.set_scale(tile_shape_size); tile_set->draw_tile_shape(p_overlay, xform * tile_xform, Color(1.0, 1.0, 1.0), false); } @@ -767,7 +767,7 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over } } else if (drag_type == DRAG_TYPE_SELECT) { // Draw the area being selected. - Rect2i rect = Rect2i(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(drag_last_mouse_pos) - tile_map->world_to_map(drag_start_mouse_pos)).abs(); + Rect2i rect = Rect2i(tile_map->local_to_map(drag_start_mouse_pos), tile_map->local_to_map(drag_last_mouse_pos) - tile_map->local_to_map(drag_start_mouse_pos)).abs(); rect.size += Vector2i(1, 1); RBSet<Vector2i> to_draw; for (int x = rect.position.x; x < rect.get_end().x; x++) { @@ -789,8 +789,8 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over for (const Vector2i &E : tile_map_selection) { top_left = top_left.min(E); } - Vector2i offset = drag_start_mouse_pos - tile_map->map_to_world(top_left); - offset = tile_map->world_to_map(drag_last_mouse_pos - offset) - tile_map->world_to_map(drag_start_mouse_pos - offset); + Vector2i offset = drag_start_mouse_pos - tile_map->map_to_local(top_left); + offset = tile_map->local_to_map(drag_last_mouse_pos - offset) - tile_map->local_to_map(drag_start_mouse_pos - offset); TypedArray<Vector2i> selection_used_cells = selection_pattern->get_used_cells(); for (int i = 0; i < selection_used_cells.size(); i++) { @@ -803,7 +803,7 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over Vector2 mouse_offset = (Vector2(tile_map_clipboard->get_size()) / 2.0 - Vector2(0.5, 0.5)) * tile_set->get_tile_size(); TypedArray<Vector2i> clipboard_used_cells = tile_map_clipboard->get_used_cells(); for (int i = 0; i < clipboard_used_cells.size(); i++) { - Vector2i coords = tile_map->map_pattern(tile_map->world_to_map(drag_last_mouse_pos - mouse_offset), clipboard_used_cells[i], tile_map_clipboard); + Vector2i coords = tile_map->map_pattern(tile_map->local_to_map(drag_last_mouse_pos - mouse_offset), clipboard_used_cells[i], tile_map_clipboard); preview[coords] = TileMapCell(tile_map_clipboard->get_cell_source_id(clipboard_used_cells[i]), tile_map_clipboard->get_cell_atlas_coords(clipboard_used_cells[i]), tile_map_clipboard->get_cell_alternative_tile(clipboard_used_cells[i])); } } else if (!picker_button->is_pressed() && !(drag_type == DRAG_TYPE_NONE && Input::get_singleton()->is_key_pressed(Key::CTRL) && !Input::get_singleton()->is_key_pressed(Key::SHIFT))) { @@ -824,11 +824,11 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over } } else if (drag_type == DRAG_TYPE_RECT) { // Preview for a rect pattern. - preview = _draw_rect(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(drag_last_mouse_pos), drag_erasing); + preview = _draw_rect(tile_map->local_to_map(drag_start_mouse_pos), tile_map->local_to_map(drag_last_mouse_pos), drag_erasing); expand_grid = true; } else if (tool_buttons_group->get_pressed_button() == bucket_tool_button && drag_type == DRAG_TYPE_NONE) { // Preview for a fill pattern. - preview = _draw_bucket_fill(tile_map->world_to_map(drag_last_mouse_pos), bucket_contiguous_checkbox->is_pressed(), erase_button->is_pressed()); + preview = _draw_bucket_fill(tile_map->local_to_map(drag_last_mouse_pos), bucket_contiguous_checkbox->is_pressed(), erase_button->is_pressed()); } // Expand the grid if needed @@ -861,7 +861,7 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over float opacity = CLAMP(MIN(left_opacity, MIN(right_opacity, MIN(top_opacity, bottom_opacity))) + 0.1, 0.0f, 1.0f); Transform2D tile_xform; - tile_xform.set_origin(tile_map->map_to_world(Vector2(x, y))); + tile_xform.set_origin(tile_map->map_to_local(Vector2(x, y))); tile_xform.set_scale(tile_shape_size); Color color = grid_color; color.a = color.a * opacity; @@ -874,7 +874,7 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over // Draw the preview. for (const KeyValue<Vector2i, TileMapCell> &E : preview) { Transform2D tile_xform; - tile_xform.set_origin(tile_map->map_to_world(E.key)); + tile_xform.set_origin(tile_map->map_to_local(E.key)); tile_xform.set_scale(tile_set->get_tile_size()); if (!(drag_erasing || erase_button->is_pressed()) && random_tile_toggle->is_pressed()) { tile_set->draw_tile_shape(p_overlay, xform * tile_xform, Color(1.0, 1.0, 1.0, 0.5), true); @@ -899,9 +899,9 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over bool transpose = tile_data->get_transpose(); if (transpose) { - dest_rect.position = (tile_map->map_to_world(E.key) - Vector2(dest_rect.size.y, dest_rect.size.x) / 2 - tile_offset); + dest_rect.position = (tile_map->map_to_local(E.key) - Vector2(dest_rect.size.y, dest_rect.size.x) / 2 - tile_offset); } else { - dest_rect.position = (tile_map->map_to_world(E.key) - dest_rect.size / 2 - tile_offset); + dest_rect.position = (tile_map->map_to_local(E.key) - dest_rect.size / 2 - tile_offset); } dest_rect = xform.xform(dest_rect); @@ -1012,7 +1012,7 @@ HashMap<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_line(Vector2 p_st // Paint the tiles on the tile map. if (!p_erase && random_tile_toggle->is_pressed()) { // Paint a random tile. - Vector<Vector2i> line = TileMapEditor::get_line(tile_map, tile_map->world_to_map(p_from_mouse_pos), tile_map->world_to_map(p_to_mouse_pos)); + Vector<Vector2i> line = TileMapEditor::get_line(tile_map, tile_map->local_to_map(p_from_mouse_pos), tile_map->local_to_map(p_to_mouse_pos)); for (int i = 0; i < line.size(); i++) { output.insert(line[i], _pick_random_tile(pattern)); } @@ -1020,9 +1020,9 @@ HashMap<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_line(Vector2 p_st // Paint the pattern. // If we paint several tiles, we virtually move the mouse as if it was in the center of the "brush" Vector2 mouse_offset = (Vector2(pattern->get_size()) / 2.0 - Vector2(0.5, 0.5)) * tile_set->get_tile_size(); - Vector2i last_hovered_cell = tile_map->world_to_map(p_from_mouse_pos - mouse_offset); - Vector2i new_hovered_cell = tile_map->world_to_map(p_to_mouse_pos - mouse_offset); - Vector2i drag_start_cell = tile_map->world_to_map(p_start_drag_mouse_pos - mouse_offset); + Vector2i last_hovered_cell = tile_map->local_to_map(p_from_mouse_pos - mouse_offset); + Vector2i new_hovered_cell = tile_map->local_to_map(p_to_mouse_pos - mouse_offset); + Vector2i drag_start_cell = tile_map->local_to_map(p_start_drag_mouse_pos - mouse_offset); TypedArray<Vector2i> used_cells = pattern->get_used_cells(); Vector2i offset = Vector2i(Math::posmod(drag_start_cell.x, pattern->get_size().x), Math::posmod(drag_start_cell.y, pattern->get_size().y)); // Note: no posmodv for Vector2i for now. Meh.s @@ -1172,7 +1172,7 @@ HashMap<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_bucket_fill(Vecto TypedArray<Vector2i> to_check; if (source_cell.source_id == TileSet::INVALID_SOURCE) { Rect2i rect = tile_map->get_used_rect(); - if (rect.has_no_area()) { + if (!rect.has_area()) { rect = Rect2i(p_coords, Vector2i(1, 1)); } for (int x = boundaries.position.x; x < boundaries.get_end().x; x++) { @@ -1241,7 +1241,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() { if (!Input::get_singleton()->is_key_pressed(Key::SHIFT) && !Input::get_singleton()->is_key_pressed(Key::CTRL)) { tile_map_selection.clear(); } - Rect2i rect = Rect2i(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(mpos) - tile_map->world_to_map(drag_start_mouse_pos)).abs(); + Rect2i rect = Rect2i(tile_map->local_to_map(drag_start_mouse_pos), tile_map->local_to_map(mpos) - tile_map->local_to_map(drag_start_mouse_pos)).abs(); for (int x = rect.position.x; x <= rect.get_end().x; x++) { for (int y = rect.position.y; y <= rect.get_end().y; y++) { Vector2i coords = Vector2i(x, y); @@ -1287,8 +1287,8 @@ void TileMapEditorTilesPlugin::_stop_dragging() { } // Get the offset from the mouse. - Vector2i offset = drag_start_mouse_pos - tile_map->map_to_world(top_left); - offset = tile_map->world_to_map(mpos - offset) - tile_map->world_to_map(drag_start_mouse_pos - offset); + Vector2i offset = drag_start_mouse_pos - tile_map->map_to_local(top_left); + offset = tile_map->local_to_map(mpos - offset) - tile_map->local_to_map(drag_start_mouse_pos - offset); TypedArray<Vector2i> selection_used_cells = selection_pattern->get_used_cells(); @@ -1334,7 +1334,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() { } } break; case DRAG_TYPE_PICK: { - Rect2i rect = Rect2i(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(mpos) - tile_map->world_to_map(drag_start_mouse_pos)).abs(); + Rect2i rect = Rect2i(tile_map->local_to_map(drag_start_mouse_pos), tile_map->local_to_map(mpos) - tile_map->local_to_map(drag_start_mouse_pos)).abs(); rect.size += Vector2i(1, 1); int picked_source = -1; @@ -1394,7 +1394,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() { undo_redo->commit_action(); } break; case DRAG_TYPE_RECT: { - HashMap<Vector2i, TileMapCell> to_draw = _draw_rect(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(mpos), drag_erasing); + HashMap<Vector2i, TileMapCell> to_draw = _draw_rect(tile_map->local_to_map(drag_start_mouse_pos), tile_map->local_to_map(mpos), drag_erasing); undo_redo->create_action(TTR("Paint tiles")); for (const KeyValue<Vector2i, TileMapCell> &E : to_draw) { if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { @@ -1418,7 +1418,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() { undo_redo->create_action(TTR("Paste tiles")); TypedArray<Vector2i> used_cells = tile_map_clipboard->get_used_cells(); for (int i = 0; i < used_cells.size(); i++) { - Vector2i coords = tile_map->map_pattern(tile_map->world_to_map(mpos - mouse_offset), used_cells[i], tile_map_clipboard); + Vector2i coords = tile_map->map_pattern(tile_map->local_to_map(mpos - mouse_offset), used_cells[i], tile_map_clipboard); undo_redo->add_do_method(tile_map, "set_cell", tile_map_layer, coords, tile_map_clipboard->get_cell_source_id(used_cells[i]), tile_map_clipboard->get_cell_atlas_coords(used_cells[i]), tile_map_clipboard->get_cell_alternative_tile(used_cells[i])); undo_redo->add_undo_method(tile_map, "set_cell", tile_map_layer, coords, tile_map->get_cell_source_id(tile_map_layer, coords), tile_map->get_cell_atlas_coords(tile_map_layer, coords), tile_map->get_cell_alternative_tile(tile_map_layer, coords)); } @@ -2558,7 +2558,7 @@ RBSet<Vector2i> TileMapEditorTerrainsPlugin::_get_cells_for_bucket_fill(Vector2i TypedArray<Vector2i> to_check; if (source_cell.source_id == TileSet::INVALID_SOURCE) { Rect2i rect = tile_map->get_used_rect(); - if (rect.has_no_area()) { + if (!rect.has_area()) { rect = Rect2i(p_coords, Vector2i(1, 1)); } for (int x = boundaries.position.x; x < boundaries.get_end().x; x++) { @@ -2640,7 +2640,7 @@ void TileMapEditorTerrainsPlugin::_stop_dragging() { switch (drag_type) { case DRAG_TYPE_PICK: { - Vector2i coords = tile_map->world_to_map(mpos); + Vector2i coords = tile_map->local_to_map(mpos); TileMapCell cell = tile_map->get_cell(tile_map_layer, coords); TileData *tile_data = nullptr; @@ -2714,7 +2714,7 @@ void TileMapEditorTerrainsPlugin::_stop_dragging() { undo_redo->commit_action(false); } break; case DRAG_TYPE_LINE: { - HashMap<Vector2i, TileMapCell> to_draw = _draw_line(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(mpos), drag_erasing); + HashMap<Vector2i, TileMapCell> to_draw = _draw_line(tile_map->local_to_map(drag_start_mouse_pos), tile_map->local_to_map(mpos), drag_erasing); undo_redo->create_action(TTR("Paint terrain")); for (const KeyValue<Vector2i, TileMapCell> &E : to_draw) { if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { @@ -2726,7 +2726,7 @@ void TileMapEditorTerrainsPlugin::_stop_dragging() { undo_redo->commit_action(); } break; case DRAG_TYPE_RECT: { - HashMap<Vector2i, TileMapCell> to_draw = _draw_rect(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(mpos), drag_erasing); + HashMap<Vector2i, TileMapCell> to_draw = _draw_rect(tile_map->local_to_map(drag_start_mouse_pos), tile_map->local_to_map(mpos), drag_erasing); undo_redo->create_action(TTR("Paint terrain")); for (const KeyValue<Vector2i, TileMapCell> &E : to_draw) { if (!drag_erasing && E.value.source_id == TileSet::INVALID_SOURCE) { @@ -2836,7 +2836,7 @@ bool TileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Ref<InputEvent> switch (drag_type) { case DRAG_TYPE_PAINT: { if (selected_terrain_set >= 0) { - HashMap<Vector2i, TileMapCell> to_draw = _draw_line(tile_map->world_to_map(drag_last_mouse_pos), tile_map->world_to_map(mpos), drag_erasing); + HashMap<Vector2i, TileMapCell> to_draw = _draw_line(tile_map->local_to_map(drag_last_mouse_pos), tile_map->local_to_map(mpos), drag_erasing); for (const KeyValue<Vector2i, TileMapCell> &E : to_draw) { if (!drag_modified.has(E.key)) { drag_modified[E.key] = tile_map->get_cell(tile_map_layer, E.key); @@ -2880,7 +2880,7 @@ bool TileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Ref<InputEvent> drag_start_mouse_pos = mpos; drag_modified.clear(); - Vector2i cell = tile_map->world_to_map(mpos); + Vector2i cell = tile_map->local_to_map(mpos); HashMap<Vector2i, TileMapCell> to_draw = _draw_line(cell, cell, drag_erasing); for (const KeyValue<Vector2i, TileMapCell> &E : to_draw) { drag_modified[E.key] = tile_map->get_cell(tile_map_layer, E.key); @@ -2907,7 +2907,7 @@ bool TileMapEditorTerrainsPlugin::forward_canvas_gui_input(const Ref<InputEvent> drag_type = DRAG_TYPE_BUCKET; drag_start_mouse_pos = mpos; drag_modified.clear(); - Vector<Vector2i> line = TileMapEditor::get_line(tile_map, tile_map->world_to_map(drag_last_mouse_pos), tile_map->world_to_map(mpos)); + Vector<Vector2i> line = TileMapEditor::get_line(tile_map, tile_map->local_to_map(drag_last_mouse_pos), tile_map->local_to_map(mpos)); for (int i = 0; i < line.size(); i++) { if (!drag_modified.has(line[i])) { HashMap<Vector2i, TileMapCell> to_draw = _draw_bucket_fill(line[i], bucket_contiguous_checkbox->is_pressed(), drag_erasing); @@ -2971,10 +2971,10 @@ void TileMapEditorTerrainsPlugin::forward_canvas_draw_over_viewport(Control *p_o if (drag_type == DRAG_TYPE_PICK) { // Draw the area being picked. - Vector2i coords = tile_map->world_to_map(drag_last_mouse_pos); + Vector2i coords = tile_map->local_to_map(drag_last_mouse_pos); if (tile_map->get_cell_source_id(tile_map_layer, coords) != TileSet::INVALID_SOURCE) { Transform2D tile_xform; - tile_xform.set_origin(tile_map->map_to_world(coords)); + tile_xform.set_origin(tile_map->map_to_local(coords)); tile_xform.set_scale(tile_shape_size); tile_set->draw_tile_shape(p_overlay, xform * tile_xform, Color(1.0, 1.0, 1.0), false); } @@ -2982,15 +2982,15 @@ void TileMapEditorTerrainsPlugin::forward_canvas_draw_over_viewport(Control *p_o bool expand_grid = false; if (tool_buttons_group->get_pressed_button() == paint_tool_button && drag_type == DRAG_TYPE_NONE) { // Preview for a single tile. - preview.insert(tile_map->world_to_map(drag_last_mouse_pos)); + preview.insert(tile_map->local_to_map(drag_last_mouse_pos)); expand_grid = true; } else if (tool_buttons_group->get_pressed_button() == line_tool_button || drag_type == DRAG_TYPE_LINE) { if (drag_type == DRAG_TYPE_NONE) { // Preview for a single tile. - preview.insert(tile_map->world_to_map(drag_last_mouse_pos)); + preview.insert(tile_map->local_to_map(drag_last_mouse_pos)); } else if (drag_type == DRAG_TYPE_LINE) { // Preview for a line. - Vector<Vector2i> line = TileMapEditor::get_line(tile_map, tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(drag_last_mouse_pos)); + Vector<Vector2i> line = TileMapEditor::get_line(tile_map, tile_map->local_to_map(drag_start_mouse_pos), tile_map->local_to_map(drag_last_mouse_pos)); for (int i = 0; i < line.size(); i++) { preview.insert(line[i]); } @@ -2999,8 +2999,8 @@ void TileMapEditorTerrainsPlugin::forward_canvas_draw_over_viewport(Control *p_o } else if (drag_type == DRAG_TYPE_RECT) { // Preview for a rect. Rect2i rect; - rect.set_position(tile_map->world_to_map(drag_start_mouse_pos)); - rect.set_end(tile_map->world_to_map(drag_last_mouse_pos)); + rect.set_position(tile_map->local_to_map(drag_start_mouse_pos)); + rect.set_end(tile_map->local_to_map(drag_last_mouse_pos)); rect = rect.abs(); HashMap<Vector2i, TileSet::TerrainsPattern> to_draw; @@ -3012,7 +3012,7 @@ void TileMapEditorTerrainsPlugin::forward_canvas_draw_over_viewport(Control *p_o expand_grid = true; } else if (tool_buttons_group->get_pressed_button() == bucket_tool_button && drag_type == DRAG_TYPE_NONE) { // Preview for a fill. - preview = _get_cells_for_bucket_fill(tile_map->world_to_map(drag_last_mouse_pos), bucket_contiguous_checkbox->is_pressed()); + preview = _get_cells_for_bucket_fill(tile_map->local_to_map(drag_last_mouse_pos), bucket_contiguous_checkbox->is_pressed()); } // Expand the grid if needed @@ -3045,7 +3045,7 @@ void TileMapEditorTerrainsPlugin::forward_canvas_draw_over_viewport(Control *p_o float opacity = CLAMP(MIN(left_opacity, MIN(right_opacity, MIN(top_opacity, bottom_opacity))) + 0.1, 0.0f, 1.0f); Transform2D tile_xform; - tile_xform.set_origin(tile_map->map_to_world(Vector2(x, y))); + tile_xform.set_origin(tile_map->map_to_local(Vector2(x, y))); tile_xform.set_scale(tile_shape_size); Color color = grid_color; color.a = color.a * opacity; @@ -3058,7 +3058,7 @@ void TileMapEditorTerrainsPlugin::forward_canvas_draw_over_viewport(Control *p_o // Draw the preview. for (const Vector2i &E : preview) { Transform2D tile_xform; - tile_xform.set_origin(tile_map->map_to_world(E)); + tile_xform.set_origin(tile_map->map_to_local(E)); tile_xform.set_scale(tile_set->get_tile_size()); if (drag_erasing || erase_button->is_pressed()) { tile_set->draw_tile_shape(p_overlay, xform * tile_xform, Color(0.0, 0.0, 0.0, 0.5), true); @@ -3838,7 +3838,7 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { // Draw the scaled tile. Transform2D tile_xform; - tile_xform.set_origin(tile_map->map_to_world(coords)); + tile_xform.set_origin(tile_map->map_to_local(coords)); tile_xform.set_scale(tile_shape_size); tile_set->draw_tile_shape(p_overlay, xform * tile_xform, color, true, warning_pattern_texture); } @@ -3848,7 +3848,7 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { Vector2 icon_size; icon_size[min_axis] = tile_set->get_tile_size()[min_axis] / 3; icon_size[(min_axis + 1) % 2] = (icon_size[min_axis] * missing_tile_texture->get_size()[(min_axis + 1) % 2] / missing_tile_texture->get_size()[min_axis]); - Rect2 rect = Rect2(xform.xform(tile_map->map_to_world(coords)) - (icon_size * xform.get_scale() / 2), icon_size * xform.get_scale()); + Rect2 rect = Rect2(xform.xform(tile_map->map_to_local(coords)) - (icon_size * xform.get_scale() / 2), icon_size * xform.get_scale()); p_overlay->draw_texture_rect(missing_tile_texture, rect); } } @@ -3861,10 +3861,10 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { // Determine the drawn area. Size2 screen_size = p_overlay->get_size(); Rect2i screen_rect; - screen_rect.position = tile_map->world_to_map(xform_inv.xform(Vector2())); - screen_rect.expand_to(tile_map->world_to_map(xform_inv.xform(Vector2(0, screen_size.height)))); - screen_rect.expand_to(tile_map->world_to_map(xform_inv.xform(Vector2(screen_size.width, 0)))); - screen_rect.expand_to(tile_map->world_to_map(xform_inv.xform(screen_size))); + screen_rect.position = tile_map->local_to_map(xform_inv.xform(Vector2())); + screen_rect.expand_to(tile_map->local_to_map(xform_inv.xform(Vector2(0, screen_size.height)))); + screen_rect.expand_to(tile_map->local_to_map(xform_inv.xform(Vector2(screen_size.width, 0)))); + screen_rect.expand_to(tile_map->local_to_map(xform_inv.xform(screen_size))); screen_rect = screen_rect.grow(1); Rect2i tilemap_used_rect = tile_map->get_used_rect(); @@ -3897,7 +3897,7 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { float opacity = CLAMP(MIN(left_opacity, MIN(right_opacity, MIN(top_opacity, bottom_opacity))) + 0.1, 0.0f, 1.0f); Transform2D tile_xform; - tile_xform.set_origin(tile_map->map_to_world(Vector2(x, y))); + tile_xform.set_origin(tile_map->map_to_local(Vector2(x, y))); tile_xform.set_scale(tile_shape_size); Color color = grid_color; color.a = color.a * opacity; @@ -3910,7 +3910,7 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { /*Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); for (int x = displayed_rect.position.x; x < (displayed_rect.position.x + displayed_rect.size.x); x++) { for (int y = displayed_rect.position.y; y < (displayed_rect.position.y + displayed_rect.size.y); y++) { - p_overlay->draw_string(font, xform.xform(tile_map->map_to_world(Vector2(x, y))) + Vector2i(-tile_shape_size.x / 2, 0), vformat("%s", Vector2(x, y))); + p_overlay->draw_string(font, xform.xform(tile_map->map_to_local(Vector2(x, y))) + Vector2i(-tile_shape_size.x / 2, 0), vformat("%s", Vector2(x, y))); } }*/ diff --git a/editor/plugins/tiles/tiles_editor_plugin.cpp b/editor/plugins/tiles/tiles_editor_plugin.cpp index b5134f6893..17115519e2 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.cpp +++ b/editor/plugins/tiles/tiles_editor_plugin.cpp @@ -91,10 +91,10 @@ void TilesEditorPlugin::_thread() { TypedArray<Vector2i> used_cells = tile_map->get_used_cells(0); Rect2 encompassing_rect = Rect2(); - encompassing_rect.set_position(tile_map->map_to_world(used_cells[0])); + encompassing_rect.set_position(tile_map->map_to_local(used_cells[0])); for (int i = 0; i < used_cells.size(); i++) { Vector2i cell = used_cells[i]; - Vector2 world_pos = tile_map->map_to_world(cell); + Vector2 world_pos = tile_map->map_to_local(cell); encompassing_rect.expand_to(world_pos); // Texture. @@ -116,7 +116,7 @@ void TilesEditorPlugin::_thread() { // Add the viewport at the last moment to avoid rendering too early. EditorNode::get_singleton()->add_child(viewport); - RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<TilesEditorPlugin *>(this), &TilesEditorPlugin::_preview_frame_started), Object::CONNECT_ONESHOT); + RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<TilesEditorPlugin *>(this), &TilesEditorPlugin::_preview_frame_started), Object::CONNECT_ONE_SHOT); pattern_preview_done.wait(); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 2fb8bbe86b..804db726a2 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -111,7 +111,7 @@ void VisualShaderGraphPlugin::_bind_methods() { ClassDB::bind_method("update_node", &VisualShaderGraphPlugin::update_node); ClassDB::bind_method("update_node_deferred", &VisualShaderGraphPlugin::update_node_deferred); ClassDB::bind_method("set_input_port_default_value", &VisualShaderGraphPlugin::set_input_port_default_value); - ClassDB::bind_method("set_uniform_name", &VisualShaderGraphPlugin::set_uniform_name); + ClassDB::bind_method("set_parameter_name", &VisualShaderGraphPlugin::set_parameter_name); ClassDB::bind_method("set_expression", &VisualShaderGraphPlugin::set_expression); ClassDB::bind_method("update_curve", &VisualShaderGraphPlugin::update_curve); ClassDB::bind_method("update_curve_xyz", &VisualShaderGraphPlugin::update_curve_xyz); @@ -223,9 +223,9 @@ void VisualShaderGraphPlugin::set_input_port_default_value(VisualShader::Type p_ } } -void VisualShaderGraphPlugin::set_uniform_name(VisualShader::Type p_type, int p_node_id, const String &p_name) { - if (visual_shader->get_shader_type() == p_type && links.has(p_node_id) && links[p_node_id].uniform_name != nullptr) { - links[p_node_id].uniform_name->set_text(p_name); +void VisualShaderGraphPlugin::set_parameter_name(VisualShader::Type p_type, int p_node_id, const String &p_name) { + if (visual_shader->get_shader_type() == p_type && links.has(p_node_id) && links[p_node_id].parameter_name != nullptr) { + links[p_node_id].parameter_name->set_text(p_name); } } @@ -290,9 +290,9 @@ void VisualShaderGraphPlugin::register_curve_editor(int p_node_id, int p_index, links[p_node_id].curve_editors[p_index] = p_curve_editor; } -void VisualShaderGraphPlugin::update_uniform_refs() { +void VisualShaderGraphPlugin::update_parameter_refs() { for (KeyValue<int, Link> &E : links) { - VisualShaderNodeUniformRef *ref = Object::cast_to<VisualShaderNodeUniformRef>(E.value.visual_node); + VisualShaderNodeParameterRef *ref = Object::cast_to<VisualShaderNodeParameterRef>(E.value.visual_node); if (ref) { remove_node(E.value.type, E.key); add_node(E.value.type, E.key); @@ -334,8 +334,8 @@ void VisualShaderGraphPlugin::register_output_port(int p_node_id, int p_port, Te links[p_node_id].output_ports.insert(p_port, { p_button }); } -void VisualShaderGraphPlugin::register_uniform_name(int p_node_id, LineEdit *p_uniform_name) { - links[p_node_id].uniform_name = p_uniform_name; +void VisualShaderGraphPlugin::register_parameter_name(int p_node_id, LineEdit *p_parameter_name) { + links[p_node_id].parameter_name = p_parameter_name; } void VisualShaderGraphPlugin::update_theme() { @@ -466,29 +466,29 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { node->set_custom_minimum_size(Size2(200 * EDSCALE, 0)); } - Ref<VisualShaderNodeUniformRef> uniform_ref = vsnode; - if (uniform_ref.is_valid()) { - uniform_ref->set_shader_rid(visual_shader->get_rid()); - uniform_ref->update_uniform_type(); + Ref<VisualShaderNodeParameterRef> parameter_ref = vsnode; + if (parameter_ref.is_valid()) { + parameter_ref->set_shader_rid(visual_shader->get_rid()); + parameter_ref->update_parameter_type(); } - Ref<VisualShaderNodeUniform> uniform = vsnode; + Ref<VisualShaderNodeParameter> parameter = vsnode; HBoxContainer *hb = nullptr; - if (uniform.is_valid()) { - LineEdit *uniform_name = memnew(LineEdit); - register_uniform_name(p_id, uniform_name); - uniform_name->set_h_size_flags(Control::SIZE_EXPAND_FILL); - uniform_name->set_text(uniform->get_uniform_name()); - uniform_name->connect("text_submitted", callable_mp(editor, &VisualShaderEditor::_uniform_line_edit_changed).bind(p_id)); - uniform_name->connect("focus_exited", callable_mp(editor, &VisualShaderEditor::_uniform_line_edit_focus_out).bind(uniform_name, p_id)); + if (parameter.is_valid()) { + LineEdit *parameter_name = memnew(LineEdit); + register_parameter_name(p_id, parameter_name); + parameter_name->set_h_size_flags(Control::SIZE_EXPAND_FILL); + parameter_name->set_text(parameter->get_parameter_name()); + parameter_name->connect("text_submitted", callable_mp(editor, &VisualShaderEditor::_parameter_line_edit_changed).bind(p_id)); + parameter_name->connect("focus_exited", callable_mp(editor, &VisualShaderEditor::_parameter_line_edit_focus_out).bind(parameter_name, p_id)); if (vsnode->get_output_port_count() == 1 && vsnode->get_output_port_name(0) == "") { hb = memnew(HBoxContainer); - hb->add_child(uniform_name); + hb->add_child(parameter_name); node->add_child(hb); } else { - node->add_child(uniform_name); + node->add_child(parameter_name); } port_offset++; } @@ -1409,13 +1409,13 @@ void VisualShaderEditor::_update_options_menu() { } } - Ref<VisualShaderNodeUniformRef> uniform_ref = Object::cast_to<VisualShaderNodeUniformRef>(vsn.ptr()); - if (uniform_ref.is_valid()) { + Ref<VisualShaderNodeParameterRef> parameter_ref = Object::cast_to<VisualShaderNodeParameterRef>(vsn.ptr()); + if (parameter_ref.is_valid()) { check_result = -1; if (members_input_port_type != VisualShaderNode::PORT_TYPE_MAX) { - for (int j = 0; j < uniform_ref->get_uniforms_count(); j++) { - if (visual_shader->is_port_types_compatible(uniform_ref->get_port_type_by_index(j), members_input_port_type)) { + for (int j = 0; j < parameter_ref->get_parameters_count(); j++) { + if (visual_shader->is_port_types_compatible(parameter_ref->get_port_type_by_index(j), members_input_port_type)) { check_result = 1; break; } @@ -1612,66 +1612,66 @@ void VisualShaderEditor::_update_created_node(GraphNode *node) { node->add_theme_color_override("resizer_color", c); } -void VisualShaderEditor::_update_uniforms(bool p_update_refs) { - VisualShaderNodeUniformRef::clear_uniforms(visual_shader->get_rid()); +void VisualShaderEditor::_update_parameters(bool p_update_refs) { + VisualShaderNodeParameterRef::clear_parameters(visual_shader->get_rid()); for (int t = 0; t < VisualShader::TYPE_MAX; t++) { Vector<int> tnodes = visual_shader->get_node_list((VisualShader::Type)t); for (int i = 0; i < tnodes.size(); i++) { Ref<VisualShaderNode> vsnode = visual_shader->get_node((VisualShader::Type)t, tnodes[i]); - Ref<VisualShaderNodeUniform> uniform = vsnode; - - if (uniform.is_valid()) { - Ref<VisualShaderNodeFloatUniform> float_uniform = vsnode; - Ref<VisualShaderNodeIntUniform> int_uniform = vsnode; - Ref<VisualShaderNodeVec2Uniform> vec2_uniform = vsnode; - Ref<VisualShaderNodeVec3Uniform> vec3_uniform = vsnode; - Ref<VisualShaderNodeVec4Uniform> vec4_uniform = vsnode; - Ref<VisualShaderNodeColorUniform> color_uniform = vsnode; - Ref<VisualShaderNodeBooleanUniform> bool_uniform = vsnode; - Ref<VisualShaderNodeTransformUniform> transform_uniform = vsnode; - - VisualShaderNodeUniformRef::UniformType uniform_type; - if (float_uniform.is_valid()) { - uniform_type = VisualShaderNodeUniformRef::UniformType::UNIFORM_TYPE_FLOAT; - } else if (int_uniform.is_valid()) { - uniform_type = VisualShaderNodeUniformRef::UniformType::UNIFORM_TYPE_INT; - } else if (bool_uniform.is_valid()) { - uniform_type = VisualShaderNodeUniformRef::UniformType::UNIFORM_TYPE_BOOLEAN; - } else if (vec2_uniform.is_valid()) { - uniform_type = VisualShaderNodeUniformRef::UniformType::UNIFORM_TYPE_VECTOR2; - } else if (vec3_uniform.is_valid()) { - uniform_type = VisualShaderNodeUniformRef::UniformType::UNIFORM_TYPE_VECTOR3; - } else if (vec4_uniform.is_valid()) { - uniform_type = VisualShaderNodeUniformRef::UniformType::UNIFORM_TYPE_VECTOR4; - } else if (transform_uniform.is_valid()) { - uniform_type = VisualShaderNodeUniformRef::UniformType::UNIFORM_TYPE_TRANSFORM; - } else if (color_uniform.is_valid()) { - uniform_type = VisualShaderNodeUniformRef::UniformType::UNIFORM_TYPE_COLOR; + Ref<VisualShaderNodeParameter> parameter = vsnode; + + if (parameter.is_valid()) { + Ref<VisualShaderNodeFloatParameter> float_parameter = vsnode; + Ref<VisualShaderNodeIntParameter> int_parameter = vsnode; + Ref<VisualShaderNodeVec2Parameter> vec2_parameter = vsnode; + Ref<VisualShaderNodeVec3Parameter> vec3_parameter = vsnode; + Ref<VisualShaderNodeVec4Parameter> vec4_parameter = vsnode; + Ref<VisualShaderNodeColorParameter> color_parameter = vsnode; + Ref<VisualShaderNodeBooleanParameter> boolean_parameter = vsnode; + Ref<VisualShaderNodeTransformParameter> transform_parameter = vsnode; + + VisualShaderNodeParameterRef::ParameterType parameter_type; + if (float_parameter.is_valid()) { + parameter_type = VisualShaderNodeParameterRef::PARAMETER_TYPE_FLOAT; + } else if (int_parameter.is_valid()) { + parameter_type = VisualShaderNodeParameterRef::PARAMETER_TYPE_INT; + } else if (boolean_parameter.is_valid()) { + parameter_type = VisualShaderNodeParameterRef::PARAMETER_TYPE_BOOLEAN; + } else if (vec2_parameter.is_valid()) { + parameter_type = VisualShaderNodeParameterRef::PARAMETER_TYPE_VECTOR2; + } else if (vec3_parameter.is_valid()) { + parameter_type = VisualShaderNodeParameterRef::PARAMETER_TYPE_VECTOR3; + } else if (vec4_parameter.is_valid()) { + parameter_type = VisualShaderNodeParameterRef::PARAMETER_TYPE_VECTOR4; + } else if (transform_parameter.is_valid()) { + parameter_type = VisualShaderNodeParameterRef::PARAMETER_TYPE_TRANSFORM; + } else if (color_parameter.is_valid()) { + parameter_type = VisualShaderNodeParameterRef::PARAMETER_TYPE_COLOR; } else { - uniform_type = VisualShaderNodeUniformRef::UniformType::UNIFORM_TYPE_SAMPLER; + parameter_type = VisualShaderNodeParameterRef::UNIFORM_TYPE_SAMPLER; } - VisualShaderNodeUniformRef::add_uniform(visual_shader->get_rid(), uniform->get_uniform_name(), uniform_type); + VisualShaderNodeParameterRef::add_parameter(visual_shader->get_rid(), parameter->get_parameter_name(), parameter_type); } } } if (p_update_refs) { - graph_plugin->update_uniform_refs(); + graph_plugin->update_parameter_refs(); } } -void VisualShaderEditor::_update_uniform_refs(HashSet<String> &p_deleted_names) { +void VisualShaderEditor::_update_parameter_refs(HashSet<String> &p_deleted_names) { for (int i = 0; i < VisualShader::TYPE_MAX; i++) { VisualShader::Type type = VisualShader::Type(i); Vector<int> nodes = visual_shader->get_node_list(type); for (int j = 0; j < nodes.size(); j++) { if (j > 0) { - Ref<VisualShaderNodeUniformRef> ref = visual_shader->get_node(type, nodes[j]); + Ref<VisualShaderNodeParameterRef> ref = visual_shader->get_node(type, nodes[j]); if (ref.is_valid()) { - if (p_deleted_names.has(ref->get_uniform_name())) { - undo_redo->add_do_method(ref.ptr(), "set_uniform_name", "[None]"); - undo_redo->add_undo_method(ref.ptr(), "set_uniform_name", ref->get_uniform_name()); + if (p_deleted_names.has(ref->get_parameter_name())) { + undo_redo->add_do_method(ref.ptr(), "set_parameter_name", "[None]"); + undo_redo->add_undo_method(ref.ptr(), "set_parameter_name", ref->get_parameter_name()); undo_redo->add_do_method(graph_plugin.ptr(), "update_node", VisualShader::Type(i), nodes[j]); undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", VisualShader::Type(i), nodes[j]); } @@ -1711,7 +1711,7 @@ void VisualShaderEditor::_update_graph() { Vector<int> nodes = visual_shader->get_node_list(type); - _update_uniforms(false); + _update_parameters(false); _update_varyings(); graph_plugin->clear_links(); @@ -2257,38 +2257,38 @@ void VisualShaderEditor::_comment_desc_popup_hide() { undo_redo->commit_action(); } -void VisualShaderEditor::_uniform_line_edit_changed(const String &p_text, int p_node_id) { +void VisualShaderEditor::_parameter_line_edit_changed(const String &p_text, int p_node_id) { VisualShader::Type type = get_current_shader_type(); - Ref<VisualShaderNodeUniform> node = visual_shader->get_node(type, p_node_id); + Ref<VisualShaderNodeParameter> node = visual_shader->get_node(type, p_node_id); ERR_FAIL_COND(!node.is_valid()); - String validated_name = visual_shader->validate_uniform_name(p_text, node); + String validated_name = visual_shader->validate_parameter_name(p_text, node); - if (validated_name == node->get_uniform_name()) { + if (validated_name == node->get_parameter_name()) { return; } - undo_redo->create_action(TTR("Set Uniform Name")); - undo_redo->add_do_method(node.ptr(), "set_uniform_name", validated_name); - undo_redo->add_undo_method(node.ptr(), "set_uniform_name", node->get_uniform_name()); - undo_redo->add_do_method(graph_plugin.ptr(), "set_uniform_name", type, p_node_id, validated_name); - undo_redo->add_undo_method(graph_plugin.ptr(), "set_uniform_name", type, p_node_id, node->get_uniform_name()); + undo_redo->create_action(TTR("Set Parameter Name")); + undo_redo->add_do_method(node.ptr(), "set_parameter_name", validated_name); + undo_redo->add_undo_method(node.ptr(), "set_parameter_name", node->get_parameter_name()); + undo_redo->add_do_method(graph_plugin.ptr(), "set_parameter_name", type, p_node_id, validated_name); + undo_redo->add_undo_method(graph_plugin.ptr(), "set_parameter_name", type, p_node_id, node->get_parameter_name()); undo_redo->add_do_method(graph_plugin.ptr(), "update_node_deferred", type, p_node_id); undo_redo->add_undo_method(graph_plugin.ptr(), "update_node_deferred", type, p_node_id); - undo_redo->add_do_method(this, "_update_uniforms", true); - undo_redo->add_undo_method(this, "_update_uniforms", true); + undo_redo->add_do_method(this, "_update_parameters", true); + undo_redo->add_undo_method(this, "_update_parameters", true); HashSet<String> changed_names; - changed_names.insert(node->get_uniform_name()); - _update_uniform_refs(changed_names); + changed_names.insert(node->get_parameter_name()); + _update_parameter_refs(changed_names); undo_redo->commit_action(); } -void VisualShaderEditor::_uniform_line_edit_focus_out(Object *line_edit, int p_node_id) { - _uniform_line_edit_changed(Object::cast_to<LineEdit>(line_edit)->get_text(), p_node_id); +void VisualShaderEditor::_parameter_line_edit_focus_out(Object *line_edit, int p_node_id) { + _parameter_line_edit_changed(Object::cast_to<LineEdit>(line_edit)->get_text(), p_node_id); } void VisualShaderEditor::_port_name_focus_out(Object *line_edit, int p_node_id, int p_port_id, bool p_output) { @@ -2674,22 +2674,22 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, Stri if (!p_ops.is_empty()) { _setup_node(vsn, p_ops); } - VisualShaderNodeUniformRef *uniform_ref = Object::cast_to<VisualShaderNodeUniformRef>(vsn); - if (uniform_ref && to_node != -1 && to_slot != -1) { + VisualShaderNodeParameterRef *parameter_ref = Object::cast_to<VisualShaderNodeParameterRef>(vsn); + if (parameter_ref && to_node != -1 && to_slot != -1) { VisualShaderNode::PortType input_port_type = visual_shader->get_node(type, to_node)->get_input_port_type(to_slot); bool success = false; - for (int i = 0; i < uniform_ref->get_uniforms_count(); i++) { - if (uniform_ref->get_port_type_by_index(i) == input_port_type) { - uniform_ref->set_uniform_name(uniform_ref->get_uniform_name_by_index(i)); + for (int i = 0; i < parameter_ref->get_parameters_count(); i++) { + if (parameter_ref->get_port_type_by_index(i) == input_port_type) { + parameter_ref->set_parameter_name(parameter_ref->get_parameter_name_by_index(i)); success = true; break; } } if (!success) { - for (int i = 0; i < uniform_ref->get_uniforms_count(); i++) { - if (visual_shader->is_port_types_compatible(uniform_ref->get_port_type_by_index(i), input_port_type)) { - uniform_ref->set_uniform_name(uniform_ref->get_uniform_name_by_index(i)); + for (int i = 0; i < parameter_ref->get_parameters_count(); i++) { + if (visual_shader->is_port_types_compatible(parameter_ref->get_port_type_by_index(i), input_port_type)) { + parameter_ref->set_parameter_name(parameter_ref->get_parameter_name_by_index(i)); break; } } @@ -2712,7 +2712,7 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, Stri bool is_cubemap = (Object::cast_to<VisualShaderNodeCubemap>(vsnode.ptr()) != nullptr); bool is_curve = (Object::cast_to<VisualShaderNodeCurveTexture>(vsnode.ptr()) != nullptr); bool is_curve_xyz = (Object::cast_to<VisualShaderNodeCurveXYZTexture>(vsnode.ptr()) != nullptr); - bool is_uniform = (Object::cast_to<VisualShaderNodeUniform>(vsnode.ptr()) != nullptr); + bool is_parameter = (Object::cast_to<VisualShaderNodeParameter>(vsnode.ptr()) != nullptr); Point2 position = graph->get_scroll_ofs(); @@ -2861,9 +2861,9 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, Stri } _member_cancel(); - if (is_uniform) { - undo_redo->add_do_method(this, "_update_uniforms", true); - undo_redo->add_undo_method(this, "_update_uniforms", true); + if (is_parameter) { + undo_redo->add_do_method(this, "_update_parameters", true); + undo_redo->add_undo_method(this, "_update_parameters", true); } if (is_curve) { @@ -3118,7 +3118,7 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) { } } - HashSet<String> uniform_names; + HashSet<String> parameter_names; for (const int &F : p_nodes) { Ref<VisualShaderNode> node = visual_shader->get_node(type, F); @@ -3141,9 +3141,9 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) { undo_redo->add_undo_method(expression, "set_expression", expression->get_expression()); } - VisualShaderNodeUniform *uniform = Object::cast_to<VisualShaderNodeUniform>(node.ptr()); - if (uniform) { - uniform_names.insert(uniform->get_uniform_name()); + VisualShaderNodeParameter *parameter = Object::cast_to<VisualShaderNodeParameter>(node.ptr()); + if (parameter) { + parameter_names.insert(parameter->get_parameter_name()); } } @@ -3172,12 +3172,12 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) { undo_redo->add_do_method(graph_plugin.ptr(), "remove_node", type, F); } - // update uniform refs if any uniform has been deleted - if (uniform_names.size() > 0) { - undo_redo->add_do_method(this, "_update_uniforms", true); - undo_redo->add_undo_method(this, "_update_uniforms", true); + // update parameter refs if any parameter has been deleted + if (parameter_names.size() > 0) { + undo_redo->add_do_method(this, "_update_parameters", true); + undo_redo->add_undo_method(this, "_update_parameters", true); - _update_uniform_refs(uniform_names); + _update_parameter_refs(parameter_names); } } @@ -3196,33 +3196,33 @@ void VisualShaderEditor::_update_constant(VisualShader::Type p_type_id, int p_no } } -void VisualShaderEditor::_update_uniform(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port) { - Ref<VisualShaderNodeUniform> uniform = visual_shader->get_node(p_type_id, p_node_id); - ERR_FAIL_COND(!uniform.is_valid()); +void VisualShaderEditor::_update_parameter(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port) { + Ref<VisualShaderNodeParameter> parameter = visual_shader->get_node(p_type_id, p_node_id); + ERR_FAIL_COND(!parameter.is_valid()); - String valid_name = visual_shader->validate_uniform_name(uniform->get_uniform_name(), uniform); - uniform->set_uniform_name(valid_name); - graph_plugin->set_uniform_name(p_type_id, p_node_id, valid_name); + String valid_name = visual_shader->validate_parameter_name(parameter->get_parameter_name(), parameter); + parameter->set_parameter_name(valid_name); + graph_plugin->set_parameter_name(p_type_id, p_node_id, valid_name); - if (uniform->has_method("set_default_value_enabled")) { - uniform->call("set_default_value_enabled", true); - uniform->call("set_default_value", p_var); + if (parameter->has_method("set_default_value_enabled")) { + parameter->call("set_default_value_enabled", true); + parameter->call("set_default_value", p_var); } if (p_preview_port != -1) { - uniform->set_output_port_for_preview(p_preview_port); + parameter->set_output_port_for_preview(p_preview_port); } } -void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) { +void VisualShaderEditor::_convert_constants_to_parameters(bool p_vice_versa) { VisualShader::Type type_id = get_current_shader_type(); if (!p_vice_versa) { - undo_redo->create_action(TTR("Convert Constant Node(s) To Uniform(s)")); + undo_redo->create_action(TTR("Convert Constant Node(s) To Parameter(s)")); } else { - undo_redo->create_action(TTR("Convert Uniform Node(s) To Constant(s)")); + undo_redo->create_action(TTR("Convert Parameter Node(s) To Constant(s)")); } - const HashSet<int> ¤t_set = p_vice_versa ? selected_uniforms : selected_constants; + const HashSet<int> ¤t_set = p_vice_versa ? selected_parameters : selected_constants; HashSet<String> deleted_names; for (const int &E : current_set) { @@ -3235,15 +3235,15 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) { if (!p_vice_versa) { Ref<VisualShaderNodeFloatConstant> float_const = Object::cast_to<VisualShaderNodeFloatConstant>(node.ptr()); if (float_const.is_valid()) { - _replace_node(type_id, node_id, "VisualShaderNodeFloatConstant", "VisualShaderNodeFloatUniform"); + _replace_node(type_id, node_id, "VisualShaderNodeFloatConstant", "VisualShaderNodeFloatParameter"); var = float_const->get_constant(); caught = true; } } else { - Ref<VisualShaderNodeFloatUniform> float_uniform = Object::cast_to<VisualShaderNodeFloatUniform>(node.ptr()); - if (float_uniform.is_valid()) { - _replace_node(type_id, node_id, "VisualShaderNodeFloatUniform", "VisualShaderNodeFloatConstant"); - var = float_uniform->get_default_value(); + Ref<VisualShaderNodeFloatParameter> float_parameter = Object::cast_to<VisualShaderNodeFloatParameter>(node.ptr()); + if (float_parameter.is_valid()) { + _replace_node(type_id, node_id, "VisualShaderNodeFloatParameter", "VisualShaderNodeFloatConstant"); + var = float_parameter->get_default_value(); caught = true; } } @@ -3253,15 +3253,15 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) { if (!p_vice_versa) { Ref<VisualShaderNodeIntConstant> int_const = Object::cast_to<VisualShaderNodeIntConstant>(node.ptr()); if (int_const.is_valid()) { - _replace_node(type_id, node_id, "VisualShaderNodeIntConstant", "VisualShaderNodeIntUniform"); + _replace_node(type_id, node_id, "VisualShaderNodeIntConstant", "VisualShaderNodeIntParameter"); var = int_const->get_constant(); caught = true; } } else { - Ref<VisualShaderNodeIntUniform> int_uniform = Object::cast_to<VisualShaderNodeIntUniform>(node.ptr()); - if (int_uniform.is_valid()) { - _replace_node(type_id, node_id, "VisualShaderNodeIntUniform", "VisualShaderNodeIntConstant"); - var = int_uniform->get_default_value(); + Ref<VisualShaderNodeIntParameter> int_parameter = Object::cast_to<VisualShaderNodeIntParameter>(node.ptr()); + if (int_parameter.is_valid()) { + _replace_node(type_id, node_id, "VisualShaderNodeIntParameter", "VisualShaderNodeIntConstant"); + var = int_parameter->get_default_value(); caught = true; } } @@ -3272,15 +3272,15 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) { if (!p_vice_versa) { Ref<VisualShaderNodeBooleanConstant> boolean_const = Object::cast_to<VisualShaderNodeBooleanConstant>(node.ptr()); if (boolean_const.is_valid()) { - _replace_node(type_id, node_id, "VisualShaderNodeBooleanConstant", "VisualShaderNodeBooleanUniform"); + _replace_node(type_id, node_id, "VisualShaderNodeBooleanConstant", "VisualShaderNodeBooleanParameter"); var = boolean_const->get_constant(); caught = true; } } else { - Ref<VisualShaderNodeBooleanUniform> boolean_uniform = Object::cast_to<VisualShaderNodeBooleanUniform>(node.ptr()); - if (boolean_uniform.is_valid()) { - _replace_node(type_id, node_id, "VisualShaderNodeBooleanUniform", "VisualShaderNodeBooleanConstant"); - var = boolean_uniform->get_default_value(); + Ref<VisualShaderNodeBooleanParameter> boolean_parameter = Object::cast_to<VisualShaderNodeBooleanParameter>(node.ptr()); + if (boolean_parameter.is_valid()) { + _replace_node(type_id, node_id, "VisualShaderNodeBooleanParameter", "VisualShaderNodeBooleanConstant"); + var = boolean_parameter->get_default_value(); caught = true; } } @@ -3291,15 +3291,15 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) { if (!p_vice_versa) { Ref<VisualShaderNodeVec2Constant> vec2_const = Object::cast_to<VisualShaderNodeVec2Constant>(node.ptr()); if (vec2_const.is_valid()) { - _replace_node(type_id, node_id, "VisualShaderNodeVec2Constant", "VisualShaderNodeVec2Uniform"); + _replace_node(type_id, node_id, "VisualShaderNodeVec2Constant", "VisualShaderNodeVec2Parameter"); var = vec2_const->get_constant(); caught = true; } } else { - Ref<VisualShaderNodeVec2Uniform> vec2_uniform = Object::cast_to<VisualShaderNodeVec2Uniform>(node.ptr()); - if (vec2_uniform.is_valid()) { - _replace_node(type_id, node_id, "VisualShaderNodeVec2Uniform", "VisualShaderNodeVec2Constant"); - var = vec2_uniform->get_default_value(); + Ref<VisualShaderNodeVec2Parameter> vec2_parameter = Object::cast_to<VisualShaderNodeVec2Parameter>(node.ptr()); + if (vec2_parameter.is_valid()) { + _replace_node(type_id, node_id, "VisualShaderNodeVec2Parameter", "VisualShaderNodeVec2Constant"); + var = vec2_parameter->get_default_value(); caught = true; } } @@ -3310,15 +3310,15 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) { if (!p_vice_versa) { Ref<VisualShaderNodeVec3Constant> vec3_const = Object::cast_to<VisualShaderNodeVec3Constant>(node.ptr()); if (vec3_const.is_valid()) { - _replace_node(type_id, node_id, "VisualShaderNodeVec3Constant", "VisualShaderNodeVec3Uniform"); + _replace_node(type_id, node_id, "VisualShaderNodeVec3Constant", "VisualShaderNodeVec3Parameter"); var = vec3_const->get_constant(); caught = true; } } else { - Ref<VisualShaderNodeVec3Uniform> vec3_uniform = Object::cast_to<VisualShaderNodeVec3Uniform>(node.ptr()); - if (vec3_uniform.is_valid()) { - _replace_node(type_id, node_id, "VisualShaderNodeVec3Uniform", "VisualShaderNodeVec3Constant"); - var = vec3_uniform->get_default_value(); + Ref<VisualShaderNodeVec3Parameter> vec3_parameter = Object::cast_to<VisualShaderNodeVec3Parameter>(node.ptr()); + if (vec3_parameter.is_valid()) { + _replace_node(type_id, node_id, "VisualShaderNodeVec3Parameter", "VisualShaderNodeVec3Constant"); + var = vec3_parameter->get_default_value(); caught = true; } } @@ -3329,15 +3329,15 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) { if (!p_vice_versa) { Ref<VisualShaderNodeVec4Constant> vec4_const = Object::cast_to<VisualShaderNodeVec4Constant>(node.ptr()); if (vec4_const.is_valid()) { - _replace_node(type_id, node_id, "VisualShaderNodeVec4Constant", "VisualShaderNodeVec4Uniform"); + _replace_node(type_id, node_id, "VisualShaderNodeVec4Constant", "VisualShaderNodeVec4Parameter"); var = vec4_const->get_constant(); caught = true; } } else { - Ref<VisualShaderNodeVec4Uniform> vec4_uniform = Object::cast_to<VisualShaderNodeVec4Uniform>(node.ptr()); - if (vec4_uniform.is_valid()) { - _replace_node(type_id, node_id, "VisualShaderNodeVec4Uniform", "VisualShaderNodeVec4Constant"); - var = vec4_uniform->get_default_value(); + Ref<VisualShaderNodeVec4Parameter> vec4_parameter = Object::cast_to<VisualShaderNodeVec4Parameter>(node.ptr()); + if (vec4_parameter.is_valid()) { + _replace_node(type_id, node_id, "VisualShaderNodeVec4Parameter", "VisualShaderNodeVec4Constant"); + var = vec4_parameter->get_default_value(); caught = true; } } @@ -3348,15 +3348,15 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) { if (!p_vice_versa) { Ref<VisualShaderNodeColorConstant> color_const = Object::cast_to<VisualShaderNodeColorConstant>(node.ptr()); if (color_const.is_valid()) { - _replace_node(type_id, node_id, "VisualShaderNodeColorConstant", "VisualShaderNodeColorUniform"); + _replace_node(type_id, node_id, "VisualShaderNodeColorConstant", "VisualShaderNodeColorParameter"); var = color_const->get_constant(); caught = true; } } else { - Ref<VisualShaderNodeColorUniform> color_uniform = Object::cast_to<VisualShaderNodeColorUniform>(node.ptr()); - if (color_uniform.is_valid()) { - _replace_node(type_id, node_id, "VisualShaderNodeColorUniform", "VisualShaderNodeColorConstant"); - var = color_uniform->get_default_value(); + Ref<VisualShaderNodeColorParameter> color_parameter = Object::cast_to<VisualShaderNodeColorParameter>(node.ptr()); + if (color_parameter.is_valid()) { + _replace_node(type_id, node_id, "VisualShaderNodeColorParameter", "VisualShaderNodeColorConstant"); + var = color_parameter->get_default_value(); caught = true; } } @@ -3367,15 +3367,15 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) { if (!p_vice_versa) { Ref<VisualShaderNodeTransformConstant> transform_const = Object::cast_to<VisualShaderNodeTransformConstant>(node.ptr()); if (transform_const.is_valid()) { - _replace_node(type_id, node_id, "VisualShaderNodeTransformConstant", "VisualShaderNodeTransformUniform"); + _replace_node(type_id, node_id, "VisualShaderNodeTransformConstant", "VisualShaderNodeTransformParameter"); var = transform_const->get_constant(); caught = true; } } else { - Ref<VisualShaderNodeTransformUniform> transform_uniform = Object::cast_to<VisualShaderNodeTransformUniform>(node.ptr()); - if (transform_uniform.is_valid()) { - _replace_node(type_id, node_id, "VisualShaderNodeTransformUniform", "VisualShaderNodeTransformConstant"); - var = transform_uniform->get_default_value(); + Ref<VisualShaderNodeTransformParameter> transform_parameter = Object::cast_to<VisualShaderNodeTransformParameter>(node.ptr()); + if (transform_parameter.is_valid()) { + _replace_node(type_id, node_id, "VisualShaderNodeTransformParameter", "VisualShaderNodeTransformConstant"); + var = transform_parameter->get_default_value(); caught = true; } } @@ -3384,27 +3384,27 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) { int preview_port = node->get_output_port_for_preview(); if (!p_vice_versa) { - undo_redo->add_do_method(this, "_update_uniform", type_id, node_id, var, preview_port); + undo_redo->add_do_method(this, "_update_parameter", type_id, node_id, var, preview_port); undo_redo->add_undo_method(this, "_update_constant", type_id, node_id, var, preview_port); } else { undo_redo->add_do_method(this, "_update_constant", type_id, node_id, var, preview_port); - undo_redo->add_undo_method(this, "_update_uniform", type_id, node_id, var, preview_port); + undo_redo->add_undo_method(this, "_update_parameter", type_id, node_id, var, preview_port); - Ref<VisualShaderNodeUniform> uniform = Object::cast_to<VisualShaderNodeUniform>(node.ptr()); - ERR_CONTINUE(!uniform.is_valid()); + Ref<VisualShaderNodeParameter> parameter = Object::cast_to<VisualShaderNodeParameter>(node.ptr()); + ERR_CONTINUE(!parameter.is_valid()); - deleted_names.insert(uniform->get_uniform_name()); + deleted_names.insert(parameter->get_parameter_name()); } undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type_id, node_id); undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type_id, node_id); } - undo_redo->add_do_method(this, "_update_uniforms", true); - undo_redo->add_undo_method(this, "_update_uniforms", true); + undo_redo->add_do_method(this, "_update_parameters", true); + undo_redo->add_undo_method(this, "_update_parameters", true); if (deleted_names.size() > 0) { - _update_uniform_refs(deleted_names); + _update_parameter_refs(deleted_names); } undo_redo->commit_action(); @@ -3468,7 +3468,7 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::RIGHT) { selected_constants.clear(); - selected_uniforms.clear(); + selected_parameters.clear(); selected_comment = -1; selected_float_constant = -1; @@ -3494,9 +3494,9 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) { if (float_constant_node != nullptr) { selected_float_constant = id; } - VisualShaderNodeUniform *uniform_node = Object::cast_to<VisualShaderNodeUniform>(node.ptr()); - if (uniform_node != nullptr && uniform_node->is_convertible_to_constant()) { - selected_uniforms.insert(id); + VisualShaderNodeParameter *parameter_node = Object::cast_to<VisualShaderNodeParameter>(node.ptr()); + if (parameter_node != nullptr && parameter_node->is_convertible_to_constant()) { + selected_parameters.insert(id); } } } @@ -3533,11 +3533,11 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) { if (temp != -1) { popup_menu->remove_item(temp); } - temp = popup_menu->get_item_index(NodeMenuOptions::CONVERT_CONSTANTS_TO_UNIFORMS); + temp = popup_menu->get_item_index(NodeMenuOptions::CONVERT_CONSTANTS_TO_PARAMETERS); if (temp != -1) { popup_menu->remove_item(temp); } - temp = popup_menu->get_item_index(NodeMenuOptions::CONVERT_UNIFORMS_TO_CONSTANTS); + temp = popup_menu->get_item_index(NodeMenuOptions::CONVERT_PARAMETERS_TO_CONSTANTS); if (temp != -1) { popup_menu->remove_item(temp); } @@ -3554,7 +3554,7 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) { popup_menu->remove_item(temp); } - if (selected_constants.size() > 0 || selected_uniforms.size() > 0) { + if (selected_constants.size() > 0 || selected_parameters.size() > 0) { popup_menu->add_separator("", NodeMenuOptions::SEPARATOR2); if (selected_float_constant != -1) { @@ -3573,11 +3573,11 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) { } if (selected_constants.size() > 0) { - popup_menu->add_item(TTR("Convert Constant(s) to Uniform(s)"), NodeMenuOptions::CONVERT_CONSTANTS_TO_UNIFORMS); + popup_menu->add_item(TTR("Convert Constant(s) to Parameter(s)"), NodeMenuOptions::CONVERT_CONSTANTS_TO_PARAMETERS); } - if (selected_uniforms.size() > 0) { - popup_menu->add_item(TTR("Convert Uniform(s) to Constant(s)"), NodeMenuOptions::CONVERT_UNIFORMS_TO_CONSTANTS); + if (selected_parameters.size() > 0) { + popup_menu->add_item(TTR("Convert Parameter(s) to Constant(s)"), NodeMenuOptions::CONVERT_PARAMETERS_TO_CONSTANTS); } } @@ -4124,32 +4124,32 @@ void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> p_input, undo_redo->commit_action(); } -void VisualShaderEditor::_uniform_select_item(Ref<VisualShaderNodeUniformRef> p_uniform_ref, String p_name) { - String prev_name = p_uniform_ref->get_uniform_name(); +void VisualShaderEditor::_parameter_ref_select_item(Ref<VisualShaderNodeParameterRef> p_parameter_ref, String p_name) { + String prev_name = p_parameter_ref->get_parameter_name(); if (p_name == prev_name) { return; } - bool type_changed = p_uniform_ref->get_uniform_type_by_name(p_name) != p_uniform_ref->get_uniform_type_by_name(prev_name); + bool type_changed = p_parameter_ref->get_parameter_type_by_name(p_name) != p_parameter_ref->get_parameter_type_by_name(prev_name); Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_undo_redo(); - undo_redo->create_action(TTR("UniformRef Name Changed")); + undo_redo->create_action(TTR("ParameterRef Name Changed")); - undo_redo->add_do_method(p_uniform_ref.ptr(), "set_uniform_name", p_name); - undo_redo->add_undo_method(p_uniform_ref.ptr(), "set_uniform_name", prev_name); + undo_redo->add_do_method(p_parameter_ref.ptr(), "set_parameter_name", p_name); + undo_redo->add_undo_method(p_parameter_ref.ptr(), "set_parameter_name", prev_name); // update output port for (int type_id = 0; type_id < VisualShader::TYPE_MAX; type_id++) { VisualShader::Type type = VisualShader::Type(type_id); - int id = visual_shader->find_node_id(type, p_uniform_ref); + int id = visual_shader->find_node_id(type, p_parameter_ref); if (id != VisualShader::NODE_ID_INVALID) { if (type_changed) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); for (const VisualShader::Connection &E : conns) { if (E.from_node == id) { - if (visual_shader->is_port_types_compatible(p_uniform_ref->get_uniform_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) { + if (visual_shader->is_port_types_compatible(p_parameter_ref->get_parameter_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) { continue; } undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); @@ -4442,11 +4442,11 @@ void VisualShaderEditor::_node_menu_id_pressed(int p_idx) { case NodeMenuOptions::CLEAR_COPY_BUFFER: _clear_copy_buffer(); break; - case NodeMenuOptions::CONVERT_CONSTANTS_TO_UNIFORMS: - _convert_constants_to_uniforms(false); + case NodeMenuOptions::CONVERT_CONSTANTS_TO_PARAMETERS: + _convert_constants_to_parameters(false); break; - case NodeMenuOptions::CONVERT_UNIFORMS_TO_CONSTANTS: - _convert_constants_to_uniforms(true); + case NodeMenuOptions::CONVERT_PARAMETERS_TO_CONSTANTS: + _convert_constants_to_parameters(true); break; case NodeMenuOptions::SET_COMMENT_TITLE: _comment_title_popup_show(get_screen_position() + get_local_mouse_position(), selected_comment); @@ -4598,7 +4598,7 @@ void VisualShaderEditor::_preview_size_changed() { } static ShaderLanguage::DataType _get_global_shader_uniform_type(const StringName &p_variable) { - RS::GlobalShaderUniformType gvt = RS::get_singleton()->global_shader_uniform_get_type(p_variable); + RS::GlobalShaderParameterType gvt = RS::get_singleton()->global_shader_parameter_get_type(p_variable); return (ShaderLanguage::DataType)RS::global_shader_uniform_type_get_shader_datatype(gvt); } @@ -4655,18 +4655,18 @@ void VisualShaderEditor::_bind_methods() { ClassDB::bind_method("_add_node", &VisualShaderEditor::_add_node); ClassDB::bind_method("_node_changed", &VisualShaderEditor::_node_changed); ClassDB::bind_method("_input_select_item", &VisualShaderEditor::_input_select_item); - ClassDB::bind_method("_uniform_select_item", &VisualShaderEditor::_uniform_select_item); + ClassDB::bind_method("_parameter_ref_select_item", &VisualShaderEditor::_parameter_ref_select_item); ClassDB::bind_method("_varying_select_item", &VisualShaderEditor::_varying_select_item); ClassDB::bind_method("_set_node_size", &VisualShaderEditor::_set_node_size); ClassDB::bind_method("_clear_copy_buffer", &VisualShaderEditor::_clear_copy_buffer); - ClassDB::bind_method("_update_uniforms", &VisualShaderEditor::_update_uniforms); + ClassDB::bind_method("_update_parameters", &VisualShaderEditor::_update_parameters); ClassDB::bind_method("_update_varyings", &VisualShaderEditor::_update_varyings); ClassDB::bind_method("_update_varying_tree", &VisualShaderEditor::_update_varying_tree); ClassDB::bind_method("_set_mode", &VisualShaderEditor::_set_mode); ClassDB::bind_method("_nodes_dragged", &VisualShaderEditor::_nodes_dragged); ClassDB::bind_method("_float_constant_selected", &VisualShaderEditor::_float_constant_selected); ClassDB::bind_method("_update_constant", &VisualShaderEditor::_update_constant); - ClassDB::bind_method("_update_uniform", &VisualShaderEditor::_update_uniform); + ClassDB::bind_method("_update_parameter", &VisualShaderEditor::_update_parameter); ClassDB::bind_method("_expand_output_port", &VisualShaderEditor::_expand_output_port); ClassDB::bind_method(D_METHOD("_get_drag_data_fw"), &VisualShaderEditor::get_drag_data_fw); @@ -5077,7 +5077,7 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("SoftLight", "Color", "Operators", "VisualShaderNodeColorOp", TTR("SoftLight operator."), { VisualShaderNodeColorOp::OP_SOFT_LIGHT }, VisualShaderNode::PORT_TYPE_VECTOR_3D)); add_options.push_back(AddOption("ColorConstant", "Color", "Variables", "VisualShaderNodeColorConstant", TTR("Color constant."), {}, VisualShaderNode::PORT_TYPE_VECTOR_4D)); - add_options.push_back(AddOption("ColorUniform", "Color", "Variables", "VisualShaderNodeColorUniform", TTR("Color uniform."), {}, VisualShaderNode::PORT_TYPE_VECTOR_4D)); + add_options.push_back(AddOption("ColorParameter", "Color", "Variables", "VisualShaderNodeColorParameter", TTR("Color parameter."), {}, VisualShaderNode::PORT_TYPE_VECTOR_4D)); // COMMON @@ -5107,7 +5107,7 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("Is", "Conditional", "Common", "VisualShaderNodeIs", TTR("Returns the boolean result of the comparison between INF (or NaN) and a scalar parameter."), {}, VisualShaderNode::PORT_TYPE_BOOLEAN)); add_options.push_back(AddOption("BooleanConstant", "Conditional", "Variables", "VisualShaderNodeBooleanConstant", TTR("Boolean constant."), {}, VisualShaderNode::PORT_TYPE_BOOLEAN)); - add_options.push_back(AddOption("BooleanUniform", "Conditional", "Variables", "VisualShaderNodeBooleanUniform", TTR("Boolean uniform."), {}, VisualShaderNode::PORT_TYPE_BOOLEAN)); + add_options.push_back(AddOption("BooleanParameter", "Conditional", "Variables", "VisualShaderNodeBooleanParameter", TTR("Boolean parameter."), {}, VisualShaderNode::PORT_TYPE_BOOLEAN)); // INPUT @@ -5396,8 +5396,8 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("FloatConstant", "Scalar", "Variables", "VisualShaderNodeFloatConstant", TTR("Scalar floating-point constant."), {}, VisualShaderNode::PORT_TYPE_SCALAR)); add_options.push_back(AddOption("IntConstant", "Scalar", "Variables", "VisualShaderNodeIntConstant", TTR("Scalar integer constant."), {}, VisualShaderNode::PORT_TYPE_SCALAR_INT)); - add_options.push_back(AddOption("FloatUniform", "Scalar", "Variables", "VisualShaderNodeFloatUniform", TTR("Scalar floating-point uniform."), {}, VisualShaderNode::PORT_TYPE_SCALAR)); - add_options.push_back(AddOption("IntUniform", "Scalar", "Variables", "VisualShaderNodeIntUniform", TTR("Scalar integer uniform."), {}, VisualShaderNode::PORT_TYPE_SCALAR_INT)); + add_options.push_back(AddOption("FloatParameter", "Scalar", "Variables", "VisualShaderNodeFloatParameter", TTR("Scalar floating-point parameter."), {}, VisualShaderNode::PORT_TYPE_SCALAR)); + add_options.push_back(AddOption("IntParameter", "Scalar", "Variables", "VisualShaderNodeIntParameter", TTR("Scalar integer parameter."), {}, VisualShaderNode::PORT_TYPE_SCALAR_INT)); // SDF { @@ -5429,11 +5429,11 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("UVPanning", "Textures", "Functions", "VisualShaderNodeUVFunc", TTR("Apply panning function on texture coordinates."), { VisualShaderNodeUVFunc::FUNC_PANNING }, VisualShaderNode::PORT_TYPE_VECTOR_2D)); add_options.push_back(AddOption("UVScaling", "Textures", "Functions", "VisualShaderNodeUVFunc", TTR("Apply scaling function on texture coordinates."), { VisualShaderNodeUVFunc::FUNC_SCALING }, VisualShaderNode::PORT_TYPE_VECTOR_2D)); - add_options.push_back(AddOption("CubeMapUniform", "Textures", "Variables", "VisualShaderNodeCubemapUniform", TTR("Cubic texture uniform lookup."), {}, VisualShaderNode::PORT_TYPE_SAMPLER)); - add_options.push_back(AddOption("TextureUniform", "Textures", "Variables", "VisualShaderNodeTextureUniform", TTR("2D texture uniform lookup."), {}, VisualShaderNode::PORT_TYPE_SAMPLER)); - add_options.push_back(AddOption("TextureUniformTriplanar", "Textures", "Variables", "VisualShaderNodeTextureUniformTriplanar", TTR("2D texture uniform lookup with triplanar."), {}, -1, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL)); - add_options.push_back(AddOption("Texture2DArrayUniform", "Textures", "Variables", "VisualShaderNodeTexture2DArrayUniform", TTR("2D array of textures uniform lookup."), {}, VisualShaderNode::PORT_TYPE_SAMPLER)); - add_options.push_back(AddOption("Texture3DUniform", "Textures", "Variables", "VisualShaderNodeTexture3DUniform", TTR("3D texture uniform lookup."), {}, VisualShaderNode::PORT_TYPE_SAMPLER)); + add_options.push_back(AddOption("CubeMapParameter", "Textures", "Variables", "VisualShaderNodeCubemapParameter", TTR("Cubic texture parameter lookup."), {}, VisualShaderNode::PORT_TYPE_SAMPLER)); + add_options.push_back(AddOption("Texture2DParameter", "Textures", "Variables", "VisualShaderNodeTexture2DParameter", TTR("2D texture parameter lookup."), {}, VisualShaderNode::PORT_TYPE_SAMPLER)); + add_options.push_back(AddOption("TextureParameterTriplanar", "Textures", "Variables", "VisualShaderNodeTextureParameterTriplanar", TTR("2D texture parameter lookup with triplanar."), {}, -1, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("Texture2DArrayParameter", "Textures", "Variables", "VisualShaderNodeTexture2DArrayParameter", TTR("2D array of textures parameter lookup."), {}, VisualShaderNode::PORT_TYPE_SAMPLER)); + add_options.push_back(AddOption("Texture3DParameter", "Textures", "Variables", "VisualShaderNodeTexture3DParameter", TTR("3D texture parameter lookup."), {}, VisualShaderNode::PORT_TYPE_SAMPLER)); // TRANSFORM @@ -5457,7 +5457,7 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("TransformVectorMult", "Transform", "Operators", "VisualShaderNodeTransformVecMult", TTR("Multiplies vector by transform."), {}, VisualShaderNode::PORT_TYPE_VECTOR_3D)); add_options.push_back(AddOption("TransformConstant", "Transform", "Variables", "VisualShaderNodeTransformConstant", TTR("Transform constant."), {}, VisualShaderNode::PORT_TYPE_TRANSFORM)); - add_options.push_back(AddOption("TransformUniform", "Transform", "Variables", "VisualShaderNodeTransformUniform", TTR("Transform uniform."), {}, VisualShaderNode::PORT_TYPE_TRANSFORM)); + add_options.push_back(AddOption("TransformParameter", "Transform", "Variables", "VisualShaderNodeTransformParameter", TTR("Transform parameter."), {}, VisualShaderNode::PORT_TYPE_TRANSFORM)); // UTILITY @@ -5659,18 +5659,18 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("Subtract", "Vector", "Operators", "VisualShaderNodeVectorOp", TTR("Subtracts 4D vector from 4D vector."), { VisualShaderNodeVectorOp::OP_SUB, VisualShaderNodeVectorOp::OP_TYPE_VECTOR_4D }, VisualShaderNode::PORT_TYPE_VECTOR_4D)); add_options.push_back(AddOption("Vector2Constant", "Vector", "Variables", "VisualShaderNodeVec2Constant", TTR("2D vector constant."), {}, VisualShaderNode::PORT_TYPE_VECTOR_2D)); - add_options.push_back(AddOption("Vector2Uniform", "Vector", "Variables", "VisualShaderNodeVec2Uniform", TTR("2D vector uniform."), {}, VisualShaderNode::PORT_TYPE_VECTOR_2D)); + add_options.push_back(AddOption("Vector2Parameter", "Vector", "Variables", "VisualShaderNodeVec2Parameter", TTR("2D vector parameter."), {}, VisualShaderNode::PORT_TYPE_VECTOR_2D)); add_options.push_back(AddOption("Vector3Constant", "Vector", "Variables", "VisualShaderNodeVec3Constant", TTR("3D vector constant."), {}, VisualShaderNode::PORT_TYPE_VECTOR_3D)); - add_options.push_back(AddOption("Vector3Uniform", "Vector", "Variables", "VisualShaderNodeVec3Uniform", TTR("3D vector uniform."), {}, VisualShaderNode::PORT_TYPE_VECTOR_3D)); + add_options.push_back(AddOption("Vector3Parameter", "Vector", "Variables", "VisualShaderNodeVec3Parameter", TTR("3D vector parameter."), {}, VisualShaderNode::PORT_TYPE_VECTOR_3D)); add_options.push_back(AddOption("Vector4Constant", "Vector", "Variables", "VisualShaderNodeVec4Constant", TTR("4D vector constant."), {}, VisualShaderNode::PORT_TYPE_VECTOR_4D)); - add_options.push_back(AddOption("Vector4Uniform", "Vector", "Variables", "VisualShaderNodeVec4Uniform", TTR("4D vector uniform."), {}, VisualShaderNode::PORT_TYPE_VECTOR_4D)); + add_options.push_back(AddOption("Vector4Parameter", "Vector", "Variables", "VisualShaderNodeVec4Parameter", TTR("4D vector parameter."), {}, VisualShaderNode::PORT_TYPE_VECTOR_4D)); // SPECIAL add_options.push_back(AddOption("Comment", "Special", "", "VisualShaderNodeComment", TTR("A rectangular area with a description string for better graph organization."))); add_options.push_back(AddOption("Expression", "Special", "", "VisualShaderNodeExpression", TTR("Custom Godot Shader Language expression, with custom amount of input and output ports. This is a direct injection of code into the vertex/fragment/light function, do not use it to write the function declarations inside."))); - add_options.push_back(AddOption("GlobalExpression", "Special", "", "VisualShaderNodeGlobalExpression", TTR("Custom Godot Shader Language expression, which is placed on top of the resulted shader. You can place various function definitions inside and call it later in the Expressions. You can also declare varyings, uniforms and constants."))); - add_options.push_back(AddOption("UniformRef", "Special", "", "VisualShaderNodeUniformRef", TTR("A reference to an existing uniform."))); + add_options.push_back(AddOption("GlobalExpression", "Special", "", "VisualShaderNodeGlobalExpression", TTR("Custom Godot Shader Language expression, which is placed on top of the resulted shader. You can place various function definitions inside and call it later in the Expressions. You can also declare varyings, parameters and constants."))); + add_options.push_back(AddOption("ParameterRef", "Special", "", "VisualShaderNodeParameterRef", TTR("A reference to an existing parameter."))); add_options.push_back(AddOption("VaryingGetter", "Special", "", "VisualShaderNodeVaryingGetter", TTR("Get varying parameter."), {}, -1, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("VaryingSetter", "Special", "", "VisualShaderNodeVaryingSetter", TTR("Set varying parameter."), {}, -1, TYPE_FLAGS_VERTEX | TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("VaryingGetter", "Special", "", "VisualShaderNodeVaryingGetter", TTR("Get varying parameter."), {}, -1, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM)); @@ -5826,28 +5826,28 @@ public: //////////////// -class VisualShaderNodePluginUniformRefEditor : public OptionButton { - GDCLASS(VisualShaderNodePluginUniformRefEditor, OptionButton); +class VisualShaderNodePluginParameterRefEditor : public OptionButton { + GDCLASS(VisualShaderNodePluginParameterRefEditor, OptionButton); VisualShaderEditor *editor = nullptr; - Ref<VisualShaderNodeUniformRef> uniform_ref; + Ref<VisualShaderNodeParameterRef> parameter_ref; public: void _notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - connect("item_selected", callable_mp(this, &VisualShaderNodePluginUniformRefEditor::_item_selected)); + connect("item_selected", callable_mp(this, &VisualShaderNodePluginParameterRefEditor::_item_selected)); } break; } } void _item_selected(int p_item) { - editor->call_deferred(SNAME("_uniform_select_item"), uniform_ref, get_item_text(p_item)); + editor->call_deferred(SNAME("_parameter_ref_select_item"), parameter_ref, get_item_text(p_item)); } - void setup(VisualShaderEditor *p_editor, const Ref<VisualShaderNodeUniformRef> &p_uniform_ref) { + void setup(VisualShaderEditor *p_editor, const Ref<VisualShaderNodeParameterRef> &p_parameter_ref) { editor = p_editor; - uniform_ref = p_uniform_ref; + parameter_ref = p_parameter_ref; Ref<Texture2D> type_icon[] = { EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("float"), SNAME("EditorIcons")), @@ -5863,11 +5863,11 @@ public: add_item("[None]"); int to_select = -1; - for (int i = 0; i < p_uniform_ref->get_uniforms_count(); i++) { - if (p_uniform_ref->get_uniform_name() == p_uniform_ref->get_uniform_name_by_index(i)) { + for (int i = 0; i < p_parameter_ref->get_parameters_count(); i++) { + if (p_parameter_ref->get_parameter_name() == p_parameter_ref->get_parameter_name_by_index(i)) { to_select = i + 1; } - add_icon_item(type_icon[p_uniform_ref->get_uniform_type_by_index(i)], p_uniform_ref->get_uniform_name_by_index(i)); + add_icon_item(type_icon[p_parameter_ref->get_parameter_type_by_index(i)], p_parameter_ref->get_parameter_name_by_index(i)); } if (to_select >= 0) { @@ -6011,8 +6011,8 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par return editor; } - if (p_node->is_class("VisualShaderNodeUniformRef")) { - VisualShaderNodePluginUniformRefEditor *editor = memnew(VisualShaderNodePluginUniformRefEditor); + if (p_node->is_class("VisualShaderNodeParameterRef")) { + VisualShaderNodePluginParameterRefEditor *editor = memnew(VisualShaderNodePluginParameterRefEditor); editor->setup(vseditor, p_node); return editor; } @@ -6222,7 +6222,7 @@ void VisualShaderNodePortPreview::_shader_changed() { preview_shader->set_code(shader_code); for (int i = 0; i < default_textures.size(); i++) { for (int j = 0; j < default_textures[i].params.size(); j++) { - preview_shader->set_default_texture_param(default_textures[i].name, default_textures[i].params[j], j); + preview_shader->set_default_texture_parameter(default_textures[i].name, default_textures[i].params[j], j); } } diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index ede6513b83..869e00ca5d 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -89,7 +89,7 @@ private: HashMap<int, InputPort> input_ports; HashMap<int, Port> output_ports; VBoxContainer *preview_box = nullptr; - LineEdit *uniform_name = nullptr; + LineEdit *parameter_name = nullptr; CodeEdit *expression_edit = nullptr; CurveEditor *curve_editors[3] = { nullptr, nullptr, nullptr }; }; @@ -110,7 +110,7 @@ public: void set_connections(const List<VisualShader::Connection> &p_connections); void register_link(VisualShader::Type p_type, int p_id, VisualShaderNode *p_visual_node, GraphNode *p_graph_node); void register_output_port(int p_id, int p_port, TextureButton *p_button); - void register_uniform_name(int p_id, LineEdit *p_uniform_name); + void register_parameter_name(int p_id, LineEdit *p_parameter_name); void register_default_input_button(int p_node_id, int p_port_id, Button *p_button); void register_expression_edit(int p_node_id, CodeEdit *p_expression_edit); void register_curve_editor(int p_node_id, int p_index, CurveEditor *p_curve_editor); @@ -129,8 +129,8 @@ public: void set_node_position(VisualShader::Type p_type, int p_id, const Vector2 &p_position); void refresh_node_ports(VisualShader::Type p_type, int p_node); void set_input_port_default_value(VisualShader::Type p_type, int p_node_id, int p_port_id, Variant p_value); - void update_uniform_refs(); - void set_uniform_name(VisualShader::Type p_type, int p_node_id, const String &p_name); + void update_parameter_refs(); + void set_parameter_name(VisualShader::Type p_type, int p_node_id, const String &p_name); void update_curve(int p_node_id); void update_curve_xyz(int p_node_id); void set_expression(VisualShader::Type p_type, int p_node_id, const String &p_expression); @@ -269,8 +269,8 @@ class VisualShaderEditor : public VBoxContainer { CLEAR_COPY_BUFFER, SEPARATOR2, // ignore FLOAT_CONSTANTS, - CONVERT_CONSTANTS_TO_UNIFORMS, - CONVERT_UNIFORMS_TO_CONSTANTS, + CONVERT_CONSTANTS_TO_PARAMETERS, + CONVERT_PARAMETERS_TO_CONSTANTS, SEPARATOR3, // ignore SET_COMMENT_TITLE, SET_COMMENT_DESCRIPTION, @@ -340,7 +340,7 @@ class VisualShaderEditor : public VBoxContainer { int curve_xyz_node_option_idx; List<String> keyword_list; - List<VisualShaderNodeUniformRef> uniform_refs; + List<VisualShaderNodeParameterRef> uniform_refs; void _draw_color_over_button(Object *obj, Color p_color); @@ -390,14 +390,14 @@ class VisualShaderEditor : public VBoxContainer { int from_slot = -1; HashSet<int> selected_constants; - HashSet<int> selected_uniforms; + HashSet<int> selected_parameters; int selected_comment = -1; int selected_float_constant = -1; - void _convert_constants_to_uniforms(bool p_vice_versa); + void _convert_constants_to_parameters(bool p_vice_versa); void _replace_node(VisualShader::Type p_type_id, int p_node_id, const StringName &p_from, const StringName &p_to); void _update_constant(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port); - void _update_uniform(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port); + void _update_parameter(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port); void _connection_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_position); void _connection_from_empty(const String &p_to, int p_to_slot, const Vector2 &p_release_position); @@ -413,8 +413,8 @@ class VisualShaderEditor : public VBoxContainer { void _comment_desc_confirm(); void _comment_desc_text_changed(); - void _uniform_line_edit_changed(const String &p_text, int p_node_id); - void _uniform_line_edit_focus_out(Object *line_edit, int p_node_id); + void _parameter_line_edit_changed(const String &p_text, int p_node_id); + void _parameter_line_edit_focus_out(Object *line_edit, int p_node_id); void _port_name_focus_out(Object *line_edit, int p_node_id, int p_port_id, bool p_output); @@ -449,7 +449,7 @@ class VisualShaderEditor : public VBoxContainer { void _custom_mode_toggled(bool p_enabled); void _input_select_item(Ref<VisualShaderNodeInput> input, String name); - void _uniform_select_item(Ref<VisualShaderNodeUniformRef> p_uniform, String p_name); + void _parameter_ref_select_item(Ref<VisualShaderNodeParameterRef> p_parameter_ref, String p_name); void _varying_select_item(Ref<VisualShaderNodeVarying> p_varying, String p_name); void _float_constant_selected(int p_which); @@ -498,8 +498,8 @@ class VisualShaderEditor : public VBoxContainer { bool _is_available(int p_mode); void _update_created_node(GraphNode *node); - void _update_uniforms(bool p_update_refs); - void _update_uniform_refs(HashSet<String> &p_names); + void _update_parameters(bool p_update_refs); + void _update_parameter_refs(HashSet<String> &p_names); void _update_varyings(); void _visibility_changed(); diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp index dbd2a7555d..ad08629cf2 100644 --- a/editor/project_converter_3_to_4.cpp +++ b/editor/project_converter_3_to_4.cpp @@ -91,6 +91,7 @@ static const char *enum_renames[][2] = { { "BUTTON_XBUTTON2", "MOUSE_BUTTON_XBUTTON2" }, // Globals { "CLEAR_MODE_ONLY_NEXT_FRAME", "CLEAR_MODE_ONCE" }, // SubViewport { "COMPRESS_PVRTC4", "COMPRESS_PVRTC1_4" }, // Image + { "CONNECT_ONESHOT", "CONNECT_ONE_SHOT" }, // Object { "CUBEMAP_BACK", "CUBEMAP_LAYER_BACK" }, // RenderingServer { "CUBEMAP_BOTTOM", "CUBEMAP_LAYER_BOTTOM" }, // RenderingServer { "CUBEMAP_FRONT", "CUBEMAP_LAYER_FRONT" }, // RenderingServer @@ -242,11 +243,11 @@ static const char *gdscript_function_renames[][2] = { { "commit_handle", "_commit_handle" }, // EditorNode3DGizmo { "convex_hull_2d", "convex_hull" }, // Geometry2D { "create_gizmo", "_create_gizmo" }, // EditorNode3DGizmoPlugin - { "cursor_get_blink_speed", "get_caret_blink_speed" }, // TextEdit + { "cursor_get_blink_speed", "get_caret_blink_interval" }, // TextEdit { "cursor_get_column", "get_caret_column" }, // TextEdit { "cursor_get_line", "get_caret_line" }, // TextEdit { "cursor_set_blink_enabled", "set_caret_blink_enabled" }, // TextEdit - { "cursor_set_blink_speed", "set_caret_blink_speed" }, // TextEdit + { "cursor_set_blink_speed", "set_caret_blink_interval" }, // TextEdit { "cursor_set_column", "set_caret_column" }, // TextEdit { "cursor_set_line", "set_caret_line" }, // TextEdit { "damped_spring_joint_create", "joint_make_damped_spring" }, // PhysicsServer2D @@ -295,7 +296,7 @@ static const char *gdscript_function_renames[][2] = { { "get_d", "get_distance" }, // LineShape2D { "get_drag_data", "_get_drag_data" }, // Control { "get_drag_data_fw", "_get_drag_data_fw" }, // ScriptEditor - { "get_editor_viewport", "get_viewport" }, // EditorPlugin + { "get_editor_viewport", "get_editor_main_screen" }, // EditorPlugin { "get_enabled_focus_mode", "get_focus_mode" }, // BaseButton { "get_endian_swap", "is_big_endian" }, // File { "get_error_string", "get_error_message" }, // JSON @@ -331,6 +332,7 @@ static const char *gdscript_function_renames[][2] = { { "get_network_peer", "get_multiplayer_peer" }, // Multiplayer API { "get_network_unique_id", "get_unique_id" }, // Multiplayer API { "get_ok", "get_ok_button" }, // AcceptDialog + { "get_oneshot", "get_one_shot" }, // AnimatedTexture { "get_option_visibility", "_get_option_visibility" }, // EditorImportPlugin { "get_parameter_default_value", "_get_parameter_default_value" }, // AnimationNode { "get_parameter_list", "_get_parameter_list" }, // AnimationNode @@ -506,6 +508,7 @@ static const char *gdscript_function_renames[][2] = { { "set_mid_height", "set_height" }, // CapsuleMesh { "set_network_master", "set_multiplayer_authority" }, // Node { "set_network_peer", "set_multiplayer_peer" }, // Multiplayer API + { "set_oneshot", "set_one_shot" }, // AnimatedTexture { "set_pause_mode", "set_process_mode" }, // Node { "set_physical_scancode", "set_physical_keycode" }, // InputEventKey { "set_refuse_new_network_connections", "set_refuse_new_connections" }, // Multiplayer API @@ -513,7 +516,6 @@ static const char *gdscript_function_renames[][2] = { { "set_region_filter_clip", "set_region_filter_clip_enabled" }, // Sprite2D { "set_rotate", "set_rotates" }, // PathFollow2D { "set_scancode", "set_keycode" }, // InputEventKey - { "set_shader_param", "set_shader_uniform" }, // ShaderMaterial { "set_shift", "set_shift_pressed" }, // InputEventWithModifiers { "set_size_override", "set_size_2d_override" }, // SubViewport broke ImageTexture { "set_size_override_stretch", "set_size_2d_override_stretch" }, // SubViewport @@ -548,6 +550,11 @@ static const char *gdscript_function_renames[][2] = { { "update_gizmo", "update_gizmos" }, // Node3D { "viewport_set_use_arvr", "viewport_set_use_xr" }, // RenderingServer { "warp_mouse_position", "warp_mouse" }, // Input + { "world_to_map", "local_to_map" }, // TileMap, GridMap + { "set_shader_param", "set_shader_parameter" }, // ShaderMaterial + { "get_shader_param", "get_shader_parameter" }, // ShaderMaterial + { "set_uniform_name", "set_parameter_name" }, // ParameterRef + { "get_uniform_name", "get_parameter_name" }, // ParameterRef // Builtin types // Remember to add them to builtin_types_excluded_functions variable, because for now this functions cannot be listed @@ -572,6 +579,7 @@ static const char *gdscript_function_renames[][2] = { { "linear2db", "linear_to_db" }, { "rad2deg", "rad_to_deg" }, { "rand_range", "randf_range" }, + { "range_lerp", "remap" }, { "stepify", "snapped" }, { "str2var", "str_to_var" }, { "var2str", "var_to_str" }, @@ -664,11 +672,11 @@ static const char *csharp_function_renames[][2] = { { "ClipPolylineWithPolygon2d", "ClipPolylineWithPolygon" }, //Geometry2D { "CommitHandle", "_CommitHandle" }, // EditorNode3DGizmo { "ConvexHull2d", "ConvexHull" }, // Geometry2D - { "CursorGetBlinkSpeed", "GetCaretBlinkSpeed" }, // TextEdit + { "CursorGetBlinkSpeed", "GetCaretBlinkInterval" }, // TextEdit { "CursorGetColumn", "GetCaretColumn" }, // TextEdit { "CursorGetLine", "GetCaretLine" }, // TextEdit { "CursorSetBlinkEnabled", "SetCaretBlinkEnabled" }, // TextEdit - { "CursorSetBlinkSpeed", "SetCaretBlinkSpeed" }, // TextEdit + { "CursorSetBlinkSpeed", "SetCaretBlinkInterval" }, // TextEdit { "CursorSetColumn", "SetCaretColumn" }, // TextEdit { "CursorSetLine", "SetCaretLine" }, // TextEdit { "DampedSpringJointCreate", "JointMakeDampedSpring" }, // PhysicsServer2D @@ -747,6 +755,7 @@ static const char *csharp_function_renames[][2] = { { "GetNetworkMaster", "GetMultiplayerAuthority" }, // Node { "GetNetworkPeer", "GetMultiplayerPeer" }, // Multiplayer API { "GetNetworkUniqueId", "GetUniqueId" }, // Multiplayer API + { "GetOneshot", "GetOneShot" }, // AnimatedTexture { "GetOk", "GetOkButton" }, // AcceptDialog { "GetOptionVisibility", "_GetOptionVisibility" }, // EditorImportPlugin { "GetParameterDefaultValue", "_GetParameterDefaultValue" }, // AnimationNode @@ -913,6 +922,7 @@ static const char *csharp_function_renames[][2] = { { "SetMidHeight", "SetHeight" }, // CapsuleMesh { "SetNetworkMaster", "SetMultiplayerAuthority" }, // Node { "SetNetworkPeer", "SetMultiplayerPeer" }, // Multiplayer API + { "SetOneshot", "SetOneShot" }, // AnimatedTexture { "SetPhysicalScancode", "SetPhysicalKeycode" }, // InputEventKey { "SetRefuseNewNetworkConnections", "SetRefuseNewConnections" }, // Multiplayer API { "SetRegion", "SetRegionEnabled" }, // Sprite2D, Sprite broke AtlasTexture @@ -955,6 +965,11 @@ static const char *csharp_function_renames[][2] = { { "UpdateGizmo", "UpdateGizmos" }, // Node3D { "ViewportSetUseArvr", "ViewportSetUseXr" }, // RenderingServer { "WarpMousePosition", "WarpMouse" }, // Input + { "WorldToMap", "LocalToMap" }, // TileMap, GridMap + { "SetShaderParam", "SetShaderParameter" }, // ShaderMaterial + { "GetShaderParam", "GetShaderParameter" }, // ShaderMaterial + { "SetUniformName", "SetParameterName" }, // ParameterRef + { "GetUniformName", "GetParameterName" }, // ParameterRef // Builtin types // { "Empty", "IsEmpty" }, // Array - Used as custom rule // Be careful, this will be used everywhere @@ -977,6 +992,7 @@ static const char *csharp_function_renames[][2] = { { "Linear2Db", "LinearToDb" }, { "Rad2Deg", "RadToDeg" }, { "RandRange", "RandfRange" }, + { "RangeLerp", "Remap" }, { "Stepify", "Snapped" }, { "Str2Var", "StrToVar" }, { "Var2Str", "VarToStr" }, @@ -1016,9 +1032,12 @@ static const char *gdscript_properties_renames[][2] = { // { "filename", "scene_file_path" }, // Node { "as_normalmap", "as_normal_map" }, // NoiseTexture { "bbcode_text", "text" }, // RichTextLabel + { "bg", "panel" }, // Theme + { "bg_focus", "focus" }, // Theme + { "caret_blink_speed", "caret_blink_interval" }, // TextEdit, LineEdit { "caret_moving_by_right_click", "caret_move_on_right_click" }, // TextEdit { "caret_position", "caret_column" }, // LineEdit - { "check_vadjust", "check_v_adjust" }, // Theme + { "check_vadjust", "check_v_offset" }, // Theme { "close_h_ofs", "close_h_offset" }, // Theme { "close_v_ofs", "close_v_offset" }, // Theme { "commentfocus", "comment_focus" }, // Theme @@ -1036,6 +1055,9 @@ static const char *gdscript_properties_renames[][2] = { { "focus_neighbour_left", "focus_neighbor_left" }, // Control { "focus_neighbour_right", "focus_neighbor_right" }, // Control { "focus_neighbour_top", "focus_neighbor_top" }, // Control + { "file_icon_modulate", "file_icon_color" }, // Theme + { "files_disabled", "file_disabled_color" }, // Theme + { "folder_icon_modulate", "folder_icon_color" }, // Theme { "global_rate_scale", "playback_speed_scale" }, // AudioServer { "gravity_distance_scale", "gravity_point_distance_scale" }, // Area2D { "gravity_vec", "gravity_direction" }, // Area2D @@ -1050,7 +1072,12 @@ static const char *gdscript_properties_renames[][2] = { { "mid_height", "height" }, // CapsuleMesh { "offset_h", "drag_horizontal_offset" }, // Camera2D { "offset_v", "drag_vertical_offset" }, // Camera2D + { "off", "unchecked" }, // Theme + { "off_disabled", "unchecked_disabled" }, // Theme { "ofs", "offset" }, // Theme + { "on", "checked" }, // Theme + { "on_disabled", "checked_disabled" }, // Theme + { "oneshot", "one_shot" }, // AnimatedTexture { "out_of_range_mode", "max_polyphony" }, // AudioStreamPlayer3D { "pause_mode", "process_mode" }, // Node { "physical_scancode", "physical_keycode" }, // InputEventKey @@ -1110,6 +1137,7 @@ static const char *csharp_properties_renames[][2] = { // { "Znear", "Near" }, // Camera3D { "AsNormalmap", "AsNormalMap" }, // NoiseTexture { "BbcodeText", "Text" }, // RichTextLabel + { "CaretBlinkSpeed", "CaretBlinkInterval" }, // TextEdit, LineEdit { "CaretMovingByRightClick", "CaretMoveOnRightClick" }, // TextEdit { "CaretPosition", "CaretColumn" }, // LineEdit { "CheckVadjust", "CheckVAdjust" }, // Theme @@ -1144,6 +1172,7 @@ static const char *csharp_properties_renames[][2] = { { "OffsetH", "DragHorizontalOffset" }, // Camera2D { "OffsetV", "DragVerticalOffset" }, // Camera2D { "Ofs", "Offset" }, // Theme + { "Oneshot", "OneShot" }, // AnimatedTexture { "OutOfRangeMode", "MaxPolyphony" }, // AudioStreamPlayer3D { "PauseMode", "ProcessMode" }, // Node { "PhysicalScancode", "PhysicalKeycode" }, // InputEventKey @@ -1449,6 +1478,7 @@ static const char *class_renames[][2] = { { "StreamCubemap", "CompressedCubemap" }, { "StreamCubemapArray", "CompressedCubemapArray" }, { "StreamPeerGDNative", "StreamPeerExtension" }, + { "StreamPeerSSL", "StreamPeerTLS" }, { "StreamTexture", "CompressedTexture2D" }, { "StreamTexture2D", "CompressedTexture2D" }, { "StreamTexture2DArray", "CompressedTexture2DArray" }, @@ -1473,7 +1503,6 @@ static const char *class_renames[][2] = { { "VisualInstance", "VisualInstance3D" }, { "VisualServer", "RenderingServer" }, { "VisualShaderNodeCubeMap", "VisualShaderNodeCubemap" }, - { "VisualShaderNodeCubeMapUniform", "VisualShaderNodeCubemapUniform" }, { "VisualShaderNodeScalarClamp", "VisualShaderNodeClamp" }, { "VisualShaderNodeScalarConstant", "VisualShaderNodeFloatConstant" }, { "VisualShaderNodeScalarFunc", "VisualShaderNodeFloatFunc" }, @@ -1482,7 +1511,6 @@ static const char *class_renames[][2] = { { "VisualShaderNodeScalarSmoothStep", "VisualShaderNodeSmoothStep" }, { "VisualShaderNodeScalarSwitch", "VisualShaderNodeSwitch" }, { "VisualShaderNodeScalarTransformMult", "VisualShaderNodeTransformOp" }, - { "VisualShaderNodeScalarUniform", "VisualShaderNodeFloatUniform" }, { "VisualShaderNodeTransformMult", "VisualShaderNode" }, { "VisualShaderNodeVectorClamp", "VisualShaderNodeClamp" }, { "VisualShaderNodeVectorInterp", "VisualShaderNodeMix" }, @@ -1490,6 +1518,16 @@ static const char *class_renames[][2] = { { "VisualShaderNodeVectorScalarSmoothStep", "VisualShaderNodeSmoothStep" }, { "VisualShaderNodeVectorScalarStep", "VisualShaderNodeStep" }, { "VisualShaderNodeVectorSmoothStep", "VisualShaderNodeSmoothStep" }, + { "VisualShaderNodeBooleanUniform", "VisualShaderNodeBooleanParameter" }, + { "VisualShaderNodeColorUniform", "VisualShaderNodeColorParameter" }, + { "VisualShaderNodeScalarUniform", "VisualShaderNodeFloatParameter" }, + { "VisualShaderNodeCubemapUniform", "VisualShaderNodeCubemapParameter" }, + { "VisualShaderNodeTextureUniform", "VisualShaderNodeTexture2DParameter" }, + { "VisualShaderNodeTextureUniformTriplanar", "VisualShaderNodeTextureParameterTriplanar" }, + { "VisualShaderNodeTransformUniform", "VisualShaderNodeTransformParameter" }, + { "VisualShaderNodeVec3Uniform", "VisualShaderNodeVec3Parameter" }, + { "VisualShaderNodeUniform", "VisualShaderNodeParameter" }, + { "VisualShaderNodeUniformRef", "VisualShaderNodeParameterRef" }, { "WebRTCDataChannelGDNative", "WebRTCDataChannelExtension" }, { "WebRTCMultiplayer", "WebRTCMultiplayerPeer" }, { "WebRTCPeerConnectionGDNative", "WebRTCPeerConnectionExtension" }, @@ -2417,7 +2455,7 @@ bool ProjectConverter3To4::test_conversion(RegExContainer ®_container) { valid = valid & test_conversion_gdscript_builtin("set_cell_item(a, b)", "set_cell_item(a, b)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); valid = valid & test_conversion_gdscript_builtin("get_cell_item_orientation(a, b,c)", "get_cell_item_orientation(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); valid = valid & test_conversion_gdscript_builtin("get_cell_item(a, b,c)", "get_cell_item(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); - valid = valid & test_conversion_gdscript_builtin("map_to_world(a, b,c)", "map_to_world(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); + valid = valid & test_conversion_gdscript_builtin("map_to_world(a, b,c)", "map_to_local(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); valid = valid & test_conversion_gdscript_builtin("PackedStringArray(req_godot).join('.')", "'.'.join(PackedStringArray(req_godot))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); valid = valid & test_conversion_gdscript_builtin("=PackedStringArray(req_godot).join('.')", "='.'.join(PackedStringArray(req_godot))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); @@ -2582,7 +2620,7 @@ bool ProjectConverter3To4::test_array_names() { // List of excluded functions from builtin types and global namespace, because currently it is not possible to get list of functions from them // This will be available when https://github.com/godotengine/godot/pull/49053 or similar will be included into Godot - static const char *builtin_types_excluded_functions[] = { "dict_to_inst", "inst_to_dict", "bytes_to_var", "bytes_to_var_with_objects", "db_to_linear", "deg_to_rad", "linear_to_db", "rad_to_deg", "randf_range", "snapped", "str_to_var", "var_to_str", "var_to_bytes", "var_to_bytes_with_objects", "move_toward", "uri_encode", "uri_decode", "remove_at", "get_rotation_quaternion", "clamp", "grow_side", "is_absolute_path", "is_valid_int", "lerp", "to_ascii_buffer", "to_utf8_buffer", "to_utf32_buffer", "snapped", nullptr }; + static const char *builtin_types_excluded_functions[] = { "dict_to_inst", "inst_to_dict", "bytes_to_var", "bytes_to_var_with_objects", "db_to_linear", "deg_to_rad", "linear_to_db", "rad_to_deg", "randf_range", "snapped", "str_to_var", "var_to_str", "var_to_bytes", "var_to_bytes_with_objects", "move_toward", "uri_encode", "uri_decode", "remove_at", "get_rotation_quaternion", "clamp", "grow_side", "is_absolute_path", "is_valid_int", "lerp", "to_ascii_buffer", "to_utf8_buffer", "to_utf32_buffer", "snapped", "remap", nullptr }; for (int current_index = 0; builtin_types_excluded_functions[current_index]; current_index++) { all_functions.insert(builtin_types_excluded_functions[current_index]); } @@ -3445,14 +3483,16 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } } - // map_to_world(a, b, c) -> map_to_world(Vector3i(a, b, c)) + // map_to_world(a, b, c) -> map_to_local(Vector3i(a, b, c)) if (line.contains("map_to_world(")) { int start = line.find("map_to_world("); int end = get_end_parenthess(line.substr(start)) + 1; if (end > -1) { Vector<String> parts = parse_arguments(line.substr(start, end)); if (parts.size() == 3) { - line = line.substr(0, start) + "map_to_world(Vector3i(" + parts[0] + "," + parts[1] + "," + parts[2] + "))" + line.substr(end + start); + line = line.substr(0, start) + "map_to_local(Vector3i(" + parts[0] + "," + parts[1] + "," + parts[2] + "))" + line.substr(end + start); + } else if (parts.size() == 1) { + line = line.substr(0, start) + "map_to_local(" + parts[0] + ")" + line.substr(end + start); } } } diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index ed8c7b14c8..2b0d6f740a 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -35,7 +35,7 @@ #include "core/io/dir_access.h" #include "core/io/file_access.h" #include "core/io/resource_saver.h" -#include "core/io/stream_peer_ssl.h" +#include "core/io/stream_peer_tls.h" #include "core/io/zip_io.h" #include "core/os/keyboard.h" #include "core/os/os.h" @@ -1901,11 +1901,13 @@ void ProjectManager::_notification(int p_what) { filter_option->select(default_sorting); _project_list->set_order_option(default_sorting); +#ifndef ANDROID_ENABLED if (_project_list->get_project_count() >= 1) { // Focus on the search box immediately to allow the user // to search without having to reach for their mouse search_box->grab_focus(); } +#endif if (asset_library) { // Removes extra border margins. @@ -2443,6 +2445,7 @@ void ProjectManager::_on_order_option_changed(int p_idx) { } void ProjectManager::_on_tab_changed(int p_tab) { +#ifndef ANDROID_ENABLED if (p_tab == 0) { // Projects // Automatically grab focus when the user moves from the Templates tab // back to the Projects tab. @@ -2451,6 +2454,7 @@ void ProjectManager::_on_tab_changed(int p_tab) { // The Templates tab's search field is focused on display in the asset // library editor plugin code. +#endif } void ProjectManager::_on_search_term_changed(const String &p_term) { @@ -2602,7 +2606,7 @@ ProjectManager::ProjectManager() { } PanelContainer *pc = memnew(PanelContainer); - pc->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + pc->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); pc->set_v_size_flags(Control::SIZE_EXPAND_FILL); search_tree_vb->add_child(pc); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 581315d512..11cbc4132c 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -521,7 +521,7 @@ void ProjectSettingsEditor::_update_action_map_editor() { void ProjectSettingsEditor::_update_theme() { search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); restart_close_button->set_icon(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); - restart_container->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + restart_container->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); restart_icon->set_texture(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); restart_label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); diff --git a/editor/scene_create_dialog.cpp b/editor/scene_create_dialog.cpp index 9b8684b7b8..573e57ca04 100644 --- a/editor/scene_create_dialog.cpp +++ b/editor/scene_create_dialog.cpp @@ -53,7 +53,7 @@ void SceneCreateDialog::_notification(int p_what) { node_type_3d->set_icon(get_theme_icon(SNAME("Node3D"), SNAME("EditorIcons"))); node_type_gui->set_icon(get_theme_icon(SNAME("Control"), SNAME("EditorIcons"))); node_type_other->add_theme_icon_override(SNAME("icon"), get_theme_icon(SNAME("Node"), SNAME("EditorIcons"))); - status_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + status_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); } break; } } diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index e2265f2f83..cde4490cd3 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1255,16 +1255,14 @@ void SceneTreeDock::_notification(int p_what) { // create_root_dialog HBoxContainer *top_row = memnew(HBoxContainer); - top_row->set_name("NodeShortcutsTopRow"); top_row->set_h_size_flags(SIZE_EXPAND_FILL); Label *l = memnew(Label(TTR("Create Root Node:"))); l->set_theme_type_variation("HeaderSmall"); top_row->add_child(l); top_row->add_spacer(); - Button *node_shortcuts_toggle = memnew(Button); + node_shortcuts_toggle = memnew(Button); node_shortcuts_toggle->set_flat(true); - node_shortcuts_toggle->set_name("NodeShortcutsToggle"); node_shortcuts_toggle->set_icon(get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); node_shortcuts_toggle->set_toggle_mode(true); node_shortcuts_toggle->set_tooltip_text(TTR("Switch to Favorite Nodes")); @@ -1276,18 +1274,15 @@ void SceneTreeDock::_notification(int p_what) { create_root_dialog->add_child(top_row); ScrollContainer *scroll_container = memnew(ScrollContainer); - scroll_container->set_name("NodeShortcutsScrollContainer"); create_root_dialog->add_child(scroll_container); scroll_container->set_v_size_flags(SIZE_EXPAND_FILL); scroll_container->set_horizontal_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); VBoxContainer *node_shortcuts = memnew(VBoxContainer); - node_shortcuts->set_name("NodeShortcuts"); scroll_container->add_child(node_shortcuts); node_shortcuts->set_h_size_flags(SIZE_EXPAND_FILL); - VBoxContainer *beginner_node_shortcuts = memnew(VBoxContainer); - beginner_node_shortcuts->set_name("BeginnerNodeShortcuts"); + beginner_node_shortcuts = memnew(VBoxContainer); node_shortcuts->add_child(beginner_node_shortcuts); button_2d = memnew(Button); @@ -1308,8 +1303,7 @@ void SceneTreeDock::_notification(int p_what) { button_ui->set_icon(get_theme_icon(SNAME("Control"), SNAME("EditorIcons"))); button_ui->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected).bind(TOOL_CREATE_USER_INTERFACE, false)); - VBoxContainer *favorite_node_shortcuts = memnew(VBoxContainer); - favorite_node_shortcuts->set_name("FavoriteNodeShortcuts"); + favorite_node_shortcuts = memnew(VBoxContainer); node_shortcuts->add_child(favorite_node_shortcuts); button_custom = memnew(Button); @@ -3227,25 +3221,11 @@ void SceneTreeDock::_local_tree_selected() { } void SceneTreeDock::_update_create_root_dialog() { - BaseButton *toggle = Object::cast_to<BaseButton>(create_root_dialog->get_node(String("NodeShortcutsTopRow/NodeShortcutsToggle"))); - Node *node_shortcuts = create_root_dialog->get_node(String("NodeShortcutsScrollContainer/NodeShortcuts")); - - if (!toggle || !node_shortcuts) { - return; - } - - Control *beginner_nodes = Object::cast_to<Control>(node_shortcuts->get_node(String("BeginnerNodeShortcuts"))); - Control *favorite_nodes = Object::cast_to<Control>(node_shortcuts->get_node(String("FavoriteNodeShortcuts"))); - - if (!beginner_nodes || !favorite_nodes) { - return; - } - - EditorSettings::get_singleton()->set_setting("_use_favorites_root_selection", toggle->is_pressed()); + EditorSettings::get_singleton()->set_setting("_use_favorites_root_selection", node_shortcuts_toggle->is_pressed()); EditorSettings::get_singleton()->save(); - if (toggle->is_pressed()) { - for (int i = 0; i < favorite_nodes->get_child_count(); i++) { - favorite_nodes->get_child(i)->queue_delete(); + if (node_shortcuts_toggle->is_pressed()) { + for (int i = 0; i < favorite_node_shortcuts->get_child_count(); i++) { + favorite_node_shortcuts->get_child(i)->queue_delete(); } Ref<FileAccess> f = FileAccess::open(EditorPaths::get_singleton()->get_project_settings_dir().path_join("favorites.Node"), FileAccess::READ); @@ -3255,7 +3235,7 @@ void SceneTreeDock::_update_create_root_dialog() { if (!l.is_empty()) { Button *button = memnew(Button); - favorite_nodes->add_child(button); + favorite_node_shortcuts->add_child(button); button->set_text(l); button->set_clip_text(true); String name = l.get_slicec(' ', 0); @@ -3268,14 +3248,14 @@ void SceneTreeDock::_update_create_root_dialog() { } } - if (!favorite_nodes->is_visible_in_tree()) { - favorite_nodes->show(); - beginner_nodes->hide(); + if (!favorite_node_shortcuts->is_visible_in_tree()) { + favorite_node_shortcuts->show(); + beginner_node_shortcuts->hide(); } } else { - if (!beginner_nodes->is_visible_in_tree()) { - beginner_nodes->show(); - favorite_nodes->hide(); + if (!beginner_node_shortcuts->is_visible_in_tree()) { + beginner_node_shortcuts->show(); + favorite_node_shortcuts->hide(); } button_clipboard->set_visible(!node_clipboard.is_empty()); } diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index e15865036b..dc228e1c93 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -119,6 +119,10 @@ class SceneTreeDock : public VBoxContainer { Button *button_detach_script = nullptr; MenuButton *button_tree_menu = nullptr; + Button *node_shortcuts_toggle = nullptr; + VBoxContainer *beginner_node_shortcuts = nullptr; + VBoxContainer *favorite_node_shortcuts = nullptr; + Button *button_2d = nullptr; Button *button_3d = nullptr; Button *button_ui = nullptr; diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index c120468ecb..50bb6496e1 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -387,17 +387,18 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { Ref<Script> script = p_node->get_script(); if (!script.is_null()) { String additional_notes; + Color button_color = Color(1, 1, 1); // Can't set tooltip after adding button, need to do it before. if (script->is_tool()) { additional_notes += "\n" + TTR("This script is currently running in the editor."); + button_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); } - item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + script->get_path() + additional_notes); if (EditorNode::get_singleton()->get_object_custom_type_base(p_node) == script) { - item->set_button_color(0, item->get_button_count(0) - 1, Color(1, 1, 1, 0.5)); - } - if (script->is_tool()) { - item->set_button_color(0, item->get_button_count(0) - 1, get_theme_color(SNAME("accent_color"), SNAME("Editor"))); + additional_notes += "\n" + TTR("This script is a custom type."); + button_color.a = 0.5; } + item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + script->get_path() + additional_notes); + item->set_button_color(0, item->get_button_count(0) - 1, button_color); } if (p_node->is_class("CanvasItem")) { diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 7d065b4920..16ab441324 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -134,7 +134,7 @@ void ScriptCreateDialog::_notification(int p_what) { path_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); parent_browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); parent_search_button->set_icon(get_theme_icon(SNAME("ClassList"), SNAME("EditorIcons"))); - status_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + status_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); } break; } } diff --git a/editor/shader_create_dialog.cpp b/editor/shader_create_dialog.cpp index 522fd7c645..ae533b5b75 100644 --- a/editor/shader_create_dialog.cpp +++ b/editor/shader_create_dialog.cpp @@ -89,7 +89,7 @@ void ShaderCreateDialog::_update_theme() { } path_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); - status_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + status_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Tree"))); } void ShaderCreateDialog::_update_language_info() { diff --git a/editor/shader_globals_editor.cpp b/editor/shader_globals_editor.cpp index 9058596830..eef0f3eae1 100644 --- a/editor/shader_globals_editor.cpp +++ b/editor/shader_globals_editor.cpp @@ -80,7 +80,7 @@ protected: } bool _set(const StringName &p_name, const Variant &p_value) { - Variant existing = RS::get_singleton()->global_shader_uniform_get(p_name); + Variant existing = RS::get_singleton()->global_shader_parameter_get(p_name); if (existing.get_type() == Variant::NIL) { return false; @@ -89,9 +89,9 @@ protected: Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Set Shader Global Variable")); - undo_redo->add_do_method(RS::get_singleton(), "global_shader_uniform_set", p_name, p_value); - undo_redo->add_undo_method(RS::get_singleton(), "global_shader_uniform_set", p_name, existing); - RS::GlobalShaderUniformType type = RS::get_singleton()->global_shader_uniform_get_type(p_name); + undo_redo->add_do_method(RS::get_singleton(), "global_shader_parameter_set", p_name, p_value); + undo_redo->add_undo_method(RS::get_singleton(), "global_shader_parameter_set", p_name, existing); + RS::GlobalShaderParameterType type = RS::get_singleton()->global_shader_parameter_get_type(p_name); Dictionary gv; gv["type"] = global_var_type_names[type]; if (type >= RS::GLOBAL_VAR_TYPE_SAMPLER2D) { @@ -118,17 +118,17 @@ protected: } bool _get(const StringName &p_name, Variant &r_ret) const { - r_ret = RS::get_singleton()->global_shader_uniform_get(p_name); + r_ret = RS::get_singleton()->global_shader_parameter_get(p_name); return r_ret.get_type() != Variant::NIL; } void _get_property_list(List<PropertyInfo> *p_list) const { Vector<StringName> variables; - variables = RS::get_singleton()->global_shader_uniform_get_list(); + variables = RS::get_singleton()->global_shader_parameter_get_list(); for (int i = 0; i < variables.size(); i++) { PropertyInfo pinfo; pinfo.name = variables[i]; - switch (RS::get_singleton()->global_shader_uniform_get_type(variables[i])) { + switch (RS::get_singleton()->global_shader_parameter_get_type(variables[i])) { case RS::GLOBAL_VAR_TYPE_BOOL: { pinfo.type = Variant::BOOL; } break; @@ -242,7 +242,7 @@ public: } }; -static Variant create_var(RS::GlobalShaderUniformType p_type) { +static Variant create_var(RS::GlobalShaderParameterType p_type) { switch (p_type) { case RS::GLOBAL_VAR_TYPE_BOOL: { return false; @@ -381,8 +381,8 @@ void ShaderGlobalsEditor::_variable_added() { return; } - if (RenderingServer::get_singleton()->global_shader_uniform_get(var).get_type() != Variant::NIL) { - EditorNode::get_singleton()->show_warning(vformat(TTR("Global shader uniform '%s' already exists'"), var)); + if (RenderingServer::get_singleton()->global_shader_parameter_get(var).get_type() != Variant::NIL) { + EditorNode::get_singleton()->show_warning(vformat(TTR("Global shader parameter '%s' already exists'"), var)); return; } @@ -396,11 +396,11 @@ void ShaderGlobalsEditor::_variable_added() { Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_singleton()->get_undo_redo(); - Variant value = create_var(RS::GlobalShaderUniformType(variable_type->get_selected())); + Variant value = create_var(RS::GlobalShaderParameterType(variable_type->get_selected())); - undo_redo->create_action(TTR("Add Shader Global Uniform")); - undo_redo->add_do_method(RS::get_singleton(), "global_shader_uniform_add", var, RS::GlobalShaderUniformType(variable_type->get_selected()), value); - undo_redo->add_undo_method(RS::get_singleton(), "global_shader_uniform_remove", var); + undo_redo->create_action(TTR("Add Shader Global Parameter")); + undo_redo->add_do_method(RS::get_singleton(), "global_shader_parameter_add", var, RS::GlobalShaderParameterType(variable_type->get_selected()), value); + undo_redo->add_undo_method(RS::get_singleton(), "global_shader_parameter_remove", var); Dictionary gv; gv["type"] = global_var_type_names[variable_type->get_selected()]; gv["value"] = value; @@ -415,9 +415,9 @@ void ShaderGlobalsEditor::_variable_added() { void ShaderGlobalsEditor::_variable_deleted(const String &p_variable) { Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_singleton()->get_undo_redo(); - undo_redo->create_action(TTR("Add Shader Global Uniform")); - undo_redo->add_do_method(RS::get_singleton(), "global_shader_uniform_remove", p_variable); - undo_redo->add_undo_method(RS::get_singleton(), "global_shader_uniform_add", p_variable, RS::get_singleton()->global_shader_uniform_get_type(p_variable), RS::get_singleton()->global_shader_uniform_get(p_variable)); + undo_redo->create_action(TTR("Add Shader Global Parameter")); + undo_redo->add_do_method(RS::get_singleton(), "global_shader_parameter_remove", p_variable); + undo_redo->add_undo_method(RS::get_singleton(), "global_shader_parameter_add", p_variable, RS::get_singleton()->global_shader_parameter_get_type(p_variable), RS::get_singleton()->global_shader_parameter_get(p_variable)); undo_redo->add_do_property(ProjectSettings::get_singleton(), "shader_globals/" + p_variable, Variant()); undo_redo->add_undo_property(ProjectSettings::get_singleton(), "shader_globals/" + p_variable, ProjectSettings::get_singleton()->get("shader_globals/" + p_variable)); |