4646#include " editor/editor_property_name_processor.h"
4747#include " editor/editor_settings.h"
4848#include " editor/editor_string_names.h"
49+ #include " editor/filesystem_dock.h"
4950#include " editor/gui/editor_toaster.h"
5051#include " editor/plugins/script_editor_plugin.h"
5152#include " editor/themes/editor_scale.h"
@@ -3870,6 +3871,37 @@ void EditorHelpBit::_update_labels() {
38703871 _add_text_to_rt (help_data.description .replace (" <EditorHelpBitCommentColor>" , comment_color.to_html ()), content, this , symbol_class_name);
38713872 }
38723873
3874+ if (!help_data.resource_path .is_empty ()) {
3875+ if (has_prev_text) {
3876+ content->add_newline ();
3877+ content->add_newline ();
3878+ }
3879+ has_prev_text = true ;
3880+
3881+ const String ext = help_data.resource_path .get_extension ();
3882+ const bool is_dir = ext.is_empty ();
3883+ const bool is_valid = is_dir || EditorFileSystem::get_singleton ()->get_valid_extensions ().has (ext);
3884+ if (!is_dir && is_valid) {
3885+ content->push_meta (" open-res:" + help_data.resource_path , RichTextLabel::META_UNDERLINE_ON_HOVER);
3886+ content->add_image (get_editor_theme_icon (SNAME (" Load" )));
3887+ content->add_text (nbsp + TTR (" Open" ));
3888+ content->pop (); // meta
3889+ content->add_newline ();
3890+ }
3891+
3892+ if (is_valid) {
3893+ content->push_meta (" show:" + help_data.resource_path , RichTextLabel::META_UNDERLINE_ON_HOVER);
3894+ content->add_image (get_editor_theme_icon (SNAME (" Filesystem" )));
3895+ content->add_text (nbsp + TTR (" Show in FileSystem" ));
3896+ content->pop (); // meta
3897+ } else {
3898+ content->push_meta (" open-file:" + help_data.resource_path , RichTextLabel::META_UNDERLINE_ON_HOVER);
3899+ content->add_image (get_editor_theme_icon (SNAME (" Filesystem" )));
3900+ content->add_text (nbsp + TTR (" Open in File Manager" ));
3901+ content->pop (); // meta
3902+ }
3903+ }
3904+
38733905 if (is_inside_tree ()) {
38743906 update_content_height ();
38753907 }
@@ -3951,6 +3983,17 @@ void EditorHelpBit::_meta_clicked(const String &p_select) {
39513983 } else {
39523984 _go_to_help (topic + " :" + symbol_class_name + " :" + link);
39533985 }
3986+ } else if (p_select.begins_with (" open-file:" )) {
3987+ String path = ProjectSettings::get_singleton ()->globalize_path (p_select.trim_prefix (" open-file:" ));
3988+ OS::get_singleton ()->shell_show_in_file_manager (path, true );
3989+ } else if (p_select.begins_with (" open-res:" )) {
3990+ if (help_data.doc_type .type == " PackedScene" ) {
3991+ EditorNode::get_singleton ()->load_scene (p_select.trim_prefix (" open-res:" ));
3992+ } else {
3993+ EditorNode::get_singleton ()->load_resource (p_select.trim_prefix (" open-res:" ));
3994+ }
3995+ } else if (p_select.begins_with (" show:" )) {
3996+ FileSystemDock::get_singleton ()->navigate_to_path (p_select.trim_prefix (" show:" ));
39543997 } else if (p_select.begins_with (" http:" ) || p_select.begins_with (" https:" )) {
39553998 OS::get_singleton ()->shell_open (p_select);
39563999 } else if (p_select.begins_with (" ^" )) { // Copy button.
@@ -4074,6 +4117,46 @@ void EditorHelpBit::parse_symbol(const String &p_symbol, const String &p_prologu
40744117 help_data.doc_type .enumeration = item_data.get (" enumeration" , " " );
40754118 help_data.doc_type .is_bitfield = item_data.get (" is_bitfield" , false );
40764119 help_data.value = item_data.get (" value" , " " );
4120+ } else if (item_type == " resource" ) {
4121+ String path = item_name.simplify_path ();
4122+ const bool is_uid = path.begins_with (" uid://" );
4123+ if (is_uid) {
4124+ if (ResourceUID::get_singleton ()->has_id (ResourceUID::get_singleton ()->text_to_id (path))) {
4125+ path = ResourceUID::uid_to_path (path);
4126+ } else {
4127+ path = " " ;
4128+ }
4129+ }
4130+ help_data.resource_path = path;
4131+
4132+ Ref<DirAccess> da = DirAccess::create (DirAccess::ACCESS_RESOURCES);
4133+ if (da->file_exists (path)) {
4134+ help_data.doc_type .type = ResourceLoader::get_resource_type (path);
4135+ if (help_data.doc_type .type .is_empty ()) {
4136+ const Vector<String> textfile_ext = ((String)(EDITOR_GET (" docks/filesystem/textfile_extensions" ))).split (" ," , false );
4137+ symbol_type = textfile_ext.has (path.get_extension ()) ? TTR (" TextFile" ) : TTR (" File" );
4138+ } else {
4139+ symbol_type = TTR (" Resource" );
4140+ symbol_hint = SYMBOL_HINT_ASSIGNABLE;
4141+ if (is_uid) {
4142+ help_data.description = vformat (" %s: [color=<EditorHelpBitCommentColor>]%s[/color]" , TTR (" Path" ), path);
4143+ }
4144+ }
4145+ symbol_name = path.get_file ();
4146+ } else if (!is_uid && da->dir_exists (path)) {
4147+ symbol_type = TTR (" Directory" );
4148+ symbol_name = path;
4149+ } else {
4150+ help_data.resource_path = " " ;
4151+ symbol_name = " " ;
4152+ if (is_uid) {
4153+ symbol_type = TTR (" Invalid UID" );
4154+ help_data.description = " [color=<EditorHelpBitCommentColor>][i]" + TTR (" This UID does not point to any valid Resource." ) + " [/i][/color]" ;
4155+ } else {
4156+ symbol_type = TTR (" Invalid path" );
4157+ help_data.description = " [color=<EditorHelpBitCommentColor>][i]" + TTR (" This path does not exist." ) + " [/i][/color]" ;
4158+ }
4159+ }
40774160 } else {
40784161 ERR_FAIL_MSG (" Invalid doc id: Unknown item type " + item_type.quote () + " ." );
40794162 }
@@ -4091,7 +4174,7 @@ void EditorHelpBit::parse_symbol(const String &p_symbol, const String &p_prologu
40914174 }
40924175 }
40934176
4094- if (help_data.description .is_empty ()) {
4177+ if (help_data.description .is_empty () && item_type != " resource " ) {
40954178 help_data.description = " [color=<EditorHelpBitCommentColor>][i]" + TTR (" No description available." ) + " [/i][/color]" ;
40964179 }
40974180
0 commit comments