diff options
author | Michael Alexsander <michaelalexsander@protonmail.com> | 2021-08-08 18:49:43 -0300 |
---|---|---|
committer | Michael Alexsander <michaelalexsander@protonmail.com> | 2021-08-08 22:56:34 -0300 |
commit | bea868f750cc833b83b237738c5d23accfb50977 (patch) | |
tree | 989e6c57c8049174ce90850ffcc0330189e9a735 /editor | |
parent | 2df1765fc28052f25a6a12f3f5c5a974a88b9134 (diff) |
Make property description in the animation editor actually show it
Diffstat (limited to 'editor')
-rw-r--r-- | editor/property_selector.cpp | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index a1deae92a4..96fcb4fe29 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -351,51 +351,64 @@ void PropertySelector::_item_selected() { String class_type; if (type != Variant::NIL) { class_type = Variant::get_type_name(type); - - } else { + } else if (base_type != String()) { class_type = base_type; + } else if (instance) { + class_type = instance->get_class(); } DocTools *dd = EditorHelp::get_doc_data(); String text; - if (properties) { - String at_class = class_type; - - while (at_class != String()) { - Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(at_class); + while (class_type != String()) { + Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(class_type); if (E) { for (int i = 0; i < E->get().properties.size(); i++) { if (E->get().properties[i].name == name) { text = DTR(E->get().properties[i].description); + break; } } } - at_class = ClassDB::get_parent_class(at_class); + if (text != String()) { + break; + } + + // The property may be from a parent class, keep looking. + class_type = ClassDB::get_parent_class(class_type); } } else { - String at_class = class_type; - - while (at_class != String()) { - Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(at_class); + while (class_type != String()) { + Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(class_type); if (E) { for (int i = 0; i < E->get().methods.size(); i++) { if (E->get().methods[i].name == name) { text = DTR(E->get().methods[i].description); + break; } } } - at_class = ClassDB::get_parent_class(at_class); + if (text != String()) { + break; + } + + // The method may be from a parent class, keep looking. + class_type = ClassDB::get_parent_class(class_type); } } - if (text == String()) { - return; + if (text != String()) { + // Display both property name and description, since the help bit may be displayed + // far away from the location (especially if the dialog was resized to be taller). + help_bit->set_text(vformat("[b]%s[/b]: %s", name, text)); + help_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 1)); + } else { + // Use nested `vformat()` as translators shouldn't interfere with BBCode tags. + help_bit->set_text(vformat(TTR("No description available for %s."), vformat("[b]%s[/b]", name))); + help_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 0.5)); } - - help_bit->set_text(text); } void PropertySelector::_hide_requested() { |