diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2023-10-04 15:34:40 +0200 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-10-04 15:34:40 +0200 |
| commit | bb30c8377c3a49edeb025ec797bd2e2fecdc179d (patch) | |
| tree | ac7d9e2b8e91e8fbdde9b8c795997a583200d2bb /editor/editor_feature_profile.cpp | |
| parent | d5db0e5032f60a832a01d3af883087447be803ae (diff) | |
| parent | ae91644c7393f29a056812ea3a551758398da98e (diff) | |
| download | redot-engine-bb30c8377c3a49edeb025ec797bd2e2fecdc179d.tar.gz | |
Merge pull request #82051 from YeldhamDev/i_just_wanted_to_add_tooltips_to_theme_items_man
Revamp how documentation tooltips work
Diffstat (limited to 'editor/editor_feature_profile.cpp')
| -rw-r--r-- | editor/editor_feature_profile.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index 50406bea6a..5a44ae1aba 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -555,21 +555,22 @@ void EditorFeatureProfileManager::_class_list_item_selected() { Variant md = item->get_metadata(0); if (md.get_type() == Variant::STRING || md.get_type() == Variant::STRING_NAME) { - String class_name = md; - String class_description; - - DocTools *dd = EditorHelp::get_doc_data(); - HashMap<String, DocData::ClassDoc>::Iterator E = dd->class_list.find(class_name); - if (E) { - class_description = DTR(E->value.brief_description); + String text = description_bit->get_class_description(md); + if (!text.is_empty()) { + // Display both class name and description, since the help bit may be displayed + // far away from the location (especially if the dialog was resized to be taller). + description_bit->set_text(vformat("[b]%s[/b]: %s", md, text)); + description_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 1)); + } else { + // Use nested `vformat()` as translators shouldn't interfere with BBCode tags. + description_bit->set_text(vformat(TTR("No description available for %s."), vformat("[b]%s[/b]", md))); + description_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 0.5)); } - - description_bit->set_text(class_description); } else if (md.get_type() == Variant::INT) { - int feature_id = md; - String feature_description = EditorFeatureProfile::get_feature_description(EditorFeatureProfile::Feature(feature_id)); + String feature_description = EditorFeatureProfile::get_feature_description(EditorFeatureProfile::Feature((int)md)); + description_bit->set_text(vformat("[b]%s[/b]: %s", TTR(item->get_text(0)), TTRGET(feature_description))); + description_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 1)); - description_bit->set_text(TTRGET(feature_description)); return; } else { return; |
