Skip to content

Commit 1bfcb6e

Browse files
committed
Set doc_name even when categories are hidden in the inspector
Otherwise, tooltips will fail to fetch descriptions.
1 parent 1e6b11d commit 1bfcb6e

File tree

2 files changed

+37
-29
lines changed

2 files changed

+37
-29
lines changed

editor/editor_help.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#include "core/object/script_language.h"
3838
#include "core/os/keyboard.h"
3939
#include "core/string/string_builder.h"
40-
#include "core/version.h"
40+
#include "core/version_generated.gen.h"
4141
#include "editor/doc_data_compressed.gen.h"
4242
#include "editor/editor_node.h"
4343
#include "editor/editor_paths.h"
@@ -3380,6 +3380,7 @@ EditorHelpBit::HelpData EditorHelpBit::_get_theme_item_help_data(const StringNam
33803380
if (theme_item.name == p_theme_item_name) {
33813381
result = current;
33823382
found = true;
3383+
33833384
if (!is_native) {
33843385
break;
33853386
}

editor/editor_inspector.cpp

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,15 +2869,6 @@ void EditorInspector::update_tree() {
28692869
// Otherwise the category was probably added via `@export_category` or `_get_property_list()`.
28702870
const bool is_custom_category = p.hint_string.is_empty();
28712871

2872-
if ((is_custom_category && !show_custom_categories) || (!is_custom_category && !show_standard_categories)) {
2873-
continue;
2874-
}
2875-
2876-
// Hide the "MultiNodeEdit" category for MultiNodeEdit.
2877-
if (Object::cast_to<MultiNodeEdit>(object) && p.name == "MultiNodeEdit") {
2878-
continue;
2879-
}
2880-
28812872
// Iterate over remaining properties. If no properties in category, skip the category.
28822873
List<PropertyInfo>::Element *N = E_property->next();
28832874
bool valid = true;
@@ -2898,22 +2889,20 @@ void EditorInspector::update_tree() {
28982889
continue; // Empty, ignore it.
28992890
}
29002891

2901-
// Create an EditorInspectorCategory and add it to the inspector.
2902-
EditorInspectorCategory *category = memnew(EditorInspectorCategory);
2903-
main_vbox->add_child(category);
2904-
category_vbox = nullptr; //reset
2892+
String category_label;
2893+
String category_tooltip;
2894+
Ref<Texture> category_icon;
29052895

29062896
// Do not add an icon, do not change the current class (`doc_name`) for custom categories.
29072897
if (is_custom_category) {
2908-
category->label = p.name;
2909-
category->set_tooltip_text(p.name);
2898+
category_label = p.name;
2899+
category_tooltip = p.name;
29102900
} else {
2911-
String type = p.name;
2912-
String label = p.name;
29132901
doc_name = p.name;
2902+
category_label = p.name;
29142903

29152904
// Use category's owner script to update some of its information.
2916-
if (!EditorNode::get_editor_data().is_type_recognized(type) && ResourceLoader::exists(p.hint_string)) {
2905+
if (!EditorNode::get_editor_data().is_type_recognized(p.name) && ResourceLoader::exists(p.hint_string)) {
29172906
Ref<Script> scr = ResourceLoader::load(p.hint_string, "Script");
29182907
if (scr.is_valid()) {
29192908
StringName script_name = EditorNode::get_editor_data().script_class_get_name(scr->get_path());
@@ -2926,32 +2915,50 @@ void EditorInspector::update_tree() {
29262915
doc_name = docs[docs.size() - 1].name;
29272916
}
29282917
if (script_name != StringName()) {
2929-
label = script_name;
2918+
category_label = script_name;
29302919
}
29312920

29322921
// Find the icon corresponding to the script.
29332922
if (script_name != StringName()) {
2934-
category->icon = EditorNode::get_singleton()->get_class_icon(script_name);
2923+
category_icon = EditorNode::get_singleton()->get_class_icon(script_name);
29352924
} else {
2936-
category->icon = EditorNode::get_singleton()->get_object_icon(scr.ptr(), "Object");
2925+
category_icon = EditorNode::get_singleton()->get_object_icon(scr.ptr(), "Object");
29372926
}
29382927
}
29392928
}
29402929

2941-
if (category->icon.is_null() && !type.is_empty()) {
2942-
category->icon = EditorNode::get_singleton()->get_class_icon(type);
2930+
if (category_icon.is_null() && !p.name.is_empty()) {
2931+
category_icon = EditorNode::get_singleton()->get_class_icon(p.name);
29432932
}
29442933

2945-
// Set the category label.
2946-
category->label = label;
2947-
category->doc_class_name = doc_name;
2948-
29492934
if (use_doc_hints) {
29502935
// `|` separators used in `EditorHelpBit`.
2951-
category->set_tooltip_text("class|" + doc_name + "|");
2936+
category_tooltip = "class|" + doc_name + "|";
29522937
}
29532938
}
29542939

2940+
if ((is_custom_category && !show_custom_categories) || (!is_custom_category && !show_standard_categories)) {
2941+
continue;
2942+
}
2943+
2944+
// Hide the "MultiNodeEdit" category for MultiNodeEdit.
2945+
if (Object::cast_to<MultiNodeEdit>(object) && p.name == "MultiNodeEdit") {
2946+
continue;
2947+
}
2948+
2949+
// Create an EditorInspectorCategory and add it to the inspector.
2950+
EditorInspectorCategory *category = memnew(EditorInspectorCategory);
2951+
main_vbox->add_child(category);
2952+
category_vbox = nullptr; // Reset.
2953+
2954+
// Set the category info.
2955+
category->label = category_label;
2956+
category->set_tooltip_text(category_tooltip);
2957+
category->icon = category_icon;
2958+
if (!is_custom_category) {
2959+
category->doc_class_name = doc_name;
2960+
}
2961+
29552962
// Add editors at the start of a category.
29562963
for (Ref<EditorInspectorPlugin> &ped : valid_plugins) {
29572964
ped->parse_category(object, p.name);

0 commit comments

Comments
 (0)