From 610864d1db2ac2d6ea7588994ce426c122556c54 Mon Sep 17 00:00:00 2001 From: Micky Date: Mon, 31 Oct 2022 11:27:10 +0100 Subject: [PATCH] Add tooltip to method qualifiers in Documentation Help --- editor/editor_help.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 51926807875..50b4f28b700 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -368,8 +368,29 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview class_desc->pop(); if (!p_method.qualifiers.is_empty()) { class_desc->push_color(qualifier_color); - class_desc->add_text(" "); - _add_text(p_method.qualifiers); + + PackedStringArray qualifiers = p_method.qualifiers.split_spaces(); + for (const String &qualifier : qualifiers) { + String hint; + if (qualifier == "vararg") { + hint = TTR("This method supports a variable number of arguments."); + } else if (qualifier == "virtual") { + hint = TTR("This method is called by the engine.\nIt can be overriden to customise built-in behavior."); + } else if (qualifier == "const") { + hint = TTR("This method has no side effects.\nIt does not modify the object in any way."); + } else if (qualifier == "static") { + hint = TTR("This method does not need an instance to be called.\nIt can be called directly using the class name."); + } + + class_desc->add_text(" "); + if (!hint.is_empty()) { + class_desc->push_hint(hint); + class_desc->add_text(qualifier); + class_desc->pop(); + } else { + class_desc->add_text(qualifier); + } + } class_desc->pop(); }