From 36e835bbd4120e9f2ac60f7e763edeef93b40e51 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Silva Dias Date: Mon, 18 Dec 2017 15:46:17 -0200 Subject: Some fixes for the Script Editor and dead code cleaning. --- editor/editor_help.cpp | 91 ++++++--------------------------- editor/plugins/script_editor_plugin.cpp | 44 +++------------- 2 files changed, 21 insertions(+), 114 deletions(-) (limited to 'editor') diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index d20b55e268..f705cd5966 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -324,23 +324,14 @@ EditorHelpSearch::EditorHelpSearch() { set_hide_on_ok(false); search_options->connect("item_activated", this, "_confirmed"); set_title(TTR("Search Help")); - - //search_options->set_hide_root(true); } ///////////////////////////////// -//////////////////////////////////// -/// ///////////////////////////////// - void EditorHelpIndex::add_type(const String &p_type, HashMap &p_types, TreeItem *p_root) { if (p_types.has(p_type)) return; - /* - if (!ClassDB::is_type(p_type,base) || p_type==base) - return; - */ String inherits = EditorHelp::get_doc_data()->class_list[p_type].inherits; @@ -379,8 +370,6 @@ void EditorHelpIndex::_tree_item_selected() { EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); emit_signal("open_class", s->get_text(0)); hide(); - - //_goto_desc(s->get_text(0)); } void EditorHelpIndex::select_class(const String &p_class) { @@ -518,8 +507,6 @@ EditorHelpIndex::EditorHelpIndex() { ///////////////////////////////// -//////////////////////////////////// -/// ///////////////////////////////// DocData *EditorHelp::doc = NULL; void EditorHelp::_init_colors() { @@ -572,9 +559,7 @@ void EditorHelp::_class_list_select(const String &p_select) { void EditorHelp::_class_desc_select(const String &p_select) { - //print_line("LINK: "+p_select); if (p_select.begins_with("$")) { //enum - //_goto_desc(p_select.substr(1,p_select.length())); String select = p_select.substr(1, p_select.length()); String class_name; if (select.find(".") != -1) { @@ -585,7 +570,6 @@ void EditorHelp::_class_desc_select(const String &p_select) { emit_signal("go_to_help", "class_enum:" + class_name + ":" + select); return; } else if (p_select.begins_with("#")) { - //_goto_desc(p_select.substr(1,p_select.length())); emit_signal("go_to_help", "class_name:" + p_select.substr(1, p_select.length())); return; } else if (p_select.begins_with("@")) { @@ -612,7 +596,6 @@ void EditorHelp::_class_desc_select(const String &p_select) { } if (link.find(".") != -1) { - //must go somewhere else emit_signal("go_to_help", topic + ":" + link.get_slice(".", 0) + ":" + link.get_slice(".", 1)); } else { @@ -749,16 +732,13 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { - //ERR_FAIL_COND(!doc->class_list.has(p_class)); if (!doc->class_list.has(p_class)) return ERR_DOES_NOT_EXIST; - //if (tree_item_map.has(p_class)) { select_locked = true; - //} class_desc->show(); - //tabs->set_current_tab(PAGE_CLASS_DESC); + description_line = 0; if (p_class == edited_class) @@ -770,7 +750,6 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { method_line.clear(); section_line.clear(); edited_class = p_class; - //edited_class->show(); _init_colors(); @@ -866,7 +845,6 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->pop(); class_desc->pop(); - //class_desc->add_newline(); class_desc->add_newline(); class_desc->push_color(text_color); class_desc->push_font(doc_font); @@ -891,7 +869,6 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->add_text(TTR("Members:")); class_desc->pop(); class_desc->pop(); - //class_desc->add_newline(); class_desc->push_indent(1); class_desc->push_table(2); @@ -970,9 +947,6 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->pop(); class_desc->pop(); - //class_desc->add_newline(); - //class_desc->add_newline(); - class_desc->push_indent(1); class_desc->push_table(2); class_desc->set_table_column_expand(1, 1); @@ -1094,7 +1068,6 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->pop(); class_desc->add_newline(); - //class_desc->add_newline(); class_desc->push_indent(1); @@ -1102,8 +1075,6 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { signal_line[cd.signals[i].name] = class_desc->get_line_count() - 2; //gets overridden if description class_desc->push_font(doc_code_font); // monofont - //_add_type("void"); - //class_desc->add_text(" "); class_desc->push_color(headline_color); _add_text(cd.signals[i].name); class_desc->pop(); @@ -1137,7 +1108,6 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->push_font(doc_font); class_desc->push_color(comment_color); class_desc->push_indent(1); - // class_desc->add_text(" "); _add_text(cd.signals[i].description); class_desc->pop(); // indent class_desc->pop(); @@ -1181,7 +1151,6 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->push_indent(1); class_desc->add_newline(); - //class_desc->add_newline(); for (Map >::Element *E = enums.front(); E; E = E->next()) { @@ -1256,7 +1225,6 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->push_indent(1); class_desc->add_newline(); - //class_desc->add_newline(); for (int i = 0; i < constants.size(); i++) { @@ -1275,7 +1243,6 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { if (constants[i].description != "") { class_desc->push_font(doc_font); class_desc->push_indent(1); - //class_desc->add_text(" "); class_desc->push_color(comment_color); _add_text(constants[i].description); class_desc->pop(); @@ -1349,8 +1316,6 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->pop(); // font class_desc->pop(); // cell - //class_desc->add_text(" "); - if (cd.properties[i].setter != "") { class_desc->push_cell(); @@ -1534,7 +1499,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { } if (brk_pos == bbcode.length()) - break; //nothing else o add + break; //nothing else to add int brk_end = bbcode.find("]", brk_pos + 1); @@ -1730,10 +1695,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { pos = brk_pos + 1; } } - - /*p_rt->pop(); - p_rt->pop(); - p_rt->pop();*/ } void EditorHelp::_add_text(const String &p_bbcode) { @@ -1758,8 +1719,7 @@ void EditorHelp::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - //forward->set_icon(get_icon("Forward","EditorIcons")); - //back->set_icon(get_icon("Back","EditorIcons")); + _update_doc(); } break; @@ -1832,7 +1792,6 @@ void EditorHelp::_bind_methods() { ClassDB::bind_method("_class_list_select", &EditorHelp::_class_list_select); ClassDB::bind_method("_class_desc_select", &EditorHelp::_class_desc_select); ClassDB::bind_method("_class_desc_input", &EditorHelp::_class_desc_input); - //ClassDB::bind_method("_button_pressed",&EditorHelp::_button_pressed); ClassDB::bind_method("_request_help", &EditorHelp::_request_help); ClassDB::bind_method("_unhandled_key_input", &EditorHelp::_unhandled_key_input); ClassDB::bind_method("_search", &EditorHelp::_search); @@ -1844,21 +1803,16 @@ void EditorHelp::_bind_methods() { EditorHelp::EditorHelp() { - VBoxContainer *vbc = this; + set_custom_minimum_size(Size2(150 * EDSCALE, 0)); EDITOR_DEF("text_editor/help/sort_functions_alphabetically", true); - //class_list->connect("meta_clicked",this,"_class_list_select"); - //class_list->set_selection_enabled(true); - - { - class_desc = memnew(RichTextLabel); - vbc->add_child(class_desc); - class_desc->set_v_size_flags(SIZE_EXPAND_FILL); - class_desc->add_color_override("selection_color", get_color("text_editor/theme/selection_color", "Editor")); - class_desc->connect("meta_clicked", this, "_class_desc_select"); - class_desc->connect("gui_input", this, "_class_desc_input"); - } + class_desc = memnew(RichTextLabel); + add_child(class_desc); + class_desc->set_v_size_flags(SIZE_EXPAND_FILL); + class_desc->add_color_override("selection_color", get_color("text_editor/theme/selection_color", "Editor")); + class_desc->connect("meta_clicked", this, "_class_desc_select"); + class_desc->connect("gui_input", this, "_class_desc_input"); class_desc->set_selection_enabled(true); @@ -1878,12 +1832,6 @@ EditorHelp::EditorHelp() { search_dialog->get_ok()->set_text(TTR("Find")); search_dialog->connect("confirmed", this, "_search_cbk"); search_dialog->set_hide_on_ok(false); - - /*class_search = memnew( EditorHelpSearch(editor) ); - editor->get_gui_base()->add_child(class_search); - class_search->connect("go_to_help",this,"_help_callback");*/ - - //prev_search_page=-1; } EditorHelp::~EditorHelp() { @@ -1901,9 +1849,9 @@ void EditorHelpBit::_go_to_help(String p_what) { void EditorHelpBit::_meta_clicked(String p_select) { print_line("got meta " + p_select); - //print_line("LINK: "+p_select); + if (p_select.begins_with("$")) { //enum - //_goto_desc(p_select.substr(1,p_select.length())); + String select = p_select.substr(1, p_select.length()); String class_name; if (select.find(".") != -1) { @@ -1914,24 +1862,15 @@ void EditorHelpBit::_meta_clicked(String p_select) { _go_to_help("class_enum:" + class_name + ":" + select); return; } else if (p_select.begins_with("#")) { - //_goto_desc(p_select.substr(1,p_select.length())); + _go_to_help("class_name:" + p_select.substr(1, p_select.length())); return; } else if (p_select.begins_with("@")) { String m = p_select.substr(1, p_select.length()); - if (m.find(".") != -1) { - //must go somewhere else - - _go_to_help("class_method:" + m.get_slice(".", 0) + ":" + m.get_slice(".", 0)); - } else { - /* - if (!method_line.has(m)) - return; - class_desc->scroll_to_line(method_line[m]); - */ - } + if (m.find(".") != -1) + _go_to_help("class_method:" + m.get_slice(".", 0) + ":" + m.get_slice(".", 0)); //must go somewhere else } } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 591e6dac56..e6a5400029 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -132,7 +132,7 @@ public: I = I->next(); } - if (O != E) { //should never heppane.. + if (O != E) { //should never happen.. cached.erase(O); } } @@ -234,7 +234,6 @@ ScriptEditorQuickOpen::ScriptEditorQuickOpen() { VBoxContainer *vbc = memnew(VBoxContainer); add_child(vbc); - //set_child_rect(vbc); search_box = memnew(LineEdit); vbc->add_margin_child(TTR("Search:"), search_box); search_box->connect("text_changed", this, "_text_changed"); @@ -257,8 +256,6 @@ ScriptEditor *ScriptEditor::script_editor = NULL; String ScriptEditor::_get_debug_tooltip(const String &p_text, Node *_se) { - //ScriptEditorBase *se=Object::cast_to(_se); - String val = debugger->get_var_value(p_text); if (val != String()) { return p_text + ": " + val; @@ -551,8 +548,6 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) { idx = history[history_pos].control->get_index(); } tab_container->set_current_tab(idx); - - //script_list->select(idx); } _update_history_arrows(); @@ -698,7 +693,6 @@ void ScriptEditor::_reload_scripts() { uint64_t last_date = script->get_last_modified_time(); uint64_t date = FileAccess::get_modified_time(script->get_path()); - //printf("last date: %lli vs date: %lli\n",last_date,date); if (last_date == date) { continue; } @@ -776,7 +770,6 @@ bool ScriptEditor::_test_script_times_on_disk(Ref