You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Merge pull request #87623 from Calinou/editor-scene-drag-and-drop-tweak-modifier
Change scene drag-and-drop modifier behavior in the 2D and 3D editors
This commit is contained in:
@@ -5661,7 +5661,7 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
|
|||||||
Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
|
Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
|
||||||
if (texture != nullptr || scene != nullptr) {
|
if (texture != nullptr || scene != nullptr) {
|
||||||
bool root_node_selected = EditorNode::get_singleton()->get_editor_selection()->is_selected(EditorNode::get_singleton()->get_edited_scene());
|
bool root_node_selected = EditorNode::get_singleton()->get_editor_selection()->is_selected(EditorNode::get_singleton()->get_edited_scene());
|
||||||
String desc = TTR("Drag and drop to add as child of current scene's root node.") + "\n" + vformat(TTR("Hold %s when dropping to add as child of selected node."), keycode_get_string((Key)KeyModifierMask::CMD_OR_CTRL));
|
String desc = TTR("Drag and drop to add as child of selected node.") + "\n" + TTR("Hold Alt when dropping to add as child of root node.");
|
||||||
if (!root_node_selected) {
|
if (!root_node_selected) {
|
||||||
desc += "\n" + TTR("Hold Shift when dropping to add as sibling of selected node.");
|
desc += "\n" + TTR("Hold Shift when dropping to add as sibling of selected node.");
|
||||||
}
|
}
|
||||||
@@ -5672,7 +5672,7 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
|
|||||||
preview_node->add_child(sprite);
|
preview_node->add_child(sprite);
|
||||||
label->show();
|
label->show();
|
||||||
label_desc->show();
|
label_desc->show();
|
||||||
desc += "\n" + TTR("Hold Alt when dropping to add as a different node type.");
|
desc += "\n" + TTR("Hold Alt + Shift when dropping to add as a different node type.");
|
||||||
label_desc->set_text(desc);
|
label_desc->set_text(desc);
|
||||||
} else {
|
} else {
|
||||||
if (scene.is_valid()) {
|
if (scene.is_valid()) {
|
||||||
@@ -5965,7 +5965,6 @@ bool CanvasItemEditorViewport::_only_packed_scenes_selected() const {
|
|||||||
|
|
||||||
void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p_data) {
|
void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p_data) {
|
||||||
bool is_shift = Input::get_singleton()->is_key_pressed(Key::SHIFT);
|
bool is_shift = Input::get_singleton()->is_key_pressed(Key::SHIFT);
|
||||||
bool is_ctrl = Input::get_singleton()->is_key_pressed(Key::CMD_OR_CTRL);
|
|
||||||
bool is_alt = Input::get_singleton()->is_key_pressed(Key::ALT);
|
bool is_alt = Input::get_singleton()->is_key_pressed(Key::ALT);
|
||||||
|
|
||||||
selected_files.clear();
|
selected_files.clear();
|
||||||
@@ -5981,9 +5980,9 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p
|
|||||||
Node *root_node = EditorNode::get_singleton()->get_edited_scene();
|
Node *root_node = EditorNode::get_singleton()->get_edited_scene();
|
||||||
if (selected_nodes.size() > 0) {
|
if (selected_nodes.size() > 0) {
|
||||||
Node *selected_node = selected_nodes[0];
|
Node *selected_node = selected_nodes[0];
|
||||||
target_node = root_node;
|
target_node = selected_node;
|
||||||
if (is_ctrl) {
|
if (is_alt) {
|
||||||
target_node = selected_node;
|
target_node = root_node;
|
||||||
} else if (is_shift && selected_node != root_node) {
|
} else if (is_shift && selected_node != root_node) {
|
||||||
target_node = selected_node->get_parent();
|
target_node = selected_node->get_parent();
|
||||||
}
|
}
|
||||||
@@ -5997,7 +5996,7 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p
|
|||||||
|
|
||||||
drop_pos = p_point;
|
drop_pos = p_point;
|
||||||
|
|
||||||
if (is_alt && !_only_packed_scenes_selected()) {
|
if (is_alt && is_shift && !_only_packed_scenes_selected()) {
|
||||||
_show_resource_type_selector();
|
_show_resource_type_selector();
|
||||||
} else {
|
} else {
|
||||||
_perform_drop_data();
|
_perform_drop_data();
|
||||||
|
|||||||
@@ -4532,7 +4532,7 @@ void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool is_shift = Input::get_singleton()->is_key_pressed(Key::SHIFT);
|
bool is_shift = Input::get_singleton()->is_key_pressed(Key::SHIFT);
|
||||||
bool is_ctrl = Input::get_singleton()->is_key_pressed(Key::CTRL);
|
bool is_alt = Input::get_singleton()->is_key_pressed(Key::ALT);
|
||||||
|
|
||||||
selected_files.clear();
|
selected_files.clear();
|
||||||
Dictionary d = p_data;
|
Dictionary d = p_data;
|
||||||
@@ -4542,15 +4542,15 @@ void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_
|
|||||||
|
|
||||||
List<Node *> selected_nodes = EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list();
|
List<Node *> selected_nodes = EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list();
|
||||||
Node *root_node = EditorNode::get_singleton()->get_edited_scene();
|
Node *root_node = EditorNode::get_singleton()->get_edited_scene();
|
||||||
if (selected_nodes.size() == 1) {
|
if (selected_nodes.size() > 0) {
|
||||||
Node *selected_node = selected_nodes[0];
|
Node *selected_node = selected_nodes[0];
|
||||||
target_node = root_node;
|
target_node = selected_node;
|
||||||
if (is_ctrl) {
|
if (is_alt) {
|
||||||
target_node = selected_node;
|
target_node = root_node;
|
||||||
} else if (is_shift && selected_node != root_node) {
|
} else if (is_shift && selected_node != root_node) {
|
||||||
target_node = selected_node->get_parent();
|
target_node = selected_node->get_parent();
|
||||||
}
|
}
|
||||||
} else if (selected_nodes.size() == 0) {
|
} else {
|
||||||
if (root_node) {
|
if (root_node) {
|
||||||
target_node = root_node;
|
target_node = root_node;
|
||||||
} else {
|
} else {
|
||||||
@@ -4558,11 +4558,6 @@ void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_
|
|||||||
SceneTreeDock::get_singleton()->add_root_node(memnew(Node3D));
|
SceneTreeDock::get_singleton()->add_root_node(memnew(Node3D));
|
||||||
target_node = get_tree()->get_edited_scene_root();
|
target_node = get_tree()->get_edited_scene_root();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
accept->set_text(TTR("Cannot drag and drop into multiple selected nodes."));
|
|
||||||
accept->popup_centered();
|
|
||||||
_remove_preview_node();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drop_pos = p_point;
|
drop_pos = p_point;
|
||||||
|
|||||||
Reference in New Issue
Block a user