| 1 | /**************************************************************************/ | 
| 2 | /*  editor_help.cpp                                                       */ | 
| 3 | /**************************************************************************/ | 
| 4 | /*                         This file is part of:                          */ | 
| 5 | /*                             GODOT ENGINE                               */ | 
| 6 | /*                        https://godotengine.org                         */ | 
| 7 | /**************************************************************************/ | 
| 8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | 
| 9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */ | 
| 10 | /*                                                                        */ | 
| 11 | /* Permission is hereby granted, free of charge, to any person obtaining  */ | 
| 12 | /* a copy of this software and associated documentation files (the        */ | 
| 13 | /* "Software"), to deal in the Software without restriction, including    */ | 
| 14 | /* without limitation the rights to use, copy, modify, merge, publish,    */ | 
| 15 | /* distribute, sublicense, and/or sell copies of the Software, and to     */ | 
| 16 | /* permit persons to whom the Software is furnished to do so, subject to  */ | 
| 17 | /* the following conditions:                                              */ | 
| 18 | /*                                                                        */ | 
| 19 | /* The above copyright notice and this permission notice shall be         */ | 
| 20 | /* included in all copies or substantial portions of the Software.        */ | 
| 21 | /*                                                                        */ | 
| 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */ | 
| 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */ | 
| 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | 
| 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */ | 
| 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */ | 
| 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */ | 
| 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */ | 
| 29 | /**************************************************************************/ | 
| 30 |  | 
| 31 | #include "editor_help.h" | 
| 32 |  | 
| 33 | #include "core/core_constants.h" | 
| 34 | #include "core/input/input.h" | 
| 35 | #include "core/object/script_language.h" | 
| 36 | #include "core/os/keyboard.h" | 
| 37 | #include "core/version.h" | 
| 38 | #include "doc_data_compressed.gen.h" | 
| 39 | #include "editor/editor_node.h" | 
| 40 | #include "editor/editor_paths.h" | 
| 41 | #include "editor/editor_scale.h" | 
| 42 | #include "editor/editor_settings.h" | 
| 43 | #include "editor/editor_string_names.h" | 
| 44 | #include "editor/plugins/script_editor_plugin.h" | 
| 45 | #include "scene/gui/line_edit.h" | 
| 46 |  | 
| 47 | #define CONTRIBUTE_URL vformat("%s/contributing/documentation/updating_the_class_reference.html", VERSION_DOCS_URL) | 
| 48 |  | 
| 49 | #ifdef MODULE_MONO_ENABLED | 
| 50 | // Sync with the types mentioned in https://docs.godotengine.org/en/stable/tutorials/scripting/c_sharp/c_sharp_differences.html | 
| 51 | const Vector<String> classes_with_csharp_differences = { | 
| 52 | 	"@GlobalScope" , | 
| 53 | 	"String" , | 
| 54 | 	"NodePath" , | 
| 55 | 	"Signal" , | 
| 56 | 	"Callable" , | 
| 57 | 	"RID" , | 
| 58 | 	"Basis" , | 
| 59 | 	"Transform2D" , | 
| 60 | 	"Transform3D" , | 
| 61 | 	"Rect2" , | 
| 62 | 	"Rect2i" , | 
| 63 | 	"AABB" , | 
| 64 | 	"Quaternion" , | 
| 65 | 	"Projection" , | 
| 66 | 	"Color" , | 
| 67 | 	"Array" , | 
| 68 | 	"Dictionary" , | 
| 69 | 	"PackedByteArray" , | 
| 70 | 	"PackedColorArray" , | 
| 71 | 	"PackedFloat32Array" , | 
| 72 | 	"PackedFloat64Array" , | 
| 73 | 	"PackedInt32Array" , | 
| 74 | 	"PackedInt64Array" , | 
| 75 | 	"PackedStringArray" , | 
| 76 | 	"PackedVector2Array" , | 
| 77 | 	"PackedVector3Array" , | 
| 78 | 	"Variant" , | 
| 79 | }; | 
| 80 | #endif | 
| 81 |  | 
| 82 | // TODO: this is sometimes used directly as doc->something, other times as EditorHelp::get_doc_data(), which is thread-safe. | 
| 83 | // Might this be a problem? | 
| 84 | DocTools *EditorHelp::doc = nullptr; | 
| 85 |  | 
| 86 | static bool _attempt_doc_load(const String &p_class) { | 
| 87 | 	// Docgen always happens in the outer-most class: it also generates docs for inner classes. | 
| 88 | 	String outer_class = p_class.get_slice("." , 0); | 
| 89 | 	if (!ScriptServer::is_global_class(outer_class)) { | 
| 90 | 		return false; | 
| 91 | 	} | 
| 92 |  | 
| 93 | 	// ResourceLoader is used in order to have a script-agnostic way to load scripts. | 
| 94 | 	// This forces GDScript to compile the code, which is unnecessary for docgen, but it's a good compromise right now. | 
| 95 | 	Ref<Script> script = ResourceLoader::load(ScriptServer::get_global_class_path(outer_class), outer_class); | 
| 96 | 	if (script.is_valid()) { | 
| 97 | 		Vector<DocData::ClassDoc> docs = script->get_documentation(); | 
| 98 | 		for (int j = 0; j < docs.size(); j++) { | 
| 99 | 			const DocData::ClassDoc &doc = docs.get(j); | 
| 100 | 			EditorHelp::get_doc_data()->add_doc(doc); | 
| 101 | 		} | 
| 102 | 		return true; | 
| 103 | 	} | 
| 104 |  | 
| 105 | 	return false; | 
| 106 | } | 
| 107 |  | 
| 108 | // Removes unnecessary prefix from p_class_specifier when within the p_edited_class context | 
| 109 | static String _contextualize_class_specifier(const String &p_class_specifier, const String &p_edited_class) { | 
| 110 | 	// If this is a completely different context than the current class, then keep full path | 
| 111 | 	if (!p_class_specifier.begins_with(p_edited_class)) { | 
| 112 | 		return p_class_specifier; | 
| 113 | 	} | 
| 114 |  | 
| 115 | 	// Here equal length + begins_with from above implies p_class_specifier == p_edited_class :) | 
| 116 | 	if (p_class_specifier.length() == p_edited_class.length()) { | 
| 117 | 		int rfind = p_class_specifier.rfind("." ); | 
| 118 | 		if (rfind == -1) { // Single identifier | 
| 119 | 			return p_class_specifier; | 
| 120 | 		} | 
| 121 | 		// Multiple specifiers: keep last one only | 
| 122 | 		return p_class_specifier.substr(rfind + 1); | 
| 123 | 	} | 
| 124 |  | 
| 125 | 	// They share a _name_ prefix but not a _class specifier_ prefix, e.g. Tree & TreeItem | 
| 126 | 	// begins_with + lengths being different implies p_class_specifier.length() > p_edited_class.length() so this is safe | 
| 127 | 	if (p_class_specifier[p_edited_class.length()] != '.') { | 
| 128 | 		return p_class_specifier; | 
| 129 | 	} | 
| 130 |  | 
| 131 | 	// Remove class specifier prefix | 
| 132 | 	return p_class_specifier.substr(p_edited_class.length() + 1); | 
| 133 | } | 
| 134 |  | 
| 135 | void EditorHelp::_update_theme_item_cache() { | 
| 136 | 	VBoxContainer::_update_theme_item_cache(); | 
| 137 |  | 
| 138 | 	theme_cache.text_color = get_theme_color(SNAME("text_color" ), SNAME("EditorHelp" )); | 
| 139 | 	theme_cache.title_color = get_theme_color(SNAME("title_color" ), SNAME("EditorHelp" )); | 
| 140 | 	theme_cache.headline_color = get_theme_color(SNAME("headline_color" ), SNAME("EditorHelp" )); | 
| 141 | 	theme_cache.comment_color = get_theme_color(SNAME("comment_color" ), SNAME("EditorHelp" )); | 
| 142 | 	theme_cache.symbol_color = get_theme_color(SNAME("symbol_color" ), SNAME("EditorHelp" )); | 
| 143 | 	theme_cache.value_color = get_theme_color(SNAME("value_color" ), SNAME("EditorHelp" )); | 
| 144 | 	theme_cache.qualifier_color = get_theme_color(SNAME("qualifier_color" ), SNAME("EditorHelp" )); | 
| 145 | 	theme_cache.type_color = get_theme_color(SNAME("type_color" ), SNAME("EditorHelp" )); | 
| 146 |  | 
| 147 | 	theme_cache.doc_font = get_theme_font(SNAME("doc" ), EditorStringName(EditorFonts)); | 
| 148 | 	theme_cache.doc_bold_font = get_theme_font(SNAME("doc_bold" ), EditorStringName(EditorFonts)); | 
| 149 | 	theme_cache.doc_italic_font = get_theme_font(SNAME("doc_italic" ), EditorStringName(EditorFonts)); | 
| 150 | 	theme_cache.doc_title_font = get_theme_font(SNAME("doc_title" ), EditorStringName(EditorFonts)); | 
| 151 | 	theme_cache.doc_code_font = get_theme_font(SNAME("doc_source" ), EditorStringName(EditorFonts)); | 
| 152 | 	theme_cache.doc_kbd_font = get_theme_font(SNAME("doc_keyboard" ), EditorStringName(EditorFonts)); | 
| 153 |  | 
| 154 | 	theme_cache.doc_font_size = get_theme_font_size(SNAME("doc_size" ), EditorStringName(EditorFonts)); | 
| 155 | 	theme_cache.doc_title_font_size = get_theme_font_size(SNAME("doc_title_size" ), EditorStringName(EditorFonts)); | 
| 156 | 	theme_cache.doc_code_font_size = get_theme_font_size(SNAME("doc_source_size" ), EditorStringName(EditorFonts)); | 
| 157 | 	theme_cache.doc_kbd_font_size = get_theme_font_size(SNAME("doc_keyboard_size" ), EditorStringName(EditorFonts)); | 
| 158 |  | 
| 159 | 	theme_cache.background_style = get_theme_stylebox(SNAME("background" ), SNAME("EditorHelp" )); | 
| 160 |  | 
| 161 | 	class_desc->add_theme_font_override("normal_font" , theme_cache.doc_font); | 
| 162 | 	class_desc->add_theme_font_size_override("normal_font_size" , theme_cache.doc_font_size); | 
| 163 |  | 
| 164 | 	class_desc->add_theme_color_override("selection_color" , get_theme_color(SNAME("selection_color" ), SNAME("EditorHelp" ))); | 
| 165 | 	class_desc->add_theme_constant_override("line_separation" , get_theme_constant(SNAME("line_separation" ), SNAME("EditorHelp" ))); | 
| 166 | 	class_desc->add_theme_constant_override("table_h_separation" , get_theme_constant(SNAME("table_h_separation" ), SNAME("EditorHelp" ))); | 
| 167 | 	class_desc->add_theme_constant_override("table_v_separation" , get_theme_constant(SNAME("table_v_separation" ), SNAME("EditorHelp" ))); | 
| 168 | 	class_desc->add_theme_constant_override("text_highlight_h_padding" , get_theme_constant(SNAME("text_highlight_h_padding" ), SNAME("EditorHelp" ))); | 
| 169 | 	class_desc->add_theme_constant_override("text_highlight_v_padding" , get_theme_constant(SNAME("text_highlight_v_padding" ), SNAME("EditorHelp" ))); | 
| 170 | } | 
| 171 |  | 
| 172 | void EditorHelp::_search(bool p_search_previous) { | 
| 173 | 	if (p_search_previous) { | 
| 174 | 		find_bar->search_prev(); | 
| 175 | 	} else { | 
| 176 | 		find_bar->search_next(); | 
| 177 | 	} | 
| 178 | } | 
| 179 |  | 
| 180 | void EditorHelp::_class_desc_finished() { | 
| 181 | 	if (scroll_to >= 0) { | 
| 182 | 		class_desc->scroll_to_paragraph(scroll_to); | 
| 183 | 	} | 
| 184 | 	scroll_to = -1; | 
| 185 | } | 
| 186 |  | 
| 187 | void EditorHelp::_class_list_select(const String &p_select) { | 
| 188 | 	_goto_desc(p_select); | 
| 189 | } | 
| 190 |  | 
| 191 | void EditorHelp::_class_desc_select(const String &p_select) { | 
| 192 | 	if (p_select.begins_with("$" )) { // enum | 
| 193 | 		String select = p_select.substr(1, p_select.length()); | 
| 194 | 		String class_name; | 
| 195 | 		int rfind = select.rfind("." ); | 
| 196 | 		if (rfind != -1) { | 
| 197 | 			class_name = select.substr(0, rfind); | 
| 198 | 			select = select.substr(rfind + 1); | 
| 199 | 		} else { | 
| 200 | 			class_name = "@GlobalScope" ; | 
| 201 | 		} | 
| 202 | 		emit_signal(SNAME("go_to_help" ), "class_enum:"  + class_name + ":"  + select); | 
| 203 | 		return; | 
| 204 | 	} else if (p_select.begins_with("#" )) { | 
| 205 | 		emit_signal(SNAME("go_to_help" ), "class_name:"  + p_select.substr(1, p_select.length())); | 
| 206 | 		return; | 
| 207 | 	} else if (p_select.begins_with("@" )) { | 
| 208 | 		int tag_end = p_select.find(" " ); | 
| 209 |  | 
| 210 | 		String tag = p_select.substr(1, tag_end - 1); | 
| 211 | 		String link = p_select.substr(tag_end + 1, p_select.length()).lstrip(" " ); | 
| 212 |  | 
| 213 | 		String topic; | 
| 214 | 		HashMap<String, int> *table = nullptr; | 
| 215 |  | 
| 216 | 		if (tag == "method" ) { | 
| 217 | 			topic = "class_method" ; | 
| 218 | 			table = &this->method_line; | 
| 219 | 		} else if (tag == "member" ) { | 
| 220 | 			topic = "class_property" ; | 
| 221 | 			table = &this->property_line; | 
| 222 | 		} else if (tag == "enum" ) { | 
| 223 | 			topic = "class_enum" ; | 
| 224 | 			table = &this->enum_line; | 
| 225 | 		} else if (tag == "signal" ) { | 
| 226 | 			topic = "class_signal" ; | 
| 227 | 			table = &this->signal_line; | 
| 228 | 		} else if (tag == "constant" ) { | 
| 229 | 			topic = "class_constant" ; | 
| 230 | 			table = &this->constant_line; | 
| 231 | 		} else if (tag == "annotation" ) { | 
| 232 | 			topic = "class_annotation" ; | 
| 233 | 			table = &this->annotation_line; | 
| 234 | 		} else if (tag == "theme_item" ) { | 
| 235 | 			topic = "theme_item" ; | 
| 236 | 			table = &this->theme_property_line; | 
| 237 | 		} else { | 
| 238 | 			return; | 
| 239 | 		} | 
| 240 |  | 
| 241 | 		// Case order is important here to correctly handle edge cases like Variant.Type in @GlobalScope. | 
| 242 | 		if (table->has(link)) { | 
| 243 | 			// Found in the current page. | 
| 244 | 			if (class_desc->is_ready()) { | 
| 245 | 				class_desc->scroll_to_paragraph((*table)[link]); | 
| 246 | 			} else { | 
| 247 | 				scroll_to = (*table)[link]; | 
| 248 | 			} | 
| 249 | 		} else { | 
| 250 | 			// Look for link in @GlobalScope. | 
| 251 | 			// Note that a link like @GlobalScope.enum_name will not be found in this section, only enum_name will be. | 
| 252 | 			if (topic == "class_enum" ) { | 
| 253 | 				const DocData::ClassDoc &cd = doc->class_list["@GlobalScope" ]; | 
| 254 |  | 
| 255 | 				for (int i = 0; i < cd.constants.size(); i++) { | 
| 256 | 					if (cd.constants[i].enumeration == link) { | 
| 257 | 						// Found in @GlobalScope. | 
| 258 | 						emit_signal(SNAME("go_to_help" ), topic + ":@GlobalScope:"  + link); | 
| 259 | 						return; | 
| 260 | 					} | 
| 261 | 				} | 
| 262 | 			} else if (topic == "class_constant" ) { | 
| 263 | 				const DocData::ClassDoc &cd = doc->class_list["@GlobalScope" ]; | 
| 264 |  | 
| 265 | 				for (int i = 0; i < cd.constants.size(); i++) { | 
| 266 | 					if (cd.constants[i].name == link) { | 
| 267 | 						// Found in @GlobalScope. | 
| 268 | 						emit_signal(SNAME("go_to_help" ), topic + ":@GlobalScope:"  + link); | 
| 269 | 						return; | 
| 270 | 					} | 
| 271 | 				} | 
| 272 | 			} | 
| 273 |  | 
| 274 | 			if (link.contains("." )) { | 
| 275 | 				int class_end = link.find("." ); | 
| 276 | 				emit_signal(SNAME("go_to_help" ), topic + ":"  + link.substr(0, class_end) + ":"  + link.substr(class_end + 1, link.length())); | 
| 277 | 			} | 
| 278 | 		} | 
| 279 | 	} else if (p_select.begins_with("http" )) { | 
| 280 | 		OS::get_singleton()->shell_open(p_select); | 
| 281 | 	} | 
| 282 | } | 
| 283 |  | 
| 284 | void EditorHelp::_class_desc_input(const Ref<InputEvent> &p_input) { | 
| 285 | } | 
| 286 |  | 
| 287 | void EditorHelp::_class_desc_resized(bool p_force_update_theme) { | 
| 288 | 	// Add extra horizontal margins for better readability. | 
| 289 | 	// The margins increase as the width of the editor help container increases. | 
| 290 | 	real_t char_width = theme_cache.doc_code_font->get_char_size('x', theme_cache.doc_code_font_size).width; | 
| 291 | 	const int new_display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - char_width * 120 * EDSCALE) * 0.5; | 
| 292 | 	if (display_margin != new_display_margin || p_force_update_theme) { | 
| 293 | 		display_margin = new_display_margin; | 
| 294 |  | 
| 295 | 		Ref<StyleBox> class_desc_stylebox = theme_cache.background_style->duplicate(); | 
| 296 | 		class_desc_stylebox->set_content_margin(SIDE_LEFT, display_margin); | 
| 297 | 		class_desc_stylebox->set_content_margin(SIDE_RIGHT, display_margin); | 
| 298 | 		class_desc->add_theme_style_override("normal" , class_desc_stylebox); | 
| 299 | 		class_desc->add_theme_style_override("focused" , class_desc_stylebox); | 
| 300 | 	} | 
| 301 | } | 
| 302 |  | 
| 303 | void EditorHelp::_add_type(const String &p_type, const String &p_enum, bool p_is_bitfield) { | 
| 304 | 	if (p_type.is_empty() || p_type == "void" ) { | 
| 305 | 		class_desc->push_color(Color(theme_cache.type_color, 0.5)); | 
| 306 | 		class_desc->push_hint(TTR("No return value." )); | 
| 307 | 		class_desc->add_text("void" ); | 
| 308 | 		class_desc->pop(); | 
| 309 | 		class_desc->pop(); | 
| 310 | 		return; | 
| 311 | 	} | 
| 312 |  | 
| 313 | 	bool is_enum_type = !p_enum.is_empty(); | 
| 314 | 	bool is_bitfield = p_is_bitfield && is_enum_type; | 
| 315 | 	bool can_ref = !p_type.contains("*" ) || is_enum_type; | 
| 316 |  | 
| 317 | 	String link_t = p_type; // For links in metadata | 
| 318 | 	String display_t; // For display purposes. | 
| 319 | 	if (is_enum_type) { | 
| 320 | 		link_t = p_enum; // The link for enums is always the full enum description | 
| 321 | 		display_t = _contextualize_class_specifier(p_enum, edited_class); | 
| 322 | 	} else { | 
| 323 | 		display_t = _contextualize_class_specifier(p_type, edited_class); | 
| 324 | 	} | 
| 325 |  | 
| 326 | 	class_desc->push_color(theme_cache.type_color); | 
| 327 | 	bool add_array = false; | 
| 328 | 	if (can_ref) { | 
| 329 | 		if (link_t.ends_with("[]" )) { | 
| 330 | 			add_array = true; | 
| 331 | 			link_t = link_t.trim_suffix("[]" ); | 
| 332 | 			display_t = display_t.trim_suffix("[]" ); | 
| 333 |  | 
| 334 | 			class_desc->push_meta("#Array" ); // class | 
| 335 | 			class_desc->add_text("Array" ); | 
| 336 | 			class_desc->pop(); | 
| 337 | 			class_desc->add_text("[" ); | 
| 338 | 		} else if (is_bitfield) { | 
| 339 | 			class_desc->push_color(Color(theme_cache.type_color, 0.5)); | 
| 340 | 			class_desc->push_hint(TTR("This value is an integer composed as a bitmask of the following flags." )); | 
| 341 | 			class_desc->add_text("BitField" ); | 
| 342 | 			class_desc->pop(); | 
| 343 | 			class_desc->add_text("[" ); | 
| 344 | 			class_desc->pop(); | 
| 345 | 		} | 
| 346 |  | 
| 347 | 		if (is_enum_type) { | 
| 348 | 			class_desc->push_meta("$"  + link_t); // enum | 
| 349 | 		} else { | 
| 350 | 			class_desc->push_meta("#"  + link_t); // class | 
| 351 | 		} | 
| 352 | 	} | 
| 353 | 	class_desc->add_text(display_t); | 
| 354 | 	if (can_ref) { | 
| 355 | 		class_desc->pop(); // Pushed meta above. | 
| 356 | 		if (add_array) { | 
| 357 | 			class_desc->add_text("]" ); | 
| 358 | 		} else if (is_bitfield) { | 
| 359 | 			class_desc->push_color(Color(theme_cache.type_color, 0.5)); | 
| 360 | 			class_desc->add_text("]" ); | 
| 361 | 			class_desc->pop(); | 
| 362 | 		} | 
| 363 | 	} | 
| 364 | 	class_desc->pop(); | 
| 365 | } | 
| 366 |  | 
| 367 | void EditorHelp::_add_type_icon(const String &p_type, int p_size, const String &p_fallback) { | 
| 368 | 	Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(p_type, p_fallback); | 
| 369 | 	Vector2i size = Vector2i(icon->get_width(), icon->get_height()); | 
| 370 | 	if (p_size > 0) { | 
| 371 | 		// Ensures icon scales proportionally on both axes, based on icon height. | 
| 372 | 		float ratio = p_size / float(size.height); | 
| 373 | 		size.width *= ratio; | 
| 374 | 		size.height *= ratio; | 
| 375 | 	} | 
| 376 |  | 
| 377 | 	class_desc->add_image(icon, size.width, size.height); | 
| 378 | } | 
| 379 |  | 
| 380 | String EditorHelp::_fix_constant(const String &p_constant) const { | 
| 381 | 	if (p_constant.strip_edges() == "4294967295" ) { | 
| 382 | 		return "0xFFFFFFFF" ; | 
| 383 | 	} | 
| 384 |  | 
| 385 | 	if (p_constant.strip_edges() == "2147483647" ) { | 
| 386 | 		return "0x7FFFFFFF" ; | 
| 387 | 	} | 
| 388 |  | 
| 389 | 	if (p_constant.strip_edges() == "1048575" ) { | 
| 390 | 		return "0xFFFFF" ; | 
| 391 | 	} | 
| 392 |  | 
| 393 | 	return p_constant; | 
| 394 | } | 
| 395 |  | 
| 396 | // Macros for assigning the deprecation/experimental information to class members | 
| 397 | #define DEPRECATED_DOC_TAG                                                                   \ | 
| 398 | 	class_desc->push_color(get_theme_color(SNAME("error_color"), EditorStringName(Editor))); \ | 
| 399 | 	Ref<Texture2D> error_icon = get_editor_theme_icon(SNAME("StatusError"));                 \ | 
| 400 | 	class_desc->add_text(" ");                                                               \ | 
| 401 | 	class_desc->add_image(error_icon, error_icon->get_width(), error_icon->get_height());    \ | 
| 402 | 	class_desc->add_text(" (" + TTR("Deprecated") + ")");                                    \ | 
| 403 | 	class_desc->pop(); | 
| 404 |  | 
| 405 | #define EXPERIMENTAL_DOC_TAG                                                                    \ | 
| 406 | 	class_desc->push_color(get_theme_color(SNAME("warning_color"), EditorStringName(Editor)));  \ | 
| 407 | 	Ref<Texture2D> warning_icon = get_editor_theme_icon(SNAME("NodeWarning"));                  \ | 
| 408 | 	class_desc->add_text(" ");                                                                  \ | 
| 409 | 	class_desc->add_image(warning_icon, warning_icon->get_width(), warning_icon->get_height()); \ | 
| 410 | 	class_desc->add_text(" (" + TTR("Experimental") + ")");                                     \ | 
| 411 | 	class_desc->pop(); | 
| 412 |  | 
| 413 | void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview) { | 
| 414 | 	method_line[p_method.name] = class_desc->get_paragraph_count() - 2; // Gets overridden if description | 
| 415 |  | 
| 416 | 	const bool is_vararg = p_method.qualifiers.contains("vararg" ); | 
| 417 |  | 
| 418 | 	if (p_overview) { | 
| 419 | 		class_desc->push_cell(); | 
| 420 | 		class_desc->push_paragraph(HORIZONTAL_ALIGNMENT_RIGHT, Control::TEXT_DIRECTION_AUTO, "" ); | 
| 421 | 	} else { | 
| 422 | 		_add_bulletpoint(); | 
| 423 | 	} | 
| 424 |  | 
| 425 | 	_add_type(p_method.return_type, p_method.return_enum, p_method.return_is_bitfield); | 
| 426 |  | 
| 427 | 	if (p_overview) { | 
| 428 | 		class_desc->pop(); // align | 
| 429 | 		class_desc->pop(); // cell | 
| 430 | 		class_desc->push_cell(); | 
| 431 | 	} else { | 
| 432 | 		class_desc->add_text(" " ); | 
| 433 | 	} | 
| 434 |  | 
| 435 | 	if (p_overview && !p_method.description.strip_edges().is_empty()) { | 
| 436 | 		class_desc->push_meta("@method "  + p_method.name); | 
| 437 | 	} | 
| 438 |  | 
| 439 | 	class_desc->push_color(theme_cache.headline_color); | 
| 440 | 	_add_text(p_method.name); | 
| 441 | 	class_desc->pop(); | 
| 442 |  | 
| 443 | 	if (p_overview && !p_method.description.strip_edges().is_empty()) { | 
| 444 | 		class_desc->pop(); // meta | 
| 445 | 	} | 
| 446 |  | 
| 447 | 	class_desc->push_color(theme_cache.symbol_color); | 
| 448 | 	class_desc->add_text("(" ); | 
| 449 | 	class_desc->pop(); | 
| 450 |  | 
| 451 | 	for (int j = 0; j < p_method.arguments.size(); j++) { | 
| 452 | 		class_desc->push_color(theme_cache.text_color); | 
| 453 | 		if (j > 0) { | 
| 454 | 			class_desc->add_text(", " ); | 
| 455 | 		} | 
| 456 |  | 
| 457 | 		_add_text(p_method.arguments[j].name); | 
| 458 | 		class_desc->add_text(": " ); | 
| 459 | 		_add_type(p_method.arguments[j].type, p_method.arguments[j].enumeration, p_method.arguments[j].is_bitfield); | 
| 460 | 		if (!p_method.arguments[j].default_value.is_empty()) { | 
| 461 | 			class_desc->push_color(theme_cache.symbol_color); | 
| 462 | 			class_desc->add_text(" = " ); | 
| 463 | 			class_desc->pop(); | 
| 464 | 			class_desc->push_color(theme_cache.value_color); | 
| 465 | 			_add_text(_fix_constant(p_method.arguments[j].default_value)); | 
| 466 | 			class_desc->pop(); | 
| 467 | 		} | 
| 468 |  | 
| 469 | 		class_desc->pop(); | 
| 470 | 	} | 
| 471 |  | 
| 472 | 	if (is_vararg) { | 
| 473 | 		class_desc->push_color(theme_cache.text_color); | 
| 474 | 		if (p_method.arguments.size()) { | 
| 475 | 			class_desc->add_text(", " ); | 
| 476 | 		} | 
| 477 | 		class_desc->push_color(theme_cache.symbol_color); | 
| 478 | 		class_desc->add_text("..." ); | 
| 479 | 		class_desc->pop(); | 
| 480 | 		class_desc->pop(); | 
| 481 | 	} | 
| 482 |  | 
| 483 | 	class_desc->push_color(theme_cache.symbol_color); | 
| 484 | 	class_desc->add_text(")" ); | 
| 485 | 	class_desc->pop(); | 
| 486 | 	if (!p_method.qualifiers.is_empty()) { | 
| 487 | 		class_desc->push_color(theme_cache.qualifier_color); | 
| 488 |  | 
| 489 | 		PackedStringArray qualifiers = p_method.qualifiers.split_spaces(); | 
| 490 | 		for (const String &qualifier : qualifiers) { | 
| 491 | 			String hint; | 
| 492 | 			if (qualifier == "vararg" ) { | 
| 493 | 				hint = TTR("This method supports a variable number of arguments." ); | 
| 494 | 			} else if (qualifier == "virtual" ) { | 
| 495 | 				hint = TTR("This method is called by the engine.\nIt can be overridden to customize built-in behavior." ); | 
| 496 | 			} else if (qualifier == "const" ) { | 
| 497 | 				hint = TTR("This method has no side effects.\nIt does not modify the object in any way." ); | 
| 498 | 			} else if (qualifier == "static" ) { | 
| 499 | 				hint = TTR("This method does not need an instance to be called.\nIt can be called directly using the class name." ); | 
| 500 | 			} | 
| 501 |  | 
| 502 | 			class_desc->add_text(" " ); | 
| 503 | 			if (!hint.is_empty()) { | 
| 504 | 				class_desc->push_hint(hint); | 
| 505 | 				class_desc->add_text(qualifier); | 
| 506 | 				class_desc->pop(); | 
| 507 | 			} else { | 
| 508 | 				class_desc->add_text(qualifier); | 
| 509 | 			} | 
| 510 | 		} | 
| 511 | 		class_desc->pop(); | 
| 512 | 	} | 
| 513 |  | 
| 514 | 	if (p_method.is_deprecated) { | 
| 515 | 		DEPRECATED_DOC_TAG; | 
| 516 | 	} | 
| 517 |  | 
| 518 | 	if (p_method.is_experimental) { | 
| 519 | 		EXPERIMENTAL_DOC_TAG; | 
| 520 | 	} | 
| 521 |  | 
| 522 | 	if (p_overview) { | 
| 523 | 		class_desc->pop(); // cell | 
| 524 | 	} | 
| 525 | } | 
| 526 |  | 
| 527 | void EditorHelp::_add_bulletpoint() { | 
| 528 | 	static const char32_t prefix[3] = { 0x25CF /* filled circle */, ' ', 0 }; | 
| 529 | 	class_desc->add_text(String(prefix)); | 
| 530 | } | 
| 531 |  | 
| 532 | void EditorHelp::_push_normal_font() { | 
| 533 | 	class_desc->push_font(theme_cache.doc_font); | 
| 534 | 	class_desc->push_font_size(theme_cache.doc_font_size); | 
| 535 | } | 
| 536 |  | 
| 537 | void EditorHelp::_pop_normal_font() { | 
| 538 | 	class_desc->pop(); | 
| 539 | 	class_desc->pop(); | 
| 540 | } | 
| 541 |  | 
| 542 | void EditorHelp::_push_title_font() { | 
| 543 | 	class_desc->push_color(theme_cache.title_color); | 
| 544 | 	class_desc->push_font(theme_cache.doc_title_font); | 
| 545 | 	class_desc->push_font_size(theme_cache.doc_title_font_size); | 
| 546 | } | 
| 547 |  | 
| 548 | void EditorHelp::_pop_title_font() { | 
| 549 | 	class_desc->pop(); | 
| 550 | 	class_desc->pop(); | 
| 551 | 	class_desc->pop(); | 
| 552 | } | 
| 553 |  | 
| 554 | void EditorHelp::_push_code_font() { | 
| 555 | 	class_desc->push_font(theme_cache.doc_code_font); | 
| 556 | 	class_desc->push_font_size(theme_cache.doc_code_font_size); | 
| 557 | } | 
| 558 |  | 
| 559 | void EditorHelp::_pop_code_font() { | 
| 560 | 	class_desc->pop(); | 
| 561 | 	class_desc->pop(); | 
| 562 | } | 
| 563 |  | 
| 564 | Error EditorHelp::_goto_desc(const String &p_class) { | 
| 565 | 	// If class doesn't have docs listed, attempt on-demand docgen | 
| 566 | 	if (!doc->class_list.has(p_class) && !_attempt_doc_load(p_class)) { | 
| 567 | 		return ERR_DOES_NOT_EXIST; | 
| 568 | 	} | 
| 569 |  | 
| 570 | 	select_locked = true; | 
| 571 |  | 
| 572 | 	class_desc->show(); | 
| 573 |  | 
| 574 | 	description_line = 0; | 
| 575 |  | 
| 576 | 	if (p_class == edited_class) { | 
| 577 | 		return OK; // Already there. | 
| 578 | 	} | 
| 579 |  | 
| 580 | 	edited_class = p_class; | 
| 581 | 	_update_doc(); | 
| 582 | 	return OK; | 
| 583 | } | 
| 584 |  | 
| 585 | void EditorHelp::_update_method_list(const Vector<DocData::MethodDoc> p_methods) { | 
| 586 | 	class_desc->add_newline(); | 
| 587 |  | 
| 588 | 	_push_code_font(); | 
| 589 | 	class_desc->push_indent(1); | 
| 590 | 	class_desc->push_table(2); | 
| 591 | 	class_desc->set_table_column_expand(1, true); | 
| 592 |  | 
| 593 | 	bool any_previous = false; | 
| 594 | 	for (int pass = 0; pass < 2; pass++) { | 
| 595 | 		Vector<DocData::MethodDoc> m; | 
| 596 |  | 
| 597 | 		for (int i = 0; i < p_methods.size(); i++) { | 
| 598 | 			const String &q = p_methods[i].qualifiers; | 
| 599 | 			if ((pass == 0 && q.contains("virtual" )) || (pass == 1 && !q.contains("virtual" ))) { | 
| 600 | 				m.push_back(p_methods[i]); | 
| 601 | 			} | 
| 602 | 		} | 
| 603 |  | 
| 604 | 		if (any_previous && !m.is_empty()) { | 
| 605 | 			class_desc->push_cell(); | 
| 606 | 			class_desc->pop(); // cell | 
| 607 | 			class_desc->push_cell(); | 
| 608 | 			class_desc->pop(); // cell | 
| 609 | 		} | 
| 610 |  | 
| 611 | 		String group_prefix; | 
| 612 | 		for (int i = 0; i < m.size(); i++) { | 
| 613 | 			const String new_prefix = m[i].name.substr(0, 3); | 
| 614 | 			bool is_new_group = false; | 
| 615 |  | 
| 616 | 			if (i < m.size() - 1 && new_prefix == m[i + 1].name.substr(0, 3) && new_prefix != group_prefix) { | 
| 617 | 				is_new_group = i > 0; | 
| 618 | 				group_prefix = new_prefix; | 
| 619 | 			} else if (!group_prefix.is_empty() && new_prefix != group_prefix) { | 
| 620 | 				is_new_group = true; | 
| 621 | 				group_prefix = "" ; | 
| 622 | 			} | 
| 623 |  | 
| 624 | 			if (is_new_group && pass == 1) { | 
| 625 | 				class_desc->push_cell(); | 
| 626 | 				class_desc->pop(); // cell | 
| 627 | 				class_desc->push_cell(); | 
| 628 | 				class_desc->pop(); // cell | 
| 629 | 			} | 
| 630 |  | 
| 631 | 			_add_method(m[i], true); | 
| 632 | 		} | 
| 633 |  | 
| 634 | 		any_previous = !m.is_empty(); | 
| 635 | 	} | 
| 636 |  | 
| 637 | 	class_desc->pop(); // table | 
| 638 | 	class_desc->pop(); | 
| 639 | 	_pop_code_font(); | 
| 640 |  | 
| 641 | 	class_desc->add_newline(); | 
| 642 | 	class_desc->add_newline(); | 
| 643 | } | 
| 644 |  | 
| 645 | void EditorHelp::_update_method_descriptions(const DocData::ClassDoc p_classdoc, const Vector<DocData::MethodDoc> p_methods, MethodType p_method_type) { | 
| 646 | 	String link_color_text = theme_cache.title_color.to_html(false); | 
| 647 |  | 
| 648 | 	class_desc->add_newline(); | 
| 649 | 	class_desc->add_newline(); | 
| 650 |  | 
| 651 | 	for (int pass = 0; pass < 2; pass++) { | 
| 652 | 		Vector<DocData::MethodDoc> methods_filtered; | 
| 653 |  | 
| 654 | 		for (int i = 0; i < p_methods.size(); i++) { | 
| 655 | 			const String &q = p_methods[i].qualifiers; | 
| 656 | 			if ((pass == 0 && q.contains("virtual" )) || (pass == 1 && !q.contains("virtual" ))) { | 
| 657 | 				methods_filtered.push_back(p_methods[i]); | 
| 658 | 			} | 
| 659 | 		} | 
| 660 |  | 
| 661 | 		for (int i = 0; i < methods_filtered.size(); i++) { | 
| 662 | 			_push_code_font(); | 
| 663 | 			_add_method(methods_filtered[i], false); | 
| 664 | 			_pop_code_font(); | 
| 665 |  | 
| 666 | 			class_desc->add_newline(); | 
| 667 | 			class_desc->add_newline(); | 
| 668 |  | 
| 669 | 			class_desc->push_color(theme_cache.text_color); | 
| 670 | 			_push_normal_font(); | 
| 671 | 			class_desc->push_indent(1); | 
| 672 | 			if (methods_filtered[i].errors_returned.size()) { | 
| 673 | 				class_desc->append_text(TTR("Error codes returned:" )); | 
| 674 | 				class_desc->add_newline(); | 
| 675 | 				class_desc->push_list(0, RichTextLabel::LIST_DOTS, false); | 
| 676 | 				for (int j = 0; j < methods_filtered[i].errors_returned.size(); j++) { | 
| 677 | 					if (j > 0) { | 
| 678 | 						class_desc->add_newline(); | 
| 679 | 					} | 
| 680 | 					int val = methods_filtered[i].errors_returned[j]; | 
| 681 | 					String text = itos(val); | 
| 682 | 					for (int k = 0; k < CoreConstants::get_global_constant_count(); k++) { | 
| 683 | 						if (CoreConstants::get_global_constant_value(k) == val && CoreConstants::get_global_constant_enum(k) == SNAME("Error" )) { | 
| 684 | 							text = CoreConstants::get_global_constant_name(k); | 
| 685 | 							break; | 
| 686 | 						} | 
| 687 | 					} | 
| 688 |  | 
| 689 | 					class_desc->push_bold(); | 
| 690 | 					class_desc->append_text(text); | 
| 691 | 					class_desc->pop(); | 
| 692 | 				} | 
| 693 | 				class_desc->pop(); | 
| 694 | 				class_desc->add_newline(); | 
| 695 | 				class_desc->add_newline(); | 
| 696 | 			} | 
| 697 | 			if (!methods_filtered[i].description.strip_edges().is_empty()) { | 
| 698 | 				_add_text(DTR(methods_filtered[i].description)); | 
| 699 | 			} else { | 
| 700 | 				class_desc->add_image(get_editor_theme_icon(SNAME("Error" ))); | 
| 701 | 				class_desc->add_text(" " ); | 
| 702 | 				class_desc->push_color(theme_cache.comment_color); | 
| 703 |  | 
| 704 | 				String message; | 
| 705 | 				if (p_classdoc.is_script_doc) { | 
| 706 | 					static const char *messages_by_type[METHOD_TYPE_MAX] = { | 
| 707 | 						TTRC("There is currently no description for this method." ), | 
| 708 | 						TTRC("There is currently no description for this constructor." ), | 
| 709 | 						TTRC("There is currently no description for this operator." ), | 
| 710 | 					}; | 
| 711 | 					message = TTRGET(messages_by_type[p_method_type]); | 
| 712 | 				} else { | 
| 713 | 					static const char *messages_by_type[METHOD_TYPE_MAX] = { | 
| 714 | 						TTRC("There is currently no description for this method. Please help us by [color=$color][url=$url]contributing one[/url][/color]!" ), | 
| 715 | 						TTRC("There is currently no description for this constructor. Please help us by [color=$color][url=$url]contributing one[/url][/color]!" ), | 
| 716 | 						TTRC("There is currently no description for this operator. Please help us by [color=$color][url=$url]contributing one[/url][/color]!" ), | 
| 717 | 					}; | 
| 718 | 					message = TTRGET(messages_by_type[p_method_type]).replace("$url" , CONTRIBUTE_URL).replace("$color" , link_color_text); | 
| 719 | 				} | 
| 720 | 				class_desc->append_text(message); | 
| 721 | 				class_desc->pop(); | 
| 722 | 			} | 
| 723 |  | 
| 724 | 			class_desc->pop(); | 
| 725 | 			_pop_normal_font(); | 
| 726 | 			class_desc->pop(); | 
| 727 |  | 
| 728 | 			class_desc->add_newline(); | 
| 729 | 			class_desc->add_newline(); | 
| 730 | 			class_desc->add_newline(); | 
| 731 | 		} | 
| 732 | 	} | 
| 733 | } | 
| 734 |  | 
| 735 | void EditorHelp::_update_doc() { | 
| 736 | 	if (!doc->class_list.has(edited_class)) { | 
| 737 | 		return; | 
| 738 | 	} | 
| 739 |  | 
| 740 | 	scroll_locked = true; | 
| 741 |  | 
| 742 | 	class_desc->clear(); | 
| 743 | 	method_line.clear(); | 
| 744 | 	section_line.clear(); | 
| 745 |  | 
| 746 | 	String link_color_text = theme_cache.title_color.to_html(false); | 
| 747 |  | 
| 748 | 	DocData::ClassDoc cd = doc->class_list[edited_class]; // Make a copy, so we can sort without worrying. | 
| 749 |  | 
| 750 | 	// Class name | 
| 751 | 	section_line.push_back(Pair<String, int>(TTR("Top" ), 0)); | 
| 752 | 	_push_title_font(); | 
| 753 | 	class_desc->add_text(TTR("Class:" ) + " " ); | 
| 754 | 	_add_type_icon(edited_class, theme_cache.doc_title_font_size, "Object" ); | 
| 755 | 	class_desc->add_text(" " ); | 
| 756 | 	class_desc->push_color(theme_cache.headline_color); | 
| 757 | 	_add_text(edited_class); | 
| 758 | 	class_desc->pop(); // color | 
| 759 | 	_pop_title_font(); | 
| 760 |  | 
| 761 | 	if (cd.is_deprecated) { | 
| 762 | 		class_desc->add_text(" " ); | 
| 763 | 		Ref<Texture2D> error_icon = get_editor_theme_icon(SNAME("StatusError" )); | 
| 764 | 		class_desc->add_image(error_icon, error_icon->get_width(), error_icon->get_height()); | 
| 765 | 	} | 
| 766 | 	if (cd.is_experimental) { | 
| 767 | 		class_desc->add_text(" " ); | 
| 768 | 		Ref<Texture2D> warning_icon = get_editor_theme_icon(SNAME("NodeWarning" )); | 
| 769 | 		class_desc->add_image(warning_icon, warning_icon->get_width(), warning_icon->get_height()); | 
| 770 | 	} | 
| 771 | 	class_desc->add_newline(); | 
| 772 |  | 
| 773 | 	const String non_breaking_space = String::chr(160); | 
| 774 |  | 
| 775 | 	// Inheritance tree | 
| 776 |  | 
| 777 | 	// Ascendents | 
| 778 | 	if (!cd.inherits.is_empty()) { | 
| 779 | 		class_desc->push_color(theme_cache.title_color); | 
| 780 | 		_push_normal_font(); | 
| 781 | 		class_desc->add_text(TTR("Inherits:" ) + " " ); | 
| 782 |  | 
| 783 | 		String inherits = cd.inherits; | 
| 784 |  | 
| 785 | 		while (!inherits.is_empty()) { | 
| 786 | 			_add_type_icon(inherits, theme_cache.doc_font_size, "ArrowRight" ); | 
| 787 | 			class_desc->add_text(non_breaking_space); // Otherwise icon borrows hyperlink from _add_type(). | 
| 788 | 			_add_type(inherits); | 
| 789 |  | 
| 790 | 			inherits = doc->class_list[inherits].inherits; | 
| 791 |  | 
| 792 | 			if (!inherits.is_empty()) { | 
| 793 | 				class_desc->add_text(" < " ); | 
| 794 | 			} | 
| 795 | 		} | 
| 796 |  | 
| 797 | 		_pop_normal_font(); | 
| 798 | 		class_desc->pop(); | 
| 799 | 		class_desc->add_newline(); | 
| 800 | 	} | 
| 801 |  | 
| 802 | 	// Descendents | 
| 803 | 	if (cd.is_script_doc || ClassDB::class_exists(cd.name)) { | 
| 804 | 		bool found = false; | 
| 805 | 		bool prev = false; | 
| 806 |  | 
| 807 | 		_push_normal_font(); | 
| 808 | 		for (const KeyValue<String, DocData::ClassDoc> &E : doc->class_list) { | 
| 809 | 			if (E.value.inherits == cd.name) { | 
| 810 | 				if (!found) { | 
| 811 | 					class_desc->push_color(theme_cache.title_color); | 
| 812 | 					class_desc->add_text(TTR("Inherited by:" ) + " " ); | 
| 813 | 					found = true; | 
| 814 | 				} | 
| 815 |  | 
| 816 | 				if (prev) { | 
| 817 | 					class_desc->add_text(" , " ); | 
| 818 | 				} | 
| 819 | 				_add_type_icon(E.value.name, theme_cache.doc_font_size, "ArrowRight" ); | 
| 820 | 				class_desc->add_text(non_breaking_space); // Otherwise icon borrows hyperlink from _add_type(). | 
| 821 | 				_add_type(E.value.name); | 
| 822 | 				prev = true; | 
| 823 | 			} | 
| 824 | 		} | 
| 825 | 		_pop_normal_font(); | 
| 826 |  | 
| 827 | 		if (found) { | 
| 828 | 			class_desc->pop(); | 
| 829 | 			class_desc->add_newline(); | 
| 830 | 		} | 
| 831 | 	} | 
| 832 |  | 
| 833 | 	// Note if deprecated. | 
| 834 | 	if (cd.is_deprecated) { | 
| 835 | 		Ref<Texture2D> error_icon = get_editor_theme_icon(SNAME("StatusError" )); | 
| 836 | 		class_desc->push_color(get_theme_color(SNAME("error_color" ), EditorStringName(Editor))); | 
| 837 | 		class_desc->add_image(error_icon, error_icon->get_width(), error_icon->get_height()); | 
| 838 | 		class_desc->add_text(String(" " ) + TTR("This class is marked as deprecated. It will be removed in future versions." )); | 
| 839 | 		class_desc->pop(); | 
| 840 | 		class_desc->add_newline(); | 
| 841 | 	} | 
| 842 |  | 
| 843 | 	// Note if experimental. | 
| 844 | 	if (cd.is_experimental) { | 
| 845 | 		Ref<Texture2D> warning_icon = get_editor_theme_icon(SNAME("NodeWarning" )); | 
| 846 | 		class_desc->push_color(get_theme_color(SNAME("warning_color" ), EditorStringName(Editor))); | 
| 847 | 		class_desc->add_image(warning_icon, warning_icon->get_width(), warning_icon->get_height()); | 
| 848 | 		class_desc->add_text(String(" " ) + TTR("This class is marked as experimental. It is subject to likely change or possible removal in future versions. Use at your own discretion." )); | 
| 849 | 		class_desc->pop(); | 
| 850 | 		class_desc->add_newline(); | 
| 851 | 	} | 
| 852 |  | 
| 853 | 	bool has_description = false; | 
| 854 |  | 
| 855 | 	class_desc->add_newline(); | 
| 856 | 	class_desc->add_newline(); | 
| 857 |  | 
| 858 | 	// Brief description | 
| 859 | 	if (!cd.brief_description.strip_edges().is_empty()) { | 
| 860 | 		has_description = true; | 
| 861 |  | 
| 862 | 		class_desc->push_color(theme_cache.text_color); | 
| 863 | 		class_desc->push_font(theme_cache.doc_bold_font); | 
| 864 | 		class_desc->push_indent(1); | 
| 865 | 		_add_text(DTR(cd.brief_description)); | 
| 866 | 		class_desc->pop(); | 
| 867 | 		class_desc->pop(); | 
| 868 | 		class_desc->pop(); | 
| 869 |  | 
| 870 | 		class_desc->add_newline(); | 
| 871 | 		class_desc->add_newline(); | 
| 872 | 		class_desc->add_newline(); | 
| 873 | 	} | 
| 874 |  | 
| 875 | 	// Class description | 
| 876 | 	if (!cd.description.strip_edges().is_empty()) { | 
| 877 | 		has_description = true; | 
| 878 |  | 
| 879 | 		section_line.push_back(Pair<String, int>(TTR("Description" ), class_desc->get_paragraph_count() - 2)); | 
| 880 | 		description_line = class_desc->get_paragraph_count() - 2; | 
| 881 | 		_push_title_font(); | 
| 882 | 		class_desc->add_text(TTR("Description" )); | 
| 883 | 		_pop_title_font(); | 
| 884 |  | 
| 885 | 		class_desc->add_newline(); | 
| 886 | 		class_desc->add_newline(); | 
| 887 | 		class_desc->push_color(theme_cache.text_color); | 
| 888 | 		_push_normal_font(); | 
| 889 | 		class_desc->push_indent(1); | 
| 890 | 		_add_text(DTR(cd.description)); | 
| 891 | 		class_desc->pop(); | 
| 892 | 		_pop_normal_font(); | 
| 893 | 		class_desc->pop(); | 
| 894 |  | 
| 895 | 		class_desc->add_newline(); | 
| 896 | 		class_desc->add_newline(); | 
| 897 | 		class_desc->add_newline(); | 
| 898 | 	} | 
| 899 |  | 
| 900 | 	if (!has_description) { | 
| 901 | 		class_desc->add_image(get_editor_theme_icon(SNAME("Error" ))); | 
| 902 | 		class_desc->add_text(" " ); | 
| 903 | 		class_desc->push_color(theme_cache.comment_color); | 
| 904 |  | 
| 905 | 		if (cd.is_script_doc) { | 
| 906 | 			class_desc->append_text(TTR("There is currently no description for this class." )); | 
| 907 | 		} else { | 
| 908 | 			class_desc->append_text(TTR("There is currently no description for this class. Please help us by [color=$color][url=$url]contributing one[/url][/color]!" ).replace("$url" , CONTRIBUTE_URL).replace("$color" , link_color_text)); | 
| 909 | 		} | 
| 910 |  | 
| 911 | 		class_desc->add_newline(); | 
| 912 | 		class_desc->add_newline(); | 
| 913 | 	} | 
| 914 |  | 
| 915 | #ifdef MODULE_MONO_ENABLED | 
| 916 | 	if (classes_with_csharp_differences.has(cd.name)) { | 
| 917 | 		const String &csharp_differences_url = vformat("%s/tutorials/scripting/c_sharp/c_sharp_differences.html" , VERSION_DOCS_URL); | 
| 918 |  | 
| 919 | 		class_desc->push_color(theme_cache.text_color); | 
| 920 | 		_push_normal_font(); | 
| 921 | 		class_desc->push_indent(1); | 
| 922 | 		_add_text("[b]"  + TTR("Note:" ) + "[/b] "  + vformat(TTR("There are notable differences when using this API with C#. See [url=%s]C# API differences to GDScript[/url] for more information." ), csharp_differences_url)); | 
| 923 | 		class_desc->pop(); | 
| 924 | 		_pop_normal_font(); | 
| 925 | 		class_desc->pop(); | 
| 926 |  | 
| 927 | 		class_desc->add_newline(); | 
| 928 | 		class_desc->add_newline(); | 
| 929 | 	} | 
| 930 | #endif | 
| 931 |  | 
| 932 | 	// Online tutorials | 
| 933 | 	if (cd.tutorials.size()) { | 
| 934 | 		_push_title_font(); | 
| 935 | 		class_desc->add_text(TTR("Online Tutorials" )); | 
| 936 | 		_pop_title_font(); | 
| 937 |  | 
| 938 | 		class_desc->add_newline(); | 
| 939 |  | 
| 940 | 		class_desc->push_indent(1); | 
| 941 | 		_push_code_font(); | 
| 942 |  | 
| 943 | 		for (int i = 0; i < cd.tutorials.size(); i++) { | 
| 944 | 			const String link = DTR(cd.tutorials[i].link); | 
| 945 | 			String linktxt = (cd.tutorials[i].title.is_empty()) ? link : DTR(cd.tutorials[i].title); | 
| 946 | 			const int seppos = linktxt.find("//" ); | 
| 947 | 			if (seppos != -1) { | 
| 948 | 				linktxt = link.substr(seppos + 2); | 
| 949 | 			} | 
| 950 |  | 
| 951 | 			class_desc->push_color(theme_cache.symbol_color); | 
| 952 | 			class_desc->append_text("[url="  + link + "]"  + linktxt + "[/url]" ); | 
| 953 | 			class_desc->pop(); | 
| 954 | 			class_desc->add_newline(); | 
| 955 | 		} | 
| 956 |  | 
| 957 | 		_pop_code_font(); | 
| 958 | 		class_desc->pop(); | 
| 959 |  | 
| 960 | 		class_desc->add_newline(); | 
| 961 | 		class_desc->add_newline(); | 
| 962 | 	} | 
| 963 |  | 
| 964 | 	// Properties overview | 
| 965 | 	HashSet<String> skip_methods; | 
| 966 |  | 
| 967 | 	bool has_properties = false; | 
| 968 | 	bool has_property_descriptions = false; | 
| 969 | 	for (const DocData::PropertyDoc &prop : cd.properties) { | 
| 970 | 		if (cd.is_script_doc && prop.name.begins_with("_" ) && prop.description.strip_edges().is_empty()) { | 
| 971 | 			continue; | 
| 972 | 		} | 
| 973 | 		has_properties = true; | 
| 974 | 		if (!prop.overridden) { | 
| 975 | 			has_property_descriptions = true; | 
| 976 | 			break; | 
| 977 | 		} | 
| 978 | 	} | 
| 979 |  | 
| 980 | 	if (has_properties) { | 
| 981 | 		section_line.push_back(Pair<String, int>(TTR("Properties" ), class_desc->get_paragraph_count() - 2)); | 
| 982 | 		_push_title_font(); | 
| 983 | 		class_desc->add_text(TTR("Properties" )); | 
| 984 | 		_pop_title_font(); | 
| 985 |  | 
| 986 | 		class_desc->add_newline(); | 
| 987 |  | 
| 988 | 		_push_code_font(); | 
| 989 | 		class_desc->push_indent(1); | 
| 990 | 		class_desc->push_table(4); | 
| 991 | 		class_desc->set_table_column_expand(1, true); | 
| 992 |  | 
| 993 | 		for (int i = 0; i < cd.properties.size(); i++) { | 
| 994 | 			// Ignore undocumented private. | 
| 995 | 			if (cd.properties[i].name.begins_with("_" ) && cd.properties[i].description.strip_edges().is_empty()) { | 
| 996 | 				continue; | 
| 997 | 			} | 
| 998 | 			property_line[cd.properties[i].name] = class_desc->get_paragraph_count() - 2; //gets overridden if description | 
| 999 |  | 
| 1000 | 			// Property type. | 
| 1001 | 			class_desc->push_cell(); | 
| 1002 | 			class_desc->push_paragraph(HORIZONTAL_ALIGNMENT_RIGHT, Control::TEXT_DIRECTION_AUTO, "" ); | 
| 1003 | 			_push_code_font(); | 
| 1004 | 			_add_type(cd.properties[i].type, cd.properties[i].enumeration, cd.properties[i].is_bitfield); | 
| 1005 | 			_pop_code_font(); | 
| 1006 | 			class_desc->pop(); | 
| 1007 | 			class_desc->pop(); // cell | 
| 1008 |  | 
| 1009 | 			bool describe = false; | 
| 1010 |  | 
| 1011 | 			if (!cd.properties[i].setter.is_empty()) { | 
| 1012 | 				skip_methods.insert(cd.properties[i].setter); | 
| 1013 | 				describe = true; | 
| 1014 | 			} | 
| 1015 | 			if (!cd.properties[i].getter.is_empty()) { | 
| 1016 | 				skip_methods.insert(cd.properties[i].getter); | 
| 1017 | 				describe = true; | 
| 1018 | 			} | 
| 1019 |  | 
| 1020 | 			if (!cd.properties[i].description.strip_edges().is_empty()) { | 
| 1021 | 				describe = true; | 
| 1022 | 			} | 
| 1023 |  | 
| 1024 | 			if (cd.properties[i].overridden) { | 
| 1025 | 				describe = false; | 
| 1026 | 			} | 
| 1027 |  | 
| 1028 | 			// Property name. | 
| 1029 | 			class_desc->push_cell(); | 
| 1030 | 			_push_code_font(); | 
| 1031 | 			class_desc->push_color(theme_cache.headline_color); | 
| 1032 |  | 
| 1033 | 			if (describe) { | 
| 1034 | 				class_desc->push_meta("@member "  + cd.properties[i].name); | 
| 1035 | 			} | 
| 1036 |  | 
| 1037 | 			_add_text(cd.properties[i].name); | 
| 1038 |  | 
| 1039 | 			if (describe) { | 
| 1040 | 				class_desc->pop(); | 
| 1041 | 			} | 
| 1042 |  | 
| 1043 | 			class_desc->pop(); | 
| 1044 | 			_pop_code_font(); | 
| 1045 | 			class_desc->pop(); // cell | 
| 1046 |  | 
| 1047 | 			// Property value. | 
| 1048 | 			class_desc->push_cell(); | 
| 1049 | 			_push_code_font(); | 
| 1050 |  | 
| 1051 | 			if (!cd.properties[i].default_value.is_empty()) { | 
| 1052 | 				class_desc->push_color(theme_cache.symbol_color); | 
| 1053 | 				if (cd.properties[i].overridden) { | 
| 1054 | 					class_desc->add_text(" [" ); | 
| 1055 | 					class_desc->push_meta("@member "  + cd.properties[i].overrides + "."  + cd.properties[i].name); | 
| 1056 | 					_add_text(vformat(TTR("overrides %s:" ), cd.properties[i].overrides)); | 
| 1057 | 					class_desc->pop(); | 
| 1058 | 					class_desc->add_text(" " ); | 
| 1059 | 				} else { | 
| 1060 | 					class_desc->add_text(" ["  + TTR("default:" ) + " " ); | 
| 1061 | 				} | 
| 1062 | 				class_desc->pop(); | 
| 1063 |  | 
| 1064 | 				class_desc->push_color(theme_cache.value_color); | 
| 1065 | 				_add_text(_fix_constant(cd.properties[i].default_value)); | 
| 1066 | 				class_desc->pop(); | 
| 1067 |  | 
| 1068 | 				class_desc->push_color(theme_cache.symbol_color); | 
| 1069 | 				class_desc->add_text("]" ); | 
| 1070 | 				class_desc->pop(); | 
| 1071 | 			} | 
| 1072 |  | 
| 1073 | 			if (cd.properties[i].is_deprecated) { | 
| 1074 | 				DEPRECATED_DOC_TAG; | 
| 1075 | 			} | 
| 1076 |  | 
| 1077 | 			if (cd.properties[i].is_experimental) { | 
| 1078 | 				EXPERIMENTAL_DOC_TAG; | 
| 1079 | 			} | 
| 1080 |  | 
| 1081 | 			_pop_code_font(); | 
| 1082 | 			class_desc->pop(); // cell | 
| 1083 |  | 
| 1084 | 			// Property setters and getters. | 
| 1085 | 			class_desc->push_cell(); | 
| 1086 | 			_push_code_font(); | 
| 1087 |  | 
| 1088 | 			if (cd.is_script_doc && (!cd.properties[i].setter.is_empty() || !cd.properties[i].getter.is_empty())) { | 
| 1089 | 				class_desc->push_color(theme_cache.symbol_color); | 
| 1090 | 				class_desc->add_text(" ["  + TTR("property:" ) + " " ); | 
| 1091 | 				class_desc->pop(); // color | 
| 1092 |  | 
| 1093 | 				if (!cd.properties[i].setter.is_empty()) { | 
| 1094 | 					class_desc->push_color(theme_cache.value_color); | 
| 1095 | 					class_desc->add_text("setter" ); | 
| 1096 | 					class_desc->pop(); // color | 
| 1097 | 				} | 
| 1098 | 				if (!cd.properties[i].getter.is_empty()) { | 
| 1099 | 					if (!cd.properties[i].setter.is_empty()) { | 
| 1100 | 						class_desc->push_color(theme_cache.symbol_color); | 
| 1101 | 						class_desc->add_text(", " ); | 
| 1102 | 						class_desc->pop(); // color | 
| 1103 | 					} | 
| 1104 | 					class_desc->push_color(theme_cache.value_color); | 
| 1105 | 					class_desc->add_text("getter" ); | 
| 1106 | 					class_desc->pop(); // color | 
| 1107 | 				} | 
| 1108 |  | 
| 1109 | 				class_desc->push_color(theme_cache.symbol_color); | 
| 1110 | 				class_desc->add_text("]" ); | 
| 1111 | 				class_desc->pop(); // color | 
| 1112 | 			} | 
| 1113 |  | 
| 1114 | 			_pop_code_font(); | 
| 1115 | 			class_desc->pop(); // cell | 
| 1116 | 		} | 
| 1117 |  | 
| 1118 | 		class_desc->pop(); // table | 
| 1119 | 		class_desc->pop(); | 
| 1120 | 		_pop_code_font(); | 
| 1121 |  | 
| 1122 | 		class_desc->add_newline(); | 
| 1123 | 		class_desc->add_newline(); | 
| 1124 | 	} | 
| 1125 |  | 
| 1126 | 	// Methods overview | 
| 1127 | 	bool sort_methods = EDITOR_GET("text_editor/help/sort_functions_alphabetically" ); | 
| 1128 |  | 
| 1129 | 	Vector<DocData::MethodDoc> methods; | 
| 1130 |  | 
| 1131 | 	for (int i = 0; i < cd.methods.size(); i++) { | 
| 1132 | 		if (skip_methods.has(cd.methods[i].name)) { | 
| 1133 | 			if (cd.methods[i].arguments.size() == 0 /* getter */ || (cd.methods[i].arguments.size() == 1 && cd.methods[i].return_type == "void"  /* setter */)) { | 
| 1134 | 				continue; | 
| 1135 | 			} | 
| 1136 | 		} | 
| 1137 | 		// Ignore undocumented non virtual private. | 
| 1138 | 		if (cd.methods[i].name.begins_with("_" ) && cd.methods[i].description.strip_edges().is_empty() && !cd.methods[i].qualifiers.contains("virtual" )) { | 
| 1139 | 			continue; | 
| 1140 | 		} | 
| 1141 | 		methods.push_back(cd.methods[i]); | 
| 1142 | 	} | 
| 1143 |  | 
| 1144 | 	if (!cd.constructors.is_empty()) { | 
| 1145 | 		if (sort_methods) { | 
| 1146 | 			cd.constructors.sort(); | 
| 1147 | 		} | 
| 1148 |  | 
| 1149 | 		section_line.push_back(Pair<String, int>(TTR("Constructors" ), class_desc->get_paragraph_count() - 2)); | 
| 1150 | 		_push_title_font(); | 
| 1151 | 		class_desc->add_text(TTR("Constructors" )); | 
| 1152 | 		_pop_title_font(); | 
| 1153 |  | 
| 1154 | 		_update_method_list(cd.constructors); | 
| 1155 | 	} | 
| 1156 |  | 
| 1157 | 	if (!methods.is_empty()) { | 
| 1158 | 		if (sort_methods) { | 
| 1159 | 			methods.sort(); | 
| 1160 | 		} | 
| 1161 |  | 
| 1162 | 		section_line.push_back(Pair<String, int>(TTR("Methods" ), class_desc->get_paragraph_count() - 2)); | 
| 1163 | 		_push_title_font(); | 
| 1164 | 		class_desc->add_text(TTR("Methods" )); | 
| 1165 | 		_pop_title_font(); | 
| 1166 |  | 
| 1167 | 		_update_method_list(methods); | 
| 1168 | 	} | 
| 1169 |  | 
| 1170 | 	if (!cd.operators.is_empty()) { | 
| 1171 | 		if (sort_methods) { | 
| 1172 | 			cd.operators.sort(); | 
| 1173 | 		} | 
| 1174 |  | 
| 1175 | 		section_line.push_back(Pair<String, int>(TTR("Operators" ), class_desc->get_paragraph_count() - 2)); | 
| 1176 | 		_push_title_font(); | 
| 1177 | 		class_desc->add_text(TTR("Operators" )); | 
| 1178 | 		_pop_title_font(); | 
| 1179 |  | 
| 1180 | 		_update_method_list(cd.operators); | 
| 1181 | 	} | 
| 1182 |  | 
| 1183 | 	// Theme properties | 
| 1184 | 	if (!cd.theme_properties.is_empty()) { | 
| 1185 | 		section_line.push_back(Pair<String, int>(TTR("Theme Properties" ), class_desc->get_paragraph_count() - 2)); | 
| 1186 | 		_push_title_font(); | 
| 1187 | 		class_desc->add_text(TTR("Theme Properties" )); | 
| 1188 | 		_pop_title_font(); | 
| 1189 |  | 
| 1190 | 		class_desc->add_newline(); | 
| 1191 | 		class_desc->add_newline(); | 
| 1192 |  | 
| 1193 | 		class_desc->push_indent(1); | 
| 1194 |  | 
| 1195 | 		String theme_data_type; | 
| 1196 | 		HashMap<String, String> data_type_names; | 
| 1197 | 		data_type_names["color" ] = TTR("Colors" ); | 
| 1198 | 		data_type_names["constant" ] = TTR("Constants" ); | 
| 1199 | 		data_type_names["font" ] = TTR("Fonts" ); | 
| 1200 | 		data_type_names["font_size" ] = TTR("Font Sizes" ); | 
| 1201 | 		data_type_names["icon" ] = TTR("Icons" ); | 
| 1202 | 		data_type_names["style" ] = TTR("Styles" ); | 
| 1203 |  | 
| 1204 | 		for (int i = 0; i < cd.theme_properties.size(); i++) { | 
| 1205 | 			theme_property_line[cd.theme_properties[i].name] = class_desc->get_paragraph_count() - 2; // Gets overridden if description. | 
| 1206 |  | 
| 1207 | 			if (theme_data_type != cd.theme_properties[i].data_type) { | 
| 1208 | 				theme_data_type = cd.theme_properties[i].data_type; | 
| 1209 |  | 
| 1210 | 				_push_title_font(); | 
| 1211 | 				if (data_type_names.has(theme_data_type)) { | 
| 1212 | 					class_desc->add_text(data_type_names[theme_data_type]); | 
| 1213 | 				} else { | 
| 1214 | 					class_desc->add_text("" ); | 
| 1215 | 				} | 
| 1216 | 				_pop_title_font(); | 
| 1217 |  | 
| 1218 | 				class_desc->add_newline(); | 
| 1219 | 				class_desc->add_newline(); | 
| 1220 | 			} | 
| 1221 |  | 
| 1222 | 			// Theme item header. | 
| 1223 | 			_push_code_font(); | 
| 1224 | 			_add_bulletpoint(); | 
| 1225 |  | 
| 1226 | 			// Theme item object type. | 
| 1227 | 			_add_type(cd.theme_properties[i].type); | 
| 1228 |  | 
| 1229 | 			// Theme item name. | 
| 1230 | 			class_desc->push_color(theme_cache.headline_color); | 
| 1231 | 			class_desc->add_text(" " ); | 
| 1232 | 			_add_text(cd.theme_properties[i].name); | 
| 1233 | 			class_desc->pop(); | 
| 1234 |  | 
| 1235 | 			// Theme item default value. | 
| 1236 | 			if (!cd.theme_properties[i].default_value.is_empty()) { | 
| 1237 | 				class_desc->push_color(theme_cache.symbol_color); | 
| 1238 | 				class_desc->add_text(" ["  + TTR("default:" ) + " " ); | 
| 1239 | 				class_desc->pop(); | 
| 1240 | 				class_desc->push_color(theme_cache.value_color); | 
| 1241 | 				_add_text(_fix_constant(cd.theme_properties[i].default_value)); | 
| 1242 | 				class_desc->pop(); | 
| 1243 | 				class_desc->push_color(theme_cache.symbol_color); | 
| 1244 | 				class_desc->add_text("]" ); | 
| 1245 | 				class_desc->pop(); | 
| 1246 | 			} | 
| 1247 |  | 
| 1248 | 			_pop_code_font(); | 
| 1249 |  | 
| 1250 | 			// Theme item description. | 
| 1251 | 			if (!cd.theme_properties[i].description.strip_edges().is_empty()) { | 
| 1252 | 				class_desc->push_color(theme_cache.comment_color); | 
| 1253 | 				_push_normal_font(); | 
| 1254 | 				class_desc->push_indent(1); | 
| 1255 | 				_add_text(DTR(cd.theme_properties[i].description)); | 
| 1256 | 				class_desc->pop(); // indent | 
| 1257 | 				_pop_normal_font(); | 
| 1258 | 				class_desc->pop(); // color | 
| 1259 | 			} | 
| 1260 |  | 
| 1261 | 			class_desc->add_newline(); | 
| 1262 | 			class_desc->add_newline(); | 
| 1263 | 		} | 
| 1264 |  | 
| 1265 | 		class_desc->pop(); | 
| 1266 | 		class_desc->add_newline(); | 
| 1267 | 	} | 
| 1268 |  | 
| 1269 | 	// Signals | 
| 1270 | 	if (!cd.signals.is_empty()) { | 
| 1271 | 		if (sort_methods) { | 
| 1272 | 			cd.signals.sort(); | 
| 1273 | 		} | 
| 1274 |  | 
| 1275 | 		section_line.push_back(Pair<String, int>(TTR("Signals" ), class_desc->get_paragraph_count() - 2)); | 
| 1276 | 		_push_title_font(); | 
| 1277 | 		class_desc->add_text(TTR("Signals" )); | 
| 1278 | 		_pop_title_font(); | 
| 1279 |  | 
| 1280 | 		class_desc->add_newline(); | 
| 1281 | 		class_desc->add_newline(); | 
| 1282 |  | 
| 1283 | 		class_desc->push_indent(1); | 
| 1284 |  | 
| 1285 | 		for (int i = 0; i < cd.signals.size(); i++) { | 
| 1286 | 			signal_line[cd.signals[i].name] = class_desc->get_paragraph_count() - 2; // Gets overridden if description. | 
| 1287 |  | 
| 1288 | 			_push_code_font(); | 
| 1289 | 			_add_bulletpoint(); | 
| 1290 | 			class_desc->push_color(theme_cache.headline_color); | 
| 1291 | 			_add_text(cd.signals[i].name); | 
| 1292 | 			class_desc->pop(); | 
| 1293 | 			class_desc->push_color(theme_cache.symbol_color); | 
| 1294 | 			class_desc->add_text("(" ); | 
| 1295 | 			class_desc->pop(); | 
| 1296 | 			for (int j = 0; j < cd.signals[i].arguments.size(); j++) { | 
| 1297 | 				class_desc->push_color(theme_cache.text_color); | 
| 1298 | 				if (j > 0) { | 
| 1299 | 					class_desc->add_text(", " ); | 
| 1300 | 				} | 
| 1301 |  | 
| 1302 | 				_add_text(cd.signals[i].arguments[j].name); | 
| 1303 | 				class_desc->add_text(": " ); | 
| 1304 | 				_add_type(cd.signals[i].arguments[j].type, cd.signals[i].arguments[j].enumeration, cd.signals[i].arguments[j].is_bitfield); | 
| 1305 | 				if (!cd.signals[i].arguments[j].default_value.is_empty()) { | 
| 1306 | 					class_desc->push_color(theme_cache.symbol_color); | 
| 1307 | 					class_desc->add_text(" = " ); | 
| 1308 | 					class_desc->pop(); | 
| 1309 | 					_add_text(cd.signals[i].arguments[j].default_value); | 
| 1310 | 				} | 
| 1311 |  | 
| 1312 | 				class_desc->pop(); | 
| 1313 | 			} | 
| 1314 |  | 
| 1315 | 			class_desc->push_color(theme_cache.symbol_color); | 
| 1316 | 			class_desc->add_text(")" ); | 
| 1317 |  | 
| 1318 | 			if (cd.signals[i].is_deprecated) { | 
| 1319 | 				DEPRECATED_DOC_TAG; | 
| 1320 | 			} | 
| 1321 |  | 
| 1322 | 			if (cd.signals[i].is_experimental) { | 
| 1323 | 				EXPERIMENTAL_DOC_TAG; | 
| 1324 | 			} | 
| 1325 |  | 
| 1326 | 			class_desc->pop(); | 
| 1327 | 			_pop_code_font(); | 
| 1328 |  | 
| 1329 | 			if (!cd.signals[i].description.strip_edges().is_empty()) { | 
| 1330 | 				class_desc->push_color(theme_cache.comment_color); | 
| 1331 | 				_push_normal_font(); | 
| 1332 | 				class_desc->push_indent(1); | 
| 1333 | 				_add_text(DTR(cd.signals[i].description)); | 
| 1334 | 				class_desc->pop(); // indent | 
| 1335 | 				_pop_normal_font(); | 
| 1336 | 				class_desc->pop(); // color | 
| 1337 | 			} | 
| 1338 |  | 
| 1339 | 			class_desc->add_newline(); | 
| 1340 | 			class_desc->add_newline(); | 
| 1341 | 		} | 
| 1342 |  | 
| 1343 | 		class_desc->pop(); | 
| 1344 | 		class_desc->add_newline(); | 
| 1345 | 	} | 
| 1346 |  | 
| 1347 | 	// Constants and enums | 
| 1348 | 	if (!cd.constants.is_empty()) { | 
| 1349 | 		HashMap<String, Vector<DocData::ConstantDoc>> enums; | 
| 1350 | 		Vector<DocData::ConstantDoc> constants; | 
| 1351 |  | 
| 1352 | 		for (int i = 0; i < cd.constants.size(); i++) { | 
| 1353 | 			if (!cd.constants[i].enumeration.is_empty()) { | 
| 1354 | 				if (!enums.has(cd.constants[i].enumeration)) { | 
| 1355 | 					enums[cd.constants[i].enumeration] = Vector<DocData::ConstantDoc>(); | 
| 1356 | 				} | 
| 1357 |  | 
| 1358 | 				enums[cd.constants[i].enumeration].push_back(cd.constants[i]); | 
| 1359 | 			} else { | 
| 1360 | 				// Ignore undocumented private. | 
| 1361 | 				if (cd.constants[i].name.begins_with("_" ) && cd.constants[i].description.strip_edges().is_empty()) { | 
| 1362 | 					continue; | 
| 1363 | 				} | 
| 1364 | 				constants.push_back(cd.constants[i]); | 
| 1365 | 			} | 
| 1366 | 		} | 
| 1367 |  | 
| 1368 | 		// Enums | 
| 1369 | 		if (enums.size()) { | 
| 1370 | 			section_line.push_back(Pair<String, int>(TTR("Enumerations" ), class_desc->get_paragraph_count() - 2)); | 
| 1371 | 			_push_title_font(); | 
| 1372 | 			class_desc->add_text(TTR("Enumerations" )); | 
| 1373 | 			_pop_title_font(); | 
| 1374 | 			class_desc->push_indent(1); | 
| 1375 |  | 
| 1376 | 			class_desc->add_newline(); | 
| 1377 |  | 
| 1378 | 			for (KeyValue<String, Vector<DocData::ConstantDoc>> &E : enums) { | 
| 1379 | 				enum_line[E.key] = class_desc->get_paragraph_count() - 2; | 
| 1380 |  | 
| 1381 | 				_push_code_font(); | 
| 1382 |  | 
| 1383 | 				class_desc->push_color(theme_cache.title_color); | 
| 1384 | 				if (E.value.size() && E.value[0].is_bitfield) { | 
| 1385 | 					class_desc->add_text("flags  " ); | 
| 1386 | 				} else { | 
| 1387 | 					class_desc->add_text("enum  " ); | 
| 1388 | 				} | 
| 1389 | 				class_desc->pop(); | 
| 1390 |  | 
| 1391 | 				String e = E.key; | 
| 1392 | 				if ((e.get_slice_count("." ) > 1) && (e.get_slice("." , 0) == edited_class)) { | 
| 1393 | 					e = e.get_slice("." , 1); | 
| 1394 | 				} | 
| 1395 |  | 
| 1396 | 				class_desc->push_color(theme_cache.headline_color); | 
| 1397 | 				class_desc->add_text(e); | 
| 1398 | 				class_desc->pop(); | 
| 1399 |  | 
| 1400 | 				class_desc->push_color(theme_cache.symbol_color); | 
| 1401 | 				class_desc->add_text(":" ); | 
| 1402 | 				class_desc->pop(); | 
| 1403 |  | 
| 1404 | 				if (cd.enums.has(e)) { | 
| 1405 | 					if (cd.enums[e].is_deprecated) { | 
| 1406 | 						DEPRECATED_DOC_TAG; | 
| 1407 | 					} | 
| 1408 |  | 
| 1409 | 					if (cd.enums[e].is_experimental) { | 
| 1410 | 						EXPERIMENTAL_DOC_TAG; | 
| 1411 | 					} | 
| 1412 | 				} | 
| 1413 |  | 
| 1414 | 				_pop_code_font(); | 
| 1415 |  | 
| 1416 | 				class_desc->add_newline(); | 
| 1417 | 				class_desc->add_newline(); | 
| 1418 |  | 
| 1419 | 				// Enum description. | 
| 1420 | 				if (e != "@unnamed_enums"  && cd.enums.has(e) && !cd.enums[e].description.strip_edges().is_empty()) { | 
| 1421 | 					class_desc->push_color(theme_cache.text_color); | 
| 1422 | 					_push_normal_font(); | 
| 1423 | 					class_desc->push_indent(1); | 
| 1424 | 					_add_text(cd.enums[e].description); | 
| 1425 | 					class_desc->pop(); | 
| 1426 | 					_pop_normal_font(); | 
| 1427 | 					class_desc->pop(); | 
| 1428 |  | 
| 1429 | 					class_desc->add_newline(); | 
| 1430 | 					class_desc->add_newline(); | 
| 1431 | 				} | 
| 1432 |  | 
| 1433 | 				class_desc->push_indent(1); | 
| 1434 | 				Vector<DocData::ConstantDoc> enum_list = E.value; | 
| 1435 |  | 
| 1436 | 				HashMap<String, int> enumValuesContainer; | 
| 1437 | 				int enumStartingLine = enum_line[E.key]; | 
| 1438 |  | 
| 1439 | 				for (int i = 0; i < enum_list.size(); i++) { | 
| 1440 | 					if (cd.name == "@GlobalScope" ) { | 
| 1441 | 						enumValuesContainer[enum_list[i].name] = enumStartingLine; | 
| 1442 | 					} | 
| 1443 |  | 
| 1444 | 					// Add the enum constant line to the constant_line map so we can locate it as a constant. | 
| 1445 | 					constant_line[enum_list[i].name] = class_desc->get_paragraph_count() - 2; | 
| 1446 |  | 
| 1447 | 					_push_code_font(); | 
| 1448 |  | 
| 1449 | 					_add_bulletpoint(); | 
| 1450 | 					class_desc->push_color(theme_cache.headline_color); | 
| 1451 | 					_add_text(enum_list[i].name); | 
| 1452 | 					class_desc->pop(); | 
| 1453 | 					class_desc->push_color(theme_cache.symbol_color); | 
| 1454 | 					class_desc->add_text(" = " ); | 
| 1455 | 					class_desc->pop(); | 
| 1456 | 					class_desc->push_color(theme_cache.value_color); | 
| 1457 | 					_add_text(_fix_constant(enum_list[i].value)); | 
| 1458 | 					class_desc->pop(); | 
| 1459 |  | 
| 1460 | 					if (enum_list[i].is_deprecated) { | 
| 1461 | 						DEPRECATED_DOC_TAG; | 
| 1462 | 					} | 
| 1463 |  | 
| 1464 | 					if (enum_list[i].is_experimental) { | 
| 1465 | 						EXPERIMENTAL_DOC_TAG; | 
| 1466 | 					} | 
| 1467 |  | 
| 1468 | 					_pop_code_font(); | 
| 1469 |  | 
| 1470 | 					class_desc->add_newline(); | 
| 1471 |  | 
| 1472 | 					if (!enum_list[i].description.strip_edges().is_empty()) { | 
| 1473 | 						class_desc->push_color(theme_cache.comment_color); | 
| 1474 | 						_push_normal_font(); | 
| 1475 | 						_add_text(DTR(enum_list[i].description)); | 
| 1476 | 						_pop_normal_font(); | 
| 1477 | 						class_desc->pop(); | 
| 1478 | 						if (DTR(enum_list[i].description).find("\n" ) > 0) { | 
| 1479 | 							class_desc->add_newline(); | 
| 1480 | 						} | 
| 1481 | 					} | 
| 1482 |  | 
| 1483 | 					class_desc->add_newline(); | 
| 1484 | 				} | 
| 1485 |  | 
| 1486 | 				if (cd.name == "@GlobalScope" ) { | 
| 1487 | 					enum_values_line[E.key] = enumValuesContainer; | 
| 1488 | 				} | 
| 1489 |  | 
| 1490 | 				class_desc->pop(); | 
| 1491 |  | 
| 1492 | 				class_desc->add_newline(); | 
| 1493 | 			} | 
| 1494 |  | 
| 1495 | 			class_desc->pop(); | 
| 1496 | 			class_desc->add_newline(); | 
| 1497 | 		} | 
| 1498 |  | 
| 1499 | 		// Constants | 
| 1500 | 		if (constants.size()) { | 
| 1501 | 			section_line.push_back(Pair<String, int>(TTR("Constants" ), class_desc->get_paragraph_count() - 2)); | 
| 1502 | 			_push_title_font(); | 
| 1503 | 			class_desc->add_text(TTR("Constants" )); | 
| 1504 | 			_pop_title_font(); | 
| 1505 | 			class_desc->push_indent(1); | 
| 1506 |  | 
| 1507 | 			class_desc->add_newline(); | 
| 1508 |  | 
| 1509 | 			for (int i = 0; i < constants.size(); i++) { | 
| 1510 | 				constant_line[constants[i].name] = class_desc->get_paragraph_count() - 2; | 
| 1511 |  | 
| 1512 | 				_push_code_font(); | 
| 1513 |  | 
| 1514 | 				if (constants[i].value.begins_with("Color(" ) && constants[i].value.ends_with(")" )) { | 
| 1515 | 					String stripped = constants[i].value.replace(" " , "" ).replace("Color(" , "" ).replace(")" , "" ); | 
| 1516 | 					PackedFloat64Array color = stripped.split_floats("," ); | 
| 1517 | 					if (color.size() >= 3) { | 
| 1518 | 						class_desc->push_color(Color(color[0], color[1], color[2])); | 
| 1519 | 						_add_bulletpoint(); | 
| 1520 | 						class_desc->pop(); | 
| 1521 | 					} | 
| 1522 | 				} else { | 
| 1523 | 					_add_bulletpoint(); | 
| 1524 | 				} | 
| 1525 |  | 
| 1526 | 				class_desc->push_color(theme_cache.headline_color); | 
| 1527 | 				_add_text(constants[i].name); | 
| 1528 | 				class_desc->pop(); | 
| 1529 | 				class_desc->push_color(theme_cache.symbol_color); | 
| 1530 | 				class_desc->add_text(" = " ); | 
| 1531 | 				class_desc->pop(); | 
| 1532 | 				class_desc->push_color(theme_cache.value_color); | 
| 1533 | 				_add_text(_fix_constant(constants[i].value)); | 
| 1534 | 				class_desc->pop(); | 
| 1535 |  | 
| 1536 | 				if (constants[i].is_deprecated) { | 
| 1537 | 					DEPRECATED_DOC_TAG; | 
| 1538 | 				} | 
| 1539 |  | 
| 1540 | 				if (constants[i].is_experimental) { | 
| 1541 | 					EXPERIMENTAL_DOC_TAG; | 
| 1542 | 				} | 
| 1543 |  | 
| 1544 | 				_pop_code_font(); | 
| 1545 |  | 
| 1546 | 				class_desc->add_newline(); | 
| 1547 |  | 
| 1548 | 				if (!constants[i].description.strip_edges().is_empty()) { | 
| 1549 | 					class_desc->push_color(theme_cache.comment_color); | 
| 1550 | 					_push_normal_font(); | 
| 1551 | 					_add_text(DTR(constants[i].description)); | 
| 1552 | 					_pop_normal_font(); | 
| 1553 | 					class_desc->pop(); | 
| 1554 | 					if (DTR(constants[i].description).find("\n" ) > 0) { | 
| 1555 | 						class_desc->add_newline(); | 
| 1556 | 					} | 
| 1557 | 				} | 
| 1558 |  | 
| 1559 | 				class_desc->add_newline(); | 
| 1560 | 			} | 
| 1561 |  | 
| 1562 | 			class_desc->pop(); | 
| 1563 | 			class_desc->add_newline(); | 
| 1564 | 		} | 
| 1565 | 	} | 
| 1566 |  | 
| 1567 | 	// Annotations | 
| 1568 | 	if (!cd.annotations.is_empty()) { | 
| 1569 | 		if (sort_methods) { | 
| 1570 | 			cd.annotations.sort(); | 
| 1571 | 		} | 
| 1572 |  | 
| 1573 | 		section_line.push_back(Pair<String, int>(TTR("Annotations" ), class_desc->get_paragraph_count() - 2)); | 
| 1574 | 		_push_title_font(); | 
| 1575 | 		class_desc->add_text(TTR("Annotations" )); | 
| 1576 | 		_pop_title_font(); | 
| 1577 |  | 
| 1578 | 		class_desc->add_newline(); | 
| 1579 | 		class_desc->add_newline(); | 
| 1580 |  | 
| 1581 | 		class_desc->push_indent(1); | 
| 1582 |  | 
| 1583 | 		for (int i = 0; i < cd.annotations.size(); i++) { | 
| 1584 | 			annotation_line[cd.annotations[i].name] = class_desc->get_paragraph_count() - 2; // Gets overridden if description. | 
| 1585 |  | 
| 1586 | 			_push_code_font(); | 
| 1587 | 			_add_bulletpoint(); | 
| 1588 | 			class_desc->push_color(theme_cache.headline_color); | 
| 1589 | 			_add_text(cd.annotations[i].name); | 
| 1590 | 			class_desc->pop(); | 
| 1591 |  | 
| 1592 | 			if (cd.annotations[i].arguments.size() > 0) { | 
| 1593 | 				class_desc->push_color(theme_cache.symbol_color); | 
| 1594 | 				class_desc->add_text("(" ); | 
| 1595 | 				class_desc->pop(); | 
| 1596 | 				for (int j = 0; j < cd.annotations[i].arguments.size(); j++) { | 
| 1597 | 					class_desc->push_color(theme_cache.text_color); | 
| 1598 | 					if (j > 0) { | 
| 1599 | 						class_desc->add_text(", " ); | 
| 1600 | 					} | 
| 1601 |  | 
| 1602 | 					_add_text(cd.annotations[i].arguments[j].name); | 
| 1603 | 					class_desc->add_text(": " ); | 
| 1604 | 					_add_type(cd.annotations[i].arguments[j].type); | 
| 1605 | 					if (!cd.annotations[i].arguments[j].default_value.is_empty()) { | 
| 1606 | 						class_desc->push_color(theme_cache.symbol_color); | 
| 1607 | 						class_desc->add_text(" = " ); | 
| 1608 | 						class_desc->pop(); | 
| 1609 | 						_add_text(cd.annotations[i].arguments[j].default_value); | 
| 1610 | 					} | 
| 1611 |  | 
| 1612 | 					class_desc->pop(); | 
| 1613 | 				} | 
| 1614 |  | 
| 1615 | 				if (cd.annotations[i].qualifiers.contains("vararg" )) { | 
| 1616 | 					class_desc->push_color(theme_cache.text_color); | 
| 1617 | 					if (cd.annotations[i].arguments.size()) { | 
| 1618 | 						class_desc->add_text(", " ); | 
| 1619 | 					} | 
| 1620 | 					class_desc->push_color(theme_cache.symbol_color); | 
| 1621 | 					class_desc->add_text("..." ); | 
| 1622 | 					class_desc->pop(); | 
| 1623 | 					class_desc->pop(); | 
| 1624 | 				} | 
| 1625 |  | 
| 1626 | 				class_desc->push_color(theme_cache.symbol_color); | 
| 1627 | 				class_desc->add_text(")" ); | 
| 1628 | 				class_desc->pop(); | 
| 1629 | 			} | 
| 1630 |  | 
| 1631 | 			if (!cd.annotations[i].qualifiers.is_empty()) { | 
| 1632 | 				class_desc->push_color(theme_cache.qualifier_color); | 
| 1633 | 				class_desc->add_text(" " ); | 
| 1634 | 				_add_text(cd.annotations[i].qualifiers); | 
| 1635 | 				class_desc->pop(); | 
| 1636 | 			} | 
| 1637 |  | 
| 1638 | 			_pop_code_font(); | 
| 1639 |  | 
| 1640 | 			if (!cd.annotations[i].description.strip_edges().is_empty()) { | 
| 1641 | 				class_desc->push_color(theme_cache.comment_color); | 
| 1642 | 				_push_normal_font(); | 
| 1643 | 				class_desc->push_indent(1); | 
| 1644 | 				_add_text(DTR(cd.annotations[i].description)); | 
| 1645 | 				class_desc->pop(); // indent | 
| 1646 | 				_pop_normal_font(); | 
| 1647 | 				class_desc->pop(); // color | 
| 1648 | 			} else { | 
| 1649 | 				class_desc->push_indent(1); | 
| 1650 | 				class_desc->add_image(get_editor_theme_icon(SNAME("Error" ))); | 
| 1651 | 				class_desc->add_text(" " ); | 
| 1652 | 				class_desc->push_color(theme_cache.comment_color); | 
| 1653 | 				if (cd.is_script_doc) { | 
| 1654 | 					class_desc->append_text(TTR("There is currently no description for this annotation." )); | 
| 1655 | 				} else { | 
| 1656 | 					class_desc->append_text(TTR("There is currently no description for this annotation. Please help us by [color=$color][url=$url]contributing one[/url][/color]!" ).replace("$url" , CONTRIBUTE_URL).replace("$color" , link_color_text)); | 
| 1657 | 				} | 
| 1658 | 				class_desc->pop(); | 
| 1659 | 				class_desc->pop(); // indent | 
| 1660 | 			} | 
| 1661 | 			class_desc->add_newline(); | 
| 1662 | 			class_desc->add_newline(); | 
| 1663 | 		} | 
| 1664 |  | 
| 1665 | 		class_desc->pop(); | 
| 1666 | 		class_desc->add_newline(); | 
| 1667 | 	} | 
| 1668 |  | 
| 1669 | 	// Property descriptions | 
| 1670 | 	if (has_property_descriptions) { | 
| 1671 | 		section_line.push_back(Pair<String, int>(TTR("Property Descriptions" ), class_desc->get_paragraph_count() - 2)); | 
| 1672 | 		_push_title_font(); | 
| 1673 | 		class_desc->add_text(TTR("Property Descriptions" )); | 
| 1674 | 		_pop_title_font(); | 
| 1675 |  | 
| 1676 | 		class_desc->add_newline(); | 
| 1677 | 		class_desc->add_newline(); | 
| 1678 |  | 
| 1679 | 		for (int i = 0; i < cd.properties.size(); i++) { | 
| 1680 | 			if (cd.properties[i].overridden) { | 
| 1681 | 				continue; | 
| 1682 | 			} | 
| 1683 | 			// Ignore undocumented private. | 
| 1684 | 			if (cd.properties[i].name.begins_with("_" ) && cd.properties[i].description.strip_edges().is_empty()) { | 
| 1685 | 				continue; | 
| 1686 | 			} | 
| 1687 |  | 
| 1688 | 			property_line[cd.properties[i].name] = class_desc->get_paragraph_count() - 2; | 
| 1689 |  | 
| 1690 | 			class_desc->push_table(2); | 
| 1691 | 			class_desc->set_table_column_expand(1, true); | 
| 1692 |  | 
| 1693 | 			class_desc->push_cell(); | 
| 1694 | 			_push_code_font(); | 
| 1695 | 			_add_bulletpoint(); | 
| 1696 |  | 
| 1697 | 			_add_type(cd.properties[i].type, cd.properties[i].enumeration, cd.properties[i].is_bitfield); | 
| 1698 | 			class_desc->add_text(" " ); | 
| 1699 | 			_pop_code_font(); | 
| 1700 | 			class_desc->pop(); // cell | 
| 1701 |  | 
| 1702 | 			class_desc->push_cell(); | 
| 1703 | 			_push_code_font(); | 
| 1704 | 			class_desc->push_color(theme_cache.headline_color); | 
| 1705 | 			_add_text(cd.properties[i].name); | 
| 1706 | 			class_desc->pop(); // color | 
| 1707 |  | 
| 1708 | 			if (!cd.properties[i].default_value.is_empty()) { | 
| 1709 | 				class_desc->push_color(theme_cache.symbol_color); | 
| 1710 | 				class_desc->add_text(" ["  + TTR("default:" ) + " " ); | 
| 1711 | 				class_desc->pop(); // color | 
| 1712 |  | 
| 1713 | 				class_desc->push_color(theme_cache.value_color); | 
| 1714 | 				_add_text(_fix_constant(cd.properties[i].default_value)); | 
| 1715 | 				class_desc->pop(); // color | 
| 1716 |  | 
| 1717 | 				class_desc->push_color(theme_cache.symbol_color); | 
| 1718 | 				class_desc->add_text("]" ); | 
| 1719 | 				class_desc->pop(); // color | 
| 1720 | 			} | 
| 1721 |  | 
| 1722 | 			if (cd.properties[i].is_deprecated) { | 
| 1723 | 				DEPRECATED_DOC_TAG; | 
| 1724 | 			} | 
| 1725 |  | 
| 1726 | 			if (cd.properties[i].is_experimental) { | 
| 1727 | 				EXPERIMENTAL_DOC_TAG; | 
| 1728 | 			} | 
| 1729 |  | 
| 1730 | 			if (cd.is_script_doc && (!cd.properties[i].setter.is_empty() || !cd.properties[i].getter.is_empty())) { | 
| 1731 | 				class_desc->push_color(theme_cache.symbol_color); | 
| 1732 | 				class_desc->add_text(" ["  + TTR("property:" ) + " " ); | 
| 1733 | 				class_desc->pop(); // color | 
| 1734 |  | 
| 1735 | 				if (!cd.properties[i].setter.is_empty()) { | 
| 1736 | 					class_desc->push_color(theme_cache.value_color); | 
| 1737 | 					class_desc->add_text("setter" ); | 
| 1738 | 					class_desc->pop(); // color | 
| 1739 | 				} | 
| 1740 | 				if (!cd.properties[i].getter.is_empty()) { | 
| 1741 | 					if (!cd.properties[i].setter.is_empty()) { | 
| 1742 | 						class_desc->push_color(theme_cache.symbol_color); | 
| 1743 | 						class_desc->add_text(", " ); | 
| 1744 | 						class_desc->pop(); // color | 
| 1745 | 					} | 
| 1746 | 					class_desc->push_color(theme_cache.value_color); | 
| 1747 | 					class_desc->add_text("getter" ); | 
| 1748 | 					class_desc->pop(); // color | 
| 1749 | 				} | 
| 1750 |  | 
| 1751 | 				class_desc->push_color(theme_cache.symbol_color); | 
| 1752 | 				class_desc->add_text("]" ); | 
| 1753 | 				class_desc->pop(); // color | 
| 1754 | 			} | 
| 1755 |  | 
| 1756 | 			_pop_code_font(); | 
| 1757 | 			class_desc->pop(); // cell | 
| 1758 |  | 
| 1759 | 			// Script doc doesn't have setter, getter. | 
| 1760 | 			if (!cd.is_script_doc) { | 
| 1761 | 				HashMap<String, DocData::MethodDoc> method_map; | 
| 1762 | 				for (int j = 0; j < methods.size(); j++) { | 
| 1763 | 					method_map[methods[j].name] = methods[j]; | 
| 1764 | 				} | 
| 1765 |  | 
| 1766 | 				if (!cd.properties[i].setter.is_empty()) { | 
| 1767 | 					class_desc->push_cell(); | 
| 1768 | 					class_desc->pop(); // cell | 
| 1769 |  | 
| 1770 | 					class_desc->push_cell(); | 
| 1771 | 					_push_code_font(); | 
| 1772 | 					class_desc->push_color(theme_cache.text_color); | 
| 1773 |  | 
| 1774 | 					if (method_map[cd.properties[i].setter].arguments.size() > 1) { | 
| 1775 | 						// Setters with additional arguments are exposed in the method list, so we link them here for quick access. | 
| 1776 | 						class_desc->push_meta("@method "  + cd.properties[i].setter); | 
| 1777 | 						class_desc->add_text(cd.properties[i].setter + TTR("(value)" )); | 
| 1778 | 						class_desc->pop(); | 
| 1779 | 					} else { | 
| 1780 | 						class_desc->add_text(cd.properties[i].setter + TTR("(value)" )); | 
| 1781 | 					} | 
| 1782 |  | 
| 1783 | 					class_desc->pop(); // color | 
| 1784 | 					class_desc->push_color(theme_cache.comment_color); | 
| 1785 | 					class_desc->add_text(" setter" ); | 
| 1786 | 					class_desc->pop(); // color | 
| 1787 | 					_pop_code_font(); | 
| 1788 | 					class_desc->pop(); // cell | 
| 1789 |  | 
| 1790 | 					method_line[cd.properties[i].setter] = property_line[cd.properties[i].name]; | 
| 1791 | 				} | 
| 1792 |  | 
| 1793 | 				if (!cd.properties[i].getter.is_empty()) { | 
| 1794 | 					class_desc->push_cell(); | 
| 1795 | 					class_desc->pop(); // cell | 
| 1796 |  | 
| 1797 | 					class_desc->push_cell(); | 
| 1798 | 					_push_code_font(); | 
| 1799 | 					class_desc->push_color(theme_cache.text_color); | 
| 1800 |  | 
| 1801 | 					if (method_map[cd.properties[i].getter].arguments.size() > 0) { | 
| 1802 | 						// Getters with additional arguments are exposed in the method list, so we link them here for quick access. | 
| 1803 | 						class_desc->push_meta("@method "  + cd.properties[i].getter); | 
| 1804 | 						class_desc->add_text(cd.properties[i].getter + "()" ); | 
| 1805 | 						class_desc->pop(); | 
| 1806 | 					} else { | 
| 1807 | 						class_desc->add_text(cd.properties[i].getter + "()" ); | 
| 1808 | 					} | 
| 1809 |  | 
| 1810 | 					class_desc->pop(); // color | 
| 1811 | 					class_desc->push_color(theme_cache.comment_color); | 
| 1812 | 					class_desc->add_text(" getter" ); | 
| 1813 | 					class_desc->pop(); // color | 
| 1814 | 					_pop_code_font(); | 
| 1815 | 					class_desc->pop(); // cell | 
| 1816 |  | 
| 1817 | 					method_line[cd.properties[i].getter] = property_line[cd.properties[i].name]; | 
| 1818 | 				} | 
| 1819 | 			} | 
| 1820 |  | 
| 1821 | 			class_desc->pop(); // table | 
| 1822 |  | 
| 1823 | 			class_desc->add_newline(); | 
| 1824 | 			class_desc->add_newline(); | 
| 1825 |  | 
| 1826 | 			class_desc->push_color(theme_cache.text_color); | 
| 1827 | 			_push_normal_font(); | 
| 1828 | 			class_desc->push_indent(1); | 
| 1829 | 			if (!cd.properties[i].description.strip_edges().is_empty()) { | 
| 1830 | 				_add_text(DTR(cd.properties[i].description)); | 
| 1831 | 			} else { | 
| 1832 | 				class_desc->add_image(get_editor_theme_icon(SNAME("Error" ))); | 
| 1833 | 				class_desc->add_text(" " ); | 
| 1834 | 				class_desc->push_color(theme_cache.comment_color); | 
| 1835 | 				if (cd.is_script_doc) { | 
| 1836 | 					class_desc->append_text(TTR("There is currently no description for this property." )); | 
| 1837 | 				} else { | 
| 1838 | 					class_desc->append_text(TTR("There is currently no description for this property. Please help us by [color=$color][url=$url]contributing one[/url][/color]!" ).replace("$url" , CONTRIBUTE_URL).replace("$color" , link_color_text)); | 
| 1839 | 				} | 
| 1840 | 				class_desc->pop(); | 
| 1841 | 			} | 
| 1842 | 			class_desc->pop(); | 
| 1843 | 			_pop_normal_font(); | 
| 1844 | 			class_desc->pop(); | 
| 1845 |  | 
| 1846 | 			class_desc->add_newline(); | 
| 1847 | 			class_desc->add_newline(); | 
| 1848 | 			class_desc->add_newline(); | 
| 1849 | 		} | 
| 1850 | 	} | 
| 1851 |  | 
| 1852 | 	// Constructor descriptions | 
| 1853 | 	if (!cd.constructors.is_empty()) { | 
| 1854 | 		section_line.push_back(Pair<String, int>(TTR("Constructor Descriptions" ), class_desc->get_paragraph_count() - 2)); | 
| 1855 | 		_push_title_font(); | 
| 1856 | 		class_desc->add_text(TTR("Constructor Descriptions" )); | 
| 1857 | 		_pop_title_font(); | 
| 1858 |  | 
| 1859 | 		_update_method_descriptions(cd, cd.constructors, METHOD_TYPE_CONSTRUCTOR); | 
| 1860 | 	} | 
| 1861 |  | 
| 1862 | 	// Method descriptions | 
| 1863 | 	if (!methods.is_empty()) { | 
| 1864 | 		section_line.push_back(Pair<String, int>(TTR("Method Descriptions" ), class_desc->get_paragraph_count() - 2)); | 
| 1865 | 		_push_title_font(); | 
| 1866 | 		class_desc->add_text(TTR("Method Descriptions" )); | 
| 1867 | 		_pop_title_font(); | 
| 1868 |  | 
| 1869 | 		_update_method_descriptions(cd, methods, METHOD_TYPE_METHOD); | 
| 1870 | 	} | 
| 1871 |  | 
| 1872 | 	// Operator descriptions | 
| 1873 | 	if (!cd.operators.is_empty()) { | 
| 1874 | 		section_line.push_back(Pair<String, int>(TTR("Operator Descriptions" ), class_desc->get_paragraph_count() - 2)); | 
| 1875 | 		_push_title_font(); | 
| 1876 | 		class_desc->add_text(TTR("Operator Descriptions" )); | 
| 1877 | 		_pop_title_font(); | 
| 1878 |  | 
| 1879 | 		_update_method_descriptions(cd, cd.operators, METHOD_TYPE_OPERATOR); | 
| 1880 | 	} | 
| 1881 |  | 
| 1882 | 	// Free the scroll. | 
| 1883 | 	scroll_locked = false; | 
| 1884 | } | 
| 1885 |  | 
| 1886 | void EditorHelp::_request_help(const String &p_string) { | 
| 1887 | 	Error err = _goto_desc(p_string); | 
| 1888 | 	if (err == OK) { | 
| 1889 | 		EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); | 
| 1890 | 	} | 
| 1891 | } | 
| 1892 |  | 
| 1893 | void EditorHelp::_help_callback(const String &p_topic) { | 
| 1894 | 	String what = p_topic.get_slice(":" , 0); | 
| 1895 | 	String clss = p_topic.get_slice(":" , 1); | 
| 1896 | 	String name; | 
| 1897 | 	if (p_topic.get_slice_count(":" ) == 3) { | 
| 1898 | 		name = p_topic.get_slice(":" , 2); | 
| 1899 | 	} | 
| 1900 |  | 
| 1901 | 	_request_help(clss); // First go to class. | 
| 1902 |  | 
| 1903 | 	int line = 0; | 
| 1904 |  | 
| 1905 | 	if (what == "class_desc" ) { | 
| 1906 | 		line = description_line; | 
| 1907 | 	} else if (what == "class_signal" ) { | 
| 1908 | 		if (signal_line.has(name)) { | 
| 1909 | 			line = signal_line[name]; | 
| 1910 | 		} | 
| 1911 | 	} else if (what == "class_method"  || what == "class_method_desc" ) { | 
| 1912 | 		if (method_line.has(name)) { | 
| 1913 | 			line = method_line[name]; | 
| 1914 | 		} | 
| 1915 | 	} else if (what == "class_property" ) { | 
| 1916 | 		if (property_line.has(name)) { | 
| 1917 | 			line = property_line[name]; | 
| 1918 | 		} | 
| 1919 | 	} else if (what == "class_enum" ) { | 
| 1920 | 		if (enum_line.has(name)) { | 
| 1921 | 			line = enum_line[name]; | 
| 1922 | 		} | 
| 1923 | 	} else if (what == "class_theme_item" ) { | 
| 1924 | 		if (theme_property_line.has(name)) { | 
| 1925 | 			line = theme_property_line[name]; | 
| 1926 | 		} | 
| 1927 | 	} else if (what == "class_constant" ) { | 
| 1928 | 		if (constant_line.has(name)) { | 
| 1929 | 			line = constant_line[name]; | 
| 1930 | 		} | 
| 1931 | 	} else if (what == "class_annotation" ) { | 
| 1932 | 		if (annotation_line.has(name)) { | 
| 1933 | 			line = annotation_line[name]; | 
| 1934 | 		} | 
| 1935 | 	} else if (what == "class_global" ) { | 
| 1936 | 		if (constant_line.has(name)) { | 
| 1937 | 			line = constant_line[name]; | 
| 1938 | 		} else if (method_line.has(name)) { | 
| 1939 | 			line = method_line[name]; | 
| 1940 | 		} else { | 
| 1941 | 			HashMap<String, HashMap<String, int>>::Iterator iter = enum_values_line.begin(); | 
| 1942 | 			while (true) { | 
| 1943 | 				if (iter->value.has(name)) { | 
| 1944 | 					line = iter->value[name]; | 
| 1945 | 					break; | 
| 1946 | 				} else if (iter == enum_values_line.last()) { | 
| 1947 | 					break; | 
| 1948 | 				} else { | 
| 1949 | 					++iter; | 
| 1950 | 				} | 
| 1951 | 			} | 
| 1952 | 		} | 
| 1953 | 	} | 
| 1954 |  | 
| 1955 | 	if (class_desc->is_ready()) { | 
| 1956 | 		class_desc->call_deferred(SNAME("scroll_to_paragraph" ), line); | 
| 1957 | 	} else { | 
| 1958 | 		scroll_to = line; | 
| 1959 | 	} | 
| 1960 | } | 
| 1961 |  | 
| 1962 | static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt, Control *p_owner_node, const String &p_class = "" ) { | 
| 1963 | 	DocTools *doc = EditorHelp::get_doc_data(); | 
| 1964 | 	String base_path; | 
| 1965 |  | 
| 1966 | 	Ref<Font> doc_font = p_owner_node->get_theme_font(SNAME("doc" ), EditorStringName(EditorFonts)); | 
| 1967 | 	Ref<Font> doc_bold_font = p_owner_node->get_theme_font(SNAME("doc_bold" ), EditorStringName(EditorFonts)); | 
| 1968 | 	Ref<Font> doc_italic_font = p_owner_node->get_theme_font(SNAME("doc_italic" ), EditorStringName(EditorFonts)); | 
| 1969 | 	Ref<Font> doc_code_font = p_owner_node->get_theme_font(SNAME("doc_source" ), EditorStringName(EditorFonts)); | 
| 1970 | 	Ref<Font> doc_kbd_font = p_owner_node->get_theme_font(SNAME("doc_keyboard" ), EditorStringName(EditorFonts)); | 
| 1971 |  | 
| 1972 | 	int doc_code_font_size = p_owner_node->get_theme_font_size(SNAME("doc_source_size" ), EditorStringName(EditorFonts)); | 
| 1973 | 	int doc_kbd_font_size = p_owner_node->get_theme_font_size(SNAME("doc_keyboard_size" ), EditorStringName(EditorFonts)); | 
| 1974 |  | 
| 1975 | 	const Color type_color = p_owner_node->get_theme_color(SNAME("type_color" ), SNAME("EditorHelp" )); | 
| 1976 | 	const Color code_color = p_owner_node->get_theme_color(SNAME("code_color" ), SNAME("EditorHelp" )); | 
| 1977 | 	const Color kbd_color = p_owner_node->get_theme_color(SNAME("kbd_color" ), SNAME("EditorHelp" )); | 
| 1978 | 	const Color code_dark_color = Color(code_color, 0.8); | 
| 1979 |  | 
| 1980 | 	const Color link_color = p_owner_node->get_theme_color(SNAME("link_color" ), SNAME("EditorHelp" )); | 
| 1981 | 	const Color link_method_color = p_owner_node->get_theme_color(SNAME("accent_color" ), EditorStringName(Editor)); | 
| 1982 | 	const Color link_property_color = link_color.lerp(p_owner_node->get_theme_color(SNAME("accent_color" ), EditorStringName(Editor)), 0.25); | 
| 1983 | 	const Color link_annotation_color = link_color.lerp(p_owner_node->get_theme_color(SNAME("accent_color" ), EditorStringName(Editor)), 0.5); | 
| 1984 |  | 
| 1985 | 	const Color code_bg_color = p_owner_node->get_theme_color(SNAME("code_bg_color" ), SNAME("EditorHelp" )); | 
| 1986 | 	const Color kbd_bg_color = p_owner_node->get_theme_color(SNAME("kbd_bg_color" ), SNAME("EditorHelp" )); | 
| 1987 | 	const Color param_bg_color = p_owner_node->get_theme_color(SNAME("param_bg_color" ), SNAME("EditorHelp" )); | 
| 1988 |  | 
| 1989 | 	String bbcode = p_bbcode.dedent().replace("\t" , "" ).replace("\r" , "" ).strip_edges(); | 
| 1990 |  | 
| 1991 | 	// Select the correct code examples. | 
| 1992 | 	switch ((int)EDITOR_GET("text_editor/help/class_reference_examples" )) { | 
| 1993 | 		case 0: // GDScript | 
| 1994 | 			bbcode = bbcode.replace("[gdscript]" , "[codeblock]" ); | 
| 1995 | 			bbcode = bbcode.replace("[/gdscript]" , "[/codeblock]" ); | 
| 1996 |  | 
| 1997 | 			for (int pos = bbcode.find("[csharp]" ); pos != -1; pos = bbcode.find("[csharp]" )) { | 
| 1998 | 				int end_pos = bbcode.find("[/csharp]" ); | 
| 1999 | 				if (end_pos == -1) { | 
| 2000 | 					WARN_PRINT("Unclosed [csharp] block or parse fail in code (search for tag errors)" ); | 
| 2001 | 					break; | 
| 2002 | 				} | 
| 2003 |  | 
| 2004 | 				bbcode = bbcode.left(pos) + bbcode.substr(end_pos + 9); // 9 is length of "[/csharp]". | 
| 2005 | 				while (bbcode[pos] == '\n') { | 
| 2006 | 					bbcode = bbcode.left(pos) + bbcode.substr(pos + 1); | 
| 2007 | 				} | 
| 2008 | 			} | 
| 2009 | 			break; | 
| 2010 | 		case 1: // C# | 
| 2011 | 			bbcode = bbcode.replace("[csharp]" , "[codeblock]" ); | 
| 2012 | 			bbcode = bbcode.replace("[/csharp]" , "[/codeblock]" ); | 
| 2013 |  | 
| 2014 | 			for (int pos = bbcode.find("[gdscript]" ); pos != -1; pos = bbcode.find("[gdscript]" )) { | 
| 2015 | 				int end_pos = bbcode.find("[/gdscript]" ); | 
| 2016 | 				if (end_pos == -1) { | 
| 2017 | 					WARN_PRINT("Unclosed [gdscript] block or parse fail in code (search for tag errors)" ); | 
| 2018 | 					break; | 
| 2019 | 				} | 
| 2020 |  | 
| 2021 | 				bbcode = bbcode.left(pos) + bbcode.substr(end_pos + 11); // 11 is length of "[/gdscript]". | 
| 2022 | 				while (bbcode[pos] == '\n') { | 
| 2023 | 					bbcode = bbcode.left(pos) + bbcode.substr(pos + 1); | 
| 2024 | 				} | 
| 2025 | 			} | 
| 2026 | 			break; | 
| 2027 | 		case 2: // GDScript and C# | 
| 2028 | 			bbcode = bbcode.replace("[csharp]" , "[b]C#:[/b]\n[codeblock]" ); | 
| 2029 | 			bbcode = bbcode.replace("[gdscript]" , "[b]GDScript:[/b]\n[codeblock]" ); | 
| 2030 |  | 
| 2031 | 			bbcode = bbcode.replace("[/csharp]" , "[/codeblock]" ); | 
| 2032 | 			bbcode = bbcode.replace("[/gdscript]" , "[/codeblock]" ); | 
| 2033 | 			break; | 
| 2034 | 	} | 
| 2035 |  | 
| 2036 | 	// Remove codeblocks (they would be printed otherwise). | 
| 2037 | 	bbcode = bbcode.replace("[codeblocks]\n" , "" ); | 
| 2038 | 	bbcode = bbcode.replace("\n[/codeblocks]" , "" ); | 
| 2039 | 	bbcode = bbcode.replace("[codeblocks]" , "" ); | 
| 2040 | 	bbcode = bbcode.replace("[/codeblocks]" , "" ); | 
| 2041 |  | 
| 2042 | 	// Remove extra new lines around code blocks. | 
| 2043 | 	bbcode = bbcode.replace("[codeblock]\n" , "[codeblock]" ); | 
| 2044 | 	bbcode = bbcode.replace("\n[/codeblock]" , "[/codeblock]" ); | 
| 2045 |  | 
| 2046 | 	List<String> tag_stack; | 
| 2047 | 	bool code_tag = false; | 
| 2048 | 	bool codeblock_tag = false; | 
| 2049 |  | 
| 2050 | 	int pos = 0; | 
| 2051 | 	while (pos < bbcode.length()) { | 
| 2052 | 		int brk_pos = bbcode.find("[" , pos); | 
| 2053 |  | 
| 2054 | 		if (brk_pos < 0) { | 
| 2055 | 			brk_pos = bbcode.length(); | 
| 2056 | 		} | 
| 2057 |  | 
| 2058 | 		if (brk_pos > pos) { | 
| 2059 | 			String text = bbcode.substr(pos, brk_pos - pos); | 
| 2060 | 			if (!code_tag && !codeblock_tag) { | 
| 2061 | 				text = text.replace("\n" , "\n\n" ); | 
| 2062 | 			} | 
| 2063 | 			p_rt->add_text(text); | 
| 2064 | 		} | 
| 2065 |  | 
| 2066 | 		if (brk_pos == bbcode.length()) { | 
| 2067 | 			break; // Nothing else to add. | 
| 2068 | 		} | 
| 2069 |  | 
| 2070 | 		int brk_end = bbcode.find("]" , brk_pos + 1); | 
| 2071 |  | 
| 2072 | 		if (brk_end == -1) { | 
| 2073 | 			String text = bbcode.substr(brk_pos, bbcode.length() - brk_pos); | 
| 2074 | 			if (!code_tag && !codeblock_tag) { | 
| 2075 | 				text = text.replace("\n" , "\n\n" ); | 
| 2076 | 			} | 
| 2077 | 			p_rt->add_text(text); | 
| 2078 |  | 
| 2079 | 			break; | 
| 2080 | 		} | 
| 2081 |  | 
| 2082 | 		String tag = bbcode.substr(brk_pos + 1, brk_end - brk_pos - 1); | 
| 2083 |  | 
| 2084 | 		if (tag.begins_with("/" )) { | 
| 2085 | 			bool tag_ok = tag_stack.size() && tag_stack.front()->get() == tag.substr(1, tag.length()); | 
| 2086 |  | 
| 2087 | 			if (!tag_ok) { | 
| 2088 | 				p_rt->add_text("[" ); | 
| 2089 | 				pos = brk_pos + 1; | 
| 2090 | 				continue; | 
| 2091 | 			} | 
| 2092 |  | 
| 2093 | 			tag_stack.pop_front(); | 
| 2094 | 			pos = brk_end + 1; | 
| 2095 | 			if (tag != "/img" ) { | 
| 2096 | 				p_rt->pop(); | 
| 2097 | 				if (code_tag) { | 
| 2098 | 					p_rt->pop(); // font size | 
| 2099 | 					// Pop both color and background color. | 
| 2100 | 					p_rt->pop(); | 
| 2101 | 					p_rt->pop(); | 
| 2102 | 				} else if (codeblock_tag) { | 
| 2103 | 					p_rt->pop(); // font size | 
| 2104 | 					// Pop color, cell and table. | 
| 2105 | 					p_rt->pop(); | 
| 2106 | 					p_rt->pop(); | 
| 2107 | 					p_rt->pop(); | 
| 2108 | 				} | 
| 2109 | 			} | 
| 2110 | 			code_tag = false; | 
| 2111 | 			codeblock_tag = false; | 
| 2112 |  | 
| 2113 | 		} else if (code_tag || codeblock_tag) { | 
| 2114 | 			p_rt->add_text("[" ); | 
| 2115 | 			pos = brk_pos + 1; | 
| 2116 |  | 
| 2117 | 		} else if (tag.begins_with("method " ) || tag.begins_with("member " ) || tag.begins_with("signal " ) || tag.begins_with("enum " ) || tag.begins_with("constant " ) || tag.begins_with("annotation " ) || tag.begins_with("theme_item " )) { | 
| 2118 | 			const int tag_end = tag.find(" " ); | 
| 2119 | 			const String link_tag = tag.substr(0, tag_end); | 
| 2120 | 			const String link_target = tag.substr(tag_end + 1, tag.length()).lstrip(" " ); | 
| 2121 |  | 
| 2122 | 			// Use monospace font to make clickable references | 
| 2123 | 			// easier to distinguish from inline code and other text. | 
| 2124 | 			p_rt->push_font(doc_code_font); | 
| 2125 | 			p_rt->push_font_size(doc_code_font_size); | 
| 2126 |  | 
| 2127 | 			Color target_color = link_color; | 
| 2128 | 			if (link_tag == "method" ) { | 
| 2129 | 				target_color = link_method_color; | 
| 2130 | 			} else if (link_tag == "member"  || link_tag == "signal"  || link_tag == "theme property" ) { | 
| 2131 | 				target_color = link_property_color; | 
| 2132 | 			} else if (link_tag == "annotation" ) { | 
| 2133 | 				target_color = link_annotation_color; | 
| 2134 | 			} | 
| 2135 | 			p_rt->push_color(target_color); | 
| 2136 | 			p_rt->push_meta("@"  + link_tag + " "  + link_target); | 
| 2137 | 			p_rt->add_text(link_target + (link_tag == "method"  ? "()"  : "" )); | 
| 2138 | 			p_rt->pop(); | 
| 2139 | 			p_rt->pop(); | 
| 2140 |  | 
| 2141 | 			p_rt->pop(); // font size | 
| 2142 | 			p_rt->pop(); // font | 
| 2143 | 			pos = brk_end + 1; | 
| 2144 |  | 
| 2145 | 		} else if (tag.begins_with("param " )) { | 
| 2146 | 			const int tag_end = tag.find(" " ); | 
| 2147 | 			const String param_name = tag.substr(tag_end + 1, tag.length()).lstrip(" " ); | 
| 2148 |  | 
| 2149 | 			// Use monospace font with translucent background color to make code easier to distinguish from other text. | 
| 2150 | 			p_rt->push_font(doc_code_font); | 
| 2151 | 			p_rt->push_font_size(doc_code_font_size); | 
| 2152 |  | 
| 2153 | 			p_rt->push_bgcolor(param_bg_color); | 
| 2154 | 			p_rt->push_color(code_color); | 
| 2155 | 			p_rt->add_text(param_name); | 
| 2156 | 			p_rt->pop(); | 
| 2157 | 			p_rt->pop(); | 
| 2158 |  | 
| 2159 | 			p_rt->pop(); // font size | 
| 2160 | 			p_rt->pop(); // font | 
| 2161 | 			pos = brk_end + 1; | 
| 2162 |  | 
| 2163 | 		} else if (tag == p_class) { | 
| 2164 | 			// Use a bold font when class reference tags are in their own page. | 
| 2165 | 			p_rt->push_font(doc_bold_font); | 
| 2166 | 			p_rt->add_text(tag); | 
| 2167 | 			p_rt->pop(); | 
| 2168 |  | 
| 2169 | 			pos = brk_end + 1; | 
| 2170 |  | 
| 2171 | 		} else if (doc->class_list.has(tag)) { | 
| 2172 | 			// Use a monospace font for class reference tags such as [Node2D] or [SceneTree]. | 
| 2173 |  | 
| 2174 | 			p_rt->push_font(doc_code_font); | 
| 2175 | 			p_rt->push_font_size(doc_code_font_size); | 
| 2176 | 			p_rt->push_color(type_color); | 
| 2177 | 			p_rt->push_meta("#"  + tag); | 
| 2178 | 			p_rt->add_text(tag); | 
| 2179 |  | 
| 2180 | 			p_rt->pop(); | 
| 2181 | 			p_rt->pop(); | 
| 2182 | 			p_rt->pop(); // Font size | 
| 2183 | 			p_rt->pop(); // Font | 
| 2184 |  | 
| 2185 | 			pos = brk_end + 1; | 
| 2186 |  | 
| 2187 | 		} else if (tag == "b" ) { | 
| 2188 | 			// Use bold font. | 
| 2189 | 			p_rt->push_font(doc_bold_font); | 
| 2190 |  | 
| 2191 | 			pos = brk_end + 1; | 
| 2192 | 			tag_stack.push_front(tag); | 
| 2193 | 		} else if (tag == "i" ) { | 
| 2194 | 			// Use italics font. | 
| 2195 | 			p_rt->push_font(doc_italic_font); | 
| 2196 |  | 
| 2197 | 			pos = brk_end + 1; | 
| 2198 | 			tag_stack.push_front(tag); | 
| 2199 | 		} else if (tag == "code" ) { | 
| 2200 | 			// Use monospace font with darkened background color to make code easier to distinguish from other text. | 
| 2201 | 			p_rt->push_font(doc_code_font); | 
| 2202 | 			p_rt->push_font_size(doc_code_font_size); | 
| 2203 | 			p_rt->push_bgcolor(code_bg_color); | 
| 2204 | 			p_rt->push_color(code_color.lerp(p_owner_node->get_theme_color(SNAME("error_color" ), EditorStringName(Editor)), 0.6)); | 
| 2205 |  | 
| 2206 | 			code_tag = true; | 
| 2207 | 			pos = brk_end + 1; | 
| 2208 | 			tag_stack.push_front(tag); | 
| 2209 | 		} else if (tag == "codeblock" ) { | 
| 2210 | 			// Use monospace font with darkened background color to make code easier to distinguish from other text. | 
| 2211 | 			// Use a single-column table with cell row background color instead of `[bgcolor]`. | 
| 2212 | 			// This makes the background color highlight cover the entire block, rather than individual lines. | 
| 2213 | 			p_rt->push_font(doc_code_font); | 
| 2214 | 			p_rt->push_font_size(doc_code_font_size); | 
| 2215 |  | 
| 2216 | 			p_rt->push_table(1); | 
| 2217 | 			p_rt->push_cell(); | 
| 2218 | 			p_rt->set_cell_row_background_color(code_bg_color, Color(code_bg_color, 0.99)); | 
| 2219 | 			p_rt->set_cell_padding(Rect2(10 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE)); | 
| 2220 | 			p_rt->push_color(code_dark_color); | 
| 2221 |  | 
| 2222 | 			codeblock_tag = true; | 
| 2223 | 			pos = brk_end + 1; | 
| 2224 | 			tag_stack.push_front(tag); | 
| 2225 | 		} else if (tag == "kbd" ) { | 
| 2226 | 			// Use keyboard font with custom color and background color. | 
| 2227 | 			p_rt->push_font(doc_kbd_font); | 
| 2228 | 			p_rt->push_font_size(doc_kbd_font_size); | 
| 2229 | 			p_rt->push_bgcolor(kbd_bg_color); | 
| 2230 | 			p_rt->push_color(kbd_color); | 
| 2231 |  | 
| 2232 | 			code_tag = true; // Though not strictly a code tag, logic is similar. | 
| 2233 | 			pos = brk_end + 1; | 
| 2234 | 			tag_stack.push_front(tag); | 
| 2235 |  | 
| 2236 | 		} else if (tag == "center" ) { | 
| 2237 | 			// Align to center. | 
| 2238 | 			p_rt->push_paragraph(HORIZONTAL_ALIGNMENT_CENTER, Control::TEXT_DIRECTION_AUTO, "" ); | 
| 2239 | 			pos = brk_end + 1; | 
| 2240 | 			tag_stack.push_front(tag); | 
| 2241 | 		} else if (tag == "br" ) { | 
| 2242 | 			// Force a line break. | 
| 2243 | 			p_rt->add_newline(); | 
| 2244 | 			pos = brk_end + 1; | 
| 2245 | 		} else if (tag == "u" ) { | 
| 2246 | 			// Use underline. | 
| 2247 | 			p_rt->push_underline(); | 
| 2248 | 			pos = brk_end + 1; | 
| 2249 | 			tag_stack.push_front(tag); | 
| 2250 | 		} else if (tag == "s" ) { | 
| 2251 | 			// Use strikethrough. | 
| 2252 | 			p_rt->push_strikethrough(); | 
| 2253 | 			pos = brk_end + 1; | 
| 2254 | 			tag_stack.push_front(tag); | 
| 2255 |  | 
| 2256 | 		} else if (tag == "url" ) { | 
| 2257 | 			int end = bbcode.find("[" , brk_end); | 
| 2258 | 			if (end == -1) { | 
| 2259 | 				end = bbcode.length(); | 
| 2260 | 			} | 
| 2261 | 			String url = bbcode.substr(brk_end + 1, end - brk_end - 1); | 
| 2262 | 			p_rt->push_meta(url); | 
| 2263 |  | 
| 2264 | 			pos = brk_end + 1; | 
| 2265 | 			tag_stack.push_front(tag); | 
| 2266 | 		} else if (tag.begins_with("url=" )) { | 
| 2267 | 			String url = tag.substr(4, tag.length()); | 
| 2268 | 			p_rt->push_meta(url); | 
| 2269 |  | 
| 2270 | 			pos = brk_end + 1; | 
| 2271 | 			tag_stack.push_front("url" ); | 
| 2272 | 		} else if (tag == "img" ) { | 
| 2273 | 			int end = bbcode.find("[" , brk_end); | 
| 2274 | 			if (end == -1) { | 
| 2275 | 				end = bbcode.length(); | 
| 2276 | 			} | 
| 2277 | 			String image = bbcode.substr(brk_end + 1, end - brk_end - 1); | 
| 2278 |  | 
| 2279 | 			Ref<Texture2D> texture = ResourceLoader::load(base_path.path_join(image), "Texture2D" ); | 
| 2280 | 			if (texture.is_valid()) { | 
| 2281 | 				p_rt->add_image(texture); | 
| 2282 | 			} | 
| 2283 |  | 
| 2284 | 			pos = end; | 
| 2285 | 			tag_stack.push_front(tag); | 
| 2286 | 		} else if (tag.begins_with("color=" )) { | 
| 2287 | 			String col = tag.substr(6, tag.length()); | 
| 2288 | 			Color color = Color::from_string(col, Color()); | 
| 2289 | 			p_rt->push_color(color); | 
| 2290 |  | 
| 2291 | 			pos = brk_end + 1; | 
| 2292 | 			tag_stack.push_front("color" ); | 
| 2293 |  | 
| 2294 | 		} else if (tag.begins_with("font=" )) { | 
| 2295 | 			String fnt = tag.substr(5, tag.length()); | 
| 2296 |  | 
| 2297 | 			Ref<Font> font = ResourceLoader::load(base_path.path_join(fnt), "Font" ); | 
| 2298 | 			if (font.is_valid()) { | 
| 2299 | 				p_rt->push_font(font); | 
| 2300 | 			} else { | 
| 2301 | 				p_rt->push_font(doc_font); | 
| 2302 | 			} | 
| 2303 |  | 
| 2304 | 			pos = brk_end + 1; | 
| 2305 | 			tag_stack.push_front("font" ); | 
| 2306 |  | 
| 2307 | 		} else { | 
| 2308 | 			p_rt->add_text("[" ); // ignore | 
| 2309 | 			pos = brk_pos + 1; | 
| 2310 | 		} | 
| 2311 | 	} | 
| 2312 | } | 
| 2313 |  | 
| 2314 | void EditorHelp::_add_text(const String &p_bbcode) { | 
| 2315 | 	_add_text_to_rt(p_bbcode, class_desc, this, edited_class); | 
| 2316 | } | 
| 2317 |  | 
| 2318 | Thread EditorHelp::thread; | 
| 2319 |  | 
| 2320 | void EditorHelp::_wait_for_thread() { | 
| 2321 | 	if (thread.is_started()) { | 
| 2322 | 		thread.wait_to_finish(); | 
| 2323 | 	} | 
| 2324 | } | 
| 2325 |  | 
| 2326 | String EditorHelp::get_cache_full_path() { | 
| 2327 | 	return EditorPaths::get_singleton()->get_cache_dir().path_join("editor_doc_cache.res" ); | 
| 2328 | } | 
| 2329 |  | 
| 2330 | static bool first_attempt = true; | 
| 2331 |  | 
| 2332 | static String _compute_doc_version_hash() { | 
| 2333 | 	uint32_t version_hash = Engine::get_singleton()->get_version_info().hash(); | 
| 2334 | 	return vformat("%d/%d/%d/%s" , version_hash, ClassDB::get_api_hash(ClassDB::API_CORE), ClassDB::get_api_hash(ClassDB::API_EDITOR), _doc_data_hash); | 
| 2335 | } | 
| 2336 |  | 
| 2337 | void EditorHelp::_load_doc_thread(void *p_udata) { | 
| 2338 | 	DEV_ASSERT(first_attempt); | 
| 2339 | 	Ref<Resource> cache_res = ResourceLoader::load(get_cache_full_path()); | 
| 2340 | 	if (cache_res.is_valid() && cache_res->get_meta("version_hash" , "" ) == _compute_doc_version_hash()) { | 
| 2341 | 		Array classes = cache_res->get_meta("classes" , Array()); | 
| 2342 | 		for (int i = 0; i < classes.size(); i++) { | 
| 2343 | 			doc->add_doc(DocData::ClassDoc::from_dict(classes[i])); | 
| 2344 | 		} | 
| 2345 | 	} else { | 
| 2346 | 		// We have to go back to the main thread to start from scratch. | 
| 2347 | 		first_attempt = false; | 
| 2348 | 		callable_mp_static(&EditorHelp::generate_doc).bind(true).call_deferred(); | 
| 2349 | 	} | 
| 2350 | } | 
| 2351 |  | 
| 2352 | void EditorHelp::_gen_doc_thread(void *p_udata) { | 
| 2353 | 	DocTools compdoc; | 
| 2354 | 	compdoc.load_compressed(_doc_data_compressed, _doc_data_compressed_size, _doc_data_uncompressed_size); | 
| 2355 | 	doc->merge_from(compdoc); // Ensure all is up to date. | 
| 2356 |  | 
| 2357 | 	Ref<Resource> cache_res; | 
| 2358 | 	cache_res.instantiate(); | 
| 2359 | 	cache_res->set_meta("version_hash" , _compute_doc_version_hash()); | 
| 2360 | 	Array classes; | 
| 2361 | 	for (const KeyValue<String, DocData::ClassDoc> &E : doc->class_list) { | 
| 2362 | 		classes.push_back(DocData::ClassDoc::to_dict(E.value)); | 
| 2363 | 	} | 
| 2364 | 	cache_res->set_meta("classes" , classes); | 
| 2365 | 	Error err = ResourceSaver::save(cache_res, get_cache_full_path(), ResourceSaver::FLAG_COMPRESS); | 
| 2366 | 	if (err) { | 
| 2367 | 		ERR_PRINT("Cannot save editor help cache ("  + get_cache_full_path() + ")." ); | 
| 2368 | 	} | 
| 2369 | } | 
| 2370 |  | 
| 2371 | static bool doc_gen_use_threads = true; | 
| 2372 |  | 
| 2373 | void EditorHelp::generate_doc(bool p_use_cache) { | 
| 2374 | 	OS::get_singleton()->benchmark_begin_measure("EditorHelp::generate_doc" ); | 
| 2375 | 	if (doc_gen_use_threads) { | 
| 2376 | 		// In case not the first attempt. | 
| 2377 | 		_wait_for_thread(); | 
| 2378 | 	} | 
| 2379 |  | 
| 2380 | 	DEV_ASSERT(first_attempt == (doc == nullptr)); | 
| 2381 |  | 
| 2382 | 	if (!doc) { | 
| 2383 | 		doc = memnew(DocTools); | 
| 2384 | 	} | 
| 2385 |  | 
| 2386 | 	if (p_use_cache && first_attempt && FileAccess::exists(get_cache_full_path())) { | 
| 2387 | 		if (doc_gen_use_threads) { | 
| 2388 | 			thread.start(_load_doc_thread, nullptr); | 
| 2389 | 		} else { | 
| 2390 | 			_load_doc_thread(nullptr); | 
| 2391 | 		} | 
| 2392 | 	} else { | 
| 2393 | 		print_verbose("Regenerating editor help cache" ); | 
| 2394 |  | 
| 2395 | 		// Not doable on threads unfortunately, since it instantiates all sorts of classes to get default values. | 
| 2396 | 		doc->generate(true); | 
| 2397 |  | 
| 2398 | 		if (doc_gen_use_threads) { | 
| 2399 | 			thread.start(_gen_doc_thread, nullptr); | 
| 2400 | 		} else { | 
| 2401 | 			_gen_doc_thread(nullptr); | 
| 2402 | 		} | 
| 2403 | 	} | 
| 2404 | 	OS::get_singleton()->benchmark_end_measure("EditorHelp::generate_doc" ); | 
| 2405 | } | 
| 2406 |  | 
| 2407 | void EditorHelp::_toggle_scripts_pressed() { | 
| 2408 | 	ScriptEditor::get_singleton()->toggle_scripts_panel(); | 
| 2409 | 	update_toggle_scripts_button(); | 
| 2410 | } | 
| 2411 |  | 
| 2412 | void EditorHelp::_notification(int p_what) { | 
| 2413 | 	switch (p_what) { | 
| 2414 | 		case NOTIFICATION_POSTINITIALIZE: { | 
| 2415 | 			// Requires theme to be up to date. | 
| 2416 | 			_class_desc_resized(false); | 
| 2417 | 		} break; | 
| 2418 |  | 
| 2419 | 		case NOTIFICATION_READY: | 
| 2420 | 		case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { | 
| 2421 | 			_wait_for_thread(); | 
| 2422 | 			_update_doc(); | 
| 2423 | 		} break; | 
| 2424 |  | 
| 2425 | 		case NOTIFICATION_THEME_CHANGED: { | 
| 2426 | 			if (is_inside_tree()) { | 
| 2427 | 				_class_desc_resized(true); | 
| 2428 | 			} | 
| 2429 | 			update_toggle_scripts_button(); | 
| 2430 | 		} break; | 
| 2431 |  | 
| 2432 | 		case NOTIFICATION_VISIBILITY_CHANGED: { | 
| 2433 | 			update_toggle_scripts_button(); | 
| 2434 | 		} break; | 
| 2435 | 	} | 
| 2436 | } | 
| 2437 |  | 
| 2438 | void EditorHelp::go_to_help(const String &p_help) { | 
| 2439 | 	_wait_for_thread(); | 
| 2440 | 	_help_callback(p_help); | 
| 2441 | } | 
| 2442 |  | 
| 2443 | void EditorHelp::go_to_class(const String &p_class) { | 
| 2444 | 	_wait_for_thread(); | 
| 2445 | 	_goto_desc(p_class); | 
| 2446 | } | 
| 2447 |  | 
| 2448 | void EditorHelp::update_doc() { | 
| 2449 | 	_wait_for_thread(); | 
| 2450 | 	ERR_FAIL_COND(!doc->class_list.has(edited_class)); | 
| 2451 | 	ERR_FAIL_COND(!doc->class_list[edited_class].is_script_doc); | 
| 2452 | 	_update_doc(); | 
| 2453 | } | 
| 2454 |  | 
| 2455 | void EditorHelp::cleanup_doc() { | 
| 2456 | 	_wait_for_thread(); | 
| 2457 | 	memdelete(doc); | 
| 2458 | } | 
| 2459 |  | 
| 2460 | Vector<Pair<String, int>> EditorHelp::get_sections() { | 
| 2461 | 	_wait_for_thread(); | 
| 2462 | 	Vector<Pair<String, int>> sections; | 
| 2463 |  | 
| 2464 | 	for (int i = 0; i < section_line.size(); i++) { | 
| 2465 | 		sections.push_back(Pair<String, int>(section_line[i].first, i)); | 
| 2466 | 	} | 
| 2467 | 	return sections; | 
| 2468 | } | 
| 2469 |  | 
| 2470 | void EditorHelp::scroll_to_section(int p_section_index) { | 
| 2471 | 	_wait_for_thread(); | 
| 2472 | 	int line = section_line[p_section_index].second; | 
| 2473 | 	if (class_desc->is_ready()) { | 
| 2474 | 		class_desc->scroll_to_paragraph(line); | 
| 2475 | 	} else { | 
| 2476 | 		scroll_to = line; | 
| 2477 | 	} | 
| 2478 | } | 
| 2479 |  | 
| 2480 | void EditorHelp::() { | 
| 2481 | 	_wait_for_thread(); | 
| 2482 | 	find_bar->popup_search(); | 
| 2483 | } | 
| 2484 |  | 
| 2485 | String EditorHelp::get_class() { | 
| 2486 | 	return edited_class; | 
| 2487 | } | 
| 2488 |  | 
| 2489 | void EditorHelp::search_again(bool p_search_previous) { | 
| 2490 | 	_search(p_search_previous); | 
| 2491 | } | 
| 2492 |  | 
| 2493 | int EditorHelp::get_scroll() const { | 
| 2494 | 	return class_desc->get_v_scroll_bar()->get_value(); | 
| 2495 | } | 
| 2496 |  | 
| 2497 | void EditorHelp::set_scroll(int p_scroll) { | 
| 2498 | 	class_desc->get_v_scroll_bar()->set_value(p_scroll); | 
| 2499 | } | 
| 2500 |  | 
| 2501 | void EditorHelp::update_toggle_scripts_button() { | 
| 2502 | 	if (is_layout_rtl()) { | 
| 2503 | 		toggle_scripts_button->set_icon(get_editor_theme_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? SNAME("Forward" ) : SNAME("Back" ))); | 
| 2504 | 	} else { | 
| 2505 | 		toggle_scripts_button->set_icon(get_editor_theme_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? SNAME("Back" ) : SNAME("Forward" ))); | 
| 2506 | 	} | 
| 2507 | 	toggle_scripts_button->set_tooltip_text(vformat("%s (%s)" , TTR("Toggle Scripts Panel" ), ED_GET_SHORTCUT("script_editor/toggle_scripts_panel" )->get_as_text())); | 
| 2508 | } | 
| 2509 |  | 
| 2510 | void EditorHelp::_bind_methods() { | 
| 2511 | 	ClassDB::bind_method("_class_list_select" , &EditorHelp::_class_list_select); | 
| 2512 | 	ClassDB::bind_method("_request_help" , &EditorHelp::_request_help); | 
| 2513 | 	ClassDB::bind_method("_search" , &EditorHelp::_search); | 
| 2514 | 	ClassDB::bind_method("_help_callback" , &EditorHelp::_help_callback); | 
| 2515 |  | 
| 2516 | 	ADD_SIGNAL(MethodInfo("go_to_help" )); | 
| 2517 | } | 
| 2518 |  | 
| 2519 | EditorHelp::EditorHelp() { | 
| 2520 | 	set_custom_minimum_size(Size2(150 * EDSCALE, 0)); | 
| 2521 |  | 
| 2522 | 	EDITOR_DEF("text_editor/help/sort_functions_alphabetically" , true); | 
| 2523 |  | 
| 2524 | 	class_desc = memnew(RichTextLabel); | 
| 2525 | 	add_child(class_desc); | 
| 2526 | 	class_desc->set_threaded(true); | 
| 2527 | 	class_desc->set_v_size_flags(SIZE_EXPAND_FILL); | 
| 2528 |  | 
| 2529 | 	class_desc->connect("finished" , callable_mp(this, &EditorHelp::_class_desc_finished)); | 
| 2530 | 	class_desc->connect("meta_clicked" , callable_mp(this, &EditorHelp::_class_desc_select)); | 
| 2531 | 	class_desc->connect("gui_input" , callable_mp(this, &EditorHelp::_class_desc_input)); | 
| 2532 | 	class_desc->connect("resized" , callable_mp(this, &EditorHelp::_class_desc_resized).bind(false)); | 
| 2533 |  | 
| 2534 | 	// Added second so it opens at the bottom so it won't offset the entire widget. | 
| 2535 | 	find_bar = memnew(FindBar); | 
| 2536 | 	add_child(find_bar); | 
| 2537 | 	find_bar->hide(); | 
| 2538 | 	find_bar->set_rich_text_label(class_desc); | 
| 2539 |  | 
| 2540 | 	status_bar = memnew(HBoxContainer); | 
| 2541 | 	add_child(status_bar); | 
| 2542 | 	status_bar->set_h_size_flags(SIZE_EXPAND_FILL); | 
| 2543 | 	status_bar->set_custom_minimum_size(Size2(0, 24 * EDSCALE)); | 
| 2544 |  | 
| 2545 | 	toggle_scripts_button = memnew(Button); | 
| 2546 | 	toggle_scripts_button->set_flat(true); | 
| 2547 | 	toggle_scripts_button->connect("pressed" , callable_mp(this, &EditorHelp::_toggle_scripts_pressed)); | 
| 2548 | 	status_bar->add_child(toggle_scripts_button); | 
| 2549 |  | 
| 2550 | 	class_desc->set_selection_enabled(true); | 
| 2551 | 	class_desc->set_context_menu_enabled(true); | 
| 2552 |  | 
| 2553 | 	class_desc->hide(); | 
| 2554 | } | 
| 2555 |  | 
| 2556 | EditorHelp::~EditorHelp() { | 
| 2557 | } | 
| 2558 |  | 
| 2559 | DocTools *EditorHelp::get_doc_data() { | 
| 2560 | 	_wait_for_thread(); | 
| 2561 | 	return doc; | 
| 2562 | } | 
| 2563 |  | 
| 2564 | //// EditorHelpBit /// | 
| 2565 |  | 
| 2566 | void EditorHelpBit::_go_to_help(String p_what) { | 
| 2567 | 	EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); | 
| 2568 | 	ScriptEditor::get_singleton()->goto_help(p_what); | 
| 2569 | 	emit_signal(SNAME("request_hide" )); | 
| 2570 | } | 
| 2571 |  | 
| 2572 | void EditorHelpBit::_meta_clicked(String p_select) { | 
| 2573 | 	if (p_select.begins_with("$" )) { // enum | 
| 2574 | 		String select = p_select.substr(1, p_select.length()); | 
| 2575 | 		String class_name; | 
| 2576 | 		int rfind = select.rfind("." ); | 
| 2577 | 		if (rfind != -1) { | 
| 2578 | 			class_name = select.substr(0, rfind); | 
| 2579 | 			select = select.substr(rfind + 1); | 
| 2580 | 		} else { | 
| 2581 | 			class_name = "@GlobalScope" ; | 
| 2582 | 		} | 
| 2583 | 		_go_to_help("class_enum:"  + class_name + ":"  + select); | 
| 2584 | 		return; | 
| 2585 | 	} else if (p_select.begins_with("#" )) { | 
| 2586 | 		_go_to_help("class_name:"  + p_select.substr(1, p_select.length())); | 
| 2587 | 		return; | 
| 2588 | 	} else if (p_select.begins_with("@" )) { | 
| 2589 | 		String m = p_select.substr(1, p_select.length()); | 
| 2590 |  | 
| 2591 | 		if (m.contains("." )) { | 
| 2592 | 			_go_to_help("class_method:"  + m.get_slice("." , 0) + ":"  + m.get_slice("." , 0)); // Must go somewhere else. | 
| 2593 | 		} | 
| 2594 | 	} | 
| 2595 | } | 
| 2596 |  | 
| 2597 | void EditorHelpBit::_bind_methods() { | 
| 2598 | 	ClassDB::bind_method(D_METHOD("set_text" , "text" ), &EditorHelpBit::set_text); | 
| 2599 | 	ADD_SIGNAL(MethodInfo("request_hide" )); | 
| 2600 | } | 
| 2601 |  | 
| 2602 | void EditorHelpBit::_notification(int p_what) { | 
| 2603 | 	switch (p_what) { | 
| 2604 | 		case NOTIFICATION_THEME_CHANGED: { | 
| 2605 | 			rich_text->add_theme_color_override("selection_color" , get_theme_color(SNAME("selection_color" ), SNAME("EditorHelp" ))); | 
| 2606 | 			rich_text->clear(); | 
| 2607 | 			_add_text_to_rt(text, rich_text, this); | 
| 2608 | 			rich_text->reset_size(); // Force recalculating size after parsing bbcode. | 
| 2609 | 		} break; | 
| 2610 | 	} | 
| 2611 | } | 
| 2612 |  | 
| 2613 | void EditorHelpBit::set_text(const String &p_text) { | 
| 2614 | 	text = p_text; | 
| 2615 | 	rich_text->clear(); | 
| 2616 | 	_add_text_to_rt(text, rich_text, this); | 
| 2617 | } | 
| 2618 |  | 
| 2619 | EditorHelpBit::EditorHelpBit() { | 
| 2620 | 	rich_text = memnew(RichTextLabel); | 
| 2621 | 	add_child(rich_text); | 
| 2622 | 	rich_text->connect("meta_clicked" , callable_mp(this, &EditorHelpBit::_meta_clicked)); | 
| 2623 | 	rich_text->set_fit_content(true); | 
| 2624 | 	set_custom_minimum_size(Size2(0, 50 * EDSCALE)); | 
| 2625 | } | 
| 2626 |  | 
| 2627 | //// FindBar /// | 
| 2628 |  | 
| 2629 | FindBar::FindBar() { | 
| 2630 | 	search_text = memnew(LineEdit); | 
| 2631 | 	add_child(search_text); | 
| 2632 | 	search_text->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); | 
| 2633 | 	search_text->set_h_size_flags(SIZE_EXPAND_FILL); | 
| 2634 | 	search_text->connect("text_changed" , callable_mp(this, &FindBar::_search_text_changed)); | 
| 2635 | 	search_text->connect("text_submitted" , callable_mp(this, &FindBar::_search_text_submitted)); | 
| 2636 |  | 
| 2637 | 	matches_label = memnew(Label); | 
| 2638 | 	add_child(matches_label); | 
| 2639 | 	matches_label->hide(); | 
| 2640 |  | 
| 2641 | 	find_prev = memnew(Button); | 
| 2642 | 	find_prev->set_flat(true); | 
| 2643 | 	add_child(find_prev); | 
| 2644 | 	find_prev->set_focus_mode(FOCUS_NONE); | 
| 2645 | 	find_prev->connect("pressed" , callable_mp(this, &FindBar::search_prev)); | 
| 2646 |  | 
| 2647 | 	find_next = memnew(Button); | 
| 2648 | 	find_next->set_flat(true); | 
| 2649 | 	add_child(find_next); | 
| 2650 | 	find_next->set_focus_mode(FOCUS_NONE); | 
| 2651 | 	find_next->connect("pressed" , callable_mp(this, &FindBar::search_next)); | 
| 2652 |  | 
| 2653 | 	Control *space = memnew(Control); | 
| 2654 | 	add_child(space); | 
| 2655 | 	space->set_custom_minimum_size(Size2(4, 0) * EDSCALE); | 
| 2656 |  | 
| 2657 | 	hide_button = memnew(TextureButton); | 
| 2658 | 	add_child(hide_button); | 
| 2659 | 	hide_button->set_focus_mode(FOCUS_NONE); | 
| 2660 | 	hide_button->set_ignore_texture_size(true); | 
| 2661 | 	hide_button->set_stretch_mode(TextureButton::STRETCH_KEEP_CENTERED); | 
| 2662 | 	hide_button->connect("pressed" , callable_mp(this, &FindBar::_hide_bar)); | 
| 2663 | } | 
| 2664 |  | 
| 2665 | void FindBar::() { | 
| 2666 | 	show(); | 
| 2667 | 	bool grabbed_focus = false; | 
| 2668 | 	if (!search_text->has_focus()) { | 
| 2669 | 		search_text->grab_focus(); | 
| 2670 | 		grabbed_focus = true; | 
| 2671 | 	} | 
| 2672 |  | 
| 2673 | 	if (!search_text->get_text().is_empty()) { | 
| 2674 | 		search_text->select_all(); | 
| 2675 | 		search_text->set_caret_column(search_text->get_text().length()); | 
| 2676 | 		if (grabbed_focus) { | 
| 2677 | 			_search(); | 
| 2678 | 		} | 
| 2679 | 	} | 
| 2680 | } | 
| 2681 |  | 
| 2682 | void FindBar::_notification(int p_what) { | 
| 2683 | 	switch (p_what) { | 
| 2684 | 		case NOTIFICATION_THEME_CHANGED: { | 
| 2685 | 			find_prev->set_icon(get_editor_theme_icon(SNAME("MoveUp" ))); | 
| 2686 | 			find_next->set_icon(get_editor_theme_icon(SNAME("MoveDown" ))); | 
| 2687 | 			hide_button->set_texture_normal(get_editor_theme_icon(SNAME("Close" ))); | 
| 2688 | 			hide_button->set_texture_hover(get_editor_theme_icon(SNAME("Close" ))); | 
| 2689 | 			hide_button->set_texture_pressed(get_editor_theme_icon(SNAME("Close" ))); | 
| 2690 | 			hide_button->set_custom_minimum_size(hide_button->get_texture_normal()->get_size()); | 
| 2691 | 			matches_label->add_theme_color_override("font_color" , results_count > 0 ? get_theme_color(SNAME("font_color" ), SNAME("Label" )) : get_theme_color(SNAME("error_color" ), EditorStringName(Editor))); | 
| 2692 | 		} break; | 
| 2693 |  | 
| 2694 | 		case NOTIFICATION_VISIBILITY_CHANGED: { | 
| 2695 | 			set_process_unhandled_input(is_visible_in_tree()); | 
| 2696 | 		} break; | 
| 2697 | 	} | 
| 2698 | } | 
| 2699 |  | 
| 2700 | void FindBar::set_rich_text_label(RichTextLabel *p_rich_text_label) { | 
| 2701 | 	rich_text_label = p_rich_text_label; | 
| 2702 | } | 
| 2703 |  | 
| 2704 | bool FindBar::search_next() { | 
| 2705 | 	return _search(); | 
| 2706 | } | 
| 2707 |  | 
| 2708 | bool FindBar::search_prev() { | 
| 2709 | 	return _search(true); | 
| 2710 | } | 
| 2711 |  | 
| 2712 | bool FindBar::_search(bool p_search_previous) { | 
| 2713 | 	String stext = search_text->get_text(); | 
| 2714 | 	bool keep = prev_search == stext; | 
| 2715 |  | 
| 2716 | 	bool ret = rich_text_label->search(stext, keep, p_search_previous); | 
| 2717 |  | 
| 2718 | 	prev_search = stext; | 
| 2719 |  | 
| 2720 | 	if (ret) { | 
| 2721 | 		_update_results_count(); | 
| 2722 | 	} else { | 
| 2723 | 		results_count = 0; | 
| 2724 | 	} | 
| 2725 | 	_update_matches_label(); | 
| 2726 |  | 
| 2727 | 	return ret; | 
| 2728 | } | 
| 2729 |  | 
| 2730 | void FindBar::_update_results_count() { | 
| 2731 | 	results_count = 0; | 
| 2732 |  | 
| 2733 | 	String searched = search_text->get_text(); | 
| 2734 | 	if (searched.is_empty()) { | 
| 2735 | 		return; | 
| 2736 | 	} | 
| 2737 |  | 
| 2738 | 	String full_text = rich_text_label->get_parsed_text(); | 
| 2739 |  | 
| 2740 | 	int from_pos = 0; | 
| 2741 |  | 
| 2742 | 	while (true) { | 
| 2743 | 		int pos = full_text.findn(searched, from_pos); | 
| 2744 | 		if (pos == -1) { | 
| 2745 | 			break; | 
| 2746 | 		} | 
| 2747 |  | 
| 2748 | 		results_count++; | 
| 2749 | 		from_pos = pos + searched.length(); | 
| 2750 | 	} | 
| 2751 | } | 
| 2752 |  | 
| 2753 | void FindBar::_update_matches_label() { | 
| 2754 | 	if (search_text->get_text().is_empty() || results_count == -1) { | 
| 2755 | 		matches_label->hide(); | 
| 2756 | 	} else { | 
| 2757 | 		matches_label->show(); | 
| 2758 |  | 
| 2759 | 		matches_label->add_theme_color_override("font_color" , results_count > 0 ? get_theme_color(SNAME("font_color" ), SNAME("Label" )) : get_theme_color(SNAME("error_color" ), EditorStringName(Editor))); | 
| 2760 | 		matches_label->set_text(vformat(results_count == 1 ? TTR("%d match." ) : TTR("%d matches." ), results_count)); | 
| 2761 | 	} | 
| 2762 | } | 
| 2763 |  | 
| 2764 | void FindBar::_hide_bar() { | 
| 2765 | 	if (search_text->has_focus()) { | 
| 2766 | 		rich_text_label->grab_focus(); | 
| 2767 | 	} | 
| 2768 |  | 
| 2769 | 	hide(); | 
| 2770 | } | 
| 2771 |  | 
| 2772 | void FindBar::unhandled_input(const Ref<InputEvent> &p_event) { | 
| 2773 | 	ERR_FAIL_COND(p_event.is_null()); | 
| 2774 |  | 
| 2775 | 	Ref<InputEventKey> k = p_event; | 
| 2776 | 	if (k.is_valid() && k->is_action_pressed(SNAME("ui_cancel" ), false, true)) { | 
| 2777 | 		if (rich_text_label->has_focus() || is_ancestor_of(get_viewport()->gui_get_focus_owner())) { | 
| 2778 | 			_hide_bar(); | 
| 2779 | 			accept_event(); | 
| 2780 | 		} | 
| 2781 | 	} | 
| 2782 | } | 
| 2783 |  | 
| 2784 | void FindBar::_search_text_changed(const String &p_text) { | 
| 2785 | 	search_next(); | 
| 2786 | } | 
| 2787 |  | 
| 2788 | void FindBar::_search_text_submitted(const String &p_text) { | 
| 2789 | 	if (Input::get_singleton()->is_key_pressed(Key::SHIFT)) { | 
| 2790 | 		search_prev(); | 
| 2791 | 	} else { | 
| 2792 | 		search_next(); | 
| 2793 | 	} | 
| 2794 | } | 
| 2795 |  |