mirror of
https://github.com/godotengine/godot.git
synced 2024-11-21 19:42:43 +00:00
Merge pull request #97912 from reduz/property-path-store-uid
Some checks are pending
🔗 GHA / 📊 Static checks (push) Waiting to run
🔗 GHA / 🤖 Android (push) Blocked by required conditions
🔗 GHA / 🍏 iOS (push) Blocked by required conditions
🔗 GHA / 🐧 Linux (push) Blocked by required conditions
🔗 GHA / 🍎 macOS (push) Blocked by required conditions
🔗 GHA / 🏁 Windows (push) Blocked by required conditions
🔗 GHA / 🌐 Web (push) Blocked by required conditions
🔗 GHA / 🪲 Godot CPP (push) Blocked by required conditions
Some checks are pending
🔗 GHA / 📊 Static checks (push) Waiting to run
🔗 GHA / 🤖 Android (push) Blocked by required conditions
🔗 GHA / 🍏 iOS (push) Blocked by required conditions
🔗 GHA / 🐧 Linux (push) Blocked by required conditions
🔗 GHA / 🍎 macOS (push) Blocked by required conditions
🔗 GHA / 🏁 Windows (push) Blocked by required conditions
🔗 GHA / 🌐 Web (push) Blocked by required conditions
🔗 GHA / 🪲 Godot CPP (push) Blocked by required conditions
Expose path properties save UID internally if referencing a resource
This commit is contained in:
commit
ec6a1c0e79
@ -462,10 +462,26 @@ void EditorPropertyPath::_set_read_only(bool p_read_only) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorPropertyPath::_path_selected(const String &p_path) {
|
void EditorPropertyPath::_path_selected(const String &p_path) {
|
||||||
emit_changed(get_edited_property(), p_path);
|
String full_path = p_path;
|
||||||
|
ResourceUID::ID id = ResourceLoader::get_resource_uid(full_path);
|
||||||
|
|
||||||
|
if (id != ResourceUID::INVALID_ID) {
|
||||||
|
full_path = ResourceUID::get_singleton()->id_to_text(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
emit_changed(get_edited_property(), full_path);
|
||||||
update_property();
|
update_property();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String EditorPropertyPath::_get_path_text() {
|
||||||
|
String full_path = get_edited_property_value();
|
||||||
|
if (full_path.begins_with("uid://")) {
|
||||||
|
full_path = ResourceUID::get_singleton()->get_id_path(ResourceUID::get_singleton()->text_to_id(full_path));
|
||||||
|
}
|
||||||
|
|
||||||
|
return full_path;
|
||||||
|
}
|
||||||
|
|
||||||
void EditorPropertyPath::_path_pressed() {
|
void EditorPropertyPath::_path_pressed() {
|
||||||
if (!dialog) {
|
if (!dialog) {
|
||||||
dialog = memnew(EditorFileDialog);
|
dialog = memnew(EditorFileDialog);
|
||||||
@ -474,7 +490,7 @@ void EditorPropertyPath::_path_pressed() {
|
|||||||
add_child(dialog);
|
add_child(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
String full_path = get_edited_property_value();
|
String full_path = _get_path_text();
|
||||||
|
|
||||||
dialog->clear_filters();
|
dialog->clear_filters();
|
||||||
|
|
||||||
@ -502,7 +518,7 @@ void EditorPropertyPath::_path_pressed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorPropertyPath::update_property() {
|
void EditorPropertyPath::update_property() {
|
||||||
String full_path = get_edited_property_value();
|
String full_path = _get_path_text();
|
||||||
path->set_text(full_path);
|
path->set_text(full_path);
|
||||||
path->set_tooltip_text(full_path);
|
path->set_tooltip_text(full_path);
|
||||||
}
|
}
|
||||||
@ -547,8 +563,7 @@ void EditorPropertyPath::_drop_data_fw(const Point2 &p_point, const Variant &p_d
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit_changed(get_edited_property(), filesPaths[0]);
|
_path_selected(filesPaths[0]);
|
||||||
update_property();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditorPropertyPath::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
bool EditorPropertyPath::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
||||||
|
@ -142,6 +142,8 @@ class EditorPropertyPath : public EditorProperty {
|
|||||||
LineEdit *path = nullptr;
|
LineEdit *path = nullptr;
|
||||||
Button *path_edit = nullptr;
|
Button *path_edit = nullptr;
|
||||||
|
|
||||||
|
String _get_path_text();
|
||||||
|
|
||||||
void _path_selected(const String &p_path);
|
void _path_selected(const String &p_path);
|
||||||
void _path_pressed();
|
void _path_pressed();
|
||||||
void _path_focus_exited();
|
void _path_focus_exited();
|
||||||
|
Loading…
Reference in New Issue
Block a user