diff options
22 files changed, 240 insertions, 87 deletions
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 3663bdee27..5ea7081667 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -1411,6 +1411,9 @@ String EditorFileSystem::_get_global_script_class(const String &p_type, const St } void EditorFileSystem::_scan_script_classes(EditorFileSystemDirectory *p_dir) { + if (p_dir->parent && p_dir->parent->name == "addons" && !EditorNode::get_singleton()->is_addon_plugin_enabled(p_dir->name)) { + return; + } int filecount = p_dir->files.size(); const EditorFileSystemDirectory::FileInfo *const *files = p_dir->files.ptr(); for (int i = 0; i < filecount; i++) { 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_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/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index a11c35e5f2..b1e8ce20d6 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -5528,6 +5528,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..9d3c580f02 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); 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/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 1e083eff52..127cead57f 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -3230,6 +3230,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) { @@ -3279,6 +3280,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)); 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..7fd6e517b5 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -546,14 +546,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); @@ -1213,9 +1213,14 @@ 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_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 +1228,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 +1314,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 +1372,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 +2044,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 +2063,20 @@ 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) { + + PoolStringArray arr = d["files"]; + for (int i = 0; i < arr.size(); i++) { + + String type = ResourceLoader::get_resource_type(arr[i]); + if (ClassDB::get_parent_class(type) == "Texture") { + saved_node_pos = p_point + Vector2(0, i * 210 * EDSCALE); + saved_node_pos_dirty = true; + _add_texture_node(arr[i]); + } + } + } } } } @@ -2558,6 +2581,7 @@ VisualShaderEditor::VisualShaderEditor() { // TEXTURES add_options.push_back(AddOption("CubeMap", "Textures", "Functions", "VisualShaderNodeCubeMap", TTR("Perform the cubic texture lookup."), -1, VisualShaderNode::PORT_TYPE_ICON_COLOR)); + texture_node_option_idx = add_options.size(); 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("CubeMapUniform", "Textures", "Variables", "VisualShaderNodeCubeMapUniform", TTR("Cubic texture uniform lookup."), -1, VisualShaderNode::PORT_TYPE_ICON_COLOR)); diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index cd5efc366b..d56e223057 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -148,11 +148,13 @@ class VisualShaderEditor : public VBoxContainer { }; Vector<AddOption> add_options; + int texture_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 _add_texture_node(const String &p_path); + VisualShaderNode *_add_node(int p_idx, int p_op_idx = -1); void _update_custom_nodes(); void _update_options_menu(); 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/main/main.cpp b/main/main.cpp index bff7633188..6df02af3a5 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -444,6 +444,32 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph if (I->next()) { audio_driver = I->next()->get(); + + bool found = false; + for (int i = 0; i < OS::get_singleton()->get_audio_driver_count(); i++) { + if (audio_driver == OS::get_singleton()->get_audio_driver_name(i)) { + found = true; + } + } + + if (!found) { + OS::get_singleton()->print("Unknown audio driver '%s', aborting.\nValid options are ", audio_driver.utf8().get_data()); + + for (int i = 0; i < OS::get_singleton()->get_audio_driver_count(); i++) { + if (i == OS::get_singleton()->get_audio_driver_count() - 1) { + OS::get_singleton()->print(" and "); + } else if (i != 0) { + OS::get_singleton()->print(", "); + } + + OS::get_singleton()->print("'%s'", OS::get_singleton()->get_audio_driver_name(i)); + } + + OS::get_singleton()->print(".\n"); + + goto error; + } + N = I->next()->next(); } else { OS::get_singleton()->print("Missing audio driver argument, aborting.\n"); @@ -455,6 +481,32 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph if (I->next()) { video_driver = I->next()->get(); + + bool found = false; + for (int i = 0; i < OS::get_singleton()->get_video_driver_count(); i++) { + if (video_driver == OS::get_singleton()->get_video_driver_name(i)) { + found = true; + } + } + + if (!found) { + OS::get_singleton()->print("Unknown video driver '%s', aborting.\nValid options are ", video_driver.utf8().get_data()); + + for (int i = 0; i < OS::get_singleton()->get_video_driver_count(); i++) { + if (i == OS::get_singleton()->get_video_driver_count() - 1) { + OS::get_singleton()->print(" and "); + } else if (i != 0) { + OS::get_singleton()->print(", "); + } + + OS::get_singleton()->print("'%s'", OS::get_singleton()->get_video_driver_name(i)); + } + + OS::get_singleton()->print(".\n"); + + goto error; + } + N = I->next()->next(); } else { OS::get_singleton()->print("Missing video driver argument, aborting.\n"); @@ -989,10 +1041,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } if (video_driver_idx < 0) { - - //OS::get_singleton()->alert("Invalid Video Driver: " + video_driver); video_driver_idx = 0; - //goto error; } if (audio_driver == "") { // specified in project.godot @@ -1009,10 +1058,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } if (audio_driver_idx < 0) { - - OS::get_singleton()->alert("Invalid Audio Driver: " + audio_driver); audio_driver_idx = 0; - //goto error; } { diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index 963b40529d..ee7313957c 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -247,7 +247,7 @@ Map<int, TextEdit::HighlighterInfo> GDScriptSyntaxHighlighter::_get_line_syntax_ in_function_args = false; } - if (expect_type && prev_is_char) { + if (expect_type && (prev_is_char || str[j] == '=')) { expect_type = false; } diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 0399dbc87c..093901ad07 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -1166,13 +1166,11 @@ void VisualScriptEditor::_member_edited() { } void VisualScriptEditor::_create_function_dialog() { - function_create_dialog->popup(); - function_create_dialog->set_position(graph->get_global_position() + Vector2(55, 80)); + function_create_dialog->popup_centered(); func_name_box->set_text(""); func_name_box->grab_focus(); for (int i = 0; i < func_input_vbox->get_child_count(); i++) { Node *nd = func_input_vbox->get_child(i); - func_input_vbox->remove_child(nd); nd->queue_delete(); } } @@ -1252,7 +1250,6 @@ void VisualScriptEditor::_add_func_input() { func_input_vbox->add_child(hbox); hbox->set_meta("id", hbox->get_position_in_parent()); - function_create_dialog->set_size(Size2(-1, -1)); delete_button->connect("pressed", this, "_remove_func_input", varray(hbox)); @@ -1263,7 +1260,6 @@ void VisualScriptEditor::_add_func_input() { void VisualScriptEditor::_remove_func_input(Node *p_node) { func_input_vbox->remove_child(p_node); p_node->queue_delete(); - function_create_dialog->set_size(Size2(-1, -1)); } void VisualScriptEditor::_deselect_input_names() { @@ -1353,6 +1349,8 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt selected = ti->get_text(0); function_name_edit->set_position(Input::get_singleton()->get_mouse_position() - Vector2(60, -10)); function_name_edit->popup(); + function_name_box->set_text(selected); + function_name_box->select_all(); } } @@ -1757,8 +1755,7 @@ void VisualScriptEditor::_members_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> btn = p_event; if (btn.is_valid() && btn->is_doubleclick()) { TreeItem *ti = members->get_selected(); - ERR_FAIL_COND(!ti); - if (ti->get_parent() == members->get_root()->get_children()) // to check if it's a function + if (ti && ti->get_parent() == members->get_root()->get_children()) // to check if it's a function _center_on_node(ti->get_metadata(0), script->get_function_node_id(ti->get_metadata(0))); } } @@ -3907,51 +3904,62 @@ void VisualScriptEditor::_hide_timer() { void VisualScriptEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_READY || (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree())) { - if (p_what == NOTIFICATION_READY) { + switch (p_what) { + case NOTIFICATION_READY: { variable_editor->connect("changed", this, "_update_members"); signal_editor->connect("changed", this, "_update_members"); + FALLTHROUGH; } + case NOTIFICATION_THEME_CHANGED: { + if (p_what != NOTIFICATION_READY && !is_visible_in_tree()) { + return; + } - Ref<Theme> tm = EditorNode::get_singleton()->get_theme_base()->get_theme(); + edit_variable_edit->add_style_override("bg", get_stylebox("bg", "Tree")); + edit_signal_edit->add_style_override("bg", get_stylebox("bg", "Tree")); + func_input_scroll->add_style_override("bg", get_stylebox("bg", "Tree")); - bool dark_theme = tm->get_constant("dark_theme", "Editor"); + Ref<Theme> tm = EditorNode::get_singleton()->get_theme_base()->get_theme(); - List<Pair<String, Color> > colors; - if (dark_theme) { - colors.push_back(Pair<String, Color>("flow_control", Color(0.96, 0.96, 0.96))); - colors.push_back(Pair<String, Color>("functions", Color(0.96, 0.52, 0.51))); - colors.push_back(Pair<String, Color>("data", Color(0.5, 0.96, 0.81))); - colors.push_back(Pair<String, Color>("operators", Color(0.67, 0.59, 0.87))); - colors.push_back(Pair<String, Color>("custom", Color(0.5, 0.73, 0.96))); - colors.push_back(Pair<String, Color>("constants", Color(0.96, 0.5, 0.69))); - } else { - colors.push_back(Pair<String, Color>("flow_control", Color(0.26, 0.26, 0.26))); - colors.push_back(Pair<String, Color>("functions", Color(0.95, 0.4, 0.38))); - colors.push_back(Pair<String, Color>("data", Color(0.07, 0.73, 0.51))); - colors.push_back(Pair<String, Color>("operators", Color(0.51, 0.4, 0.82))); - colors.push_back(Pair<String, Color>("custom", Color(0.31, 0.63, 0.95))); - colors.push_back(Pair<String, Color>("constants", Color(0.94, 0.18, 0.49))); - } + bool dark_theme = tm->get_constant("dark_theme", "Editor"); - for (List<Pair<String, Color> >::Element *E = colors.front(); E; E = E->next()) { - Ref<StyleBoxFlat> sb = tm->get_stylebox("frame", "GraphNode"); - if (!sb.is_null()) { - Ref<StyleBoxFlat> frame_style = sb->duplicate(); - Color c = sb->get_border_color(); - Color cn = E->get().second; - cn.a = c.a; - frame_style->set_border_color(cn); - node_styles[E->get().first] = frame_style; + List<Pair<String, Color> > colors; + if (dark_theme) { + colors.push_back(Pair<String, Color>("flow_control", Color(0.96, 0.96, 0.96))); + colors.push_back(Pair<String, Color>("functions", Color(0.96, 0.52, 0.51))); + colors.push_back(Pair<String, Color>("data", Color(0.5, 0.96, 0.81))); + colors.push_back(Pair<String, Color>("operators", Color(0.67, 0.59, 0.87))); + colors.push_back(Pair<String, Color>("custom", Color(0.5, 0.73, 0.96))); + colors.push_back(Pair<String, Color>("constants", Color(0.96, 0.5, 0.69))); + } else { + colors.push_back(Pair<String, Color>("flow_control", Color(0.26, 0.26, 0.26))); + colors.push_back(Pair<String, Color>("functions", Color(0.95, 0.4, 0.38))); + colors.push_back(Pair<String, Color>("data", Color(0.07, 0.73, 0.51))); + colors.push_back(Pair<String, Color>("operators", Color(0.51, 0.4, 0.82))); + colors.push_back(Pair<String, Color>("custom", Color(0.31, 0.63, 0.95))); + colors.push_back(Pair<String, Color>("constants", Color(0.94, 0.18, 0.49))); } - } - if (is_visible_in_tree() && script.is_valid()) { - _update_members(); - _update_graph(); - } - } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - members_section->set_visible(is_visible_in_tree()); + for (List<Pair<String, Color> >::Element *E = colors.front(); E; E = E->next()) { + Ref<StyleBoxFlat> sb = tm->get_stylebox("frame", "GraphNode"); + if (!sb.is_null()) { + Ref<StyleBoxFlat> frame_style = sb->duplicate(); + Color c = sb->get_border_color(); + Color cn = E->get().second; + cn.a = c.a; + frame_style->set_border_color(cn); + node_styles[E->get().first] = frame_style; + } + } + + if (is_visible_in_tree() && script.is_valid()) { + _update_members(); + _update_graph(); + } + } break; + case NOTIFICATION_VISIBILITY_CHANGED: { + members_section->set_visible(is_visible_in_tree()); + } break; } } @@ -4541,6 +4549,8 @@ void VisualScriptEditor::_member_option(int p_option) { } else if (p_option == MEMBER_EDIT) { selected = members->get_selected()->get_text(0); function_name_edit->popup(); + function_name_box->set_text(selected); + function_name_box->select_all(); } } break; case MEMBER_VARIABLE: { @@ -4762,7 +4772,7 @@ VisualScriptEditor::VisualScriptEditor() { add_nds->connect("pressed", this, "_add_node_dialog"); Button *fn_btn = memnew(Button); - fn_btn->set_text("Add Function"); + fn_btn->set_text("Add Function..."); graph_hbc->add_child(fn_btn); fn_btn->connect("pressed", this, "_create_function_dialog"); @@ -4790,17 +4800,20 @@ VisualScriptEditor::VisualScriptEditor() { Button *add_input_button = memnew(Button); add_input_button->set_h_size_flags(SIZE_EXPAND_FILL); - add_input_button->set_text(TTR("Add input +")); + add_input_button->set_text(TTR("Add Input")); add_input_button->connect("pressed", this, "_add_func_input"); function_vb->add_child(add_input_button); - func_input_vbox = memnew(VBoxContainer); - function_vb->add_child(func_input_vbox); + func_input_scroll = memnew(ScrollContainer); + func_input_scroll->set_v_size_flags(SIZE_EXPAND_FILL); + function_vb->add_child(func_input_scroll); - function_vb->add_child(memnew(HSeparator)); + func_input_vbox = memnew(VBoxContainer); + func_input_vbox->set_h_size_flags(SIZE_EXPAND_FILL); + func_input_scroll->add_child(func_input_vbox); function_create_dialog = memnew(ConfirmationDialog); - function_create_dialog->set_custom_minimum_size(Size2(450 * EDSCALE, 0)); + function_create_dialog->set_custom_minimum_size(Size2(450, 300) * EDSCALE); function_create_dialog->set_v_size_flags(SIZE_EXPAND_FILL); function_create_dialog->set_title(TTR("Create Function")); function_create_dialog->add_child(function_vb); diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h index 0e7783214b..5a00469eea 100644 --- a/modules/visual_script/visual_script_editor.h +++ b/modules/visual_script/visual_script_editor.h @@ -89,6 +89,7 @@ class VisualScriptEditor : public ScriptEditorBase { Button *base_type_select; LineEdit *func_name_box; + ScrollContainer *func_input_scroll; VBoxContainer *func_input_vbox; ConfirmationDialog *function_create_dialog; diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index dbcd3c19f8..957127fe61 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -4075,6 +4075,14 @@ VisualScriptDeconstruct::VisualScriptDeconstruct() { type = Variant::NIL; } +template <Variant::Type T> +static Ref<VisualScriptNode> create_node_deconst_typed(const String &p_name) { + Ref<VisualScriptDeconstruct> node; + node.instance(); + node->set_deconstruct_type(T); + return node; +} + void register_visual_script_nodes() { VisualScriptLanguage::singleton->add_register_func("data/set_variable", create_node_generic<VisualScriptVariableSet>); @@ -4132,7 +4140,16 @@ void register_visual_script_nodes() { VisualScriptLanguage::singleton->add_register_func("operators/logic/in", create_op_node<Variant::OP_IN>); VisualScriptLanguage::singleton->add_register_func("operators/logic/select", create_node_generic<VisualScriptSelect>); - VisualScriptLanguage::singleton->add_register_func("functions/deconstruct", create_node_generic<VisualScriptDeconstruct>); + VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::VECTOR2), create_node_deconst_typed<Variant::Type::VECTOR2>); + VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::VECTOR3), create_node_deconst_typed<Variant::Type::VECTOR3>); + VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::COLOR), create_node_deconst_typed<Variant::Type::COLOR>); + VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::RECT2), create_node_deconst_typed<Variant::Type::RECT2>); + VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::TRANSFORM2D), create_node_deconst_typed<Variant::Type::TRANSFORM2D>); + VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::PLANE), create_node_deconst_typed<Variant::Type::PLANE>); + VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::QUAT), create_node_deconst_typed<Variant::Type::QUAT>); + VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::AABB), create_node_deconst_typed<Variant::Type::AABB>); + VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::BASIS), create_node_deconst_typed<Variant::Type::BASIS>); + VisualScriptLanguage::singleton->add_register_func("functions/deconstruct/" + Variant::get_type_name(Variant::Type::TRANSFORM), create_node_deconst_typed<Variant::Type::TRANSFORM>); VisualScriptLanguage::singleton->add_register_func("functions/compose_array", create_node_generic<VisualScriptComposeArray>); for (int i = 1; i < Variant::VARIANT_MAX; i++) { diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp index 0366801a11..42d4c5e209 100644 --- a/modules/visual_script/visual_script_property_selector.cpp +++ b/modules/visual_script/visual_script_property_selector.cpp @@ -271,6 +271,7 @@ void VisualScriptPropertySelector::_update_search() { get_visual_node_names("flow_control/type_cast", Set<String>(), found, root, search_box); get_visual_node_names("functions/built_in/print", Set<String>(), found, root, search_box); get_visual_node_names("functions/by_type/" + Variant::get_type_name(type), Set<String>(), found, root, search_box); + get_visual_node_names("functions/deconstruct/" + Variant::get_type_name(type), Set<String>(), found, root, search_box); get_visual_node_names("operators/compare/", Set<String>(), found, root, search_box); if (type == Variant::INT) { get_visual_node_names("operators/bitwise/", Set<String>(), found, root, search_box); @@ -324,7 +325,7 @@ void VisualScriptPropertySelector::create_visualscript_item(const String &name, } } -void VisualScriptPropertySelector::get_visual_node_names(const String &root_filter, const Set<String> &filter, bool &found, TreeItem *const root, LineEdit *const search_box) { +void VisualScriptPropertySelector::get_visual_node_names(const String &root_filter, const Set<String> &p_modifiers, bool &found, TreeItem *const root, LineEdit *const search_box) { Map<String, TreeItem *> path_cache; List<String> fnodes; @@ -335,27 +336,34 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt continue; } Vector<String> path = E->get().split("/"); - bool is_filter = false; - for (Set<String>::Element *F = filter.front(); F; F = F->next()) { - if (path.size() >= 2 && path[1].findn(F->get()) != -1) { - is_filter = true; + + // check if the name has the filter + bool in_filter = false; + Vector<String> tx_filters = search_box->get_text().split(" "); + for (int i = 0; i < tx_filters.size(); i++) { + if (tx_filters[i] == "") { + in_filter = true; + } else { + in_filter = false; + } + if (E->get().findn(tx_filters[i]) != -1) { + in_filter = true; break; } } - if (is_filter) { + if (!in_filter) { continue; } - Vector<String> tx_filters = search_box->get_text().split(" "); - for (int i = 0; i < tx_filters.size(); i++) { - if (tx_filters[i] != String() && E->get().findn(tx_filters[i]) == -1) { - is_filter = true; - break; - } + bool in_modifier = false | p_modifiers.empty(); + for (Set<String>::Element *F = p_modifiers.front(); F && in_modifier; F = F->next()) { + if (E->get().findn(F->get()) != -1) + in_modifier = true; } - if (is_filter) { + if (!in_modifier) { continue; } + TreeItem *item = search_options->create_item(root); Ref<VisualScriptNode> vnode = VisualScriptLanguage::singleton->create_node_from_name(E->get()); Ref<VisualScriptOperator> vnode_operator = vnode; @@ -376,6 +384,10 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt if (vnode_constructor.is_valid()) { type_name = "Construct "; } + Ref<VisualScriptDeconstruct> vnode_deconstruct = vnode; + if (vnode_deconstruct.is_valid()) { + type_name = "Deconstruct "; + } Vector<String> desc = path[path.size() - 1].replace("(", " ").replace(")", " ").replace(",", " ").split(" "); for (int i = 0; i < desc.size(); i++) { desc.write[i] = desc[i].capitalize(); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 75c845b8db..e2bb4e3e91 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3965,7 +3965,7 @@ void TextEdit::_base_remove_text(int p_from_line, int p_from_column, int p_to_li void TextEdit::_insert_text(int p_line, int p_char, const String &p_text, int *r_end_line, int *r_end_char) { - if (!setting_text) + if (!setting_text && idle_detect->is_inside_tree()) idle_detect->start(); if (undo_enabled) { @@ -4019,7 +4019,7 @@ void TextEdit::_insert_text(int p_line, int p_char, const String &p_text, int *r void TextEdit::_remove_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column) { - if (!setting_text) + if (!setting_text && idle_detect->is_inside_tree()) idle_detect->start(); String text; diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 0465c9305b..3ee21ce38b 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -561,6 +561,8 @@ bool SceneTree::idle(float p_time) { E = N; } + flush_transform_notifications(); //additional transforms after timers update + _call_idle_callbacks(); #ifdef TOOLS_ENABLED diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 5704212831..99a2881d58 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -192,7 +192,7 @@ Error DynamicFontAtSize::_load() { ERR_FAIL_V_MSG(ERR_FILE_CANT_OPEN, "Error loading font."); } - if (FT_HAS_COLOR(face)) { + if (FT_HAS_COLOR(face) && face->num_fixed_sizes > 0) { int best_match = 0; int diff = ABS(id.size - ((int64_t)face->available_sizes[0].width)); scale_color_font = float(id.size) / face->available_sizes[0].width; |