diff options
Diffstat (limited to 'editor')
32 files changed, 394 insertions, 155 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index b6cd69c3cd..4c31797c50 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -456,10 +456,10 @@ void FindReplaceBar::_show_search(bool p_focus_replace, bool p_show_only) { void FindReplaceBar::popup_search(bool p_show_only) { - if (!is_visible()) - replace_text->hide(); + replace_text->hide(); hbc_button_replace->hide(); hbc_option_replace->hide(); + _show_search(false, p_show_only); } diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp index b2567249d8..8a03292708 100644 --- a/editor/editor_about.cpp +++ b/editor/editor_about.cpp @@ -141,7 +141,7 @@ EditorAbout::EditorAbout() { hbc->add_child(about_text); TabContainer *tc = memnew(TabContainer); - tc->set_custom_minimum_size(Size2(630, 240) * EDSCALE); + tc->set_custom_minimum_size(Size2(950, 400) * EDSCALE); tc->set_v_size_flags(Control::SIZE_EXPAND_FILL); vbc->add_child(tc); diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 90f54df485..9510092a86 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -1606,6 +1606,9 @@ Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_pr da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); for (int i = 0; i < so_files.size() && err == OK; i++) { err = da->copy(so_files[i].path, p_path.get_base_dir().plus_file(so_files[i].path.get_file())); + if (err == OK) { + err = sign_shared_object(p_preset, p_debug, p_path.get_base_dir().plus_file(so_files[i].path.get_file())); + } } memdelete(da); } @@ -1614,6 +1617,10 @@ Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_pr return err; } +Error EditorExportPlatformPC::sign_shared_object(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path) { + return OK; +} + void EditorExportPlatformPC::set_extension(const String &p_extension, const String &p_feature_key) { extensions[p_feature_key] = p_extension; } diff --git a/editor/editor_export.h b/editor/editor_export.h index 3152e249bd..11dc464b5a 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -423,6 +423,7 @@ public: virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const; virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const; virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0); + virtual Error sign_shared_object(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path); void set_extension(const String &p_extension, const String &p_feature_key = "default"); void set_name(const String &p_name); diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 55cae35a4a..b6d27d84e0 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -232,6 +232,7 @@ void editor_register_fonts(Ref<Theme> p_theme) { // Default font MAKE_DEFAULT_FONT(df, default_font_size); p_theme->set_default_theme_font(df); + p_theme->set_font("main", "EditorFonts", df); // Bold font MAKE_BOLD_FONT(df_bold, default_font_size); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 2b58d105de..83434a6d9f 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -1107,37 +1107,47 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); class_desc->add_newline(); - for (int i = 0; i < methods.size(); i++) { + for (int pass = 0; pass < 2; pass++) { + Vector<DocData::MethodDoc> methods_filtered; - class_desc->push_font(doc_code_font); - _add_method(methods[i], false); - class_desc->pop(); + for (int i = 0; i < methods.size(); i++) { + const String &q = methods[i].qualifiers; + if ((pass == 0 && q.find("virtual") != -1) || (pass == 1 && q.find("virtual") == -1)) { + methods_filtered.push_back(methods[i]); + } + } - class_desc->add_newline(); - class_desc->add_newline(); + for (int i = 0; i < methods_filtered.size(); i++) { - class_desc->push_color(text_color); - class_desc->push_font(doc_font); - class_desc->push_indent(1); - if (methods[i].description.strip_edges() != String()) { - _add_text(methods[i].description); - } else { - class_desc->add_image(get_icon("Error", "EditorIcons")); - class_desc->add_text(" "); - class_desc->push_color(comment_color); - class_desc->append_bbcode(TTR("There is currently no description for this method. Please help us by [color=$color][url=$url]contributing one[/url][/color]!").replace("$url", CONTRIBUTE_URL).replace("$color", link_color_text)); + class_desc->push_font(doc_code_font); + _add_method(methods_filtered[i], false); class_desc->pop(); - } - class_desc->pop(); - class_desc->pop(); - class_desc->pop(); - class_desc->add_newline(); - class_desc->add_newline(); - class_desc->add_newline(); + class_desc->add_newline(); + class_desc->add_newline(); + + class_desc->push_color(text_color); + class_desc->push_font(doc_font); + class_desc->push_indent(1); + if (methods_filtered[i].description.strip_edges() != String()) { + _add_text(methods_filtered[i].description); + } else { + class_desc->add_image(get_icon("Error", "EditorIcons")); + class_desc->add_text(" "); + class_desc->push_color(comment_color); + class_desc->append_bbcode(TTR("There is currently no description for this method. Please help us by [color=$color][url=$url]contributing one[/url][/color]!").replace("$url", CONTRIBUTE_URL).replace("$color", link_color_text)); + class_desc->pop(); + } + + class_desc->pop(); + class_desc->pop(); + class_desc->pop(); + class_desc->add_newline(); + class_desc->add_newline(); + class_desc->add_newline(); + } } } - scroll_locked = false; } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 05b50d5dfe..2c3a84857a 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4891,7 +4891,7 @@ Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_paths, Control * } int max_rows = 6; - int num_rows = p_paths.size() > max_rows ? max_rows - 1 : p_paths.size(); //Don't waste a row to say "1 more file" - list it instead. + int num_rows = p_paths.size() > max_rows ? max_rows - 1 : p_paths.size(); // Don't waste a row to say "1 more file" - list it instead. VBoxContainer *vbox = memnew(VBoxContainer); for (int i = 0; i < num_rows; i++) { HBoxContainer *hbox = memnew(HBoxContainer); @@ -4905,6 +4905,7 @@ Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_paths, Control * label->set_text(p_paths[i].get_file()); icon->set_texture(gui_base->get_icon("File", "EditorIcons")); } + icon->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED); icon->set_size(Size2(16, 16)); hbox->add_child(icon); hbox->add_child(label); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 690b7a8ec4..460f75eef0 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2649,6 +2649,7 @@ void EditorPropertyResource::update_property() { if (res == RES()) { assign->set_icon(Ref<Texture>()); assign->set_text(TTR("[empty]")); + assign->set_tooltip(""); } else { assign->set_icon(EditorNode::get_singleton()->get_object_icon(res.operator->(), "Node")); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 9d24e443c4..3ea59115b0 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -666,6 +666,7 @@ void EditorSettings::_load_default_text_editor_theme() { _initial_set("text_editor/highlighting/keyword_color", Color(1.0, 1.0, 0.7)); _initial_set("text_editor/highlighting/base_type_color", Color(0.64, 1.0, 0.83)); _initial_set("text_editor/highlighting/engine_type_color", Color(0.51, 0.83, 1.0)); + _initial_set("text_editor/highlighting/user_type_color", Color(0.42, 0.67, 0.93)); _initial_set("text_editor/highlighting/comment_color", Color(0.4, 0.4, 0.4)); _initial_set("text_editor/highlighting/string_color", Color(0.94, 0.43, 0.75)); _initial_set("text_editor/highlighting/background_color", dark_theme ? Color(0.0, 0.0, 0.0, 0.23) : Color(0.2, 0.23, 0.31)); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 93d3ff1e18..0c7c2c6cc3 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1130,7 +1130,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { const Color symbol_color = Color(0.34, 0.57, 1.0).linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3); const Color keyword_color = Color(1.0, 0.44, 0.52); const Color basetype_color = dark_theme ? Color(0.26, 1.0, 0.76) : Color(0.0, 0.76, 0.38); - const Color type_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.7 : 0.5); + const Color type_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.4 : 0.3); + const Color usertype_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.7 : 0.5); const Color comment_color = dim_color; const Color string_color = (dark_theme ? Color(1.0, 0.85, 0.26) : Color(1.0, 0.82, 0.09)).linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3); @@ -1169,6 +1170,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { setting->set_initial_value("text_editor/highlighting/keyword_color", keyword_color, true); setting->set_initial_value("text_editor/highlighting/base_type_color", basetype_color, true); setting->set_initial_value("text_editor/highlighting/engine_type_color", type_color, true); + setting->set_initial_value("text_editor/highlighting/user_type_color", usertype_color, true); setting->set_initial_value("text_editor/highlighting/comment_color", comment_color, true); setting->set_initial_value("text_editor/highlighting/string_color", string_color, true); setting->set_initial_value("text_editor/highlighting/background_color", te_background_color, true); diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 760388d616..3a99968192 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -1178,7 +1178,7 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/import", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "animation/fps", PROPERTY_HINT_RANGE, "1,120,1"), 15)); r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "animation/filter_script", PROPERTY_HINT_MULTILINE_TEXT), "")); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "animation/storage", PROPERTY_HINT_ENUM, "Built-In,Files (.anim),Files (.tres)"), animations_out)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "animation/storage", PROPERTY_HINT_ENUM, "Built-In,Files (.anim),Files (.tres)", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), animations_out)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/keep_custom_tracks"), animations_out)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/optimizer/enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "animation/optimizer/max_linear_error"), 0.05)); diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 2d00324c84..80353bab01 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -304,6 +304,7 @@ void AnimationPlayerEditor::_animation_selected(int p_which) { AnimationPlayerEditor::singleton->get_track_editor()->update_keying(); EditorNode::get_singleton()->update_keying(); + _animation_key_editor_seek(timeline_position, false); } void AnimationPlayerEditor::_animation_new() { @@ -483,6 +484,8 @@ double AnimationPlayerEditor::_get_editor_step() const { if (track_editor->is_snap_enabled()) { const String current = player->get_assigned_animation(); const Ref<Animation> anim = player->get_animation(current); + ERR_FAIL_COND_V(!anim.is_valid(), 0.0); + // Use more precise snapping when holding Shift return Input::get_singleton()->is_key_pressed(KEY_SHIFT) ? anim->get_step() * 0.25 : anim->get_step(); } @@ -1072,14 +1075,20 @@ void AnimationPlayerEditor::_animation_key_editor_anim_len_changed(float p_len) void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos, bool p_drag) { + timeline_position = p_pos; + if (!is_visible_in_tree()) return; + if (!player) return; if (player->is_playing()) return; + if (!player->has_animation(player->get_assigned_animation())) + return; + Ref<Animation> anim = player->get_animation(player->get_assigned_animation()); updating = true; @@ -1753,6 +1762,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay renaming = false; last_active = false; + timeline_position = 0; set_process_unhandled_key_input(true); diff --git a/editor/plugins/animation_player_editor_plugin.h b/editor/plugins/animation_player_editor_plugin.h index eed7344395..663ffd57f3 100644 --- a/editor/plugins/animation_player_editor_plugin.h +++ b/editor/plugins/animation_player_editor_plugin.h @@ -107,6 +107,7 @@ class AnimationPlayerEditor : public VBoxContainer { UndoRedo *undo_redo; Ref<Texture> autoplay_icon; bool last_active; + float timeline_position; EditorFileDialog *file; AcceptDialog *accept; diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index a11c35e5f2..0d388512f4 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -72,7 +72,7 @@ class SnapDialog : public ConfirmationDialog { public: SnapDialog() { - const int SPIN_BOX_GRID_RANGE = 256; + const int SPIN_BOX_GRID_RANGE = 16384; const int SPIN_BOX_ROTATION_RANGE = 360; Label *label; VBoxContainer *container; @@ -96,6 +96,8 @@ public: grid_offset_x = memnew(SpinBox); grid_offset_x->set_min(-SPIN_BOX_GRID_RANGE); grid_offset_x->set_max(SPIN_BOX_GRID_RANGE); + grid_offset_x->set_allow_lesser(true); + grid_offset_x->set_allow_greater(true); grid_offset_x->set_suffix("px"); grid_offset_x->set_h_size_flags(SIZE_EXPAND_FILL); child_container->add_child(grid_offset_x); @@ -103,6 +105,8 @@ public: grid_offset_y = memnew(SpinBox); grid_offset_y->set_min(-SPIN_BOX_GRID_RANGE); grid_offset_y->set_max(SPIN_BOX_GRID_RANGE); + grid_offset_y->set_allow_lesser(true); + grid_offset_y->set_allow_greater(true); grid_offset_y->set_suffix("px"); grid_offset_y->set_h_size_flags(SIZE_EXPAND_FILL); child_container->add_child(grid_offset_y); @@ -115,6 +119,7 @@ public: grid_step_x = memnew(SpinBox); grid_step_x->set_min(0.01); grid_step_x->set_max(SPIN_BOX_GRID_RANGE); + grid_step_x->set_allow_greater(true); grid_step_x->set_suffix("px"); grid_step_x->set_h_size_flags(SIZE_EXPAND_FILL); child_container->add_child(grid_step_x); @@ -122,6 +127,7 @@ public: grid_step_y = memnew(SpinBox); grid_step_y->set_min(0.01); grid_step_y->set_max(SPIN_BOX_GRID_RANGE); + grid_step_y->set_allow_greater(true); grid_step_y->set_suffix("px"); grid_step_y->set_h_size_flags(SIZE_EXPAND_FILL); child_container->add_child(grid_step_y); @@ -2708,6 +2714,7 @@ void CanvasItemEditor::_draw_ruler_tool() { font_secondary_color.a = 0.5; float text_height = font->get_height(); const float text_width = 76; + const float angle_text_width = 54; Point2 text_pos = (begin + end) / 2 - Vector2(text_width / 2, text_height / 2); text_pos.x = CLAMP(text_pos.x, text_width / 2, viewport->get_rect().size.x - text_width * 1.5); @@ -2715,14 +2722,38 @@ void CanvasItemEditor::_draw_ruler_tool() { viewport->draw_string(font, text_pos, vformat("%.2f px", length_vector.length()), font_color); if (draw_secondary_lines) { + int horizontal_axis_angle = round(180 * atan2(length_vector.y, length_vector.x) / Math_PI); + int vertictal_axis_angle = 90 - horizontal_axis_angle; Point2 text_pos2 = text_pos; text_pos2.x = begin.x < text_pos.x ? MIN(text_pos.x - text_width, begin.x - text_width / 2) : MAX(text_pos.x + text_width, begin.x - text_width / 2); viewport->draw_string(font, text_pos2, vformat("%.2f px", length_vector.y), font_secondary_color); + Point2 v_angle_text_pos = Point2(); + v_angle_text_pos.x = CLAMP(begin.x - angle_text_width / 2, angle_text_width / 2, viewport->get_rect().size.x - angle_text_width); + v_angle_text_pos.y = begin.y < end.y ? MIN(text_pos2.y - 2 * text_height, begin.y - text_height * 0.5) : MAX(text_pos2.y + text_height * 3, begin.y + text_height * 1.5); + viewport->draw_string(font, v_angle_text_pos, vformat("%d deg", vertictal_axis_angle), font_secondary_color); + text_pos2 = text_pos; text_pos2.y = end.y < text_pos.y ? MIN(text_pos.y - text_height * 2, end.y - text_height / 2) : MAX(text_pos.y + text_height * 2, end.y - text_height / 2); viewport->draw_string(font, text_pos2, vformat("%.2f px", length_vector.x), font_secondary_color); + + Point2 h_angle_text_pos = Point2(); + h_angle_text_pos.x = CLAMP(end.x - angle_text_width / 2, angle_text_width / 2, viewport->get_rect().size.x - angle_text_width); + if (begin.y < end.y) { + h_angle_text_pos.y = end.y + text_height * 1.5; + if (ABS(text_pos2.x - h_angle_text_pos.x) < text_width) { + int height_multiplier = 1.5 + (int)is_snap_active; + h_angle_text_pos.y = MAX(text_pos.y + height_multiplier * text_height, MAX(end.y + text_height * 1.5, text_pos2.y + height_multiplier * text_height)); + } + } else { + h_angle_text_pos.y = end.y - text_height * 0.5; + if (ABS(text_pos2.x - h_angle_text_pos.x) < text_width) { + int height_multiplier = 1 + (int)is_snap_active; + h_angle_text_pos.y = MIN(text_pos.y - height_multiplier * text_height, MIN(end.y - text_height * 0.5, text_pos2.y - height_multiplier * text_height)); + } + } + viewport->draw_string(font, h_angle_text_pos, vformat("%d deg", horizontal_axis_angle), font_secondary_color); } if (is_snap_active) { @@ -5135,6 +5166,8 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { warning_child_of_container = memnew(Label); warning_child_of_container->hide(); warning_child_of_container->set_text(TTR("Warning: Children of a container get their position and size determined only by their parent.")); + warning_child_of_container->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("warning_color", "Editor")); + warning_child_of_container->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("main", "EditorFonts")); add_control_to_info_overlay(warning_child_of_container); h_scroll = memnew(HScrollBar); @@ -5528,6 +5561,7 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons for (int i = 0; i < files.size(); i++) { String path = files[i]; RES res = ResourceLoader::load(path); + ERR_FAIL_COND(res.is_null()); Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res)); Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); if (texture != NULL || scene != NULL) { diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 073e6f74e9..ecb2354aa1 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -224,6 +224,7 @@ void ScriptTextEditor::_load_theme_settings() { Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color"); Color basetype_color = EDITOR_GET("text_editor/highlighting/base_type_color"); Color type_color = EDITOR_GET("text_editor/highlighting/engine_type_color"); + Color usertype_color = EDITOR_GET("text_editor/highlighting/user_type_color"); Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color"); Color string_color = EDITOR_GET("text_editor/highlighting/string_color"); @@ -262,6 +263,7 @@ void ScriptTextEditor::_load_theme_settings() { colors_cache.keyword_color = keyword_color; colors_cache.basetype_color = basetype_color; colors_cache.type_color = type_color; + colors_cache.usertype_color = usertype_color; colors_cache.comment_color = comment_color; colors_cache.string_color = string_color; @@ -325,6 +327,29 @@ void ScriptTextEditor::_set_theme_for_script() { } _update_member_keywords(); + //colorize user types + List<StringName> global_classes; + ScriptServer::get_global_class_list(&global_classes); + + for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) { + + text_edit->add_keyword_color(E->get(), colors_cache.usertype_color); + } + + //colorize singleton autoloads (as types, just as engine singletons are) + List<PropertyInfo> props; + ProjectSettings::get_singleton()->get_property_list(&props); + for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { + String s = E->get().name; + if (!s.begins_with("autoload/")) { + continue; + } + String path = ProjectSettings::get_singleton()->get(s); + if (path.begins_with("*")) { + text_edit->add_keyword_color(s.get_slice("/", 1), colors_cache.usertype_color); + } + } + //colorize comments List<String> comments; script->get_language()->get_comment_delimiters(&comments); @@ -789,7 +814,7 @@ void ScriptTextEditor::_code_complete_script(const String &p_code, List<ScriptCo } String hint; Error err = script->get_language()->complete_code(p_code, script->get_path(), base, r_options, r_force, hint); - if (err == OK && hint != "") { + if (err == OK) { code_editor->get_text_edit()->set_code_hint(hint); } } diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index 0ea8726ecc..eba75befd4 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -91,6 +91,7 @@ class ScriptTextEditor : public ScriptEditorBase { Color keyword_color; Color basetype_color; Color type_color; + Color usertype_color; Color comment_color; Color string_color; } colors_cache; diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index df3e23a9e9..97f194e40f 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -198,13 +198,9 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptCo ShaderLanguage sl; String calltip; - Error err = sl.complete(p_code, ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types(), r_options, calltip); - if (err != OK) - ERR_PRINT("Shaderlang complete failed"); + sl.complete(p_code, ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types(), r_options, calltip); - if (calltip != "") { - get_text_edit()->set_code_hint(calltip); - } + get_text_edit()->set_code_hint(calltip); } void ShaderTextEditor::_validate_script() { diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index ba40fc5612..095350d0e1 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -2172,7 +2172,7 @@ void SpatialEditorViewport::_notification(int p_what) { VisualInstance *vi = Object::cast_to<VisualInstance>(sp); - se->aabb = vi ? vi->get_aabb() : AABB(Vector3(-0.2, -0.2, -0.2), Vector3(0.4, 0.4, 0.4)); + se->aabb = vi ? vi->get_aabb() : _calculate_spatial_bounds(sp); Transform t = sp->get_global_gizmo_transform(); t.translate(se->aabb.position); @@ -3209,20 +3209,35 @@ Vector3 SpatialEditorViewport::_get_instance_position(const Point2 &p_pos) const return point + offset; } -AABB SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, const AABB &p_bounds) { - AABB bounds = p_bounds; +AABB SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, bool p_exclude_toplevel_transform) { + AABB bounds; + + const MeshInstance *mesh_instance = Object::cast_to<MeshInstance>(p_parent); + if (mesh_instance) { + bounds = mesh_instance->get_aabb(); + } + for (int i = 0; i < p_parent->get_child_count(); i++) { Spatial *child = Object::cast_to<Spatial>(p_parent->get_child(i)); if (child) { - MeshInstance *mesh_instance = Object::cast_to<MeshInstance>(child); - if (mesh_instance) { - AABB mesh_instance_bounds = mesh_instance->get_aabb(); - mesh_instance_bounds.position += mesh_instance->get_global_gizmo_transform().origin - p_parent->get_global_gizmo_transform().origin; - bounds.merge_with(mesh_instance_bounds); + AABB child_bounds = _calculate_spatial_bounds(child, false); + + if (bounds.size == Vector3() && p_parent->get_class_name() == StringName("Spatial")) { + bounds = child_bounds; + } else { + bounds.merge_with(child_bounds); } - bounds = _calculate_spatial_bounds(child, bounds); } } + + if (bounds.size == Vector3() && p_parent->get_class_name() != StringName("Spatial")) { + bounds = AABB(Vector3(-0.2, -0.2, -0.2), Vector3(0.4, 0.4, 0.4)); + } + + if (!p_exclude_toplevel_transform) { + bounds = p_parent->get_transform().xform(bounds); + } + return bounds; } @@ -3230,6 +3245,7 @@ void SpatialEditorViewport::_create_preview(const Vector<String> &files) const { for (int i = 0; i < files.size(); i++) { String path = files[i]; RES res = ResourceLoader::load(path); + ERR_CONTINUE(res.is_null()); Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); Ref<Mesh> mesh = Ref<Mesh>(Object::cast_to<Mesh>(*res)); if (mesh != NULL || scene != NULL) { @@ -3248,7 +3264,7 @@ void SpatialEditorViewport::_create_preview(const Vector<String> &files) const { editor->get_scene_root()->add_child(preview_node); } } - *preview_bounds = _calculate_spatial_bounds(preview_node, AABB()); + *preview_bounds = _calculate_spatial_bounds(preview_node); } void SpatialEditorViewport::_remove_preview() { @@ -3279,6 +3295,7 @@ bool SpatialEditorViewport::_cyclical_dependency_exists(const String &p_target_s bool SpatialEditorViewport::_create_instance(Node *parent, String &path, const Point2 &p_point) { RES res = ResourceLoader::load(path); + ERR_FAIL_COND_V(res.is_null(), false); Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); Ref<Mesh> mesh = Ref<Mesh>(Object::cast_to<Mesh>(*res)); @@ -4062,7 +4079,6 @@ void _update_all_gizmos(Node *p_node) { void SpatialEditor::update_all_gizmos(Node *p_node) { if (!p_node) { - if (!SceneTree::get_singleton()) return; p_node = SceneTree::get_singleton()->get_root(); } _update_all_gizmos(p_node); @@ -6269,5 +6285,7 @@ EditorSpatialGizmoPlugin::~EditorSpatialGizmoPlugin() { current_gizmos[i]->set_plugin(NULL); current_gizmos[i]->get_spatial_node()->set_gizmo(NULL); } - SpatialEditor::get_singleton()->update_all_gizmos(); + if (SpatialEditor::get_singleton()) { + SpatialEditor::get_singleton()->update_all_gizmos(); + } } diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index 208495c2f5..fe91c33642 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -375,7 +375,7 @@ private: Point2i _get_warped_mouse_motion(const Ref<InputEventMouseMotion> &p_ev_mouse_motion) const; Vector3 _get_instance_position(const Point2 &p_pos) const; - static AABB _calculate_spatial_bounds(const Spatial *p_parent, const AABB &p_bounds); + static AABB _calculate_spatial_bounds(const Spatial *p_parent, bool p_exclude_toplevel_transform = true); void _create_preview(const Vector<String> &files) const; void _remove_preview(); bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node); diff --git a/editor/plugins/sprite_editor_plugin.cpp b/editor/plugins/sprite_editor_plugin.cpp index 69fd592652..40734cffc4 100644 --- a/editor/plugins/sprite_editor_plugin.cpp +++ b/editor/plugins/sprite_editor_plugin.cpp @@ -178,6 +178,7 @@ void SpriteEditor::_update_mesh_data() { err_dialog->popup_centered_minsize(); return; } + Ref<Image> image = texture->get_data(); ERR_FAIL_COND(image.is_null()); Rect2 rect; @@ -190,7 +191,12 @@ void SpriteEditor::_update_mesh_data() { bm.instance(); bm->create_from_image_alpha(image); - int grow = island_merging->get_value(); + int shrink = shrink_pixels->get_value(); + if (shrink > 0) { + bm->shrink_mask(shrink, rect); + } + + int grow = grow_pixels->get_value(); if (grow > 0) { bm->grow_mask(grow, rect); } @@ -338,6 +344,13 @@ void SpriteEditor::_convert_to_mesh_2d_node() { } void SpriteEditor::_convert_to_polygon_2d_node() { + + if (computed_outline_lines.empty()) { + err_dialog->set_text(TTR("Invalid geometry, can't create polygon.")); + err_dialog->popup_centered_minsize(); + return; + } + Polygon2D *polygon_2d_instance = memnew(Polygon2D); int total_point_count = 0; @@ -362,12 +375,6 @@ void SpriteEditor::_convert_to_polygon_2d_node() { Vector<Vector2> outline = computed_outline_lines[i]; Vector<Vector2> uv_outline = outline_lines[i]; - if (outline.size() < 3) { - err_dialog->set_text(TTR("Invalid geometry, can't create polygon.")); - err_dialog->popup_centered_minsize(); - return; - } - PoolIntArray pia; pia.resize(outline.size()); PoolIntArray::Write pia_write = pia.write(); @@ -396,16 +403,17 @@ void SpriteEditor::_convert_to_polygon_2d_node() { } void SpriteEditor::_create_collision_polygon_2d_node() { + + if (computed_outline_lines.empty()) { + err_dialog->set_text(TTR("Invalid geometry, can't create collision polygon.")); + err_dialog->popup_centered_minsize(); + return; + } + for (int i = 0; i < computed_outline_lines.size(); i++) { Vector<Vector2> outline = computed_outline_lines[i]; - if (outline.size() < 3) { - err_dialog->set_text(TTR("Invalid geometry, can't create collision polygon.")); - err_dialog->popup_centered_minsize(); - continue; - } - CollisionPolygon2D *collision_polygon_2d_instance = memnew(CollisionPolygon2D); collision_polygon_2d_instance->set_polygon(outline); @@ -419,16 +427,17 @@ void SpriteEditor::_create_collision_polygon_2d_node() { } void SpriteEditor::_create_light_occluder_2d_node() { + + if (computed_outline_lines.empty()) { + err_dialog->set_text(TTR("Invalid geometry, can't create light occluder.")); + err_dialog->popup_centered_minsize(); + return; + } + for (int i = 0; i < computed_outline_lines.size(); i++) { Vector<Vector2> outline = computed_outline_lines[i]; - if (outline.size() < 3) { - err_dialog->set_text(TTR("Invalid geometry, can't create light occluder.")); - err_dialog->popup_centered_minsize(); - continue; - } - Ref<OccluderPolygon2D> polygon; polygon.instance(); @@ -531,10 +540,14 @@ void SpriteEditor::_debug_uv_draw() { Ref<Texture> tex = node->get_texture(); ERR_FAIL_COND(!tex.is_valid()); + + Point2 draw_pos_offset = Point2(1.0, 1.0); + Size2 draw_size_offset = Size2(2.0, 2.0); + debug_uv->set_clip_contents(true); - debug_uv->draw_texture(tex, Point2()); - debug_uv->set_custom_minimum_size(tex->get_size()); - //debug_uv->draw_set_transform(Vector2(), 0, debug_uv->get_size()); + debug_uv->draw_texture(tex, draw_pos_offset); + debug_uv->set_custom_minimum_size(tex->get_size() + draw_size_offset); + debug_uv->draw_set_transform(draw_pos_offset, 0, Size2(1.0, 1.0)); Color color = Color(1.0, 0.8, 0.7); @@ -604,13 +617,21 @@ SpriteEditor::SpriteEditor() { simplification->set_value(2); hb->add_child(simplification); hb->add_spacer(); + hb->add_child(memnew(Label(TTR("Shrink (Pixels): ")))); + shrink_pixels = memnew(SpinBox); + shrink_pixels->set_min(0); + shrink_pixels->set_max(10); + shrink_pixels->set_step(1); + shrink_pixels->set_value(0); + hb->add_child(shrink_pixels); + hb->add_spacer(); hb->add_child(memnew(Label(TTR("Grow (Pixels): ")))); - island_merging = memnew(SpinBox); - island_merging->set_min(0); - island_merging->set_max(10); - island_merging->set_step(1); - island_merging->set_value(2); - hb->add_child(island_merging); + grow_pixels = memnew(SpinBox); + grow_pixels->set_min(0); + grow_pixels->set_max(10); + grow_pixels->set_step(1); + grow_pixels->set_value(2); + hb->add_child(grow_pixels); hb->add_spacer(); update_preview = memnew(Button); update_preview->set_text(TTR("Update Preview")); diff --git a/editor/plugins/sprite_editor_plugin.h b/editor/plugins/sprite_editor_plugin.h index 81be4a19e9..4ca7bca1a8 100644 --- a/editor/plugins/sprite_editor_plugin.h +++ b/editor/plugins/sprite_editor_plugin.h @@ -67,7 +67,8 @@ class SpriteEditor : public Control { Vector<int> computed_indices; SpinBox *simplification; - SpinBox *island_merging; + SpinBox *grow_pixels; + SpinBox *shrink_pixels; Button *update_preview; void _menu_option(int p_option); diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp index e8cd7692b6..d4f985e1de 100644 --- a/editor/plugins/version_control_editor_plugin.cpp +++ b/editor/plugins/version_control_editor_plugin.cpp @@ -380,6 +380,7 @@ void VersionControlEditorPlugin::fetch_available_vcs_addon_names() { String path = ScriptServer::get_global_class_path(global_classes[i]); Ref<Script> script = ResourceLoader::load(path); + ERR_FAIL_COND(script.is_null()); if (script->get_instance_base_type() == "EditorVCSInterface") { diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 82baa99da2..c962751c7a 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -88,7 +88,6 @@ void VisualShaderEditor::edit(VisualShader *p_visual_shader) { } else { if (changed) { // to avoid tree collapse _clear_buffer(); - _update_custom_nodes(); _update_options_menu(); _update_preview(); } @@ -178,7 +177,7 @@ bool VisualShaderEditor::_is_available(int p_mode) { return (p_mode == -1 || (p_mode & current_mode) != 0); } -void VisualShaderEditor::_update_custom_nodes() { +void VisualShaderEditor::update_custom_nodes() { clear_custom_types(); List<StringName> class_list; ScriptServer::get_global_class_list(&class_list); @@ -228,6 +227,7 @@ void VisualShaderEditor::_update_custom_nodes() { add_custom_type(name, script, description, return_icon_type, category, sub_category); } } + _update_options_menu(); } String VisualShaderEditor::_get_description(int p_idx) { @@ -359,8 +359,8 @@ void VisualShaderEditor::_update_options_menu() { case VisualShaderNode::PORT_TYPE_TRANSFORM: item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("Transform", "EditorIcons")); break; - case VisualShaderNode::PORT_TYPE_ICON_COLOR: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("Color", "EditorIcons")); + case VisualShaderNode::PORT_TYPE_SAMPLER: + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("ImageTexture", "EditorIcons")); break; default: break; @@ -437,11 +437,12 @@ void VisualShaderEditor::_update_graph() { } } - static const Color type_color[4] = { + static const Color type_color[5] = { Color(0.38, 0.85, 0.96), // scalar Color(0.84, 0.49, 0.93), // vector Color(0.55, 0.65, 0.94), // boolean - Color(0.96, 0.66, 0.43) // transform + Color(0.96, 0.66, 0.43), // transform + Color(1.0, 1.0, 0.0) // sampler }; List<VisualShader::Connection> connections; @@ -546,14 +547,14 @@ void VisualShaderEditor::_update_graph() { HBoxContainer *hb2 = memnew(HBoxContainer); Button *add_input_btn = memnew(Button); - add_input_btn->set_text(TTR("Add input +")); + add_input_btn->set_text(TTR("Add Input")); add_input_btn->connect("pressed", this, "_add_input_port", varray(nodes[n_i], group_node->get_free_input_port_id(), VisualShaderNode::PORT_TYPE_VECTOR, "input" + itos(group_node->get_free_input_port_id())), CONNECT_DEFERRED); hb2->add_child(add_input_btn); hb2->add_spacer(); Button *add_output_btn = memnew(Button); - add_output_btn->set_text(TTR("Add output +")); + add_output_btn->set_text(TTR("Add Output")); add_output_btn->connect("pressed", this, "_add_output_port", varray(nodes[n_i], group_node->get_free_output_port_id(), VisualShaderNode::PORT_TYPE_VECTOR, "output" + itos(group_node->get_free_output_port_id())), CONNECT_DEFERRED); hb2->add_child(add_output_btn); @@ -640,6 +641,7 @@ void VisualShaderEditor::_update_graph() { type_box->add_item(TTR("Vector")); type_box->add_item(TTR("Boolean")); type_box->add_item(TTR("Transform")); + type_box->add_item(TTR("Sampler")); type_box->select(group_node->get_input_port_type(i)); type_box->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); type_box->connect("item_selected", this, "_change_input_port_type", varray(nodes[n_i], i), CONNECT_DEFERRED); @@ -663,6 +665,15 @@ void VisualShaderEditor::_update_graph() { label->set_text(name_left); label->add_style_override("normal", label_style); //more compact hb->add_child(label); + + if (vsnode->get_input_port_default_hint(i) != "" && !port_left_used) { + + Label *hint_label = memnew(Label); + hint_label->set_text("[" + vsnode->get_input_port_default_hint(i) + "]"); + hint_label->add_color_override("font_color", get_color("font_color_readonly", "TextEdit")); + hint_label->add_style_override("normal", label_style); + hb->add_child(hint_label); + } } } @@ -704,7 +715,7 @@ void VisualShaderEditor::_update_graph() { } } - if (valid_right && edit_type->get_selected() == VisualShader::TYPE_FRAGMENT && port_right != VisualShaderNode::PORT_TYPE_TRANSFORM) { + if (valid_right && edit_type->get_selected() == VisualShader::TYPE_FRAGMENT && port_right != VisualShaderNode::PORT_TYPE_TRANSFORM && port_right != VisualShaderNode::PORT_TYPE_SAMPLER) { TextureButton *preview = memnew(TextureButton); preview->set_toggle_mode(true); preview->set_normal_texture(get_icon("GuiVisibilityHidden", "EditorIcons")); @@ -731,15 +742,19 @@ void VisualShaderEditor::_update_graph() { node->set_slot(i + port_offset, valid_left, port_left, type_color[port_left], valid_right, port_right, type_color[port_right]); } - if (vsnode->get_output_port_for_preview() >= 0 && vsnode->get_output_port_type(vsnode->get_output_port_for_preview()) != VisualShaderNode::PORT_TYPE_TRANSFORM) { - offset = memnew(Control); - offset->set_custom_minimum_size(Size2(0, 5 * EDSCALE)); - node->add_child(offset); + if (vsnode->get_output_port_for_preview() >= 0) { + int port_type = vsnode->get_output_port_type(vsnode->get_output_port_for_preview()); + + if (port_type != VisualShaderNode::PORT_TYPE_TRANSFORM && port_type != VisualShaderNode::PORT_TYPE_SAMPLER) { + offset = memnew(Control); + offset->set_custom_minimum_size(Size2(0, 5 * EDSCALE)); + node->add_child(offset); - VisualShaderNodePortPreview *port_preview = memnew(VisualShaderNodePortPreview); - port_preview->setup(visual_shader, type, nodes[n_i], vsnode->get_output_port_for_preview()); - port_preview->set_h_size_flags(SIZE_SHRINK_CENTER); - node->add_child(port_preview); + VisualShaderNodePortPreview *port_preview = memnew(VisualShaderNodePortPreview); + port_preview->setup(visual_shader, type, nodes[n_i], vsnode->get_output_port_for_preview()); + port_preview->set_h_size_flags(SIZE_SHRINK_CENTER); + node->add_child(port_preview); + } } offset = memnew(Control); @@ -1213,9 +1228,31 @@ void VisualShaderEditor::_edit_port_default_input(Object *p_button, int p_node, editing_port = p_port; } -void VisualShaderEditor::_add_node(int p_idx, int p_op_idx) { +void VisualShaderEditor::_add_custom_node(const String &p_path) { + + int idx = -1; + + for (int i = custom_node_option_idx; i < add_options.size(); i++) { + if (add_options[i].script.is_valid()) { + if (add_options[i].script->get_path() == p_path) { + idx = i; + break; + } + } + } + if (idx != -1) { + _add_node(idx); + } +} + +void VisualShaderEditor::_add_texture_node(const String &p_path) { + VisualShaderNodeTexture *texture = (VisualShaderNodeTexture *)_add_node(texture_node_option_idx, -1); + texture->set_texture(ResourceLoader::load(p_path)); +} + +VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) { - ERR_FAIL_INDEX(p_idx, add_options.size()); + ERR_FAIL_INDEX_V(p_idx, add_options.size(), NULL); Ref<VisualShaderNode> vsnode; @@ -1223,7 +1260,7 @@ void VisualShaderEditor::_add_node(int p_idx, int p_op_idx) { if (!is_custom && add_options[p_idx].type != String()) { VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instance(add_options[p_idx].type)); - ERR_FAIL_COND(!vsn); + ERR_FAIL_COND_V(!vsn, NULL); VisualShaderNodeScalarConstant *constant = Object::cast_to<VisualShaderNodeScalarConstant>(vsn); @@ -1309,10 +1346,10 @@ void VisualShaderEditor::_add_node(int p_idx, int p_op_idx) { vsnode = Ref<VisualShaderNode>(vsn); } else { - ERR_FAIL_COND(add_options[p_idx].script.is_null()); + ERR_FAIL_COND_V(add_options[p_idx].script.is_null(), NULL); String base_type = add_options[p_idx].script->get_instance_base_type(); VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instance(base_type)); - ERR_FAIL_COND(!vsn); + ERR_FAIL_COND_V(!vsn, NULL); vsnode = Ref<VisualShaderNode>(vsn); vsnode->set_script(add_options[p_idx].script.get_ref_ptr()); } @@ -1367,6 +1404,7 @@ void VisualShaderEditor::_add_node(int p_idx, int p_op_idx) { undo_redo->add_do_method(this, "_update_graph"); undo_redo->add_undo_method(this, "_update_graph"); undo_redo->commit_action(); + return vsnode.ptr(); } void VisualShaderEditor::_node_dragged(const Vector2 &p_from, const Vector2 &p_to, int p_node) { @@ -2038,6 +2076,9 @@ bool VisualShaderEditor::can_drop_data_fw(const Point2 &p_point, const Variant & if (d.has("id")) { return true; } + if (d.has("files")) { + return true; + } } return false; @@ -2054,6 +2095,30 @@ void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da saved_node_pos = p_point; saved_node_pos_dirty = true; _add_node(idx, add_options[idx].sub_func); + } else if (d.has("files")) { + if (d["files"].get_type() == Variant::POOL_STRING_ARRAY) { + + int j = 0; + PoolStringArray arr = d["files"]; + for (int i = 0; i < arr.size(); i++) { + + String type = ResourceLoader::get_resource_type(arr[i]); + if (type == "GDScript") { + Ref<Script> script = ResourceLoader::load(arr[i]); + if (script->get_instance_base_type() == "VisualShaderNodeCustom") { + saved_node_pos = p_point + Vector2(0, j * 210 * EDSCALE); + saved_node_pos_dirty = true; + _add_custom_node(arr[i]); + j++; + } + } else if (ClassDB::get_parent_class(type) == "Texture") { + saved_node_pos = p_point + Vector2(0, j * 210 * EDSCALE); + saved_node_pos_dirty = true; + _add_texture_node(arr[i]); + j++; + } + } + } } } } @@ -2191,6 +2256,7 @@ VisualShaderEditor::VisualShaderEditor() { graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_BOOLEAN); graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_VECTOR); graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_TRANSFORM); + graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_SAMPLER); //graph->add_valid_left_disconnect_type(0); graph->set_v_size_flags(SIZE_EXPAND_FILL); graph->connect("connection_request", this, "_connection_request", varray(), CONNECT_DEFERRED); @@ -2214,6 +2280,7 @@ VisualShaderEditor::VisualShaderEditor() { graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShaderNode::PORT_TYPE_VECTOR); graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShaderNode::PORT_TYPE_BOOLEAN); graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShaderNode::PORT_TYPE_TRANSFORM); + graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SAMPLER, VisualShaderNode::PORT_TYPE_SAMPLER); VSeparator *vs = memnew(VSeparator); graph->get_zoom_hbox()->add_child(vs); @@ -2350,8 +2417,8 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("Screen", "Color", "Operators", "VisualShaderNodeColorOp", TTR("Screen operator."), VisualShaderNodeColorOp::OP_SCREEN, VisualShaderNode::PORT_TYPE_VECTOR)); add_options.push_back(AddOption("SoftLight", "Color", "Operators", "VisualShaderNodeColorOp", TTR("SoftLight operator."), VisualShaderNodeColorOp::OP_SOFT_LIGHT, VisualShaderNode::PORT_TYPE_VECTOR)); - add_options.push_back(AddOption("ColorConstant", "Color", "Variables", "VisualShaderNodeColorConstant", TTR("Color constant."), -1, VisualShaderNode::PORT_TYPE_ICON_COLOR)); - add_options.push_back(AddOption("ColorUniform", "Color", "Variables", "VisualShaderNodeColorUniform", TTR("Color uniform."), -1, VisualShaderNode::PORT_TYPE_ICON_COLOR)); + add_options.push_back(AddOption("ColorConstant", "Color", "Variables", "VisualShaderNodeColorConstant", TTR("Color constant."), -1, -1)); + add_options.push_back(AddOption("ColorUniform", "Color", "Variables", "VisualShaderNodeColorUniform", TTR("Color uniform."), -1, -1)); // CONDITIONAL @@ -2557,12 +2624,13 @@ VisualShaderEditor::VisualShaderEditor() { // TEXTURES - add_options.push_back(AddOption("CubeMap", "Textures", "Functions", "VisualShaderNodeCubeMap", TTR("Perform the cubic texture lookup."), -1, VisualShaderNode::PORT_TYPE_ICON_COLOR)); - add_options.push_back(AddOption("Texture", "Textures", "Functions", "VisualShaderNodeTexture", TTR("Perform the texture lookup."), -1, VisualShaderNode::PORT_TYPE_ICON_COLOR)); + add_options.push_back(AddOption("CubeMap", "Textures", "Functions", "VisualShaderNodeCubeMap", TTR("Perform the cubic texture lookup."), -1, -1)); + texture_node_option_idx = add_options.size(); + add_options.push_back(AddOption("Texture", "Textures", "Functions", "VisualShaderNodeTexture", TTR("Perform the texture lookup."), -1, -1)); - add_options.push_back(AddOption("CubeMapUniform", "Textures", "Variables", "VisualShaderNodeCubeMapUniform", TTR("Cubic texture uniform lookup."), -1, VisualShaderNode::PORT_TYPE_ICON_COLOR)); - add_options.push_back(AddOption("TextureUniform", "Textures", "Variables", "VisualShaderNodeTextureUniform", TTR("2D texture uniform lookup."), -1, VisualShaderNode::PORT_TYPE_ICON_COLOR)); - add_options.push_back(AddOption("TextureUniformTriplanar", "Textures", "Variables", "VisualShaderNodeTextureUniformTriplanar", TTR("2D texture uniform lookup with triplanar."), -1, VisualShaderNode::PORT_TYPE_ICON_COLOR, VisualShader::TYPE_FRAGMENT | VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("CubeMapUniform", "Textures", "Variables", "VisualShaderNodeCubeMapUniform", TTR("Cubic texture uniform lookup."), -1, -1)); + add_options.push_back(AddOption("TextureUniform", "Textures", "Variables", "VisualShaderNodeTextureUniform", TTR("2D texture uniform lookup."), -1, -1)); + add_options.push_back(AddOption("TextureUniformTriplanar", "Textures", "Variables", "VisualShaderNodeTextureUniformTriplanar", TTR("2D texture uniform lookup with triplanar."), -1, -1, VisualShader::TYPE_FRAGMENT | VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL)); // TRANSFORM @@ -2666,6 +2734,7 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("DdYS", "Special", "Derivative", "VisualShaderNodeScalarDerivativeFunc", TTR("(Fragment/Light mode only) (Scalar) Derivative in 'y' using local differencing."), VisualShaderNodeScalarDerivativeFunc::FUNC_Y, VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT | VisualShader::TYPE_LIGHT, -1, -1, true)); add_options.push_back(AddOption("Sum", "Special", "Derivative", "VisualShaderNodeVectorDerivativeFunc", TTR("(Fragment/Light mode only) (Vector) Sum of absolute derivative in 'x' and 'y'."), VisualShaderNodeVectorDerivativeFunc::FUNC_SUM, VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT | VisualShader::TYPE_LIGHT, -1, -1, true)); add_options.push_back(AddOption("SumS", "Special", "Derivative", "VisualShaderNodeScalarDerivativeFunc", TTR("(Fragment/Light mode only) (Scalar) Sum of absolute derivative in 'x' and 'y'."), VisualShaderNodeScalarDerivativeFunc::FUNC_SUM, VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT | VisualShader::TYPE_LIGHT, -1, -1, true)); + custom_node_option_idx = add_options.size(); ///////////////////////////////////////////////////////////////////// @@ -2707,6 +2776,7 @@ void VisualShaderEditorPlugin::make_visible(bool p_visible) { //editor->animation_panel_make_visible(true); button->show(); editor->make_bottom_panel_item_visible(visual_shader_editor); + visual_shader_editor->update_custom_nodes(); visual_shader_editor->set_process_input(true); //visual_shader_editor->set_process(true); } else { diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index cd5efc366b..6f77641936 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -137,6 +137,7 @@ class VisualShaderEditor : public VBoxContainer { category = p_category; sub_category = p_sub_category; description = p_description; + sub_func = 0; sub_func_str = p_sub_func; return_type = p_return_type; mode = p_mode; @@ -148,12 +149,15 @@ class VisualShaderEditor : public VBoxContainer { }; Vector<AddOption> add_options; + int texture_node_option_idx; + int custom_node_option_idx; List<String> keyword_list; void _draw_color_over_button(Object *obj, Color p_color); - void _add_node(int p_idx, int p_op_idx = -1); - void _update_custom_nodes(); + void _add_custom_node(const String &p_path); + void _add_texture_node(const String &p_path); + VisualShaderNode *_add_node(int p_idx, int p_op_idx = -1); void _update_options_menu(); void _show_preview_text(); @@ -253,6 +257,7 @@ protected: static void _bind_methods(); public: + void update_custom_nodes(); void add_plugin(const Ref<VisualShaderNodePlugin> &p_plugin); void remove_plugin(const Ref<VisualShaderNodePlugin> &p_plugin); diff --git a/editor/project_export.cpp b/editor/project_export.cpp index c54103f6f7..7456396460 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -1149,11 +1149,15 @@ ProjectExportDialog::ProjectExportDialog() { include_files->connect("item_edited", this, "_tree_changed"); include_filters = memnew(LineEdit); - resources_vb->add_margin_child(TTR("Filters to export non-resource files (comma separated, e.g: *.json, *.txt)"), include_filters); + resources_vb->add_margin_child( + TTR("Filters to export non-resource files/folders\n(comma-separated, e.g: *.json, *.txt, docs/*)"), + include_filters); include_filters->connect("text_changed", this, "_filter_changed"); exclude_filters = memnew(LineEdit); - resources_vb->add_margin_child(TTR("Filters to exclude files from project (comma separated, e.g: *.json, *.txt)"), exclude_filters); + resources_vb->add_margin_child( + TTR("Filters to exclude files/folders from project\n(comma-separated, e.g: *.json, *.txt, docs/*)"), + exclude_filters); exclude_filters->connect("text_changed", this, "_filter_changed"); VBoxContainer *patch_vb = memnew(VBoxContainer); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index f70dcab931..d903e153a7 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -1753,6 +1753,12 @@ void ProjectManager::_notification(int p_what) { Engine::get_singleton()->set_editor_hint(false); } break; + case NOTIFICATION_RESIZED: { + + if (open_templates->is_visible()) { + open_templates->popup_centered_minsize(); + } + } break; case NOTIFICATION_READY: { if (_project_list->get_project_count() == 0 && StreamPeerSSL::is_available()) diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index d42f15cce8..35187214a6 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -74,6 +74,26 @@ static const char *_axis_names[JOY_AXIS_MAX * 2] = { "", " (R2)" }; +void ProjectSettingsEditor::_unhandled_input(const Ref<InputEvent> &p_event) { + + const Ref<InputEventKey> k = p_event; + + if (k.is_valid() && is_window_modal_on_top() && k->is_pressed()) { + + if (k->get_scancode_with_modifiers() == (KEY_MASK_CMD | KEY_F)) { + if (search_button->is_pressed()) { + search_box->grab_focus(); + search_box->select_all(); + } else { + // This toggles the search bar display while giving the button its "pressed" appearance + search_button->set_pressed(true); + } + + accept_event(); + } + } +} + void ProjectSettingsEditor::_notification(int p_what) { switch (p_what) { @@ -116,6 +136,7 @@ void ProjectSettingsEditor::_notification(int p_what) { } break; case NOTIFICATION_POPUP_HIDE: { EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "project_settings", get_rect()); + set_process_unhandled_input(false); } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { search_button->set_icon(get_icon("Search", "EditorIcons")); @@ -800,6 +821,7 @@ void ProjectSettingsEditor::popup_project_settings() { _update_translations(); autoload_settings->update_autoload(); plugin_settings->update_plugins(); + set_process_unhandled_input(true); } void ProjectSettingsEditor::update_plugins() { @@ -823,13 +845,9 @@ void ProjectSettingsEditor::_item_adds(String) { void ProjectSettingsEditor::_item_add() { - Variant value; - switch (type->get_selected()) { - case 0: value = false; break; - case 1: value = 0; break; - case 2: value = 0.0; break; - case 3: value = ""; break; - } + // Initialize the property with the default value for the given type + Variant::CallError ce; + const Variant value = Variant::construct(Variant::Type(type->get_selected()), NULL, 0, ce); String catname = category->get_text().strip_edges(); String propname = property->get_text().strip_edges(); @@ -1078,7 +1096,7 @@ bool ProjectSettingsEditor::can_drop_data_fw(const Point2 &p_point, const Varian TreeItem *selected = input_editor->get_selected(); TreeItem *item = input_editor->get_item_at_position(p_point); - if (!selected || !item || item->get_parent() == selected) + if (!selected || !item || item == selected || item->get_parent() == selected) return false; return true; @@ -1697,6 +1715,7 @@ void ProjectSettingsEditor::_editor_restart_close() { void ProjectSettingsEditor::_bind_methods() { + ClassDB::bind_method(D_METHOD("_unhandled_input"), &ProjectSettingsEditor::_unhandled_input); ClassDB::bind_method(D_METHOD("_item_selected"), &ProjectSettingsEditor::_item_selected); ClassDB::bind_method(D_METHOD("_item_add"), &ProjectSettingsEditor::_item_add); ClassDB::bind_method(D_METHOD("_item_adds"), &ProjectSettingsEditor::_item_adds); @@ -1811,10 +1830,11 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { type = memnew(OptionButton); type->set_h_size_flags(Control::SIZE_EXPAND_FILL); add_prop_bar->add_child(type); - type->add_item("bool"); - type->add_item("int"); - type->add_item("float"); - type->add_item("string"); + + // Start at 1 to avoid adding "Nil" as an option + for (int i = 1; i < Variant::VARIANT_MAX; i++) { + type->add_item(Variant::get_type_name(Variant::Type(i)), i); + } Button *add = memnew(Button); add_prop_bar->add_child(add); diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h index 4dfd8ba602..c164b49d0e 100644 --- a/editor/project_settings_editor.h +++ b/editor/project_settings_editor.h @@ -178,6 +178,7 @@ class ProjectSettingsEditor : public AcceptDialog { void _editor_restart_close(); protected: + void _unhandled_input(const Ref<InputEvent> &p_event); void _notification(int p_what); static void _bind_methods(); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 9afe99c16d..98ab1bfb54 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -714,9 +714,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().create_action(TTR("Make node as Root")); editor_data->get_undo_redo().add_do_method(node->get_parent(), "remove_child", node); - editor_data->get_undo_redo().add_do_method(root->get_parent(), "remove_child", root); - editor_data->get_undo_redo().add_do_method(node, "add_child", root); editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", node); + editor_data->get_undo_redo().add_do_method(node, "add_child", root); editor_data->get_undo_redo().add_do_method(node, "set_filename", root->get_filename()); editor_data->get_undo_redo().add_do_method(root, "set_filename", String()); editor_data->get_undo_redo().add_do_method(node, "set_owner", (Object *)NULL); @@ -728,14 +727,13 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_undo_method(node, "remove_child", root); editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", root); editor_data->get_undo_redo().add_undo_method(node->get_parent(), "add_child", node); + editor_data->get_undo_redo().add_undo_method(node->get_parent(), "move_child", node, node->get_index()); editor_data->get_undo_redo().add_undo_method(root, "set_owner", (Object *)NULL); editor_data->get_undo_redo().add_undo_method(node, "set_owner", root); - _node_replace_owner(root, root, root, MODE_UNDO); editor_data->get_undo_redo().add_do_method(scene_tree, "update_tree"); editor_data->get_undo_redo().add_undo_method(scene_tree, "update_tree"); - editor_data->get_undo_redo().add_undo_reference(root); editor_data->get_undo_redo().commit_action(); } break; case TOOL_MULTI_EDIT: { diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index f1fc4eb950..dc5eb4bbd0 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -959,6 +959,7 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from HBoxContainer *hb = memnew(HBoxContainer); TextureRect *tf = memnew(TextureRect); tf->set_texture(icons[i]); + tf->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED); hb->add_child(tf); Label *label = memnew(Label(selected[i]->get_name())); hb->add_child(label); diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index e96dfdd7b9..89d275a90b 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -728,6 +728,10 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da } variables->add_property("Members/" + n, v, h, hs); + + if (n == "self") { + _scene_tree_property_select_object(v); + } } ofs += mcount * 2; diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index c9c1f9c3e0..f8425ebe22 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -140,32 +140,35 @@ void EditorSettingsDialog::_notification(int p_what) { void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) { - Ref<InputEventKey> k = p_event; + const Ref<InputEventKey> k = p_event; - if (k.is_valid() && is_window_modal_on_top()) { + if (k.is_valid() && is_window_modal_on_top() && k->is_pressed()) { - if (k->is_pressed()) { + bool handled = false; - bool handled = false; + if (ED_IS_SHORTCUT("editor/undo", p_event)) { + String action = undo_redo->get_current_action_name(); + if (action != "") + EditorNode::get_log()->add_message("Undo: " + action, EditorLog::MSG_TYPE_EDITOR); + undo_redo->undo(); + handled = true; + } - if (ED_IS_SHORTCUT("editor/undo", p_event)) { - String action = undo_redo->get_current_action_name(); - if (action != "") - EditorNode::get_log()->add_message("Undo: " + action, EditorLog::MSG_TYPE_EDITOR); - undo_redo->undo(); - handled = true; - } - if (ED_IS_SHORTCUT("editor/redo", p_event)) { - undo_redo->redo(); - String action = undo_redo->get_current_action_name(); - if (action != "") - EditorNode::get_log()->add_message("Redo: " + action, EditorLog::MSG_TYPE_EDITOR); - handled = true; - } + if (ED_IS_SHORTCUT("editor/redo", p_event)) { + undo_redo->redo(); + String action = undo_redo->get_current_action_name(); + if (action != "") + EditorNode::get_log()->add_message("Redo: " + action, EditorLog::MSG_TYPE_EDITOR); + handled = true; + } - if (handled) { - accept_event(); - } + if (k->get_scancode_with_modifiers() == (KEY_MASK_CMD | KEY_F)) { + _focus_current_search_box(); + handled = true; + } + + if (handled) { + accept_event(); } } } @@ -408,7 +411,6 @@ EditorSettingsDialog::EditorSettingsDialog() { tabs->set_tab_align(TabContainer::ALIGN_LEFT); tabs->connect("tab_changed", this, "_tabs_tab_changed"); add_child(tabs); - //set_child_rect(tabs); // General Tab @@ -425,7 +427,6 @@ EditorSettingsDialog::EditorSettingsDialog() { hbc->add_child(search_box); inspector = memnew(SectionedInspector); - //inspector->hide_top_label(); inspector->get_inspector()->set_use_filter(true); inspector->register_search_box(search_box); inspector->set_v_size_flags(Control::SIZE_EXPAND_FILL); @@ -474,7 +475,6 @@ EditorSettingsDialog::EditorSettingsDialog() { shortcuts->set_v_size_flags(SIZE_EXPAND_FILL); shortcuts->set_columns(2); shortcuts->set_hide_root(true); - //shortcuts->set_hide_folding(true); shortcuts->set_column_titles_visible(true); shortcuts->set_column_title(0, TTR("Name")); shortcuts->set_column_title(1, TTR("Binding")); @@ -495,9 +495,7 @@ EditorSettingsDialog::EditorSettingsDialog() { press_a_key->connect("gui_input", this, "_wait_for_key"); press_a_key->connect("confirmed", this, "_press_a_key_confirm"); - //get_ok()->set_text("Apply"); set_hide_on_ok(true); - //get_cancel()->set_text("Close"); timer = memnew(Timer); timer->set_wait_time(1.5); |