diff options
Diffstat (limited to 'editor/plugins/script_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 68 |
1 files changed, 41 insertions, 27 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index edec4af094..6c63d9ff0d 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -137,12 +137,22 @@ void EditorStandardSyntaxHighlighter::_update_cache() { } } - const Ref<Script> scr = _get_edited_resource(); - if (scr.is_valid()) { + const ScriptLanguage *scr_lang = script_language; + StringName instance_base; + + if (scr_lang == nullptr) { + const Ref<Script> scr = _get_edited_resource(); + if (scr.is_valid()) { + scr_lang = scr->get_language(); + instance_base = scr->get_instance_base_type(); + } + } + + if (scr_lang != nullptr) { /* Core types. */ const Color basetype_color = EDITOR_GET("text_editor/theme/highlighting/base_type_color"); List<String> core_types; - scr->get_language()->get_core_type_words(&core_types); + scr_lang->get_core_type_words(&core_types); for (const String &E : core_types) { highlighter->add_keyword_color(E, basetype_color); } @@ -151,9 +161,9 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color"); const Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color"); List<String> keywords; - scr->get_language()->get_reserved_words(&keywords); + scr_lang->get_reserved_words(&keywords); for (const String &E : keywords) { - if (scr->get_language()->is_control_flow_keyword(E)) { + if (scr_lang->is_control_flow_keyword(E)) { highlighter->add_keyword_color(E, control_flow_keyword_color); } else { highlighter->add_keyword_color(E, keyword_color); @@ -162,7 +172,6 @@ void EditorStandardSyntaxHighlighter::_update_cache() { /* Member types. */ const Color member_variable_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color"); - StringName instance_base = scr->get_instance_base_type(); if (instance_base != StringName()) { List<PropertyInfo> plist; ClassDB::get_property_list(instance_base, &plist); @@ -187,7 +196,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { /* Comments */ const Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color"); List<String> comments; - scr->get_language()->get_comment_delimiters(&comments); + scr_lang->get_comment_delimiters(&comments); for (const String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); @@ -197,7 +206,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { /* Doc comments */ const Color doc_comment_color = EDITOR_GET("text_editor/theme/highlighting/doc_comment_color"); List<String> doc_comments; - scr->get_language()->get_doc_comment_delimiters(&doc_comments); + scr_lang->get_doc_comment_delimiters(&doc_comments); for (const String &doc_comment : doc_comments) { String beg = doc_comment.get_slice(" ", 0); String end = doc_comment.get_slice_count(" ") > 1 ? doc_comment.get_slice(" ", 1) : String(); @@ -207,7 +216,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { /* Strings */ const Color string_color = EDITOR_GET("text_editor/theme/highlighting/string_color"); List<String> strings; - scr->get_language()->get_string_delimiters(&strings); + scr_lang->get_string_delimiters(&strings); for (const String &string : strings) { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); @@ -423,6 +432,7 @@ ScriptEditorQuickOpen::ScriptEditorQuickOpen() { register_text_enter(search_box); set_hide_on_ok(false); search_options->connect("item_activated", callable_mp(this, &ScriptEditorQuickOpen::_confirmed)); + search_options->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); search_options->set_hide_root(true); search_options->set_hide_folding(true); search_options->add_theme_constant_override("draw_guides", 1); @@ -1223,8 +1233,8 @@ void ScriptEditor::_menu_option(int p_option) { for (const String &E : textfile_extensions) { file_dialog->add_filter("*." + E, E.to_upper()); } - file_dialog->popup_file_dialog(); file_dialog->set_title(TTR("New Text File...")); + file_dialog->popup_file_dialog(); open_textfile_after_create = true; } break; case FILE_OPEN: { @@ -1243,8 +1253,8 @@ void ScriptEditor::_menu_option(int p_option) { file_dialog->add_filter("*." + E, E.to_upper()); } - file_dialog->popup_file_dialog(); file_dialog->set_title(TTR("Open File")); + file_dialog->popup_file_dialog(); return; } break; case FILE_REOPEN_CLOSED: { @@ -1367,8 +1377,8 @@ void ScriptEditor::_menu_option(int p_option) { file_dialog->clear_filters(); file_dialog->set_current_dir(text_file->get_path().get_base_dir()); file_dialog->set_current_file(text_file->get_path().get_file()); - file_dialog->popup_file_dialog(); file_dialog->set_title(TTR("Save File As...")); + file_dialog->popup_file_dialog(); break; } @@ -1542,8 +1552,8 @@ void ScriptEditor::_theme_option(int p_option) { file_dialog_option = THEME_IMPORT; file_dialog->clear_filters(); file_dialog->add_filter("*.tet"); - file_dialog->popup_file_dialog(); file_dialog->set_title(TTR("Import Theme")); + file_dialog->popup_file_dialog(); } break; case THEME_RELOAD: { EditorSettings::get_singleton()->load_text_editor_theme(); @@ -1568,8 +1578,8 @@ void ScriptEditor::_show_save_theme_as_dialog() { file_dialog->clear_filters(); file_dialog->add_filter("*.tet"); file_dialog->set_current_path(EditorPaths::get_singleton()->get_text_editor_themes_dir().path_join(EDITOR_GET("text_editor/theme/color_theme"))); - file_dialog->popup_file_dialog(); file_dialog->set_title(TTR("Save Theme As...")); + file_dialog->popup_file_dialog(); } bool ScriptEditor::_has_docs_tab() const { @@ -1715,18 +1725,6 @@ void ScriptEditor::_notification(int p_what) { _test_script_times_on_disk(); _update_modified_scripts_for_external_editor(); } break; - - case CanvasItem::NOTIFICATION_VISIBILITY_CHANGED: { - if (is_visible()) { - find_in_files_button->show(); - } else { - if (find_in_files->is_visible_in_tree()) { - EditorNode::get_bottom_panel()->hide_bottom_panel(); - } - find_in_files_button->hide(); - } - - } break; } } @@ -1892,7 +1890,7 @@ struct _ScriptEditorItemData { if (sort_key == id.sort_key) { return index < id.index; } else { - return sort_key.naturalnocasecmp_to(id.sort_key) < 0; + return sort_key.filenocasecmp_to(id.sort_key) < 0; } } else { return category < id.category; @@ -3775,6 +3773,7 @@ void ScriptEditor::_on_find_in_files_result_selected(const String &fpath, int li ScriptTextEditor *ste = Object::cast_to<ScriptTextEditor>(_get_current_editor()); if (ste) { + EditorInterface::get_singleton()->set_main_screen_editor("Script"); ste->goto_line_selection(line_number, begin, end); } } @@ -3789,6 +3788,7 @@ void ScriptEditor::_on_find_in_files_result_selected(const String &fpath, int li ScriptTextEditor *ste = Object::cast_to<ScriptTextEditor>(_get_current_editor()); if (ste) { + EditorInterface::get_singleton()->set_main_screen_editor("Script"); ste->goto_line_selection(line_number - 1, begin, end); } return; @@ -3822,6 +3822,13 @@ void ScriptEditor::_start_find_in_files(bool with_replace) { find_in_files->set_replace_text(find_in_files_dialog->get_replace_text()); find_in_files->start_search(); + if (find_in_files_button->get_index() != find_in_files_button->get_parent()->get_child_count()) { + find_in_files_button->get_parent()->move_child(find_in_files_button, -1); + } + if (!find_in_files_button->is_visible()) { + find_in_files_button->show(); + } + EditorNode::get_bottom_panel()->make_item_visible(find_in_files); } @@ -3848,6 +3855,11 @@ void ScriptEditor::_set_zoom_factor(float p_zoom_factor) { } } +void ScriptEditor::_on_find_in_files_close_button_clicked() { + EditorNode::get_bottom_panel()->hide_bottom_panel(); + find_in_files_button->hide(); +} + void ScriptEditor::_window_changed(bool p_visible) { make_floating->set_visible(!p_visible); is_floating = p_visible; @@ -4167,6 +4179,7 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) { disk_changed_list = memnew(Tree); vbc->add_child(disk_changed_list); + disk_changed_list->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); disk_changed_list->set_v_size_flags(SIZE_EXPAND_FILL); disk_changed->connect("confirmed", callable_mp(this, &ScriptEditor::reload_scripts).bind(false)); @@ -4201,6 +4214,7 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) { find_in_files->set_custom_minimum_size(Size2(0, 200) * EDSCALE); find_in_files->connect(FindInFilesPanel::SIGNAL_RESULT_SELECTED, callable_mp(this, &ScriptEditor::_on_find_in_files_result_selected)); find_in_files->connect(FindInFilesPanel::SIGNAL_FILES_MODIFIED, callable_mp(this, &ScriptEditor::_on_find_in_files_modified_files)); + find_in_files->connect(FindInFilesPanel::SIGNAL_CLOSE_BUTTON_CLICKED, callable_mp(this, &ScriptEditor::_on_find_in_files_close_button_clicked)); find_in_files->hide(); find_in_files_button->hide(); |