Merge pull request #45943 from KoBeWi/YEEEET

Remove Merge From Scene
This commit is contained in:
Rémi Verschelde 2021-02-18 15:15:19 +01:00 committed by GitHub
commit 72f74eb29e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 0 additions and 382 deletions

View File

@ -2520,16 +2520,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case FILE_IMPORT_SUBSCENE: {
if (!editor_data.get_edited_scene_root()) {
show_accept(TTR("This operation can't be done without a selected node."), TTR("OK"));
break;
}
scene_tree_dock->import_subscene();
} break;
case FILE_EXTERNAL_OPEN_SCENE: {
if (unsaved_cache && !p_confirmed) {
confirmation->get_ok_button()->set_text(TTR("Open"));

View File

@ -128,7 +128,6 @@ private:
FILE_SAVE_ALL_SCENES,
FILE_SAVE_AND_RUN,
FILE_SHOW_IN_FILESYSTEM,
FILE_IMPORT_SUBSCENE,
FILE_EXPORT_PROJECT,
FILE_EXPORT_MESH_LIBRARY,
FILE_INSTALL_ANDROID_SOURCE,
@ -719,8 +718,6 @@ public:
void save_resource(const Ref<Resource> &p_resource);
void save_resource_as(const Ref<Resource> &p_resource, const String &p_at_path = String());
void merge_from_scene() { _menu_option_confirm(FILE_IMPORT_SUBSCENE, false); }
void show_about() { _menu_option_confirm(HELP_ABOUT, false); }
static bool has_unsaved_changes() { return singleton->unsaved_cache; }

View File

@ -1,265 +0,0 @@
/*************************************************************************/
/* editor_sub_scene.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor_sub_scene.h"
#include "editor/editor_node.h"
#include "scene/gui/margin_container.h"
#include "scene/resources/packed_scene.h"
void EditorSubScene::_path_selected(const String &p_path) {
path->set_text(p_path);
_path_changed(p_path);
}
void EditorSubScene::_path_changed(const String &p_path) {
tree->clear();
if (scene) {
memdelete(scene);
scene = nullptr;
}
if (p_path == "") {
return;
}
Ref<PackedScene> ps = ResourceLoader::load(p_path, "PackedScene");
if (ps.is_null()) {
return;
}
scene = ps->instance();
if (!scene) {
return;
}
_fill_tree(scene, nullptr);
}
void EditorSubScene::_path_browse() {
file_dialog->popup_file_dialog();
}
void EditorSubScene::_notification(int p_what) {
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
if (is_visible() && scene == nullptr) {
_path_browse();
}
}
}
void EditorSubScene::_fill_tree(Node *p_node, TreeItem *p_parent) {
TreeItem *it = tree->create_item(p_parent);
it->set_metadata(0, p_node);
it->set_text(0, p_node->get_name());
it->set_editable(0, false);
it->set_selectable(0, true);
it->set_icon(0, EditorNode::get_singleton()->get_object_icon(p_node, "Node"));
for (int i = 0; i < p_node->get_child_count(); i++) {
Node *c = p_node->get_child(i);
if (c->get_owner() != scene) {
continue;
}
_fill_tree(c, it);
}
}
void EditorSubScene::_selected_changed() {
TreeItem *item = tree->get_selected();
ERR_FAIL_COND(!item);
Node *n = item->get_metadata(0);
if (!n || !selection.find(n)) {
selection.clear();
is_root = false;
}
}
void EditorSubScene::_item_multi_selected(Object *p_object, int p_cell, bool p_selected) {
if (!is_root) {
TreeItem *item = Object::cast_to<TreeItem>(p_object);
ERR_FAIL_COND(!item);
Node *n = item->get_metadata(0);
if (!n) {
return;
}
if (p_selected) {
if (n == scene) {
is_root = true;
selection.clear();
}
selection.push_back(n);
} else {
List<Node *>::Element *E = selection.find(n);
if (E) {
selection.erase(E);
}
}
}
}
void EditorSubScene::_item_activated() {
_ok_pressed(); // From AcceptDialog.
}
void EditorSubScene::_remove_selection_child(Node *p_node) {
if (p_node->get_child_count() > 0) {
for (int i = 0; i < p_node->get_child_count(); i++) {
Node *c = p_node->get_child(i);
List<Node *>::Element *E = selection.find(c);
if (E) {
selection.move_to_back(E);
selection.pop_back();
}
if (c->get_child_count() > 0) {
_remove_selection_child(c);
}
}
}
}
void EditorSubScene::ok_pressed() {
if (selection.size() <= 0) {
return;
}
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Node *c = E->get();
_remove_selection_child(c);
}
emit_signal("subscene_selected");
hide();
clear();
}
void EditorSubScene::_reown(Node *p_node, List<Node *> *p_to_reown) {
if (p_node == scene) {
scene->set_filename("");
p_to_reown->push_back(p_node);
} else if (p_node->get_owner() == scene) {
p_to_reown->push_back(p_node);
}
for (int i = 0; i < p_node->get_child_count(); i++) {
Node *c = p_node->get_child(i);
_reown(c, p_to_reown);
}
}
void EditorSubScene::move(Node *p_new_parent, Node *p_new_owner) {
if (!scene) {
return;
}
if (selection.size() <= 0) {
return;
}
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Node *selnode = E->get();
if (!selnode) {
return;
}
List<Node *> to_reown;
_reown(selnode, &to_reown);
if (selnode != scene) {
selnode->get_parent()->remove_child(selnode);
}
p_new_parent->add_child(selnode);
for (List<Node *>::Element *F = to_reown.front(); F; F = F->next()) {
F->get()->set_owner(p_new_owner);
}
}
if (!is_root) {
memdelete(scene);
}
scene = nullptr;
//return selnode;
}
void EditorSubScene::clear() {
path->set_text("");
_path_changed("");
}
void EditorSubScene::_bind_methods() {
ADD_SIGNAL(MethodInfo("subscene_selected"));
}
EditorSubScene::EditorSubScene() {
scene = nullptr;
is_root = false;
set_title(TTR("Select Node(s) to Import"));
set_hide_on_ok(false);
VBoxContainer *vb = memnew(VBoxContainer);
add_child(vb);
//set_child_rect(vb);
HBoxContainer *hb = memnew(HBoxContainer);
path = memnew(LineEdit);
path->connect("text_entered", callable_mp(this, &EditorSubScene::_path_changed));
hb->add_child(path);
path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
Button *b = memnew(Button);
b->set_text(TTR("Browse"));
hb->add_child(b);
b->connect("pressed", callable_mp(this, &EditorSubScene::_path_browse));
vb->add_margin_child(TTR("Scene Path:"), hb);
tree = memnew(Tree);
tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
vb->add_margin_child(TTR("Import From Node:"), tree, true);
tree->set_select_mode(Tree::SELECT_MULTI);
tree->connect("multi_selected", callable_mp(this, &EditorSubScene::_item_multi_selected));
//tree->connect("nothing_selected", this, "_deselect_items");
tree->connect("cell_selected", callable_mp(this, &EditorSubScene::_selected_changed));
tree->connect("item_activated", callable_mp(this, &EditorSubScene::_item_activated), make_binds(), CONNECT_DEFERRED);
file_dialog = memnew(EditorFileDialog);
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions);
for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
file_dialog->add_filter("*." + E->get());
}
file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
add_child(file_dialog);
file_dialog->connect("file_selected", callable_mp(this, &EditorSubScene::_path_selected));
}

View File

@ -1,71 +0,0 @@
/*************************************************************************/
/* editor_sub_scene.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef EDITOR_SUB_SCENE_H
#define EDITOR_SUB_SCENE_H
#include "editor/editor_file_dialog.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/tree.h"
class EditorSubScene : public ConfirmationDialog {
GDCLASS(EditorSubScene, ConfirmationDialog);
List<Node *> selection;
LineEdit *path;
Tree *tree;
Node *scene;
bool is_root;
EditorFileDialog *file_dialog;
void _fill_tree(Node *p_node, TreeItem *p_parent);
void _selected_changed();
void _item_multi_selected(Object *p_object, int p_cell, bool p_selected);
void _item_activated();
void _remove_selection_child(Node *p_node);
void _reown(Node *p_node, List<Node *> *p_to_reown);
void ok_pressed() override;
protected:
void _notification(int p_what);
static void _bind_methods();
void _path_browse();
void _path_selected(const String &p_path);
void _path_changed(const String &p_path);
public:
void move(Node *p_new_parent, Node *p_new_owner);
void clear();
EditorSubScene();
};
#endif // EDITOR_SUB_SCENE_H

View File

@ -107,8 +107,6 @@ void SceneTreeDock::_unhandled_key_input(Ref<InputEvent> p_event) {
_tool_selected(TOOL_MOVE_DOWN);
} else if (ED_IS_SHORTCUT("scene_tree/reparent", p_event)) {
_tool_selected(TOOL_REPARENT);
} else if (ED_IS_SHORTCUT("scene_tree/merge_from_scene", p_event)) {
_tool_selected(TOOL_MERGE_FROM_SCENE);
} else if (ED_IS_SHORTCUT("scene_tree/save_branch_as_scene", p_event)) {
_tool_selected(TOOL_NEW_SCENE_FROM);
} else if (ED_IS_SHORTCUT("scene_tree/delete_no_confirm", p_event)) {
@ -880,13 +878,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
} break;
case TOOL_MERGE_FROM_SCENE: {
if (!profile_allow_editing) {
break;
}
EditorNode::get_singleton()->merge_from_scene();
} break;
case TOOL_NEW_SCENE_FROM: {
if (!profile_allow_editing) {
break;
@ -2291,21 +2282,6 @@ void SceneTreeDock::set_selected(Node *p_node, bool p_emit_selected) {
scene_tree->set_selected(p_node, p_emit_selected);
}
void SceneTreeDock::import_subscene() {
import_subscene_dialog->popup_centered_clamped(Size2(500, 800) * EDSCALE, 0.8);
}
void SceneTreeDock::_import_subscene() {
Node *parent = scene_tree->get_selected();
if (!parent) {
parent = editor_data->get_edited_scene_root();
ERR_FAIL_COND(!parent);
}
import_subscene_dialog->move(parent, edited_scene);
editor_data->get_undo_redo().clear_history(); //no undo for now..
}
void SceneTreeDock::_new_scene_from(String p_file) {
List<Node *> selection = editor_selection->get_selected_node_list();
@ -2622,7 +2598,6 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
if (selection.size() == 1) {
if (profile_allow_editing) {
menu->add_separator();
menu->add_icon_shortcut(get_theme_icon("Blend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/merge_from_scene"), TOOL_MERGE_FROM_SCENE);
menu->add_icon_shortcut(get_theme_icon("CreateNewSceneFrom", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM);
}
if (full_selection.size() == 1) {
@ -3000,7 +2975,6 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
ED_SHORTCUT("scene_tree/reparent", TTR("Reparent"));
ED_SHORTCUT("scene_tree/reparent_to_new_node", TTR("Reparent to New Node"));
ED_SHORTCUT("scene_tree/make_root", TTR("Make Scene Root"));
ED_SHORTCUT("scene_tree/merge_from_scene", TTR("Merge From Scene"));
ED_SHORTCUT("scene_tree/save_branch_as_scene", TTR("Save Branch as Scene"));
ED_SHORTCUT("scene_tree/copy_node_path", TTR("Copy Node Path"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_C);
ED_SHORTCUT("scene_tree/delete_no_confirm", TTR("Delete (No Confirm)"), KEY_MASK_SHIFT | KEY_DELETE);
@ -3130,10 +3104,6 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
add_child(placeholder_editable_instance_remove_dialog);
placeholder_editable_instance_remove_dialog->connect("confirmed", callable_mp(this, &SceneTreeDock::_toggle_placeholder_from_selection));
import_subscene_dialog = memnew(EditorSubScene);
add_child(import_subscene_dialog);
import_subscene_dialog->connect("subscene_selected", callable_mp(this, &SceneTreeDock::_import_subscene));
new_scene_from_dialog = memnew(EditorFileDialog);
new_scene_from_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
add_child(new_scene_from_dialog);

View File

@ -34,7 +34,6 @@
#include "editor/connections_dialog.h"
#include "editor/create_dialog.h"
#include "editor/editor_data.h"
#include "editor/editor_sub_scene.h"
#include "editor/groups_editor.h"
#include "editor/quick_open.h"
#include "editor/rename_dialog.h"
@ -74,7 +73,6 @@ class SceneTreeDock : public VBoxContainer {
TOOL_REPARENT_TO_NEW_NODE,
TOOL_MAKE_ROOT,
TOOL_NEW_SCENE_FROM,
TOOL_MERGE_FROM_SCENE,
TOOL_MULTI_EDIT,
TOOL_ERASE,
TOOL_COPY_NODE_PATH,
@ -141,7 +139,6 @@ class SceneTreeDock : public VBoxContainer {
ReparentDialog *reparent_dialog;
EditorQuickOpen *quick_open;
EditorSubScene *import_subscene_dialog;
EditorFileDialog *new_scene_from_dialog;
LineEdit *filter;