summaryrefslogtreecommitdiffstats
path: root/editor/editor_help.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_help.cpp')
-rw-r--r--editor/editor_help.cpp104
1 files changed, 85 insertions, 19 deletions
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 00ac1c7c6f..fe758bf99b 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -288,7 +288,7 @@ void EditorHelp::_class_desc_select(const String &p_select) {
// Case order is important here to correctly handle edge cases like Variant.Type in @GlobalScope.
if (table->has(link)) {
// Found in the current page.
- if (class_desc->is_ready()) {
+ if (class_desc->is_finished()) {
emit_signal(SNAME("request_save_history"));
class_desc->scroll_to_paragraph((*table)[link]);
} else {
@@ -376,10 +376,10 @@ static void _add_type_to_rt(const String &p_type, const String &p_enum, bool p_i
}
p_rt->push_color(type_color);
- bool add_array = false;
+ bool add_typed_container = false;
if (can_ref) {
if (link_t.ends_with("[]")) {
- add_array = true;
+ add_typed_container = true;
link_t = link_t.trim_suffix("[]");
display_t = display_t.trim_suffix("[]");
@@ -387,6 +387,22 @@ static void _add_type_to_rt(const String &p_type, const String &p_enum, bool p_i
p_rt->add_text("Array");
p_rt->pop(); // meta
p_rt->add_text("[");
+ } else if (link_t.begins_with("Dictionary[")) {
+ add_typed_container = true;
+ link_t = link_t.trim_prefix("Dictionary[").trim_suffix("]");
+ display_t = display_t.trim_prefix("Dictionary[").trim_suffix("]");
+
+ p_rt->push_meta("#Dictionary", RichTextLabel::META_UNDERLINE_ON_HOVER); // class
+ p_rt->add_text("Dictionary");
+ p_rt->pop(); // meta
+ p_rt->add_text("[");
+ p_rt->push_meta("#" + link_t.get_slice(", ", 0), RichTextLabel::META_UNDERLINE_ON_HOVER); // class
+ p_rt->add_text(_contextualize_class_specifier(display_t.get_slice(", ", 0), p_class));
+ p_rt->pop(); // meta
+ p_rt->add_text(", ");
+
+ link_t = link_t.get_slice(", ", 1);
+ display_t = _contextualize_class_specifier(display_t.get_slice(", ", 1), p_class);
} else if (is_bitfield) {
p_rt->push_color(Color(type_color, 0.5));
p_rt->push_hint(TTR("This value is an integer composed as a bitmask of the following flags."));
@@ -405,7 +421,7 @@ static void _add_type_to_rt(const String &p_type, const String &p_enum, bool p_i
p_rt->add_text(display_t);
if (can_ref) {
p_rt->pop(); // meta
- if (add_array) {
+ if (add_typed_container) {
p_rt->add_text("]");
} else if (is_bitfield) {
p_rt->push_color(Color(type_color, 0.5));
@@ -1456,10 +1472,31 @@ void EditorHelp::_update_doc() {
_push_normal_font();
class_desc->push_color(theme_cache.comment_color);
+ bool has_prev_text = false;
+
+ if (theme_item.is_deprecated) {
+ has_prev_text = true;
+ DEPRECATED_DOC_MSG(HANDLE_DOC(theme_item.deprecated_message), TTR("This theme property may be changed or removed in future versions."));
+ }
+
+ if (theme_item.is_experimental) {
+ if (has_prev_text) {
+ class_desc->add_newline();
+ class_desc->add_newline();
+ }
+ has_prev_text = true;
+ EXPERIMENTAL_DOC_MSG(HANDLE_DOC(theme_item.experimental_message), TTR("This theme property may be changed or removed in future versions."));
+ }
+
const String descr = HANDLE_DOC(theme_item.description);
if (!descr.is_empty()) {
+ if (has_prev_text) {
+ class_desc->add_newline();
+ class_desc->add_newline();
+ }
+ has_prev_text = true;
_add_text(descr);
- } else {
+ } else if (!has_prev_text) {
class_desc->add_image(get_editor_theme_icon(SNAME("Error")));
class_desc->add_text(" ");
class_desc->push_color(theme_cache.comment_color);
@@ -2220,12 +2257,6 @@ void EditorHelp::_update_doc() {
}
has_prev_text = true;
_add_text(descr);
- // Add copy note to built-in properties returning Packed*Array.
- if (!cd.is_script_doc && packed_array_types.has(prop.type)) {
- class_desc->add_newline();
- class_desc->add_newline();
- _add_text(vformat(TTR("[b]Note:[/b] The returned array is [i]copied[/i] and any changes to it will not update the original property value. See [%s] for more details."), prop.type));
- }
} else if (!has_prev_text) {
class_desc->add_image(get_editor_theme_icon(SNAME("Error")));
class_desc->add_text(" ");
@@ -2238,6 +2269,13 @@ void EditorHelp::_update_doc() {
class_desc->pop(); // color
}
+ // Add copy note to built-in properties returning `Packed*Array`.
+ if (!cd.is_script_doc && packed_array_types.has(prop.type)) {
+ class_desc->add_newline();
+ class_desc->add_newline();
+ _add_text(vformat(TTR("[b]Note:[/b] The returned array is [i]copied[/i] and any changes to it will not update the original property value. See [%s] for more details."), prop.type));
+ }
+
class_desc->pop(); // color
_pop_normal_font();
class_desc->pop(); // indent
@@ -2338,7 +2376,7 @@ void EditorHelp::_help_callback(const String &p_topic) {
}
}
- if (class_desc->is_ready()) {
+ if (class_desc->is_finished()) {
// call_deferred() is not enough.
if (class_desc->is_connected(SceneStringName(draw), callable_mp(class_desc, &RichTextLabel::scroll_to_paragraph))) {
class_desc->disconnect(SceneStringName(draw), callable_mp(class_desc, &RichTextLabel::scroll_to_paragraph));
@@ -2856,7 +2894,7 @@ void EditorHelp::_compute_doc_version_hash() {
}
String EditorHelp::get_cache_full_path() {
- return EditorPaths::get_singleton()->get_cache_dir().path_join("editor_doc_cache.res");
+ return EditorPaths::get_singleton()->get_cache_dir().path_join(vformat("editor_doc_cache-%d.%d.res", VERSION_MAJOR, VERSION_MINOR));
}
void EditorHelp::load_xml_buffer(const uint8_t *p_buffer, int p_size) {
@@ -3024,6 +3062,7 @@ void EditorHelp::update_doc() {
void EditorHelp::cleanup_doc() {
_wait_for_thread();
memdelete(doc);
+ doc = nullptr;
}
Vector<Pair<String, int>> EditorHelp::get_sections() {
@@ -3039,7 +3078,7 @@ Vector<Pair<String, int>> EditorHelp::get_sections() {
void EditorHelp::scroll_to_section(int p_section_index) {
_wait_for_thread();
int line = section_line[p_section_index].second;
- if (class_desc->is_ready()) {
+ if (class_desc->is_finished()) {
class_desc->scroll_to_paragraph(line);
} else {
scroll_to = line;
@@ -3379,6 +3418,20 @@ EditorHelpBit::HelpData EditorHelpBit::_get_theme_item_help_data(const StringNam
for (const DocData::ThemeItemDoc &theme_item : E->value.theme_properties) {
HelpData current;
current.description = HANDLE_DOC(theme_item.description);
+ if (theme_item.is_deprecated) {
+ if (theme_item.deprecated_message.is_empty()) {
+ current.deprecated_message = TTR("This theme property may be changed or removed in future versions.");
+ } else {
+ current.deprecated_message = HANDLE_DOC(theme_item.deprecated_message);
+ }
+ }
+ if (theme_item.is_experimental) {
+ if (theme_item.experimental_message.is_empty()) {
+ current.experimental_message = TTR("This theme property may be changed or removed in future versions.");
+ } else {
+ current.experimental_message = HANDLE_DOC(theme_item.experimental_message);
+ }
+ }
if (theme_item.name == p_theme_item_name) {
result = current;
@@ -3761,6 +3814,12 @@ EditorHelpBit::EditorHelpBit(const String &p_symbol) {
/// EditorHelpBitTooltip ///
+void EditorHelpBitTooltip::_start_timer() {
+ if (timer->is_inside_tree() && timer->is_stopped()) {
+ timer->start();
+ }
+}
+
void EditorHelpBitTooltip::_safe_queue_free() {
if (_pushing_input > 0) {
_need_free = true;
@@ -3769,13 +3828,20 @@ void EditorHelpBitTooltip::_safe_queue_free() {
}
}
+void EditorHelpBitTooltip::_target_gui_input(const Ref<InputEvent> &p_event) {
+ const Ref<InputEventMouse> mouse_event = p_event;
+ if (mouse_event.is_valid()) {
+ _start_timer();
+ }
+}
+
void EditorHelpBitTooltip::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_WM_MOUSE_ENTER:
timer->stop();
break;
case NOTIFICATION_WM_MOUSE_EXIT:
- timer->start();
+ _start_timer();
break;
}
}
@@ -3783,7 +3849,7 @@ void EditorHelpBitTooltip::_notification(int p_what) {
// Forwards non-mouse input to the parent viewport.
void EditorHelpBitTooltip::_input_from_window(const Ref<InputEvent> &p_event) {
if (p_event->is_action_pressed(SNAME("ui_cancel"), false, true)) {
- hide(); // Will be deleted on its timer.
+ _safe_queue_free();
} else {
const Ref<InputEventMouse> mouse_event = p_event;
if (mouse_event.is_null()) {
@@ -3801,7 +3867,7 @@ void EditorHelpBitTooltip::_input_from_window(const Ref<InputEvent> &p_event) {
void EditorHelpBitTooltip::show_tooltip(EditorHelpBit *p_help_bit, Control *p_target) {
ERR_FAIL_NULL(p_help_bit);
EditorHelpBitTooltip *tooltip = memnew(EditorHelpBitTooltip(p_target));
- p_help_bit->connect("request_hide", callable_mp(static_cast<Window *>(tooltip), &Window::hide)); // Will be deleted on its timer.
+ p_help_bit->connect("request_hide", callable_mp(tooltip, &EditorHelpBitTooltip::_safe_queue_free));
tooltip->add_child(p_help_bit);
p_target->get_viewport()->add_child(tooltip);
p_help_bit->update_content_height();
@@ -3858,8 +3924,8 @@ EditorHelpBitTooltip::EditorHelpBitTooltip(Control *p_target) {
add_child(timer);
ERR_FAIL_NULL(p_target);
- p_target->connect(SceneStringName(mouse_entered), callable_mp(timer, &Timer::stop));
- p_target->connect(SceneStringName(mouse_exited), callable_mp(timer, &Timer::start).bind(-1));
+ p_target->connect(SceneStringName(mouse_exited), callable_mp(this, &EditorHelpBitTooltip::_start_timer));
+ p_target->connect(SceneStringName(gui_input), callable_mp(this, &EditorHelpBitTooltip::_target_gui_input));
}
#if defined(MODULE_GDSCRIPT_ENABLED) || defined(MODULE_MONO_ENABLED)