mirror of
https://github.com/godotengine/godot.git
synced 2024-12-01 16:42:26 +00:00
Editor: Fix _parse_category()
is not called for custom categories
(cherry picked from commit 547f03b6d7
)
This commit is contained in:
parent
d771bc6084
commit
34010bf4d2
@ -2808,53 +2808,53 @@ void EditorInspector::update_tree() {
|
||||
|
||||
// `hint_script` should contain a native class name or a script path.
|
||||
// Otherwise the category was probably added via `@export_category` or `_get_property_list()`.
|
||||
// Do not add an icon, do not change the current class (`doc_name`) for custom categories.
|
||||
if (p.hint_string.is_empty()) {
|
||||
category->label = p.name;
|
||||
category->set_tooltip_text(p.name);
|
||||
continue; // Do not add an icon, do not change the current class (`doc_name`).
|
||||
}
|
||||
} else {
|
||||
String type = p.name;
|
||||
String label = p.name;
|
||||
doc_name = p.name;
|
||||
|
||||
String type = p.name;
|
||||
String label = p.name;
|
||||
doc_name = p.name;
|
||||
// Use category's owner script to update some of its information.
|
||||
if (!EditorNode::get_editor_data().is_type_recognized(type) && ResourceLoader::exists(p.hint_string)) {
|
||||
Ref<Script> scr = ResourceLoader::load(p.hint_string, "Script");
|
||||
if (scr.is_valid()) {
|
||||
StringName script_name = EditorNode::get_editor_data().script_class_get_name(scr->get_path());
|
||||
|
||||
// Use category's owner script to update some of its information.
|
||||
if (!EditorNode::get_editor_data().is_type_recognized(type) && p.hint_string.length() && ResourceLoader::exists(p.hint_string)) {
|
||||
Ref<Script> scr = ResourceLoader::load(p.hint_string, "Script");
|
||||
if (scr.is_valid()) {
|
||||
StringName script_name = EditorNode::get_editor_data().script_class_get_name(scr->get_path());
|
||||
// Update the docs reference and the label based on the script.
|
||||
Vector<DocData::ClassDoc> docs = scr->get_documentation();
|
||||
if (!docs.is_empty()) {
|
||||
// The documentation of a GDScript's main class is at the end of the array.
|
||||
// Hacky because this isn't necessarily always guaranteed.
|
||||
doc_name = docs[docs.size() - 1].name;
|
||||
}
|
||||
if (script_name != StringName()) {
|
||||
label = script_name;
|
||||
}
|
||||
|
||||
// Update the docs reference and the label based on the script.
|
||||
Vector<DocData::ClassDoc> docs = scr->get_documentation();
|
||||
if (!docs.is_empty()) {
|
||||
// The documentation of a GDScript's main class is at the end of the array.
|
||||
// Hacky because this isn't necessarily always guaranteed.
|
||||
doc_name = docs[docs.size() - 1].name;
|
||||
}
|
||||
if (script_name != StringName()) {
|
||||
label = script_name;
|
||||
}
|
||||
|
||||
// Find the icon corresponding to the script.
|
||||
if (script_name != StringName()) {
|
||||
category->icon = EditorNode::get_singleton()->get_class_icon(script_name);
|
||||
} else {
|
||||
category->icon = EditorNode::get_singleton()->get_object_icon(scr.ptr(), "Object");
|
||||
// Find the icon corresponding to the script.
|
||||
if (script_name != StringName()) {
|
||||
category->icon = EditorNode::get_singleton()->get_class_icon(script_name);
|
||||
} else {
|
||||
category->icon = EditorNode::get_singleton()->get_object_icon(scr.ptr(), "Object");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (category->icon.is_null() && !type.is_empty()) {
|
||||
category->icon = EditorNode::get_singleton()->get_class_icon(type);
|
||||
}
|
||||
if (category->icon.is_null() && !type.is_empty()) {
|
||||
category->icon = EditorNode::get_singleton()->get_class_icon(type);
|
||||
}
|
||||
|
||||
// Set the category label.
|
||||
category->label = label;
|
||||
category->doc_class_name = doc_name;
|
||||
// Set the category label.
|
||||
category->label = label;
|
||||
category->doc_class_name = doc_name;
|
||||
|
||||
if (use_doc_hints) {
|
||||
// `|` separator used in `EditorHelpTooltip` for formatting.
|
||||
category->set_tooltip_text("class|" + doc_name + "||");
|
||||
if (use_doc_hints) {
|
||||
// `|` separator used in `EditorHelpTooltip` for formatting.
|
||||
category->set_tooltip_text("class|" + doc_name + "||");
|
||||
}
|
||||
}
|
||||
|
||||
// Add editors at the start of a category.
|
||||
|
Loading…
Reference in New Issue
Block a user