diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-02-27 20:53:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-27 20:53:51 +0100 |
commit | fec9a76aba2b45a13ba8d85392549d41f6c6fe60 (patch) | |
tree | ba1aeba92a0ab58a981a2f6295f428e9f16c41a6 | |
parent | eced623c579d59d4cfdb48fd983a47f497d6024c (diff) | |
parent | 28d3f85e64493de58ddd4f83a72545ff6fa617a6 (diff) |
Merge pull request #36546 from YeldhamDev/inspector_tooltip_no_doubles
Don't show a copy of the property's name in the inspector's tooltip if there's no description
-rw-r--r-- | editor/connections_dialog.cpp | 1 | ||||
-rw-r--r-- | editor/editor_inspector.cpp | 36 |
2 files changed, 28 insertions, 9 deletions
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 2adc6f5398..f78867e493 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -502,7 +502,6 @@ Control *ConnectionsDockTree::make_custom_tooltip(const String &p_text) const { String text = TTR("Signal:") + " [u][b]" + p_text.get_slice("::", 0) + "[/b][/u]"; text += p_text.get_slice("::", 1).strip_edges() + "\n"; text += p_text.get_slice("::", 2).strip_edges(); - help_bit->set_text(text); help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene return help_bit; } diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index d10cc7f91e..adf6a42f53 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -778,10 +778,20 @@ Control *EditorProperty::make_custom_tooltip(const String &p_text) const { help_bit->add_style_override("panel", get_stylebox("panel", "TooltipPanel")); help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE); - String text = TTR("Property:") + " [u][b]" + p_text.get_slice("::", 0) + "[/b][/u]\n"; - text += p_text.get_slice("::", 1).strip_edges(); - help_bit->set_text(text); - help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene + PackedStringArray slices = p_text.split("::", false); + if (!slices.empty()) { + String property_name = slices[0].strip_edges(); + String text = TTR("Property:") + " [u][b]" + property_name + "[/b][/u]"; + + if (slices.size() > 1) { + String property_doc = slices[1].strip_edges(); + if (property_name != property_doc) { + text += "\n" + property_doc; + } + } + help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene + } + return help_bit; } @@ -1005,10 +1015,20 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons help_bit->add_style_override("panel", get_stylebox("panel", "TooltipPanel")); help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE); - String text = "[u][b]" + p_text.get_slice("::", 0) + "[/b][/u]\n"; - text += p_text.get_slice("::", 1).strip_edges(); - help_bit->set_text(text); - help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene + PackedStringArray slices = p_text.split("::", false); + if (!slices.empty()) { + String property_name = slices[0].strip_edges(); + String text = "[u][b]" + property_name + "[/b][/u]"; + + if (slices.size() > 1) { + String property_doc = slices[1].strip_edges(); + if (property_name != property_doc) { + text += "\n" + property_doc; + } + } + help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene + } + return help_bit; } |