diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/audio_stream_preview.h | 9 | ||||
-rw-r--r-- | editor/editor_node.cpp | 25 | ||||
-rw-r--r-- | editor/editor_node.h | 3 | ||||
-rw-r--r-- | editor/editor_vcs_interface.h | 20 | ||||
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.cpp | 16 | ||||
-rw-r--r-- | editor/plugins/visual_shader_editor_plugin.cpp | 7 | ||||
-rw-r--r-- | editor/plugins/voxel_gi_editor_plugin.cpp | 5 | ||||
-rw-r--r-- | editor/scene_tree_dock.cpp | 18 | ||||
-rw-r--r-- | editor/scene_tree_dock.h | 1 |
9 files changed, 76 insertions, 28 deletions
diff --git a/editor/audio_stream_preview.h b/editor/audio_stream_preview.h index 61567598ed..9cf47fd51a 100644 --- a/editor/audio_stream_preview.h +++ b/editor/audio_stream_preview.h @@ -75,6 +75,15 @@ class AudioStreamPreviewGenerator : public Node { thread = p_rhs.thread; return *this; } + Preview(const Preview &p_rhs) { + preview = p_rhs.preview; + base_stream = p_rhs.base_stream; + playback = p_rhs.playback; + generating.set_to(generating.is_set()); + id = p_rhs.id; + thread = p_rhs.thread; + } + Preview() {} }; Map<ObjectID, Preview> previews; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 0f8a645dfe..e7c0b02ae2 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3875,6 +3875,21 @@ Ref<ImageTexture> EditorNode::_load_custom_class_icon(const String &p_path) cons return nullptr; } +void EditorNode::_pick_main_scene_custom_action(const String &p_custom_action_name) { + if (p_custom_action_name == "select_current") { + Node *scene = editor_data.get_edited_scene_root(); + + if (!scene) { + show_accept(TTR("There is no defined scene to run."), TTR("OK")); + return; + } + + pick_main_scene->hide(); + current_option = SETTINGS_PICK_MAIN_SCENE; + _dialog_action(scene->get_filename()); + } +} + Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) const { ERR_FAIL_COND_V(!p_object || !gui_base, nullptr); @@ -4669,6 +4684,14 @@ bool EditorNode::ensure_main_scene(bool p_from_native) { current_option = -1; pick_main_scene->set_text(TTR("No main scene has ever been defined, select one?\nYou can change it later in \"Project Settings\" under the 'application' category.")); pick_main_scene->popup_centered(); + + if (editor_data.get_edited_scene_root()) { + select_current_scene_button->set_disabled(false); + select_current_scene_button->grab_focus(); + } else { + select_current_scene_button->set_disabled(true); + } + return false; } @@ -6946,6 +6969,8 @@ EditorNode::EditorNode() { gui_base->add_child(pick_main_scene); pick_main_scene->get_ok_button()->set_text(TTR("Select")); pick_main_scene->connect("confirmed", callable_mp(this, &EditorNode::_menu_option), varray(SETTINGS_PICK_MAIN_SCENE)); + select_current_scene_button = pick_main_scene->add_button(TTR("Select Current"), true, "select_current"); + pick_main_scene->connect("custom_action", callable_mp(this, &EditorNode::_pick_main_scene_custom_action)); for (int i = 0; i < _init_callbacks.size(); i++) { _init_callbacks[i](); diff --git a/editor/editor_node.h b/editor/editor_node.h index dcb6ad6e94..07bed6999b 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -301,6 +301,7 @@ private: ConfirmationDialog *save_confirmation; ConfirmationDialog *import_confirmation; ConfirmationDialog *pick_main_scene; + Button *select_current_scene_button; AcceptDialog *accept; EditorAbout *about; AcceptDialog *warning; @@ -663,6 +664,8 @@ private: bool _is_class_editor_disabled_by_feature_profile(const StringName &p_class); Ref<ImageTexture> _load_custom_class_icon(const String &p_path) const; + void _pick_main_scene_custom_action(const String &p_custom_action_name); + protected: void _notification(int p_what); diff --git a/editor/editor_vcs_interface.h b/editor/editor_vcs_interface.h index af952eaffc..52ab6d68ee 100644 --- a/editor/editor_vcs_interface.h +++ b/editor/editor_vcs_interface.h @@ -46,16 +46,16 @@ protected: static void _bind_methods(); // Implemented by addons as end points for the proxy functions - bool _initialize(String p_project_root_path); - bool _is_vcs_initialized(); - Dictionary _get_modified_files_data(); - void _stage_file(String p_file_path); - void _unstage_file(String p_file_path); - void _commit(String p_msg); - Array _get_file_diff(String p_file_path); - bool _shut_down(); - String _get_project_name(); - String _get_vcs_name(); + virtual bool _initialize(String p_project_root_path); + virtual bool _is_vcs_initialized(); + virtual Dictionary _get_modified_files_data(); + virtual void _stage_file(String p_file_path); + virtual void _unstage_file(String p_file_path); + virtual void _commit(String p_msg); + virtual Array _get_file_diff(String p_file_path); + virtual bool _shut_down(); + virtual String _get_project_name(); + virtual String _get_vcs_name(); public: static EditorVCSInterface *get_singleton(); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 98a36307b8..a7177faafa 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -2511,15 +2511,15 @@ void Node3DEditorViewport::_notification(int p_what) { } if (show_info) { + const String viewport_size = vformat(String::utf8("%d × %d"), viewport->get_size().x, viewport->get_size().y); String text; text += vformat(TTR("X: %s\n"), rtos(current_camera->get_position().x).pad_decimals(1)); text += vformat(TTR("Y: %s\n"), rtos(current_camera->get_position().y).pad_decimals(1)); text += vformat(TTR("Z: %s\n"), rtos(current_camera->get_position().z).pad_decimals(1)); text += "\n"; text += vformat( - TTR("Size: %dx%d (%.1fMP)\n"), - viewport->get_size().x, - viewport->get_size().y, + TTR("Size: %s (%.1fMP)\n"), + viewport_size, viewport->get_size().x * viewport->get_size().y * 0.000001); text += "\n"; @@ -6223,8 +6223,9 @@ void Node3DEditor::_add_sun_to_scene() { Node *base = get_tree()->get_edited_scene_root(); if (!base) { - EditorNode::get_singleton()->show_warning(TTR("A root node is needed for this operation")); - return; + // Create a root node so we can add child nodes to it. + EditorNode::get_singleton()->get_scene_tree_dock()->add_root_node(memnew(Node3D)); + base = get_tree()->get_edited_scene_root(); } ERR_FAIL_COND(!base); Node *new_sun = preview_sun->duplicate(); @@ -6241,8 +6242,9 @@ void Node3DEditor::_add_environment_to_scene() { Node *base = get_tree()->get_edited_scene_root(); if (!base) { - EditorNode::get_singleton()->show_warning(TTR("A root node is needed for this operation")); - return; + // Create a root node so we can add child nodes to it. + EditorNode::get_singleton()->get_scene_tree_dock()->add_root_node(memnew(Node3D)); + base = get_tree()->get_edited_scene_root(); } ERR_FAIL_COND(!base); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 1183da4d04..94863bf722 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -888,6 +888,7 @@ void VisualShaderGraphPlugin::remove_node(VisualShader::Type p_type, int p_id) { void VisualShaderGraphPlugin::connect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) { if (visual_shader->get_shader_type() == p_type) { VisualShaderEditor::get_singleton()->graph->connect_node(itos(p_from_node), p_from_port, itos(p_to_node), p_to_port); + connections.push_back({ p_from_node, p_from_port, p_to_node, p_to_port }); if (links[p_to_node].input_ports.has(p_to_port) && links[p_to_node].input_ports[p_to_port].default_input_button != nullptr) { links[p_to_node].input_ports[p_to_port].default_input_button->hide(); } @@ -897,6 +898,12 @@ void VisualShaderGraphPlugin::connect_nodes(VisualShader::Type p_type, int p_fro void VisualShaderGraphPlugin::disconnect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) { if (visual_shader->get_shader_type() == p_type) { VisualShaderEditor::get_singleton()->graph->disconnect_node(itos(p_from_node), p_from_port, itos(p_to_node), p_to_port); + for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) { + if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) { + connections.erase(E); + break; + } + } if (links[p_to_node].input_ports.has(p_to_port) && links[p_to_node].input_ports[p_to_port].default_input_button != nullptr && links[p_to_node].visual_node->get_input_port_default_value(p_to_port).get_type() != Variant::NIL) { links[p_to_node].input_ports[p_to_port].default_input_button->show(); set_input_port_default_value(p_type, p_to_node, p_to_port, links[p_to_node].visual_node->get_input_port_default_value(p_to_port)); diff --git a/editor/plugins/voxel_gi_editor_plugin.cpp b/editor/plugins/voxel_gi_editor_plugin.cpp index d30cc7ad17..162379a49d 100644 --- a/editor/plugins/voxel_gi_editor_plugin.cpp +++ b/editor/plugins/voxel_gi_editor_plugin.cpp @@ -69,10 +69,7 @@ void VoxelGIEditorPlugin::_notification(int p_what) { const Vector3i size = voxel_gi->get_estimated_cell_size(); String text = vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z); - int data_size = 4; - if (GLOBAL_GET("rendering/quality/voxel_gi/anisotropic")) { - data_size += 4; - } + const int data_size = 4; const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0); text += " - " + vformat(TTR("VRAM Size: %s MB"), String::num(size_mb, 2)); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 262861cb11..3f66f1f375 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -359,7 +359,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; } - if (reset_create_dialog) { + if (reset_create_dialog && !p_confirm_override) { create_dialog->set_base_type("Node"); reset_create_dialog = false; } @@ -1134,12 +1134,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } } - editor_data->get_undo_redo().create_action(TTR("New Scene Root")); - editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", new_node); - editor_data->get_undo_redo().add_do_method(scene_tree, "update_tree"); - editor_data->get_undo_redo().add_do_reference(new_node); - editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", (Object *)nullptr); - editor_data->get_undo_redo().commit_action(); + add_root_node(new_node); editor->edit_node(new_node); editor_selection->clear(); @@ -1162,6 +1157,15 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } } +void SceneTreeDock::add_root_node(Node *p_node) { + editor_data->get_undo_redo().create_action(TTR("New Scene Root")); + editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", p_node); + editor_data->get_undo_redo().add_do_method(scene_tree, "update_tree"); + editor_data->get_undo_redo().add_do_reference(p_node); + editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", (Object *)nullptr); + editor_data->get_undo_redo().commit_action(); +} + void SceneTreeDock::_node_collapsed(Object *p_obj) { TreeItem *ti = Object::cast_to<TreeItem>(p_obj); if (!ti) { diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 88c4a85f4c..08d992d465 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -261,6 +261,7 @@ public: void _focus_node(); void import_subscene(); + void add_root_node(Node *p_node); void set_edited_scene(Node *p_scene); void instantiate(const String &p_file); void instantiate_scenes(const Vector<String> &p_files, Node *p_parent = nullptr); |