Placeholder dialog for editable children

Fire placeholder confirmation dialog box when editable children option is already checked.
Fixes #28863
This commit is contained in:
Bhupendra Aole 2019-09-04 15:02:26 -04:00
parent b25b1fb600
commit cb528e31d9
2 changed files with 37 additions and 4 deletions

View file

@ -890,16 +890,22 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (e) { if (e) {
Node *node = e->get(); Node *node = e->get();
if (node) { if (node) {
bool editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(node);
bool placeholder = node->get_scene_instance_load_placeholder(); bool placeholder = node->get_scene_instance_load_placeholder();
// Fire confirmation dialog when children are editable.
if (editable && !placeholder) {
placeholder_editable_instance_remove_dialog->set_text(TTR("Enabling \"Load As Placeholder\" will disable \"Editable Children\" and cause all properties of the node to be reverted to their default."));
placeholder_editable_instance_remove_dialog->popup_centered_minsize();
break;
}
placeholder = !placeholder; placeholder = !placeholder;
int editable_item_idx = menu->get_item_idx_from_text(TTR("Editable Children"));
int placeholder_item_idx = menu->get_item_idx_from_text(TTR("Load As Placeholder"));
if (placeholder) if (placeholder)
EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node, false); EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(node, false);
node->set_scene_instance_load_placeholder(placeholder); node->set_scene_instance_load_placeholder(placeholder);
menu->set_item_checked(editable_item_idx, false);
menu->set_item_checked(placeholder_item_idx, placeholder);
scene_tree->update_tree(); scene_tree->update_tree();
} }
} }
@ -1761,6 +1767,25 @@ void SceneTreeDock::_toggle_editable_children_from_selection() {
} }
} }
void SceneTreeDock::_toggle_placeholder_from_selection() {
List<Node *> selection = editor_selection->get_selected_node_list();
List<Node *>::Element *e = selection.front();
if (e) {
Node *node = e->get();
if (node) {
_toggle_editable_children(node);
bool placeholder = node->get_scene_instance_load_placeholder();
placeholder = !placeholder;
node->set_scene_instance_load_placeholder(placeholder);
scene_tree->update_tree();
}
}
}
void SceneTreeDock::_toggle_editable_children(Node *p_node) { void SceneTreeDock::_toggle_editable_children(Node *p_node) {
if (p_node) { if (p_node) {
@ -2698,6 +2723,7 @@ void SceneTreeDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_nodes_drag_begin"), &SceneTreeDock::_nodes_drag_begin); ClassDB::bind_method(D_METHOD("_nodes_drag_begin"), &SceneTreeDock::_nodes_drag_begin);
ClassDB::bind_method(D_METHOD("_delete_confirm"), &SceneTreeDock::_delete_confirm); ClassDB::bind_method(D_METHOD("_delete_confirm"), &SceneTreeDock::_delete_confirm);
ClassDB::bind_method(D_METHOD("_toggle_editable_children_from_selection"), &SceneTreeDock::_toggle_editable_children_from_selection); ClassDB::bind_method(D_METHOD("_toggle_editable_children_from_selection"), &SceneTreeDock::_toggle_editable_children_from_selection);
ClassDB::bind_method(D_METHOD("_toggle_placeholder_from_selection"), &SceneTreeDock::_toggle_placeholder_from_selection);
ClassDB::bind_method(D_METHOD("_node_prerenamed"), &SceneTreeDock::_node_prerenamed); ClassDB::bind_method(D_METHOD("_node_prerenamed"), &SceneTreeDock::_node_prerenamed);
ClassDB::bind_method(D_METHOD("_import_subscene"), &SceneTreeDock::_import_subscene); ClassDB::bind_method(D_METHOD("_import_subscene"), &SceneTreeDock::_import_subscene);
ClassDB::bind_method(D_METHOD("_selection_changed"), &SceneTreeDock::_selection_changed); ClassDB::bind_method(D_METHOD("_selection_changed"), &SceneTreeDock::_selection_changed);
@ -2871,6 +2897,10 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
add_child(editable_instance_remove_dialog); add_child(editable_instance_remove_dialog);
editable_instance_remove_dialog->connect("confirmed", this, "_toggle_editable_children_from_selection"); editable_instance_remove_dialog->connect("confirmed", this, "_toggle_editable_children_from_selection");
placeholder_editable_instance_remove_dialog = memnew(ConfirmationDialog);
add_child(placeholder_editable_instance_remove_dialog);
placeholder_editable_instance_remove_dialog->connect("confirmed", this, "_toggle_placeholder_from_selection");
import_subscene_dialog = memnew(EditorSubScene); import_subscene_dialog = memnew(EditorSubScene);
add_child(import_subscene_dialog); add_child(import_subscene_dialog);
import_subscene_dialog->connect("subscene_selected", this, "_import_subscene"); import_subscene_dialog->connect("subscene_selected", this, "_import_subscene");

View file

@ -127,6 +127,7 @@ class SceneTreeDock : public VBoxContainer {
AcceptDialog *accept; AcceptDialog *accept;
ConfirmationDialog *delete_dialog; ConfirmationDialog *delete_dialog;
ConfirmationDialog *editable_instance_remove_dialog; ConfirmationDialog *editable_instance_remove_dialog;
ConfirmationDialog *placeholder_editable_instance_remove_dialog;
ReparentDialog *reparent_dialog; ReparentDialog *reparent_dialog;
EditorQuickOpen *quick_open; EditorQuickOpen *quick_open;
@ -184,6 +185,8 @@ class SceneTreeDock : public VBoxContainer {
void _toggle_editable_children_from_selection(); void _toggle_editable_children_from_selection();
void _toggle_editable_children(Node *p_node); void _toggle_editable_children(Node *p_node);
void _toggle_placeholder_from_selection();
void _node_prerenamed(Node *p_node, const String &p_new_name); void _node_prerenamed(Node *p_node, const String &p_new_name);
void _nodes_drag_begin(); void _nodes_drag_begin();