Merge pull request #69291 from nongvantinh/fix-suggest-message

Fix Sprite drag and drop hint mentions invalid option with root node selected
This commit is contained in:
Rémi Verschelde 2022-12-12 12:19:37 +01:00
commit e2a37295f5
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 8 additions and 2 deletions

View File

@ -5504,6 +5504,11 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res)); Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res));
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());
String desc = TTR("Drag and drop to add as child of current scene's root node.") + "\n" + TTR("Hold Ctrl when dropping to add as child of selected node.");
if (!root_node_selected) {
desc += "\n" + TTR("Hold Shift when dropping to add as sibling of selected node.");
}
if (texture != nullptr) { if (texture != nullptr) {
Sprite2D *sprite = memnew(Sprite2D); Sprite2D *sprite = memnew(Sprite2D);
sprite->set_texture(texture); sprite->set_texture(texture);
@ -5511,14 +5516,15 @@ 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();
label_desc->set_text(TTR("Drag and drop to add as child of current scene's root node.\nHold Ctrl when dropping to add as child of selected node.\nHold Shift when dropping to add as sibling of selected node.\nHold Alt when dropping to add as a different node type.")); desc += "\n" + TTR("Hold Alt when dropping to add as a different node type.");
label_desc->set_text(desc);
} else { } else {
if (scene.is_valid()) { if (scene.is_valid()) {
Node *instance = scene->instantiate(); Node *instance = scene->instantiate();
if (instance) { if (instance) {
preview_node->add_child(instance); preview_node->add_child(instance);
label_desc->show(); label_desc->show();
label_desc->set_text(TTR("Drag and drop to add as child of current scene's root node.\nHold Ctrl when dropping to add as child of selected node.\nHold Shift when dropping to add as sibling of selected node.")); label_desc->set_text(desc);
} }
} }
} }