mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Merge pull request #106947 from Meorge/feat/quick-load-preview
Allow Quick Open dialog to preview change in scene
This commit is contained in:
commit
fe9cdea92c
9 changed files with 183 additions and 16 deletions
|
|
@ -3472,6 +3472,7 @@ void EditorPropertyResource::setup(Object *p_object, const String &p_path, const
|
|||
|
||||
resource_picker->set_base_type(p_base_type);
|
||||
resource_picker->set_resource_owner(p_object);
|
||||
resource_picker->set_property_path(p_path);
|
||||
resource_picker->set_editable(true);
|
||||
resource_picker->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
add_child(resource_picker);
|
||||
|
|
|
|||
|
|
@ -379,7 +379,13 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) {
|
|||
base_types.push_back(type);
|
||||
}
|
||||
|
||||
EditorNode::get_singleton()->get_quick_open_dialog()->popup_dialog(base_types, callable_mp(this, &EditorResourcePicker::_file_selected));
|
||||
EditorQuickOpenDialog *quick_open = EditorNode::get_singleton()->get_quick_open_dialog();
|
||||
if (resource_owner) {
|
||||
quick_open->popup_dialog_for_property(base_types, resource_owner, property_path, callable_mp(this, &EditorResourcePicker::_file_selected));
|
||||
} else {
|
||||
quick_open->popup_dialog(base_types, callable_mp(this, &EditorResourcePicker::_file_selected));
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
case OBJ_MENU_INSPECT: {
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ class EditorResourcePicker : public HBoxContainer {
|
|||
};
|
||||
|
||||
Object *resource_owner = nullptr;
|
||||
StringName property_path;
|
||||
|
||||
PopupMenu *edit_menu = nullptr;
|
||||
|
||||
|
|
@ -144,6 +145,7 @@ public:
|
|||
bool is_toggle_pressed() const;
|
||||
|
||||
void set_resource_owner(Object *p_object);
|
||||
void set_property_path(const StringName &p_path) { property_path = p_path; }
|
||||
|
||||
void set_editable(bool p_editable);
|
||||
bool is_editable() const;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ bool MultiNodeEdit::_set(const StringName &p_name, const Variant &p_value) {
|
|||
return _set_impl(p_name, p_value, "");
|
||||
}
|
||||
|
||||
bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value, const String &p_field) {
|
||||
bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value, const String &p_field, bool p_undo_redo) {
|
||||
Node *es = EditorNode::get_singleton()->get_edited_scene();
|
||||
if (!es) {
|
||||
return false;
|
||||
|
|
@ -59,7 +59,10 @@ bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value,
|
|||
|
||||
EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton();
|
||||
|
||||
ur->create_action(vformat(TTR("Set %s on %d nodes"), name, get_node_count()), UndoRedo::MERGE_ENDS);
|
||||
if (p_undo_redo) {
|
||||
ur->create_action(vformat(TTR("Set %s on %d nodes"), name, get_node_count()), UndoRedo::MERGE_ENDS);
|
||||
}
|
||||
|
||||
for (const NodePath &E : nodes) {
|
||||
Node *n = es->get_node_or_null(E);
|
||||
if (!n) {
|
||||
|
|
@ -71,7 +74,12 @@ bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value,
|
|||
if (node_path_target) {
|
||||
path = n->get_path_to(node_path_target);
|
||||
}
|
||||
ur->add_do_property(n, name, path);
|
||||
|
||||
if (p_undo_redo) {
|
||||
ur->add_do_property(n, name, path);
|
||||
} else {
|
||||
n->set(name, path);
|
||||
}
|
||||
} else {
|
||||
Variant new_value;
|
||||
if (p_field.is_empty()) {
|
||||
|
|
@ -81,13 +89,22 @@ bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value,
|
|||
// only one field
|
||||
new_value = fieldwise_assign(n->get(name), p_value, p_field);
|
||||
}
|
||||
ur->add_do_property(n, name, new_value);
|
||||
|
||||
if (p_undo_redo) {
|
||||
ur->add_do_property(n, name, new_value);
|
||||
} else {
|
||||
n->set(name, new_value);
|
||||
}
|
||||
}
|
||||
|
||||
ur->add_undo_property(n, name, n->get(name));
|
||||
if (p_undo_redo) {
|
||||
ur->add_undo_property(n, name, n->get(name));
|
||||
}
|
||||
}
|
||||
|
||||
ur->commit_action();
|
||||
if (p_undo_redo) {
|
||||
ur->commit_action();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@
|
|||
class MultiNodeEdit : public RefCounted {
|
||||
GDCLASS(MultiNodeEdit, RefCounted);
|
||||
|
||||
friend class EditorQuickOpenDialog;
|
||||
|
||||
LocalVector<NodePath> nodes;
|
||||
bool notify_property_list_changed_pending = false;
|
||||
struct PLData {
|
||||
|
|
@ -42,7 +44,7 @@ class MultiNodeEdit : public RefCounted {
|
|||
PropertyInfo info;
|
||||
};
|
||||
|
||||
bool _set_impl(const StringName &p_name, const Variant &p_value, const String &p_field);
|
||||
bool _set_impl(const StringName &p_name, const Variant &p_value, const String &p_field, bool p_undo_redo = true);
|
||||
void _queue_notify_property_list_changed();
|
||||
void _notify_property_list_changed();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue