You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Merge pull request #97348 from pafuent/updating_inspector_dock_when_rename_on_filesystem_dock
Update Inspector when renaming a file via File System Dock
This commit is contained in:
@@ -7808,11 +7808,12 @@ EditorNode::EditorNode() {
|
|||||||
// Instantiate and place editor docks.
|
// Instantiate and place editor docks.
|
||||||
|
|
||||||
memnew(SceneTreeDock(scene_root, editor_selection, editor_data));
|
memnew(SceneTreeDock(scene_root, editor_selection, editor_data));
|
||||||
|
memnew(FileSystemDock);
|
||||||
memnew(InspectorDock(editor_data));
|
memnew(InspectorDock(editor_data));
|
||||||
memnew(ImportDock);
|
memnew(ImportDock);
|
||||||
memnew(NodeDock);
|
memnew(NodeDock);
|
||||||
|
|
||||||
FileSystemDock *filesystem_dock = memnew(FileSystemDock);
|
FileSystemDock *filesystem_dock = FileSystemDock::get_singleton();
|
||||||
filesystem_dock->connect("inherit", callable_mp(this, &EditorNode::_inherit_request));
|
filesystem_dock->connect("inherit", callable_mp(this, &EditorNode::_inherit_request));
|
||||||
filesystem_dock->connect("instantiate", callable_mp(this, &EditorNode::_instantiate_request));
|
filesystem_dock->connect("instantiate", callable_mp(this, &EditorNode::_instantiate_request));
|
||||||
filesystem_dock->connect("display_mode_changed", callable_mp(this, &EditorNode::_save_editor_layout));
|
filesystem_dock->connect("display_mode_changed", callable_mp(this, &EditorNode::_save_editor_layout));
|
||||||
|
|||||||
@@ -399,6 +399,21 @@ void InspectorDock::_resource_selected(const Ref<Resource> &p_res, const String
|
|||||||
EditorNode::get_singleton()->push_item(r.operator->(), p_property);
|
EditorNode::get_singleton()->push_item(r.operator->(), p_property);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InspectorDock::_files_moved(const String &p_old_file, const String &p_new_file) {
|
||||||
|
// Because only the file name is shown, we care about changes on the file name.
|
||||||
|
if (p_old_file.get_file() == p_new_file.get_file()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectID current_id = EditorNode::get_singleton()->get_editor_selection_history()->get_current();
|
||||||
|
Ref<Resource> res(current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr);
|
||||||
|
// We only care about updating the path if the current object is the one being renamed.
|
||||||
|
if (res.is_valid() && p_old_file == res->get_path()) {
|
||||||
|
res->set_path(p_new_file);
|
||||||
|
object_selector->update_path();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void InspectorDock::_edit_forward() {
|
void InspectorDock::_edit_forward() {
|
||||||
if (EditorNode::get_singleton()->get_editor_selection_history()->next()) {
|
if (EditorNode::get_singleton()->get_editor_selection_history()->next()) {
|
||||||
EditorNode::get_singleton()->edit_current();
|
EditorNode::get_singleton()->edit_current();
|
||||||
@@ -823,6 +838,8 @@ InspectorDock::InspectorDock(EditorData &p_editor_data) {
|
|||||||
|
|
||||||
inspector->connect("resource_selected", callable_mp(this, &InspectorDock::_resource_selected));
|
inspector->connect("resource_selected", callable_mp(this, &InspectorDock::_resource_selected));
|
||||||
|
|
||||||
|
FileSystemDock::get_singleton()->connect("files_moved", callable_mp(this, &InspectorDock::_files_moved));
|
||||||
|
|
||||||
set_process_shortcut_input(true);
|
set_process_shortcut_input(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ class InspectorDock : public VBoxContainer {
|
|||||||
void _info_pressed();
|
void _info_pressed();
|
||||||
void _resource_created();
|
void _resource_created();
|
||||||
void _resource_selected(const Ref<Resource> &p_res, const String &p_property);
|
void _resource_selected(const Ref<Resource> &p_res, const String &p_property);
|
||||||
|
void _files_moved(const String &p_old_file, const String &p_new_file);
|
||||||
void _edit_forward();
|
void _edit_forward();
|
||||||
void _edit_back();
|
void _edit_back();
|
||||||
void _menu_collapseall();
|
void _menu_collapseall();
|
||||||
|
|||||||
Reference in New Issue
Block a user