diff options
Diffstat (limited to 'editor/plugins/script_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 63 |
1 files changed, 49 insertions, 14 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 165023a2fa..63eecd357d 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -64,7 +64,6 @@ #include "editor/window_wrapper.h" #include "scene/main/node.h" #include "scene/main/window.h" -#include "scene/scene_string_names.h" #include "script_text_editor.h" #include "servers/display_server.h" #include "text_editor.h" @@ -425,7 +424,7 @@ ScriptEditorQuickOpen::ScriptEditorQuickOpen() { search_box = memnew(LineEdit); vbc->add_margin_child(TTR("Search:"), search_box); search_box->connect("text_changed", callable_mp(this, &ScriptEditorQuickOpen::_text_changed)); - search_box->connect("gui_input", callable_mp(this, &ScriptEditorQuickOpen::_sbox_input)); + search_box->connect(SceneStringName(gui_input), callable_mp(this, &ScriptEditorQuickOpen::_sbox_input)); search_options = memnew(Tree); vbc->add_margin_child(TTR("Matches:"), search_options, true); set_ok_button_text(TTR("Open")); @@ -732,6 +731,7 @@ void ScriptEditor::_go_to_tab(int p_idx) { _update_members_overview(); _update_help_overview(); _update_selected_editor_menu(); + _update_online_doc(); _update_members_overview_visibility(); _update_help_overview_visibility(); } @@ -904,6 +904,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) { _go_to_tab(idx); } else { _update_selected_editor_menu(); + _update_online_doc(); } _update_history_arrows(); @@ -973,7 +974,7 @@ void ScriptEditor::_queue_close_tabs() { // Maybe there are unsaved changes. if (se->is_unsaved()) { _ask_close_current_unsaved_tab(se); - erase_tab_confirm->connect(SceneStringNames::get_singleton()->visibility_changed, callable_mp(this, &ScriptEditor::_queue_close_tabs), CONNECT_ONE_SHOT); + erase_tab_confirm->connect(SceneStringName(visibility_changed), callable_mp(this, &ScriptEditor::_queue_close_tabs), CONNECT_ONE_SHOT); break; } } @@ -1351,7 +1352,21 @@ void ScriptEditor::_menu_option(int p_option) { help_search_dialog->popup_dialog(); } break; case SEARCH_WEBSITE: { - OS::get_singleton()->shell_open(VERSION_DOCS_URL "/"); + Control *tab = tab_container->get_current_tab_control(); + + EditorHelp *eh = Object::cast_to<EditorHelp>(tab); + bool native_class_doc = false; + if (eh) { + const HashMap<String, DocData::ClassDoc>::ConstIterator E = EditorHelp::get_doc_data()->class_list.find(eh->get_class()); + native_class_doc = E && !E->value.is_script_doc; + } + if (native_class_doc) { + String name = eh->get_class().to_lower(); + String doc_url = vformat(VERSION_DOCS_URL "/classes/class_%s.html", name); + OS::get_singleton()->shell_open(doc_url); + } else { + OS::get_singleton()->shell_open(VERSION_DOCS_URL "/"); + } } break; case WINDOW_NEXT: { _history_forward(); @@ -1714,7 +1729,7 @@ void ScriptEditor::_notification(int p_what) { filter_scripts->set_right_icon(get_editor_theme_icon(SNAME("Search"))); filter_methods->set_right_icon(get_editor_theme_icon(SNAME("Search"))); - filename->add_theme_style_override("normal", get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))); + filename->add_theme_style_override("normal", get_theme_stylebox(CoreStringName(normal), SNAME("LineEdit"))); recent_scripts->reset_size(); @@ -1725,7 +1740,7 @@ void ScriptEditor::_notification(int p_what) { case NOTIFICATION_READY: { // Can't set own styles in NOTIFICATION_THEME_CHANGED, so for now this will do. - add_theme_style_override("panel", get_theme_stylebox(SNAME("ScriptEditorPanel"), SNAME("EditorStyles"))); + add_theme_style_override("panel", get_theme_stylebox(SNAME("ScriptEditorPanel"), EditorStringName(EditorStyles))); get_tree()->connect("tree_changed", callable_mp(this, &ScriptEditor::_tree_changed)); InspectorDock::get_singleton()->connect("request_help", callable_mp(this, &ScriptEditor::_help_class_open)); @@ -2030,6 +2045,26 @@ void ScriptEditor::_update_help_overview() { } } +void ScriptEditor::_update_online_doc() { + Node *current = tab_container->get_tab_control(tab_container->get_current_tab()); + + EditorHelp *eh = Object::cast_to<EditorHelp>(current); + bool native_class_doc = false; + if (eh) { + const HashMap<String, DocData::ClassDoc>::ConstIterator E = EditorHelp::get_doc_data()->class_list.find(eh->get_class()); + native_class_doc = E && !E->value.is_script_doc; + } + if (native_class_doc) { + String name = eh->get_class(); + String tooltip = vformat(TTR("Open '%s' in Godot online documentation."), name); + site_search->set_text(TTR("Open in Online Docs")); + site_search->set_tooltip_text(tooltip); + } else { + site_search->set_text(TTR("Online Docs")); + site_search->set_tooltip_text(TTR("Open Godot online documentation.")); + } +} + void ScriptEditor::_update_script_colors() { bool script_temperature_enabled = EDITOR_GET("text_editor/script_list/script_temperature_enabled"); @@ -4000,7 +4035,7 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) { filename = memnew(Label); filename->set_clip_text(true); filename->set_h_size_flags(SIZE_EXPAND_FILL); - filename->add_theme_style_override("normal", EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("normal"), SNAME("LineEdit"))); + filename->add_theme_style_override("normal", EditorNode::get_singleton()->get_editor_theme()->get_stylebox(CoreStringName(normal), SNAME("LineEdit"))); buttons_hbox->add_child(filename); members_overview_alphabeta_sort_button = memnew(Button); @@ -4151,15 +4186,13 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) { site_search = memnew(Button); site_search->set_flat(true); - site_search->set_text(TTR("Online Docs")); - site_search->connect("pressed", callable_mp(this, &ScriptEditor::_menu_option).bind(SEARCH_WEBSITE)); + site_search->connect(SceneStringName(pressed), callable_mp(this, &ScriptEditor::_menu_option).bind(SEARCH_WEBSITE)); menu_hb->add_child(site_search); - site_search->set_tooltip_text(TTR("Open Godot online documentation.")); help_search = memnew(Button); help_search->set_flat(true); help_search->set_text(TTR("Search Help")); - help_search->connect("pressed", callable_mp(this, &ScriptEditor::_menu_option).bind(SEARCH_HELP)); + help_search->connect(SceneStringName(pressed), callable_mp(this, &ScriptEditor::_menu_option).bind(SEARCH_HELP)); menu_hb->add_child(help_search); help_search->set_tooltip_text(TTR("Search the reference documentation.")); @@ -4167,14 +4200,14 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) { script_back = memnew(Button); script_back->set_flat(true); - script_back->connect("pressed", callable_mp(this, &ScriptEditor::_history_back)); + script_back->connect(SceneStringName(pressed), callable_mp(this, &ScriptEditor::_history_back)); menu_hb->add_child(script_back); script_back->set_disabled(true); script_back->set_tooltip_text(TTR("Go to previous edited document.")); script_forward = memnew(Button); script_forward->set_flat(true); - script_forward->connect("pressed", callable_mp(this, &ScriptEditor::_history_forward)); + script_forward->connect(SceneStringName(pressed), callable_mp(this, &ScriptEditor::_history_forward)); menu_hb->add_child(script_forward); script_forward->set_disabled(true); script_forward->set_tooltip_text(TTR("Go to next edited document.")); @@ -4241,7 +4274,7 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) { autosave_timer = memnew(Timer); autosave_timer->set_one_shot(false); - autosave_timer->connect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &ScriptEditor::_update_autosave_timer)); + autosave_timer->connect(SceneStringName(tree_entered), callable_mp(this, &ScriptEditor::_update_autosave_timer)); autosave_timer->connect("timeout", callable_mp(this, &ScriptEditor::_autosave_scripts)); add_child(autosave_timer); @@ -4275,6 +4308,8 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) { Ref<EditorJSONSyntaxHighlighter> json_syntax_highlighter; json_syntax_highlighter.instantiate(); register_syntax_highlighter(json_syntax_highlighter); + + _update_online_doc(); } ScriptEditor::~ScriptEditor() { |