Skip to content

Commit 925baf1

Browse files
committed
Editor: Show actual class name in resource picker tooltips
- Replaced generic "Resource" with the actual class name (e.g. "Texture2D"). - Used TTRN for correct pluralization support. - Removed unnecessary parentheses around the count. - Added handling for custom resources
1 parent dec5a37 commit 925baf1

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

editor/inspector/editor_resource_picker.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include "editor/themes/editor_scale.h"
4747
#include "scene/gui/button.h"
4848
#include "scene/gui/texture_rect.h"
49+
#include "scene/property_utils.h"
4950
#include "scene/resources/gradient_texture.h"
5051
#include "scene/resources/image_texture.h"
5152

@@ -107,19 +108,34 @@ void EditorResourcePicker::_update_resource() {
107108

108109
String tooltip;
109110

111+
String resource_name = "resource";
112+
if (edited_resource.is_valid()) {
113+
resource_name = edited_resource->get_class();
114+
115+
if (edited_resource->has_meta(SceneStringNames::get_singleton()->_custom_type_script)) {
116+
if (const Ref<Script> custom_script = PropertyUtils::get_custom_type_script(*edited_resource); custom_script.is_valid()) {
117+
if (const String global_name = custom_script->get_global_name(); !global_name.is_empty()) {
118+
resource_name = global_name;
119+
}
120+
}
121+
}
122+
}
123+
110124
if (num_of_copies > 1) {
111-
tooltip = vformat(TTR("This Resource is used in (%d) places."), num_of_copies);
125+
tooltip = vformat(TTRN("This %s is used in %d place.", "This %s is used in %d places.", num_of_copies), resource_name, num_of_copies);
112126
} else if (!is_internal) {
113-
tooltip = TTR("This Resource is external to scene.");
127+
tooltip = vformat(TTR("This %s is external to scene."), resource_name);
114128
}
115129

116130
if (!editable) {
117-
tooltip += "\n" + TTR("The Resource cannot be edited in the inspector and can't be made unique directly.") + "\n";
131+
tooltip += "\n" + vformat(TTR("The %s cannot be edited in the inspector and can't be made unique directly."), resource_name) + "\n";
118132
} else {
119-
tooltip += unique_enable ? TTR(" Left-click to make it unique.") + "\n" : "\n";
133+
if (unique_enable) {
134+
tooltip += "\n" + TTR("Left-click to make it unique.") + "\n";
135+
}
120136

121137
if (unique_recursive_enabled) {
122-
tooltip += TTR("It is possible to make its subresources unique. Right-click to make them unique.") + "\n";
138+
tooltip += TTR("It is possible to make its subresources unique.") + "\n" + TTR("Right-click to make them unique.");
123139
}
124140

125141
if (!unique_enable && EditorNode::get_singleton()->get_editor_selection()->get_full_selected_node_list().size() == 1) {

0 commit comments

Comments
 (0)