2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* editor_help.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* http://www.godotengine.org */
|
|
|
|
/*************************************************************************/
|
2017-01-01 21:01:57 +00:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-07 22:45:00 +00:00
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
2014-02-10 01:10:30 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
|
|
|
#include "editor_help.h"
|
2017-03-18 23:36:26 +00:00
|
|
|
#include "doc_data_compressed.h"
|
|
|
|
#include "editor/plugins/script_editor_plugin.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "editor_node.h"
|
|
|
|
#include "editor_settings.h"
|
|
|
|
#include "os/keyboard.h"
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
#include "os/keyboard.h"
|
|
|
|
|
2015-11-24 21:33:26 +00:00
|
|
|
void EditorHelpSearch::popup() {
|
|
|
|
popup_centered_ratio(0.6);
|
2017-03-18 23:36:26 +00:00
|
|
|
if (search_box->get_text() != "") {
|
2015-11-24 21:33:26 +00:00
|
|
|
search_box->select_all();
|
|
|
|
_update_search();
|
|
|
|
}
|
|
|
|
search_box->grab_focus();
|
|
|
|
}
|
2014-02-21 02:01:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelpSearch::popup(const String &p_term) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
popup_centered_ratio(0.6);
|
2017-03-18 23:36:26 +00:00
|
|
|
if (p_term != "") {
|
2014-02-21 02:01:44 +00:00
|
|
|
search_box->set_text(p_term);
|
|
|
|
search_box->select_all();
|
2014-05-05 13:59:18 +00:00
|
|
|
_update_search();
|
2014-05-06 09:41:19 +00:00
|
|
|
} else
|
2014-02-21 02:01:44 +00:00
|
|
|
search_box->clear();
|
2014-05-06 09:41:19 +00:00
|
|
|
search_box->grab_focus();
|
2014-02-21 02:01:44 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelpSearch::_text_changed(const String &p_newtext) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
_update_search();
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelpSearch::_sbox_input(const InputEvent &p_ie) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (p_ie.type == InputEvent::KEY && (p_ie.key.scancode == KEY_UP ||
|
|
|
|
p_ie.key.scancode == KEY_DOWN ||
|
|
|
|
p_ie.key.scancode == KEY_PAGEUP ||
|
|
|
|
p_ie.key.scancode == KEY_PAGEDOWN)) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
search_options->call("_input_event", p_ie);
|
2014-02-21 02:01:44 +00:00
|
|
|
search_box->accept_event();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorHelpSearch::_update_search() {
|
|
|
|
|
|
|
|
search_options->clear();
|
|
|
|
search_options->set_hide_root(true);
|
|
|
|
|
|
|
|
/*
|
|
|
|
TreeItem *root = search_options->create_item();
|
|
|
|
_parse_fs(EditorFileSystem::get_singleton()->get_filesystem());
|
|
|
|
*/
|
|
|
|
|
2015-06-29 03:29:49 +00:00
|
|
|
List<StringName> type_list;
|
2014-02-21 02:01:44 +00:00
|
|
|
ObjectTypeDB::get_type_list(&type_list);
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
DocData *doc = EditorHelp::get_doc_data();
|
2014-02-21 02:01:44 +00:00
|
|
|
String term = search_box->get_text();
|
2017-03-18 23:36:26 +00:00
|
|
|
if (term.length() < 2)
|
2014-02-21 02:01:44 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
TreeItem *root = search_options->create_item();
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
Ref<Texture> def_icon = get_icon("Node", "EditorIcons");
|
2014-02-21 02:01:44 +00:00
|
|
|
//classes first
|
2017-03-18 23:36:26 +00:00
|
|
|
for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (E->key().findn(term) != -1) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
TreeItem *item = search_options->create_item(root);
|
2017-03-18 23:36:26 +00:00
|
|
|
item->set_metadata(0, "class_name:" + E->key());
|
|
|
|
item->set_text(0, E->key() + " (Class)");
|
|
|
|
if (has_icon(E->key(), "EditorIcons"))
|
|
|
|
item->set_icon(0, get_icon(E->key(), "EditorIcons"));
|
2014-02-21 02:01:44 +00:00
|
|
|
else
|
2017-03-18 23:36:26 +00:00
|
|
|
item->set_icon(0, def_icon);
|
2014-02-21 02:01:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//class methods, etc second
|
2017-03-18 23:36:26 +00:00
|
|
|
for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
DocData::ClassDoc &c = E->get();
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
Ref<Texture> cicon;
|
2017-03-18 23:36:26 +00:00
|
|
|
if (has_icon(E->key(), "EditorIcons"))
|
|
|
|
cicon = get_icon(E->key(), "EditorIcons");
|
2014-02-21 02:01:44 +00:00
|
|
|
else
|
2017-03-18 23:36:26 +00:00
|
|
|
cicon = def_icon;
|
2016-05-29 14:37:26 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < c.methods.size(); i++) {
|
|
|
|
if ((term.begins_with(".") && c.methods[i].name.begins_with(term.right(1))) || (term.ends_with("(") && c.methods[i].name.ends_with(term.left(term.length() - 1).strip_edges())) || (term.begins_with(".") && term.ends_with("(") && c.methods[i].name == term.substr(1, term.length() - 2).strip_edges()) || c.methods[i].name.findn(term) != -1) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
TreeItem *item = search_options->create_item(root);
|
2017-03-18 23:36:26 +00:00
|
|
|
item->set_metadata(0, "class_method:" + E->key() + ":" + c.methods[i].name);
|
|
|
|
item->set_text(0, E->key() + "." + c.methods[i].name + " (Method)");
|
|
|
|
item->set_icon(0, cicon);
|
2014-02-21 02:01:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < c.signals.size(); i++) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (c.signals[i].name.findn(term) != -1) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
TreeItem *item = search_options->create_item(root);
|
2017-03-18 23:36:26 +00:00
|
|
|
item->set_metadata(0, "class_signal:" + E->key() + ":" + c.signals[i].name);
|
|
|
|
item->set_text(0, E->key() + "." + c.signals[i].name + " (Signal)");
|
|
|
|
item->set_icon(0, cicon);
|
2014-02-21 02:01:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < c.constants.size(); i++) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (c.constants[i].name.findn(term) != -1) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
TreeItem *item = search_options->create_item(root);
|
2017-03-18 23:36:26 +00:00
|
|
|
item->set_metadata(0, "class_constant:" + E->key() + ":" + c.constants[i].name);
|
|
|
|
item->set_text(0, E->key() + "." + c.constants[i].name + " (Constant)");
|
|
|
|
item->set_icon(0, cicon);
|
2014-02-21 02:01:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < c.properties.size(); i++) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (c.properties[i].name.findn(term) != -1) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
TreeItem *item = search_options->create_item(root);
|
2017-03-18 23:36:26 +00:00
|
|
|
item->set_metadata(0, "class_property:" + E->key() + ":" + c.properties[i].name);
|
|
|
|
item->set_text(0, E->key() + "." + c.properties[i].name + " (Property)");
|
|
|
|
item->set_icon(0, cicon);
|
2014-02-21 02:01:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < c.theme_properties.size(); i++) {
|
2014-06-30 01:41:02 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (c.theme_properties[i].name.findn(term) != -1) {
|
2014-06-30 01:41:02 +00:00
|
|
|
|
|
|
|
TreeItem *item = search_options->create_item(root);
|
2017-03-18 23:36:26 +00:00
|
|
|
item->set_metadata(0, "class_theme_item:" + E->key() + ":" + c.theme_properties[i].name);
|
|
|
|
item->set_text(0, E->key() + "." + c.theme_properties[i].name + " (Theme Item)");
|
|
|
|
item->set_icon(0, cicon);
|
2014-06-30 01:41:02 +00:00
|
|
|
}
|
|
|
|
}
|
2014-02-21 02:01:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//same but descriptions
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
DocData::ClassDoc &c = E->get();
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
Ref<Texture> cicon;
|
2017-03-18 23:36:26 +00:00
|
|
|
if (has_icon(E->key(), "EditorIcons"))
|
|
|
|
cicon = get_icon(E->key(), "EditorIcons");
|
2014-02-21 02:01:44 +00:00
|
|
|
else
|
2017-03-18 23:36:26 +00:00
|
|
|
cicon = def_icon;
|
2014-02-21 02:01:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (c.description.findn(term) != -1) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
TreeItem *item = search_options->create_item(root);
|
2017-03-18 23:36:26 +00:00
|
|
|
item->set_metadata(0, "class_desc:" + E->key());
|
|
|
|
item->set_text(0, E->key() + " (Class Description)");
|
|
|
|
item->set_icon(0, cicon);
|
2014-02-21 02:01:44 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < c.methods.size(); i++) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (c.methods[i].description.findn(term) != -1) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
TreeItem *item = search_options->create_item(root);
|
2017-03-18 23:36:26 +00:00
|
|
|
item->set_metadata(0, "class_method_desc:" + E->key() + ":" + c.methods[i].name);
|
|
|
|
item->set_text(0, E->key() + "." + c.methods[i].name + " (Method Description)");
|
|
|
|
item->set_icon(0, cicon);
|
2014-02-21 02:01:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < c.signals.size(); i++) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (c.signals[i].description.findn(term) != -1) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
TreeItem *item = search_options->create_item(root);
|
2017-03-18 23:36:26 +00:00
|
|
|
item->set_metadata(0, "class_signal:" + E->key() + ":" + c.signals[i].name);
|
|
|
|
item->set_text(0, E->key() + "." + c.signals[i].name + " (Signal Description)");
|
|
|
|
item->set_icon(0, cicon);
|
2014-02-21 02:01:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < c.constants.size(); i++) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (c.constants[i].description.findn(term) != -1) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
TreeItem *item = search_options->create_item(root);
|
2017-03-18 23:36:26 +00:00
|
|
|
item->set_metadata(0, "class_constant:" + E->key() + ":" + c.constants[i].name);
|
|
|
|
item->set_text(0, E->key() + "." + c.constants[i].name + " (Constant Description)");
|
|
|
|
item->set_icon(0, cicon);
|
2014-02-21 02:01:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < c.properties.size(); i++) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (c.properties[i].description.findn(term) != -1) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
TreeItem *item = search_options->create_item(root);
|
2017-03-18 23:36:26 +00:00
|
|
|
item->set_metadata(0, "class_property_desc:" + E->key() + ":" + c.properties[i].name);
|
|
|
|
item->set_text(0, E->key() + "." + c.properties[i].name + " (Property Description)");
|
|
|
|
item->set_icon(0, cicon);
|
2014-02-21 02:01:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
get_ok()->set_disabled(root->get_children() == NULL);
|
2014-02-21 02:01:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorHelpSearch::_confirmed() {
|
|
|
|
|
|
|
|
TreeItem *ti = search_options->get_selected();
|
|
|
|
if (!ti)
|
|
|
|
return;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
String mdata = ti->get_metadata(0);
|
|
|
|
emit_signal("go_to_help", mdata);
|
|
|
|
editor->call("_editor_select", EditorNode::EDITOR_SCRIPT); // in case EditorHelpSearch beeen invoked on top of other editor window
|
2014-02-21 02:01:44 +00:00
|
|
|
// go to that
|
|
|
|
hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorHelpSearch::_notification(int p_what) {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (p_what == NOTIFICATION_ENTER_TREE) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
connect("confirmed", this, "_confirmed");
|
2014-02-21 02:01:44 +00:00
|
|
|
_update_search();
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
if (is_visible()) {
|
|
|
|
|
|
|
|
search_box->call_deferred("grab_focus"); // still not visible
|
|
|
|
search_box->select_all();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorHelpSearch::_bind_methods() {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
ObjectTypeDB::bind_method(_MD("_text_changed"), &EditorHelpSearch::_text_changed);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_confirmed"), &EditorHelpSearch::_confirmed);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_sbox_input"), &EditorHelpSearch::_sbox_input);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_update_search"), &EditorHelpSearch::_update_search);
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
ADD_SIGNAL(MethodInfo("go_to_help"));
|
|
|
|
}
|
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
EditorHelpSearch::EditorHelpSearch() {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
editor = EditorNode::get_singleton();
|
|
|
|
VBoxContainer *vbc = memnew(VBoxContainer);
|
2014-02-21 02:01:44 +00:00
|
|
|
add_child(vbc);
|
|
|
|
set_child_rect(vbc);
|
2017-03-18 23:36:26 +00:00
|
|
|
HBoxContainer *sb_hb = memnew(HBoxContainer);
|
|
|
|
search_box = memnew(LineEdit);
|
2014-02-21 02:01:44 +00:00
|
|
|
sb_hb->add_child(search_box);
|
|
|
|
search_box->set_h_size_flags(SIZE_EXPAND_FILL);
|
2017-03-18 23:36:26 +00:00
|
|
|
Button *sb = memnew(Button(TTR("Search")));
|
|
|
|
sb->connect("pressed", this, "_update_search");
|
2014-02-21 02:01:44 +00:00
|
|
|
sb_hb->add_child(sb);
|
2017-03-18 23:36:26 +00:00
|
|
|
vbc->add_margin_child(TTR("Search:"), sb_hb);
|
|
|
|
search_box->connect("text_changed", this, "_text_changed");
|
|
|
|
search_box->connect("input_event", this, "_sbox_input");
|
|
|
|
search_options = memnew(Tree);
|
|
|
|
vbc->add_margin_child(TTR("Matches:"), search_options, true);
|
2016-05-04 01:25:37 +00:00
|
|
|
get_ok()->set_text(TTR("Open"));
|
2014-02-21 02:01:44 +00:00
|
|
|
get_ok()->set_disabled(true);
|
|
|
|
register_text_enter(search_box);
|
|
|
|
set_hide_on_ok(false);
|
2017-03-18 23:36:26 +00:00
|
|
|
search_options->connect("item_activated", this, "_confirmed");
|
2016-07-09 14:12:15 +00:00
|
|
|
set_title(TTR("Search Help"));
|
2015-11-17 12:46:08 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
// search_options->set_hide_root(true);
|
2014-02-21 02:01:44 +00:00
|
|
|
}
|
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
/////////////////////////////////
|
|
|
|
|
|
|
|
////////////////////////////////////
|
|
|
|
/// /////////////////////////////////
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelpIndex::add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root) {
|
2015-11-17 12:46:08 +00:00
|
|
|
|
|
|
|
if (p_types.has(p_type))
|
|
|
|
return;
|
2017-03-18 23:36:26 +00:00
|
|
|
// if (!ObjectTypeDB::is_type(p_type,base) || p_type==base)
|
|
|
|
// return;
|
2015-11-17 12:46:08 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
String inherits = EditorHelp::get_doc_data()->class_list[p_type].inherits;
|
2015-11-17 12:46:08 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
TreeItem *parent = p_root;
|
2015-11-17 12:46:08 +00:00
|
|
|
|
|
|
|
if (inherits.length()) {
|
|
|
|
|
|
|
|
if (!p_types.has(inherits)) {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
add_type(inherits, p_types, p_root);
|
2015-11-17 12:46:08 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (p_types.has(inherits))
|
|
|
|
parent = p_types[inherits];
|
2015-11-17 12:46:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TreeItem *item = class_list->create_item(parent);
|
2017-03-18 23:36:26 +00:00
|
|
|
item->set_metadata(0, p_type);
|
|
|
|
item->set_tooltip(0, EditorHelp::get_doc_data()->class_list[p_type].brief_description);
|
|
|
|
item->set_text(0, p_type);
|
2015-11-17 12:46:08 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (has_icon(p_type, "EditorIcons")) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
item->set_icon(0, get_icon(p_type, "EditorIcons"));
|
2015-11-17 12:46:08 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
p_types[p_type] = item;
|
2015-11-17 12:46:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorHelpIndex::_tree_item_selected() {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
TreeItem *s = class_list->get_selected();
|
2015-11-17 12:46:08 +00:00
|
|
|
if (!s)
|
|
|
|
return;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
emit_signal("open_class", s->get_text(0));
|
2015-11-17 12:46:08 +00:00
|
|
|
|
|
|
|
hide();
|
|
|
|
|
|
|
|
//_goto_desc(s->get_text(0));
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelpIndex::select_class(const String &p_class) {
|
2015-11-17 12:46:08 +00:00
|
|
|
|
|
|
|
if (!tree_item_map.has(p_class))
|
|
|
|
return;
|
|
|
|
tree_item_map[p_class]->select(0);
|
|
|
|
class_list->ensure_cursor_is_visible();
|
|
|
|
}
|
|
|
|
|
2016-03-05 10:51:09 +00:00
|
|
|
void EditorHelpIndex::popup() {
|
|
|
|
|
|
|
|
popup_centered_ratio(0.6);
|
|
|
|
|
|
|
|
search_box->set_text("");
|
|
|
|
_update_class_list();
|
|
|
|
}
|
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
void EditorHelpIndex::_notification(int p_what) {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (p_what == NOTIFICATION_ENTER_TREE) {
|
2015-11-17 12:46:08 +00:00
|
|
|
|
2016-03-05 10:51:09 +00:00
|
|
|
_update_class_list();
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
connect("confirmed", this, "_tree_item_selected");
|
2015-11-17 12:46:08 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
} else if (p_what == NOTIFICATION_POST_POPUP) {
|
2016-03-05 10:51:09 +00:00
|
|
|
|
|
|
|
search_box->call_deferred("grab_focus");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelpIndex::_text_changed(const String &p_text) {
|
2016-03-05 10:51:09 +00:00
|
|
|
|
|
|
|
_update_class_list();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorHelpIndex::_update_class_list() {
|
|
|
|
|
|
|
|
class_list->clear();
|
|
|
|
tree_item_map.clear();
|
|
|
|
TreeItem *root = class_list->create_item();
|
|
|
|
class_list->set_hide_root(true);
|
2015-11-17 12:46:08 +00:00
|
|
|
|
2016-03-05 10:51:09 +00:00
|
|
|
String filter = search_box->get_text().strip_edges();
|
|
|
|
String to_select = "";
|
2015-11-17 12:46:08 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (Map<String, DocData::ClassDoc>::Element *E = EditorHelp::get_doc_data()->class_list.front(); E; E = E->next()) {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
2016-03-05 10:51:09 +00:00
|
|
|
if (filter == "") {
|
2017-03-18 23:36:26 +00:00
|
|
|
add_type(E->key(), tree_item_map, root);
|
2016-03-05 10:51:09 +00:00
|
|
|
} else {
|
|
|
|
|
|
|
|
bool found = false;
|
|
|
|
String type = E->key();
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
while (type != "") {
|
2016-06-12 16:43:31 +00:00
|
|
|
if (filter.is_subsequence_ofi(type)) {
|
2016-03-05 10:51:09 +00:00
|
|
|
|
|
|
|
if (to_select.empty()) {
|
|
|
|
to_select = type;
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
found = true;
|
2016-03-05 10:51:09 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
type = EditorHelp::get_doc_data()->class_list[type].inherits;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (found) {
|
2017-03-18 23:36:26 +00:00
|
|
|
add_type(E->key(), tree_item_map, root);
|
2016-03-05 10:51:09 +00:00
|
|
|
}
|
2015-11-17 12:46:08 +00:00
|
|
|
}
|
2016-03-05 10:51:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tree_item_map.has(filter)) {
|
|
|
|
select_class(filter);
|
|
|
|
} else if (to_select != "") {
|
|
|
|
select_class(to_select);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelpIndex::_sbox_input(const InputEvent &p_ie) {
|
2016-03-05 10:51:09 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (p_ie.type == InputEvent::KEY && (p_ie.key.scancode == KEY_UP ||
|
|
|
|
p_ie.key.scancode == KEY_DOWN ||
|
|
|
|
p_ie.key.scancode == KEY_PAGEUP ||
|
|
|
|
p_ie.key.scancode == KEY_PAGEDOWN)) {
|
2015-11-17 12:46:08 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
class_list->call("_input_event", p_ie);
|
2016-03-05 10:51:09 +00:00
|
|
|
search_box->accept_event();
|
2015-11-17 12:46:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorHelpIndex::_bind_methods() {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
ObjectTypeDB::bind_method("_tree_item_selected", &EditorHelpIndex::_tree_item_selected);
|
|
|
|
ObjectTypeDB::bind_method("_text_changed", &EditorHelpIndex::_text_changed);
|
|
|
|
ObjectTypeDB::bind_method("_sbox_input", &EditorHelpIndex::_sbox_input);
|
|
|
|
ObjectTypeDB::bind_method("select_class", &EditorHelpIndex::select_class);
|
|
|
|
ADD_SIGNAL(MethodInfo("open_class"));
|
2015-11-17 12:46:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EditorHelpIndex::EditorHelpIndex() {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
VBoxContainer *vbc = memnew(VBoxContainer);
|
2015-11-17 12:46:08 +00:00
|
|
|
add_child(vbc);
|
|
|
|
set_child_rect(vbc);
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
search_box = memnew(LineEdit);
|
2016-05-04 01:25:37 +00:00
|
|
|
vbc->add_margin_child(TTR("Search:"), search_box);
|
2016-03-05 10:51:09 +00:00
|
|
|
search_box->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
|
|
|
|
register_text_enter(search_box);
|
|
|
|
|
|
|
|
search_box->connect("text_changed", this, "_text_changed");
|
|
|
|
search_box->connect("input_event", this, "_sbox_input");
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
class_list = memnew(Tree);
|
|
|
|
vbc->add_margin_child(TTR("Class List:") + " ", class_list, true);
|
2015-11-17 12:46:08 +00:00
|
|
|
class_list->set_v_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
class_list->connect("item_activated", this, "_tree_item_selected");
|
2015-11-17 12:46:08 +00:00
|
|
|
|
2016-05-04 01:25:37 +00:00
|
|
|
get_ok()->set_text(TTR("Open"));
|
2016-07-09 14:12:15 +00:00
|
|
|
set_title(TTR("Search Classes"));
|
2015-11-17 12:46:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////
|
|
|
|
|
|
|
|
////////////////////////////////////
|
|
|
|
/// /////////////////////////////////
|
2017-03-18 23:36:26 +00:00
|
|
|
DocData *EditorHelp::doc = NULL;
|
2014-02-16 00:16:33 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelp::_unhandled_key_input(const InputEvent &p_ev) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2014-05-06 09:41:19 +00:00
|
|
|
if (!is_visible())
|
|
|
|
return;
|
2017-03-18 23:36:26 +00:00
|
|
|
if (p_ev.key.mod.control && p_ev.key.scancode == KEY_F) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
search->grab_focus();
|
|
|
|
search->select_all();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelp::_search(const String &) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (search->get_text() == "")
|
2014-02-10 01:10:30 +00:00
|
|
|
return;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
String stext = search->get_text();
|
|
|
|
bool keep = prev_search == stext;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
bool ret = class_desc->search(stext, keep);
|
|
|
|
if (!ret) {
|
|
|
|
class_desc->search(stext, false);
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
prev_search = stext;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
#if 0
|
2014-02-10 01:10:30 +00:00
|
|
|
void EditorHelp::_button_pressed(int p_idx) {
|
|
|
|
|
|
|
|
if (p_idx==PAGE_CLASS_LIST) {
|
|
|
|
|
|
|
|
// edited_class->set_pressed(false);
|
|
|
|
// class_list_button->set_pressed(true);
|
|
|
|
// tabs->set_current_tab(PAGE_CLASS_LIST);
|
|
|
|
|
|
|
|
} else if (p_idx==PAGE_CLASS_DESC) {
|
|
|
|
|
|
|
|
// edited_class->set_pressed(true);
|
|
|
|
// class_list_button->set_pressed(false);
|
|
|
|
// tabs->set_current_tab(PAGE_CLASS_DESC);
|
|
|
|
|
|
|
|
} else if (p_idx==PAGE_CLASS_PREV) {
|
|
|
|
|
|
|
|
if (history_pos<2)
|
|
|
|
return;
|
|
|
|
history_pos--;
|
|
|
|
ERR_FAIL_INDEX(history_pos-1,history.size());
|
|
|
|
_goto_desc(history[history_pos-1].c,false,history[history_pos-1].scroll);
|
|
|
|
_update_history_buttons();
|
|
|
|
|
|
|
|
|
|
|
|
} else if (p_idx==PAGE_CLASS_NEXT) {
|
|
|
|
|
|
|
|
if (history_pos>=history.size())
|
|
|
|
return;
|
|
|
|
|
|
|
|
history_pos++;
|
|
|
|
ERR_FAIL_INDEX(history_pos-1,history.size());
|
|
|
|
_goto_desc(history[history_pos-1].c,false,history[history_pos-1].scroll);
|
|
|
|
_update_history_buttons();
|
|
|
|
|
|
|
|
} else if (p_idx==PAGE_SEARCH) {
|
|
|
|
|
|
|
|
_search("");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
#endif
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelp::_class_list_select(const String &p_select) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
_goto_desc(p_select);
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelp::_class_desc_select(const String &p_select) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
// print_line("LINK: "+p_select);
|
2014-02-10 01:10:30 +00:00
|
|
|
if (p_select.begins_with("#")) {
|
2015-11-17 12:46:08 +00:00
|
|
|
//_goto_desc(p_select.substr(1,p_select.length()));
|
2017-03-18 23:36:26 +00:00
|
|
|
emit_signal("go_to_help", "class_name:" + p_select.substr(1, p_select.length()));
|
2014-02-10 01:10:30 +00:00
|
|
|
return;
|
|
|
|
} else if (p_select.begins_with("@")) {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
String m = p_select.substr(1, p_select.length());
|
2015-11-17 12:46:08 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (m.find(".") != -1) {
|
2015-11-17 12:46:08 +00:00
|
|
|
//must go somewhere else
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
emit_signal("go_to_help", "class_method:" + m.get_slice(".", 0) + ":" + m.get_slice(".", 0));
|
2015-11-17 12:46:08 +00:00
|
|
|
} else {
|
|
|
|
|
|
|
|
if (!method_line.has(m))
|
|
|
|
return;
|
|
|
|
class_desc->scroll_to_line(method_line[m]);
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelp::_class_desc_input(const InputEvent &p_input) {
|
|
|
|
if (p_input.type == InputEvent::MOUSE_BUTTON && p_input.mouse_button.pressed && p_input.mouse_button.button_index == 1) {
|
2016-06-03 18:11:34 +00:00
|
|
|
class_desc->set_selection_enabled(false);
|
|
|
|
class_desc->set_selection_enabled(true);
|
|
|
|
}
|
2016-06-09 13:07:59 +00:00
|
|
|
set_focused();
|
2016-06-03 18:11:34 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelp::_add_type(const String &p_type) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
String t = p_type;
|
2017-03-18 23:36:26 +00:00
|
|
|
if (t == "")
|
|
|
|
t = "void";
|
|
|
|
bool can_ref = (t != "int" && t != "real" && t != "bool" && t != "void");
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/base_type_color"));
|
|
|
|
if (can_ref)
|
2017-03-18 23:36:26 +00:00
|
|
|
class_desc->push_meta("#" + t); //class
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->add_text(t);
|
|
|
|
if (can_ref)
|
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorHelp::_scroll_changed(double p_scroll) {
|
|
|
|
|
|
|
|
if (scroll_locked)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (class_desc->get_v_scroll()->is_hidden())
|
2017-03-18 23:36:26 +00:00
|
|
|
p_scroll = 0;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
//history[p].scroll=p_scroll;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2014-05-06 09:41:19 +00:00
|
|
|
//ERR_FAIL_COND(!doc->class_list.has(p_class));
|
|
|
|
if (!doc->class_list.has(p_class))
|
|
|
|
return ERR_DOES_NOT_EXIST;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
//if (tree_item_map.has(p_class)) {
|
2017-03-18 23:36:26 +00:00
|
|
|
select_locked = true;
|
2015-11-17 12:46:08 +00:00
|
|
|
//}
|
2014-06-23 15:43:37 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->show();
|
|
|
|
//tabs->set_current_tab(PAGE_CLASS_DESC);
|
2017-03-18 23:36:26 +00:00
|
|
|
description_line = 0;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (p_class == edited_class)
|
2014-05-06 09:41:19 +00:00
|
|
|
return OK; //already there
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
scroll_locked = true;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
class_desc->clear();
|
|
|
|
method_line.clear();
|
2017-03-18 23:36:26 +00:00
|
|
|
edited_class = p_class;
|
2014-02-21 02:01:44 +00:00
|
|
|
//edited_class->show();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
DocData::ClassDoc cd = doc->class_list[p_class]; //make a copy, so we can sort without worrying
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
Color h_color;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
Ref<Font> doc_font = get_font("doc", "EditorFonts");
|
|
|
|
Ref<Font> doc_title_font = get_font("doc_title", "EditorFonts");
|
|
|
|
Ref<Font> doc_code_font = get_font("doc_source", "EditorFonts");
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
h_color = Color(1, 1, 1, 1);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2014-02-21 02:01:44 +00:00
|
|
|
class_desc->push_font(doc_title_font);
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
|
2017-03-18 23:36:26 +00:00
|
|
|
class_desc->add_text(TTR("Class:") + " ");
|
2014-02-21 02:01:44 +00:00
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/base_type_color"));
|
2015-10-20 15:41:27 +00:00
|
|
|
_add_text(p_class);
|
2014-02-21 02:01:44 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
class_desc->add_newline();
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (cd.inherits != "") {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
|
|
|
|
class_desc->push_font(doc_title_font);
|
2017-03-18 23:36:26 +00:00
|
|
|
class_desc->add_text(TTR("Inherits:") + " ");
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
2016-03-05 15:28:25 +00:00
|
|
|
|
|
|
|
String inherits = cd.inherits;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->push_font(doc_font);
|
2016-03-05 15:28:25 +00:00
|
|
|
|
|
|
|
while (inherits != "") {
|
|
|
|
_add_type(inherits);
|
|
|
|
|
|
|
|
inherits = doc->class_list[inherits].inherits;
|
|
|
|
|
|
|
|
if (inherits != "") {
|
|
|
|
class_desc->add_text(" , ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->add_newline();
|
2016-03-05 15:28:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ObjectTypeDB::type_exists(cd.name)) {
|
|
|
|
|
|
|
|
bool found = false;
|
|
|
|
bool prev = false;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-03-05 15:28:25 +00:00
|
|
|
if (E->get().inherits == cd.name) {
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
|
|
|
|
class_desc->push_font(doc_title_font);
|
2017-03-18 23:36:26 +00:00
|
|
|
class_desc->add_text(TTR("Inherited by:") + " ");
|
2016-03-05 15:28:25 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
|
|
|
|
found = true;
|
|
|
|
class_desc->push_font(doc_font);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prev) {
|
|
|
|
|
|
|
|
class_desc->add_text(" , ");
|
|
|
|
prev = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
_add_type(E->get().name);
|
|
|
|
prev = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (found)
|
|
|
|
class_desc->pop();
|
|
|
|
|
|
|
|
class_desc->add_newline();
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2016-03-05 15:28:25 +00:00
|
|
|
class_desc->add_newline();
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (cd.brief_description != "") {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
|
|
|
|
class_desc->push_font(doc_title_font);
|
2016-05-04 01:25:37 +00:00
|
|
|
class_desc->add_text(TTR("Brief Description:"));
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
|
|
|
|
//class_desc->add_newline();
|
|
|
|
class_desc->add_newline();
|
2015-10-20 15:41:27 +00:00
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/text_color"));
|
2017-03-18 23:36:26 +00:00
|
|
|
class_desc->push_font(doc_font);
|
2015-10-20 15:41:27 +00:00
|
|
|
class_desc->push_indent(1);
|
2014-02-10 01:10:30 +00:00
|
|
|
_add_text(cd.brief_description);
|
2015-10-20 15:41:27 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->add_newline();
|
2015-09-30 02:38:23 +00:00
|
|
|
class_desc->add_newline();
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
bool method_descr = false;
|
2016-05-29 14:37:26 +00:00
|
|
|
bool sort_methods = EditorSettings::get_singleton()->get("help/sort_functions_alphabetically");
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
if (cd.methods.size()) {
|
|
|
|
|
2016-05-29 14:37:26 +00:00
|
|
|
if (sort_methods)
|
|
|
|
cd.methods.sort();
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
|
|
|
|
class_desc->push_font(doc_title_font);
|
2016-05-04 01:25:37 +00:00
|
|
|
class_desc->add_text(TTR("Public Methods:"));
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
|
|
|
|
//class_desc->add_newline();
|
2017-03-18 23:36:26 +00:00
|
|
|
// class_desc->add_newline();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
class_desc->push_indent(1);
|
2015-12-26 13:25:17 +00:00
|
|
|
class_desc->push_table(2);
|
2017-03-18 23:36:26 +00:00
|
|
|
class_desc->set_table_column_expand(1, 1);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < cd.methods.size(); i++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-12-26 13:25:17 +00:00
|
|
|
class_desc->push_cell();
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
method_line[cd.methods[i].name] = class_desc->get_line_count() - 2; //gets overriden if description
|
2015-12-26 13:25:17 +00:00
|
|
|
class_desc->push_align(RichTextLabel::ALIGN_RIGHT);
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->push_font(doc_code_font);
|
|
|
|
_add_type(cd.methods[i].return_type);
|
2015-12-26 13:25:17 +00:00
|
|
|
//class_desc->add_text(" ");
|
|
|
|
class_desc->pop(); //align
|
|
|
|
class_desc->pop(); //font
|
|
|
|
class_desc->pop(); //cell
|
|
|
|
class_desc->push_cell();
|
|
|
|
class_desc->push_font(doc_code_font);
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (cd.methods[i].description != "") {
|
|
|
|
method_descr = true;
|
|
|
|
class_desc->push_meta("@" + cd.methods[i].name);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/text_color"));
|
2015-10-20 15:41:27 +00:00
|
|
|
_add_text(cd.methods[i].name);
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
2017-03-18 23:36:26 +00:00
|
|
|
if (cd.methods[i].description != "")
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/symbol_color"));
|
2017-03-18 23:36:26 +00:00
|
|
|
class_desc->add_text(cd.methods[i].arguments.size() ? "( " : "(");
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int j = 0; j < cd.methods[i].arguments.size(); j++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/text_color"));
|
2017-03-18 23:36:26 +00:00
|
|
|
if (j > 0)
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->add_text(", ");
|
|
|
|
_add_type(cd.methods[i].arguments[j].type);
|
2015-10-20 15:41:27 +00:00
|
|
|
class_desc->add_text(" ");
|
|
|
|
_add_text(cd.methods[i].arguments[j].name);
|
2017-03-18 23:36:26 +00:00
|
|
|
if (cd.methods[i].arguments[j].default_value != "") {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/symbol_color"));
|
|
|
|
class_desc->add_text("=");
|
|
|
|
class_desc->pop();
|
2015-10-20 15:41:27 +00:00
|
|
|
_add_text(cd.methods[i].arguments[j].default_value);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class_desc->pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/symbol_color"));
|
2017-03-18 23:36:26 +00:00
|
|
|
class_desc->add_text(cd.methods[i].arguments.size() ? " )" : ")");
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
2017-03-18 23:36:26 +00:00
|
|
|
if (cd.methods[i].qualifiers != "") {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
|
2015-10-20 15:41:27 +00:00
|
|
|
class_desc->add_text(" ");
|
|
|
|
_add_text(cd.methods[i].qualifiers);
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
}
|
2017-03-18 23:36:26 +00:00
|
|
|
class_desc->pop(); //monofont
|
|
|
|
// class_desc->add_newline();
|
2015-12-26 13:25:17 +00:00
|
|
|
class_desc->pop(); //cell
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2015-12-26 13:25:17 +00:00
|
|
|
class_desc->pop(); //table
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->add_newline();
|
2015-12-26 13:25:17 +00:00
|
|
|
class_desc->add_newline();
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cd.properties.size()) {
|
|
|
|
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
|
|
|
|
class_desc->push_font(doc_title_font);
|
2016-05-04 01:25:37 +00:00
|
|
|
class_desc->add_text(TTR("Members:"));
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
class_desc->add_newline();
|
|
|
|
|
|
|
|
class_desc->push_indent(1);
|
|
|
|
|
|
|
|
//class_desc->add_newline();
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < cd.properties.size(); i++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
property_line[cd.properties[i].name] = class_desc->get_line_count() - 2; //gets overriden if description
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->push_font(doc_code_font);
|
|
|
|
_add_type(cd.properties[i].type);
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/text_color"));
|
2015-10-20 15:41:27 +00:00
|
|
|
class_desc->add_text(" ");
|
|
|
|
_add_text(cd.properties[i].name);
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (cd.properties[i].description != "") {
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->push_font(doc_font);
|
|
|
|
class_desc->add_text(" ");
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/comment_color"));
|
2015-10-20 15:41:27 +00:00
|
|
|
_add_text(cd.properties[i].description);
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
class_desc->add_newline();
|
|
|
|
}
|
|
|
|
|
2016-08-01 08:30:09 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->add_newline();
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2014-06-30 01:41:02 +00:00
|
|
|
if (cd.theme_properties.size()) {
|
|
|
|
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
|
|
|
|
class_desc->push_font(doc_title_font);
|
2016-05-04 01:25:37 +00:00
|
|
|
class_desc->add_text(TTR("GUI Theme Items:"));
|
2014-06-30 01:41:02 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
class_desc->add_newline();
|
|
|
|
|
|
|
|
class_desc->push_indent(1);
|
|
|
|
|
|
|
|
//class_desc->add_newline();
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < cd.theme_properties.size(); i++) {
|
2014-06-30 01:41:02 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
theme_property_line[cd.theme_properties[i].name] = class_desc->get_line_count() - 2; //gets overriden if description
|
2014-06-30 01:41:02 +00:00
|
|
|
class_desc->push_font(doc_code_font);
|
|
|
|
_add_type(cd.theme_properties[i].type);
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/text_color"));
|
2015-10-20 15:41:27 +00:00
|
|
|
class_desc->add_text(" ");
|
|
|
|
_add_text(cd.theme_properties[i].name);
|
2014-06-30 01:41:02 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (cd.theme_properties[i].description != "") {
|
2014-06-30 01:41:02 +00:00
|
|
|
class_desc->push_font(doc_font);
|
|
|
|
class_desc->add_text(" ");
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/comment_color"));
|
2015-10-20 15:41:27 +00:00
|
|
|
_add_text(cd.theme_properties[i].description);
|
2014-06-30 01:41:02 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
class_desc->add_newline();
|
|
|
|
}
|
|
|
|
|
|
|
|
class_desc->pop();
|
2016-08-01 08:30:09 +00:00
|
|
|
class_desc->add_newline();
|
2014-06-30 01:41:02 +00:00
|
|
|
}
|
2016-08-01 08:30:09 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
if (cd.signals.size()) {
|
|
|
|
|
2016-05-29 14:37:26 +00:00
|
|
|
if (sort_methods) {
|
|
|
|
cd.signals.sort();
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
|
|
|
|
class_desc->push_font(doc_title_font);
|
2016-05-04 01:25:37 +00:00
|
|
|
class_desc->add_text(TTR("Signals:"));
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
|
|
|
|
class_desc->add_newline();
|
|
|
|
//class_desc->add_newline();
|
|
|
|
|
|
|
|
class_desc->push_indent(1);
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < cd.signals.size(); i++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
signal_line[cd.signals[i].name] = class_desc->get_line_count() - 2; //gets overriden if description
|
|
|
|
class_desc->push_font(doc_code_font); // monofont
|
2014-02-10 01:10:30 +00:00
|
|
|
//_add_type("void");
|
|
|
|
//class_desc->add_text(" ");
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/text_color"));
|
2015-10-20 15:41:27 +00:00
|
|
|
_add_text(cd.signals[i].name);
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/symbol_color"));
|
2017-03-18 23:36:26 +00:00
|
|
|
class_desc->add_text(cd.signals[i].arguments.size() ? "( " : "(");
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int j = 0; j < cd.signals[i].arguments.size(); j++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/text_color"));
|
2017-03-18 23:36:26 +00:00
|
|
|
if (j > 0)
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->add_text(", ");
|
|
|
|
_add_type(cd.signals[i].arguments[j].type);
|
2015-10-20 15:41:27 +00:00
|
|
|
class_desc->add_text(" ");
|
|
|
|
_add_text(cd.signals[i].arguments[j].name);
|
2017-03-18 23:36:26 +00:00
|
|
|
if (cd.signals[i].arguments[j].default_value != "") {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/symbol_color"));
|
|
|
|
class_desc->add_text("=");
|
|
|
|
class_desc->pop();
|
2015-10-20 15:41:27 +00:00
|
|
|
_add_text(cd.signals[i].arguments[j].default_value);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class_desc->pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/symbol_color"));
|
2017-03-18 23:36:26 +00:00
|
|
|
class_desc->add_text(cd.signals[i].arguments.size() ? " )" : ")");
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
2015-10-20 15:41:27 +00:00
|
|
|
class_desc->pop(); // end monofont
|
2017-03-18 23:36:26 +00:00
|
|
|
if (cd.signals[i].description != "") {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/comment_color"));
|
2015-10-20 15:41:27 +00:00
|
|
|
class_desc->add_text(" ");
|
|
|
|
_add_text(cd.signals[i].description);
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
}
|
|
|
|
class_desc->add_newline();
|
|
|
|
}
|
|
|
|
|
|
|
|
class_desc->pop();
|
|
|
|
class_desc->add_newline();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cd.constants.size()) {
|
|
|
|
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
|
|
|
|
class_desc->push_font(doc_title_font);
|
2016-05-04 01:25:37 +00:00
|
|
|
class_desc->add_text(TTR("Constants:"));
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
class_desc->push_indent(1);
|
|
|
|
|
|
|
|
class_desc->add_newline();
|
|
|
|
//class_desc->add_newline();
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < cd.constants.size(); i++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
constant_line[cd.constants[i].name] = class_desc->get_line_count() - 2;
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->push_font(doc_code_font);
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/base_type_color"));
|
2015-10-20 15:41:27 +00:00
|
|
|
_add_text(cd.constants[i].name);
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/symbol_color"));
|
|
|
|
class_desc->add_text(" = ");
|
|
|
|
class_desc->pop();
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
|
2015-10-20 15:41:27 +00:00
|
|
|
_add_text(cd.constants[i].value);
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
2017-03-18 23:36:26 +00:00
|
|
|
if (cd.constants[i].description != "") {
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->push_font(doc_font);
|
|
|
|
class_desc->add_text(" ");
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/comment_color"));
|
2015-10-20 15:41:27 +00:00
|
|
|
_add_text(cd.constants[i].description);
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
class_desc->add_newline();
|
|
|
|
}
|
|
|
|
|
|
|
|
class_desc->pop();
|
|
|
|
class_desc->add_newline();
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (cd.description != "") {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
description_line = class_desc->get_line_count() - 2;
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
|
|
|
|
class_desc->push_font(doc_title_font);
|
2016-05-04 01:25:37 +00:00
|
|
|
class_desc->add_text(TTR("Description:"));
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
|
|
|
|
class_desc->add_newline();
|
|
|
|
class_desc->add_newline();
|
2015-10-20 15:41:27 +00:00
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/text_color"));
|
2017-03-18 23:36:26 +00:00
|
|
|
class_desc->push_font(doc_font);
|
2015-10-20 15:41:27 +00:00
|
|
|
class_desc->push_indent(1);
|
|
|
|
_add_text(cd.description);
|
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->add_newline();
|
2015-09-30 02:38:23 +00:00
|
|
|
class_desc->add_newline();
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (method_descr) {
|
|
|
|
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
|
|
|
|
class_desc->push_font(doc_title_font);
|
2016-05-04 01:25:37 +00:00
|
|
|
class_desc->add_text(TTR("Method Description:"));
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
|
|
|
|
class_desc->add_newline();
|
|
|
|
class_desc->add_newline();
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < cd.methods.size(); i++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
method_line[cd.methods[i].name] = class_desc->get_line_count() - 2;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
class_desc->push_font(doc_code_font);
|
|
|
|
_add_type(cd.methods[i].return_type);
|
|
|
|
|
|
|
|
class_desc->add_text(" ");
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/text_color"));
|
2015-10-20 15:41:27 +00:00
|
|
|
_add_text(cd.methods[i].name);
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/symbol_color"));
|
2017-03-18 23:36:26 +00:00
|
|
|
class_desc->add_text(cd.methods[i].arguments.size() ? "( " : "(");
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int j = 0; j < cd.methods[i].arguments.size(); j++) {
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/text_color"));
|
2017-03-18 23:36:26 +00:00
|
|
|
if (j > 0)
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->add_text(", ");
|
|
|
|
_add_type(cd.methods[i].arguments[j].type);
|
2015-10-20 15:41:27 +00:00
|
|
|
class_desc->add_text(" ");
|
|
|
|
_add_text(cd.methods[i].arguments[j].name);
|
2017-03-18 23:36:26 +00:00
|
|
|
if (cd.methods[i].arguments[j].default_value != "") {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/symbol_color"));
|
|
|
|
class_desc->add_text("=");
|
|
|
|
class_desc->pop();
|
2015-10-20 15:41:27 +00:00
|
|
|
_add_text(cd.methods[i].arguments[j].default_value);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class_desc->pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/symbol_color"));
|
2017-03-18 23:36:26 +00:00
|
|
|
class_desc->add_text(cd.methods[i].arguments.size() ? " )" : ")");
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
2017-03-18 23:36:26 +00:00
|
|
|
if (cd.methods[i].qualifiers != "") {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
|
2015-10-20 15:41:27 +00:00
|
|
|
class_desc->add_text(" ");
|
|
|
|
_add_text(cd.methods[i].qualifiers);
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
class_desc->pop();
|
|
|
|
|
2015-10-20 15:41:27 +00:00
|
|
|
class_desc->add_newline();
|
|
|
|
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/text_color"));
|
2017-03-18 23:36:26 +00:00
|
|
|
class_desc->push_font(doc_font);
|
2015-10-20 15:41:27 +00:00
|
|
|
class_desc->push_indent(1);
|
|
|
|
_add_text(cd.methods[i].description);
|
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
class_desc->pop();
|
|
|
|
class_desc->add_newline();
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->add_newline();
|
|
|
|
class_desc->add_newline();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
scroll_locked = false;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2014-05-06 09:41:19 +00:00
|
|
|
return OK;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelp::_request_help(const String &p_string) {
|
2014-05-06 09:41:19 +00:00
|
|
|
Error err = _goto_desc(p_string);
|
2017-03-18 23:36:26 +00:00
|
|
|
if (err == OK) {
|
|
|
|
editor->call("_editor_select", EditorNode::EDITOR_SCRIPT);
|
2014-05-06 09:41:19 +00:00
|
|
|
}
|
2014-02-21 02:01:44 +00:00
|
|
|
//100 palabras
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelp::_help_callback(const String &p_topic) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
String what = p_topic.get_slice(":", 0);
|
|
|
|
String clss = p_topic.get_slice(":", 1);
|
2014-02-21 02:01:44 +00:00
|
|
|
String name;
|
2017-03-18 23:36:26 +00:00
|
|
|
if (p_topic.get_slice_count(":") == 3)
|
|
|
|
name = p_topic.get_slice(":", 2);
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
_request_help(clss); //first go to class
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
int line = 0;
|
2014-02-21 02:01:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (what == "class_desc") {
|
|
|
|
line = description_line;
|
|
|
|
} else if (what == "class_signal") {
|
2014-02-21 02:01:44 +00:00
|
|
|
if (signal_line.has(name))
|
2017-03-18 23:36:26 +00:00
|
|
|
line = signal_line[name];
|
|
|
|
} else if (what == "class_method" || what == "class_method_desc") {
|
2014-02-21 02:01:44 +00:00
|
|
|
if (method_line.has(name))
|
2017-03-18 23:36:26 +00:00
|
|
|
line = method_line[name];
|
|
|
|
} else if (what == "class_property") {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
if (property_line.has(name))
|
2017-03-18 23:36:26 +00:00
|
|
|
line = property_line[name];
|
|
|
|
} else if (what == "class_theme_item") {
|
2014-06-30 01:41:02 +00:00
|
|
|
|
|
|
|
if (theme_property_line.has(name))
|
2017-03-18 23:36:26 +00:00
|
|
|
line = theme_property_line[name];
|
|
|
|
} else if (what == "class_constant") {
|
2014-02-21 02:01:44 +00:00
|
|
|
|
|
|
|
if (constant_line.has(name))
|
2017-03-18 23:36:26 +00:00
|
|
|
line = constant_line[name];
|
2014-02-21 02:01:44 +00:00
|
|
|
}
|
|
|
|
|
2015-11-27 23:11:49 +00:00
|
|
|
class_desc->call_deferred("scroll_to_line", line);
|
2014-02-21 02:01:44 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
|
2016-08-24 02:15:16 +00:00
|
|
|
|
|
|
|
DocData *doc = EditorHelp::get_doc_data();
|
|
|
|
String base_path;
|
|
|
|
|
|
|
|
/*p_rt->push_color(EditorSettings::get_singleton()->get("text_editor/text_color"));
|
|
|
|
p_rt->push_font( get_font("normal","Fonts") );
|
|
|
|
p_rt->push_indent(1);*/
|
2014-02-10 01:10:30 +00:00
|
|
|
int pos = 0;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
Ref<Font> doc_font = p_rt->get_font("doc", "EditorFonts");
|
|
|
|
Ref<Font> doc_code_font = p_rt->get_font("doc_source", "EditorFonts");
|
2016-05-29 14:37:26 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
String bbcode = p_bbcode.replace("\t", " ").replace("\r", " ").strip_edges();
|
2016-02-28 02:10:44 +00:00
|
|
|
|
2016-05-29 14:37:26 +00:00
|
|
|
//change newlines for double newlines
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < bbcode.length(); i++) {
|
2016-02-28 02:10:44 +00:00
|
|
|
|
|
|
|
//find valid newlines (double)
|
2017-03-18 23:36:26 +00:00
|
|
|
if (bbcode[i] == '\n') {
|
|
|
|
bool dnl = false;
|
|
|
|
int j = i + 1;
|
|
|
|
for (; j < p_bbcode.length(); j++) {
|
|
|
|
if (bbcode[j] == ' ')
|
2016-02-28 02:10:44 +00:00
|
|
|
continue;
|
2017-03-18 23:36:26 +00:00
|
|
|
if (bbcode[j] == '\n') {
|
|
|
|
dnl = true;
|
2016-02-28 02:10:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dnl) {
|
2017-03-18 23:36:26 +00:00
|
|
|
bbcode[i] = 0xFFFF;
|
2016-05-29 14:37:26 +00:00
|
|
|
//keep
|
2017-03-18 23:36:26 +00:00
|
|
|
i = j;
|
2016-02-28 02:10:44 +00:00
|
|
|
} else {
|
2017-03-18 23:36:26 +00:00
|
|
|
bbcode = bbcode.insert(i, "\n");
|
2016-05-29 14:37:26 +00:00
|
|
|
i++;
|
|
|
|
//bbcode[i]=' ';
|
|
|
|
//i=j-1;
|
2016-02-28 02:10:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//remove double spaces or spaces after newlines
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int i = 0; i < bbcode.length(); i++) {
|
2016-02-28 02:10:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (bbcode[i] == ' ' || bbcode[i] == '\n' || bbcode[i] == 0xFFFF) {
|
2016-02-28 02:10:44 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
for (int j = i + 1; j < p_bbcode.length(); j++) {
|
|
|
|
if (bbcode[j] == ' ') {
|
2016-02-28 02:10:44 +00:00
|
|
|
bbcode.remove(j);
|
|
|
|
j--;
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//change newlines to double newlines
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
CharType dnls[2] = { 0xFFFF, 0 };
|
|
|
|
bbcode = bbcode.replace(dnls, "\n");
|
2016-02-28 02:10:44 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
List<String> tag_stack;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
while (pos < bbcode.length()) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
int brk_pos = bbcode.find("[", pos);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (brk_pos < 0)
|
|
|
|
brk_pos = bbcode.length();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
if (brk_pos > pos) {
|
2017-03-18 23:36:26 +00:00
|
|
|
p_rt->add_text(bbcode.substr(pos, brk_pos - pos));
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (brk_pos == bbcode.length())
|
2014-02-10 01:10:30 +00:00
|
|
|
break; //nothing else o add
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
int brk_end = bbcode.find("]", brk_pos + 1);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (brk_end == -1) {
|
2014-02-10 01:10:30 +00:00
|
|
|
//no close, add the rest
|
2017-03-18 23:36:26 +00:00
|
|
|
p_rt->add_text(bbcode.substr(brk_pos, bbcode.length() - brk_pos));
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
String tag = bbcode.substr(brk_pos + 1, brk_end - brk_pos - 1);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
if (tag.begins_with("/")) {
|
2017-03-18 23:36:26 +00:00
|
|
|
bool tag_ok = tag_stack.size() && tag_stack.front()->get() == tag.substr(1, tag.length());
|
2014-02-10 01:10:30 +00:00
|
|
|
if (tag_stack.size()) {
|
|
|
|
}
|
|
|
|
if (!tag_ok) {
|
|
|
|
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->add_text("[");
|
2014-02-10 01:10:30 +00:00
|
|
|
pos++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
tag_stack.pop_front();
|
2017-03-18 23:36:26 +00:00
|
|
|
pos = brk_end + 1;
|
|
|
|
if (tag != "/img")
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->pop();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
} else if (tag.begins_with("method ")) {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
String m = tag.substr(7, tag.length());
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
|
2017-03-18 23:36:26 +00:00
|
|
|
p_rt->push_meta("@" + m);
|
|
|
|
p_rt->add_text(m + "()");
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->pop();
|
|
|
|
p_rt->pop();
|
2017-03-18 23:36:26 +00:00
|
|
|
pos = brk_end + 1;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2014-02-16 00:16:33 +00:00
|
|
|
} else if (doc->class_list.has(tag)) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
|
2017-03-18 23:36:26 +00:00
|
|
|
p_rt->push_meta("#" + tag);
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->add_text(tag);
|
|
|
|
p_rt->pop();
|
|
|
|
p_rt->pop();
|
2017-03-18 23:36:26 +00:00
|
|
|
pos = brk_end + 1;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
} else if (tag == "b") {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
//use bold font
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->push_font(doc_code_font);
|
2017-03-18 23:36:26 +00:00
|
|
|
pos = brk_end + 1;
|
2014-02-10 01:10:30 +00:00
|
|
|
tag_stack.push_front(tag);
|
2017-03-18 23:36:26 +00:00
|
|
|
} else if (tag == "i") {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
//use italics font
|
2016-05-29 14:37:26 +00:00
|
|
|
Color text_color = EditorSettings::get_singleton()->get("text_editor/text_color");
|
|
|
|
//no italics so emphasize with color
|
2017-03-18 23:36:26 +00:00
|
|
|
text_color.r *= 1.1;
|
|
|
|
text_color.g *= 1.1;
|
|
|
|
text_color.b *= 1.1;
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->push_color(text_color);
|
|
|
|
//p_rt->push_font(get_font("italic","Fonts"));
|
2017-03-18 23:36:26 +00:00
|
|
|
pos = brk_end + 1;
|
2014-02-10 01:10:30 +00:00
|
|
|
tag_stack.push_front(tag);
|
2017-03-18 23:36:26 +00:00
|
|
|
} else if (tag == "code" || tag == "codeblock") {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
//use monospace font
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->push_font(doc_code_font);
|
2017-03-18 23:36:26 +00:00
|
|
|
pos = brk_end + 1;
|
2014-02-10 01:10:30 +00:00
|
|
|
tag_stack.push_front(tag);
|
2017-03-18 23:36:26 +00:00
|
|
|
} else if (tag == "center") {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
//use monospace font
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->push_align(RichTextLabel::ALIGN_CENTER);
|
2017-03-18 23:36:26 +00:00
|
|
|
pos = brk_end + 1;
|
2014-02-10 01:10:30 +00:00
|
|
|
tag_stack.push_front(tag);
|
2017-03-18 23:36:26 +00:00
|
|
|
} else if (tag == "br") {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
//use monospace font
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->add_newline();
|
2017-03-18 23:36:26 +00:00
|
|
|
pos = brk_end + 1;
|
|
|
|
} else if (tag == "u") {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
//use underline
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->push_underline();
|
2017-03-18 23:36:26 +00:00
|
|
|
pos = brk_end + 1;
|
2014-02-10 01:10:30 +00:00
|
|
|
tag_stack.push_front(tag);
|
2017-03-18 23:36:26 +00:00
|
|
|
} else if (tag == "s") {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
//use strikethrough (not supported underline instead)
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->push_underline();
|
2017-03-18 23:36:26 +00:00
|
|
|
pos = brk_end + 1;
|
2014-02-10 01:10:30 +00:00
|
|
|
tag_stack.push_front(tag);
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
} else if (tag == "url") {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
//use strikethrough (not supported underline instead)
|
2017-03-18 23:36:26 +00:00
|
|
|
int end = bbcode.find("[", brk_end);
|
|
|
|
if (end == -1)
|
|
|
|
end = bbcode.length();
|
|
|
|
String url = bbcode.substr(brk_end + 1, end - brk_end - 1);
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->push_meta(url);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
pos = brk_end + 1;
|
2014-02-10 01:10:30 +00:00
|
|
|
tag_stack.push_front(tag);
|
|
|
|
} else if (tag.begins_with("url=")) {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
String url = tag.substr(4, tag.length());
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->push_meta(url);
|
2017-03-18 23:36:26 +00:00
|
|
|
pos = brk_end + 1;
|
2014-02-10 01:10:30 +00:00
|
|
|
tag_stack.push_front("url");
|
2017-03-18 23:36:26 +00:00
|
|
|
} else if (tag == "img") {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
//use strikethrough (not supported underline instead)
|
2017-03-18 23:36:26 +00:00
|
|
|
int end = bbcode.find("[", brk_end);
|
|
|
|
if (end == -1)
|
|
|
|
end = bbcode.length();
|
|
|
|
String image = bbcode.substr(brk_end + 1, end - brk_end - 1);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
Ref<Texture> texture = ResourceLoader::load(base_path + "/" + image, "Texture");
|
2014-02-10 01:10:30 +00:00
|
|
|
if (texture.is_valid())
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->add_image(texture);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
pos = end;
|
2014-02-10 01:10:30 +00:00
|
|
|
tag_stack.push_front(tag);
|
|
|
|
} else if (tag.begins_with("color=")) {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
String col = tag.substr(6, tag.length());
|
2014-02-10 01:10:30 +00:00
|
|
|
Color color;
|
|
|
|
|
|
|
|
if (col.begins_with("#"))
|
2017-03-18 23:36:26 +00:00
|
|
|
color = Color::html(col);
|
|
|
|
else if (col == "aqua")
|
|
|
|
color = Color::html("#00FFFF");
|
|
|
|
else if (col == "black")
|
|
|
|
color = Color::html("#000000");
|
|
|
|
else if (col == "blue")
|
|
|
|
color = Color::html("#0000FF");
|
|
|
|
else if (col == "fuchsia")
|
|
|
|
color = Color::html("#FF00FF");
|
|
|
|
else if (col == "gray" || col == "grey")
|
|
|
|
color = Color::html("#808080");
|
|
|
|
else if (col == "green")
|
|
|
|
color = Color::html("#008000");
|
|
|
|
else if (col == "lime")
|
|
|
|
color = Color::html("#00FF00");
|
|
|
|
else if (col == "maroon")
|
|
|
|
color = Color::html("#800000");
|
|
|
|
else if (col == "navy")
|
|
|
|
color = Color::html("#000080");
|
|
|
|
else if (col == "olive")
|
|
|
|
color = Color::html("#808000");
|
|
|
|
else if (col == "purple")
|
|
|
|
color = Color::html("#800080");
|
|
|
|
else if (col == "red")
|
|
|
|
color = Color::html("#FF0000");
|
|
|
|
else if (col == "silver")
|
|
|
|
color = Color::html("#C0C0C0");
|
|
|
|
else if (col == "teal")
|
|
|
|
color = Color::html("#008008");
|
|
|
|
else if (col == "white")
|
|
|
|
color = Color::html("#FFFFFF");
|
|
|
|
else if (col == "yellow")
|
|
|
|
color = Color::html("#FFFF00");
|
2014-02-10 01:10:30 +00:00
|
|
|
else
|
2017-03-18 23:36:26 +00:00
|
|
|
color = Color(0, 0, 0, 1); //base_color;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->push_color(color);
|
2017-03-18 23:36:26 +00:00
|
|
|
pos = brk_end + 1;
|
2014-02-10 01:10:30 +00:00
|
|
|
tag_stack.push_front("color");
|
|
|
|
|
|
|
|
} else if (tag.begins_with("font=")) {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
String fnt = tag.substr(5, tag.length());
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
Ref<Font> font = ResourceLoader::load(base_path + "/" + fnt, "Font");
|
2014-02-10 01:10:30 +00:00
|
|
|
if (font.is_valid())
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->push_font(font);
|
2014-02-10 01:10:30 +00:00
|
|
|
else {
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->push_font(doc_font);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
pos = brk_end + 1;
|
2014-02-10 01:10:30 +00:00
|
|
|
tag_stack.push_front("font");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2016-08-24 02:15:16 +00:00
|
|
|
p_rt->add_text("["); //ignore
|
2017-03-18 23:36:26 +00:00
|
|
|
pos = brk_pos + 1;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-24 02:15:16 +00:00
|
|
|
/*p_rt->pop();
|
|
|
|
p_rt->pop();
|
|
|
|
p_rt->pop();*/
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelp::_add_text(const String &p_bbcode) {
|
2016-08-24 02:15:16 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
_add_text_to_rt(p_bbcode, class_desc);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
void EditorHelp::_update_doc() {
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
void EditorHelp::generate_doc() {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
doc = memnew(DocData);
|
2015-11-17 12:46:08 +00:00
|
|
|
doc->generate(true);
|
|
|
|
DocData compdoc;
|
2017-03-18 23:36:26 +00:00
|
|
|
compdoc.load_compressed(_doc_data_compressed, _doc_data_compressed_size, _doc_data_uncompressed_size);
|
2015-11-17 12:46:08 +00:00
|
|
|
doc->merge_from(compdoc); //ensure all is up to date
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
void EditorHelp::_notification(int p_what) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
switch (p_what) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
case NOTIFICATION_READY: {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
// forward->set_icon(get_icon("Forward","EditorIcons"));
|
|
|
|
// back->set_icon(get_icon("Back","EditorIcons"));
|
2015-11-17 12:46:08 +00:00
|
|
|
_update_doc();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
} break;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2015-11-17 12:46:08 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelp::go_to_help(const String &p_help) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
_help_callback(p_help);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelp::go_to_class(const String &p_class, int p_scroll) {
|
2014-02-16 00:16:33 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
_goto_desc(p_class, p_scroll);
|
2015-11-17 12:46:08 +00:00
|
|
|
}
|
2014-02-16 00:16:33 +00:00
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
void EditorHelp::popup_search() {
|
2014-02-16 00:16:33 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
search_dialog->popup_centered(Size2(250, 80));
|
2015-11-17 12:46:08 +00:00
|
|
|
search->grab_focus();
|
2014-02-16 00:16:33 +00:00
|
|
|
}
|
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
void EditorHelp::_search_cbk() {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
_search(search->get_text());
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
String EditorHelp::get_class_name() {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
return edited_class;
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
void EditorHelp::search_again() {
|
|
|
|
_search(prev_search);
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
int EditorHelp::get_scroll() const {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
return class_desc->get_v_scroll()->get_val();
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2015-11-17 12:46:08 +00:00
|
|
|
void EditorHelp::set_scroll(int p_scroll) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
class_desc->get_v_scroll()->set_val(p_scroll);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorHelp::_bind_methods() {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
ObjectTypeDB::bind_method("_class_list_select", &EditorHelp::_class_list_select);
|
|
|
|
ObjectTypeDB::bind_method("_class_desc_select", &EditorHelp::_class_desc_select);
|
|
|
|
ObjectTypeDB::bind_method("_class_desc_input", &EditorHelp::_class_desc_input);
|
|
|
|
// ObjectTypeDB::bind_method("_button_pressed",&EditorHelp::_button_pressed);
|
|
|
|
ObjectTypeDB::bind_method("_scroll_changed", &EditorHelp::_scroll_changed);
|
|
|
|
ObjectTypeDB::bind_method("_request_help", &EditorHelp::_request_help);
|
|
|
|
ObjectTypeDB::bind_method("_unhandled_key_input", &EditorHelp::_unhandled_key_input);
|
|
|
|
ObjectTypeDB::bind_method("_search", &EditorHelp::_search);
|
|
|
|
ObjectTypeDB::bind_method("_search_cbk", &EditorHelp::_search_cbk);
|
|
|
|
ObjectTypeDB::bind_method("_help_callback", &EditorHelp::_help_callback);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
ADD_SIGNAL(MethodInfo("go_to_help"));
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
EditorHelp::EditorHelp() {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
editor = EditorNode::get_singleton();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
VBoxContainer *vbc = this;
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
EDITOR_DEF("help/sort_functions_alphabetically", true);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
//class_list->connect("meta_clicked",this,"_class_list_select");
|
|
|
|
//class_list->set_selection_enabled(true);
|
|
|
|
|
|
|
|
{
|
2017-03-18 23:36:26 +00:00
|
|
|
Panel *pc = memnew(Panel);
|
|
|
|
Ref<StyleBoxFlat> style(memnew(StyleBoxFlat));
|
|
|
|
style->set_bg_color(EditorSettings::get_singleton()->get("text_editor/background_color"));
|
2015-11-20 00:12:29 +00:00
|
|
|
pc->set_v_size_flags(SIZE_EXPAND_FILL);
|
2015-03-26 14:45:53 +00:00
|
|
|
pc->add_style_override("panel", style); //get_stylebox("normal","TextEdit"));
|
2015-11-17 12:46:08 +00:00
|
|
|
vbc->add_child(pc);
|
2017-03-18 23:36:26 +00:00
|
|
|
class_desc = memnew(RichTextLabel);
|
2014-02-10 01:10:30 +00:00
|
|
|
pc->add_child(class_desc);
|
2015-11-17 12:46:08 +00:00
|
|
|
class_desc->set_area_as_parent_rect(8);
|
2017-03-18 23:36:26 +00:00
|
|
|
class_desc->connect("meta_clicked", this, "_class_desc_select");
|
|
|
|
class_desc->connect("input_event", this, "_class_desc_input");
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
class_desc->get_v_scroll()->connect("value_changed", this, "_scroll_changed");
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->set_selection_enabled(true);
|
2015-11-17 12:46:08 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
scroll_locked = false;
|
|
|
|
select_locked = false;
|
2014-04-10 03:18:27 +00:00
|
|
|
set_process_unhandled_key_input(true);
|
2014-02-10 01:10:30 +00:00
|
|
|
class_desc->hide();
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
search_dialog = memnew(ConfirmationDialog);
|
2015-11-17 12:46:08 +00:00
|
|
|
add_child(search_dialog);
|
2017-03-18 23:36:26 +00:00
|
|
|
VBoxContainer *search_vb = memnew(VBoxContainer);
|
2015-11-17 12:46:08 +00:00
|
|
|
search_dialog->add_child(search_vb);
|
|
|
|
search_dialog->set_child_rect(search_vb);
|
2017-03-18 23:36:26 +00:00
|
|
|
search = memnew(LineEdit);
|
2015-11-17 12:46:08 +00:00
|
|
|
search_dialog->register_text_enter(search);
|
2017-03-18 23:36:26 +00:00
|
|
|
search_vb->add_margin_child(TTR("Search Text"), search);
|
2016-05-04 01:25:37 +00:00
|
|
|
search_dialog->get_ok()->set_text(TTR("Find"));
|
2017-03-18 23:36:26 +00:00
|
|
|
search_dialog->connect("confirmed", this, "_search_cbk");
|
2015-11-17 12:46:08 +00:00
|
|
|
search_dialog->set_hide_on_ok(false);
|
|
|
|
search_dialog->set_self_opacity(0.8);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
/*class_search = memnew( EditorHelpSearch(editor) );
|
|
|
|
editor->get_gui_base()->add_child(class_search);
|
|
|
|
class_search->connect("go_to_help",this,"_help_callback");*/
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
// prev_search_page=-1;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
EditorHelp::~EditorHelp() {
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 02:15:16 +00:00
|
|
|
/////////////
|
|
|
|
|
|
|
|
void EditorHelpBit::_go_to_help(String p_what) {
|
|
|
|
|
|
|
|
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT);
|
|
|
|
ScriptEditor::get_singleton()->goto_help(p_what);
|
|
|
|
emit_signal("request_hide");
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorHelpBit::_meta_clicked(String p_select) {
|
|
|
|
|
|
|
|
// print_line("LINK: "+p_select);
|
|
|
|
if (p_select.begins_with("#")) {
|
|
|
|
//_goto_desc(p_select.substr(1,p_select.length()));
|
2017-03-18 23:36:26 +00:00
|
|
|
_go_to_help("class_name:" + p_select.substr(1, p_select.length()));
|
2016-08-24 02:15:16 +00:00
|
|
|
return;
|
|
|
|
} else if (p_select.begins_with("@")) {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
String m = p_select.substr(1, p_select.length());
|
2016-08-24 02:15:16 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (m.find(".") != -1) {
|
2016-08-24 02:15:16 +00:00
|
|
|
//must go somewhere else
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
_go_to_help("class_method:" + m.get_slice(".", 0) + ":" + m.get_slice(".", 0));
|
2016-08-24 02:15:16 +00:00
|
|
|
} else {
|
2017-03-18 23:36:26 +00:00
|
|
|
//
|
|
|
|
// if (!method_line.has(m))
|
2016-08-24 02:15:16 +00:00
|
|
|
// return;
|
|
|
|
//class_desc->scroll_to_line(method_line[m]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorHelpBit::_bind_methods() {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
ObjectTypeDB::bind_method("_meta_clicked", &EditorHelpBit::_meta_clicked);
|
2016-08-24 02:15:16 +00:00
|
|
|
ADD_SIGNAL(MethodInfo("request_hide"));
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelpBit::_notification(int p_what) {
|
2016-08-24 02:15:16 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
if (p_what == NOTIFICATION_ENTER_TREE) {
|
|
|
|
add_style_override("panel", get_stylebox("normal", "TextEdit"));
|
2016-08-24 02:15:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void EditorHelpBit::set_text(const String &p_text) {
|
2016-08-24 02:15:16 +00:00
|
|
|
|
|
|
|
rich_text->clear();
|
2017-03-18 23:36:26 +00:00
|
|
|
_add_text_to_rt(p_text, rich_text);
|
2016-08-24 02:15:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EditorHelpBit::EditorHelpBit() {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
rich_text = memnew(RichTextLabel);
|
2016-08-24 02:15:16 +00:00
|
|
|
add_child(rich_text);
|
2017-03-18 23:36:26 +00:00
|
|
|
rich_text->set_area_as_parent_rect(8 * EDSCALE);
|
|
|
|
rich_text->connect("meta_clicked", this, "_meta_clicked");
|
|
|
|
set_custom_minimum_size(Size2(0, 70 * EDSCALE));
|
2016-08-24 02:15:16 +00:00
|
|
|
}
|